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

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.269     wiz        15: Copyright    1994-2026 The NetBSD Foundation, Inc
1.1       dsieger    16: 
1.269     wiz        17: $NetBSD: pkgsrc.xml,v 1.46 2026/01/01 08:41:23 wiz 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.271     wiz        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
1.272     wiz        83:         8.3. Speeding up bulk build scans
                     84:         8.4. Requirements of a full bulk build
                     85:         8.5. Bulk build variants
                     86:             8.5.1. Detect unknown configure options
                     87:             8.5.2. Detect classes of bugs by forcing compiler warnings
                     88:             8.5.3. Force compiler options only in the build phase
                     89:             8.5.4. Use custom directories
                     90:             8.5.5. Turn warnings into errors
                     91:             8.5.6. Reject packages for which pkglint reports errors
                     92:             8.5.7. Reject packages that contain forbidden strings
                     93:             8.5.8. Reject packages whose self-test fails
                     94:             8.5.9. Reject packages that use undefined shell variables
                     95:             8.5.10. Turn off verbose logging
                     96:         8.6. Creating a multiple CD-ROM packages collection
                     97:             8.6.1. Example of cdpack
1.154     rillig     98:     9. Directory layout of the installed files
                     99:         9.1. File system layout in ${LOCALBASE}
                    100:         9.2. File system layout in ${VARBASE}
                    101:     10. Frequently Asked Questions
                    102:         10.1. Are there any mailing lists for pkg-related discussion?
                    103:         10.2. Utilities for package management (pkgtools)
                    104:         10.3. How to use pkgsrc as non-root
                    105:         10.4. How to resume transfers when fetching distfiles?
                    106:         10.5. How can I install/use modular X.org from pkgsrc?
                    107:         10.6. How to fetch files from behind a firewall
                    108:         10.7. How to fetch files from HTTPS sites
                    109:         10.8. How do I tell make fetch to do passive FTP?
                    110:         10.9. How to fetch all distfiles at once
1.266     martin    111:         10.10. What does    Don't know how to make /usr/share/tmac/tmac.andoc   
1.271     wiz       112:         mean?
1.266     martin    113:         10.11. What does    Could not find bsd.own.mk    mean?
1.221     nia       114:         10.12. Using 'sudo' or `priv` with pkgsrc
1.154     rillig    115:         10.13. How do I change the location of configuration files?
                    116:         10.14. Automated security checks
                    117:         10.15. Why do some packages ignore my CFLAGS?
                    118:         10.16. A package does not build. What shall I do?
1.266     martin    119:         10.17. What does    Makefile appears to contain unresolved cvs/rcs/???
1.271     wiz       120:         merge conflicts    mean?
1.1       dsieger   121: II. The pkgsrc developer's guide
1.154     rillig    122:     11. Getting help
1.184     rillig    123:     12. Package components - files, directories and contents
                    124:         12.1. Makefile
                    125:         12.2. distinfo
                    126:         12.3. patches/*
                    127:             12.3.1. Structure of a single patch file
                    128:             12.3.2. Creating patch files
                    129:             12.3.3. Sources where the patch files come from
                    130:             12.3.4. Patching guidelines
                    131:             12.3.5. Feedback to the author
                    132:         12.4. Other mandatory files
                    133:         12.5. Optional files
                    134:             12.5.1. Files affecting the binary package
                    135:             12.5.2. Files affecting the build process
                    136:             12.5.3. Files affecting nothing at all
                    137:         12.6. work*
                    138:         12.7. files/*
                    139:     13. The build process
                    140:         13.1. Introduction
                    141:         13.2. Program location
                    142:         13.3. Directories used during the build process
                    143:         13.4. Running a phase
                    144:         13.5. The fetch phase
                    145:             13.5.1. What to fetch and where to get it from
                    146:             13.5.2. How are the files fetched?
                    147:         13.6. The checksum phase
                    148:         13.7. The extract phase
                    149:         13.8. The patch phase
                    150:         13.9. The tools phase
                    151:         13.10. The wrapper phase
                    152:         13.11. The configure phase
                    153:         13.12. The build phase
                    154:         13.13. The test phase
                    155:         13.14. The install phase
                    156:         13.15. The package phase
                    157:         13.16. Cleaning up
                    158:         13.17. Other helpful targets
                    159:     14. Creating a new pkgsrc package from scratch
                    160:         14.1. Common types of packages
1.219     nia       161:             14.1.1. Python modules and programs
                    162:             14.1.2. R packages
                    163:             14.1.3. TeXlive packages
1.184     rillig    164:         14.2. Examples
                    165:             14.2.1. How the www/nvu package came into pkgsrc
                    166:     15. Programming in Makefiles
                    167:         15.1. Caveats
                    168:         15.2. Makefile variables
                    169:             15.2.1. Naming conventions
                    170:         15.3. Code snippets
                    171:             15.3.1. Adding things to a list
                    172:             15.3.2. Echoing a string exactly as-is
                    173:             15.3.3. Passing CFLAGS to GNU configure scripts
                    174:             15.3.4. Handling possibly empty variables
1.229     gutterid  175:             15.3.5. Testing yes/no variables in conditions
1.184     rillig    176:     16. Options handling
                    177:         16.1. Global default options
                    178:         16.2. Converting packages to use bsd.options.mk
                    179:         16.3. Option Names
                    180:         16.4. Determining the options of dependencies
                    181:     17. Tools needed for building or running
                    182:         17.1. Tools for pkgsrc builds
                    183:         17.2. Tools needed by packages
                    184:         17.3. Tools provided by platforms
                    185:     18. Buildlink methodology
                    186:         18.1. Converting packages to use buildlink3
                    187:         18.2. Writing buildlink3.mk files
                    188:             18.2.1. Anatomy of a buildlink3.mk file
                    189:             18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
1.271     wiz       190:             BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
1.184     rillig    191:         18.3. Writing builtin.mk files
                    192:             18.3.1. Anatomy of a builtin.mk file
                    193:     19. PLIST issues
                    194:         19.1. RCS ID
                    195:         19.2. Semi-automatic PLIST generation
                    196:         19.3. Tweaking output of make print-PLIST
                    197:         19.4. Variable substitution in PLIST
                    198:         19.5. Man page compression
                    199:         19.6. Changing PLIST source with PLIST_SRC
                    200:         19.7. Platform-specific and differing PLISTs
                    201:         19.8. Build-specific PLISTs
                    202:         19.9. Sharing directories between packages
                    203:     20. The pkginstall framework
                    204:         20.1. Files and directories outside the installation prefix
                    205:             20.1.1. Directory manipulation
                    206:             20.1.2. File manipulation
                    207:         20.2. Configuration files
                    208:             20.2.1. How PKG_SYSCONFDIR is set
                    209:             20.2.2. Telling the software where configuration files are
1.239     dholland  210:             20.2.3. Patching installation
                    211:             20.2.4. Declaring configuration files
                    212:             20.2.5. Disabling handling of configuration files
1.184     rillig    213:         20.3. System startup scripts
                    214:             20.3.1. Disabling handling of system startup scripts
                    215:         20.4. System users and groups
                    216:         20.5. System shells
                    217:             20.5.1. Disabling shell registration
                    218:         20.6. Fonts
                    219:             20.6.1. Disabling automatic update of the fonts databases
1.154     rillig    220:     21. Making your package work
                    221:         21.1. General operation
                    222:             21.1.1. How to pull in user-settable variables from mk.conf
                    223:             21.1.2. User interaction
                    224:             21.1.3. Handling licenses
                    225:             21.1.4. Restricted packages
                    226:             21.1.5. Handling dependencies
                    227:             21.1.6. Handling conflicts with other packages
                    228:             21.1.7. Packages that cannot or should not be built
                    229:             21.1.8. Packages which should not be deleted, once installed
                    230:             21.1.9. Handling packages with security problems
                    231:             21.1.10. How to handle incrementing versions when fixing an
1.271     wiz       232:             existing package
1.154     rillig    233:             21.1.11. Substituting variable text in the package files (the SUBST
1.271     wiz       234:             framework)
1.154     rillig    235:         21.2. The fetch phase
                    236:             21.2.1. Packages whose distfiles aren't available for plain
1.271     wiz       237:             downloading
1.154     rillig    238:             21.2.2. How to handle modified distfiles with the 'old' name
                    239:             21.2.3. Packages hosted on github.com
                    240:         21.3. The configure phase
                    241:             21.3.1. Shared libraries - libtool
                    242:             21.3.2. Using libtool on GNU packages that already support libtool
                    243:             21.3.3. GNU Autoconf/Automake
1.223     nia       244:             21.3.4. Meson / ninja
1.260     wiz       245:             21.3.5. Determining the endianness
1.154     rillig    246:         21.4. Programming languages
                    247:             21.4.1. C, C++, and Fortran
                    248:             21.4.2. Java
1.205     wiz       249:             21.4.3. Go
1.223     nia       250:             21.4.4. Rust
                    251:             21.4.5. Packages containing Perl scripts
                    252:             21.4.6. Packages containing shell scripts
                    253:             21.4.7. Other programming languages
1.154     rillig    254:         21.5. The build phase
                    255:             21.5.1. Compiling C and C++ code conditionally
                    256:             21.5.2. How to handle compiler bugs
1.172     rillig    257:             21.5.3. No such file or directory
1.266     martin    258:             21.5.4. Undefined reference to    ...   
1.172     rillig    259:             21.5.5. Running out of memory
1.154     rillig    260:         21.6. The install phase
                    261:             21.6.1. Creating needed directories
                    262:             21.6.2. Where to install documentation
                    263:             21.6.3. Installing highscore files
                    264:             21.6.4. Adding DESTDIR support to packages
                    265:             21.6.5. Packages with hardcoded paths to other interpreters
1.203     nia       266:             21.6.6. Packages installing Perl modules
1.254     wiz       267:             21.6.7. Packages installing pkg-config files
                    268:             21.6.8. Packages installing info files
                    269:             21.6.9. Packages installing man pages
                    270:             21.6.10. Packages installing X11 fonts
                    271:             21.6.11. Packages installing SGML or XML data
                    272:             21.6.12. Packages installing extensions to the MIME database
                    273:             21.6.13. Packages using intltool
                    274:             21.6.14. Packages installing startup scripts
                    275:             21.6.15. Packages installing TeX modules
                    276:             21.6.16. Packages supporting running binaries in emulation
                    277:             21.6.17. Packages installing hicolor icons
                    278:             21.6.18. Packages installing desktop files
1.154     rillig    279:         21.7. Marking packages as having problems
1.184     rillig    280:     22. GNOME packaging and porting
                    281:         22.1. Meta packages
                    282:         22.2. Packaging a GNOME application
                    283:         22.3. Updating GNOME to a newer version
                    284:         22.4. Patching guidelines
1.154     rillig    285:     23. Submitting and Committing
                    286:         23.1. Submitting binary packages
                    287:         23.2. Submitting source packages (for non-NetBSD-developers)
                    288:         23.3. General notes when adding, updating, or removing packages
                    289:         23.4. Commit Messages
                    290:         23.5. Committing: Adding a package to CVS
                    291:         23.6. Updating a package to a newer version
                    292:         23.7. Renaming a package in pkgsrc
                    293:         23.8. Moving a package in pkgsrc
1.263     wiz       294:     24. pkgsrc Policies
                    295:         24.1. Packages for which updating is restricted
                    296:             24.1.1. Limited Updates - ABI
                    297:             24.1.2. Limited Updates - Bootstrap
                    298:     25. Frequently Asked Questions
1.1       dsieger   299: III. The pkgsrc infrastructure internals
1.263     wiz       300:     26. Design of the pkgsrc infrastructure
                    301:         26.1. The meaning of variable definitions
                    302:         26.2. Avoiding problems before they arise
                    303:         26.3. Variable evaluation
                    304:             26.3.1. At load time
                    305:             26.3.2. At runtime
                    306:         26.4. How can variables be specified?
                    307:         26.5. Designing interfaces for Makefile fragments
                    308:             26.5.1. Procedures with parameters
                    309:             26.5.2. Actions taken on behalf of parameters
                    310:         26.6. The order in which files are loaded
                    311:             26.6.1. The order in bsd.prefs.mk
                    312:             26.6.2. The order in bsd.pkg.mk
                    313:     27. Regression tests
                    314:         27.1. Running the regression tests
                    315:         27.2. Adding a new regression test
                    316:             27.2.1. Overridable functions
                    317:             27.2.2. Helper functions
                    318:     28. Porting pkgsrc
                    319:         28.1. Porting pkgsrc to a new operating system
1.1       dsieger   320: A. A simple example package: bison
                    321:     A.1. files
                    322:         A.1.1. Makefile
                    323:         A.1.2. DESCR
                    324:         A.1.3. PLIST
                    325:         A.1.4. Checking a package with pkglint
                    326:     A.2. Steps for building, installing, packaging
1.207     leot      327: B. Security hardening
                    328:     B.1. Mechanisms
                    329:         B.1.1. Enabled by default
                    330:         B.1.2. Not enabled by default
                    331:     B.2. Caveats
                    332:         B.2.1. Problems with PKGSRC_MKPIE
                    333:         B.2.2. Problems with PKGSRC_USE_FORTIFY
                    334:         B.2.3. Problems with PKGSRC_USE_RELRO
                    335:         B.2.4. Problems with PKGSRC_USE_SSP
                    336:     B.3. Auditing the system
                    337:         B.3.1. Checking for PIE
                    338:         B.3.2. Checking for partial RELRO
                    339:         B.3.3. Checking for full RELRO
                    340:         B.3.4. Checking for SSP
                    341: C. Build logs
                    342:     C.1. Building figlet
                    343:     C.2. Packaging figlet
                    344: D. Directory layout of the pkgsrc FTP server
                    345:     D.1. distfiles: The distributed source files
                    346:     D.2. misc: Miscellaneous things
                    347:     D.3. packages: Binary packages
                    348:     D.4. reports: Bulk build reports
                    349:     D.5. current, stable, pkgsrc-20xxQy: source packages
                    350: E. Help topics
                    351: F. Editing guidelines for the pkgsrc guide
                    352:     F.1. Make targets
                    353:     F.2. Procedure
1.1       dsieger   354: 
                    355: List of Tables
                    356: 
                    357: 1.1. Platforms supported by pkgsrc
1.184     rillig    358: 12.1. Patching examples
                    359: 22.1. PLIST handling for GNOME packages
1.1       dsieger   360: 
1.266     martin    361: Chapter  1.  What is pkgsrc?
1.1       dsieger   362: 
                    363: Table of Contents
                    364: 
                    365: 1.1. Introduction
                    366:     1.1.1. Why pkgsrc?
                    367:     1.1.2. Supported platforms
                    368: 1.2. Overview
                    369: 1.3. Terminology
                    370:     1.3.1. Roles involved in pkgsrc
                    371: 1.4. Typography
                    372: 
1.266     martin    373: 1.1.  Introduction
1.1       dsieger   374: 
                    375: There is a lot of software freely available for Unix-based systems, which is
                    376: usually available in form of the source code. Before such software can be used,
                    377: it needs to be configured to the local system, compiled and installed, and this
                    378: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
                    379: some basic commands to handle binary packages, so that not every user has to
                    380: build the packages for himself, which is a time-costly task.
                    381: 
                    382: pkgsrc currently contains several thousand packages, including:
                    383: 
1.104     sevan     384:   * www/apache24 - The Apache web server
1.1       dsieger   385: 
                    386:   * www/firefox - The Firefox web browser
                    387: 
                    388:   * meta-pkgs/gnome - The GNOME Desktop Environment
                    389: 
1.102     ryoon     390:   * meta-pkgs/kde4 - The K Desktop Environment
1.1       dsieger   391: 
1.266     martin    392:     just to name a few.
1.1       dsieger   393: 
                    394: pkgsrc has built-in support for handling varying dependencies, such as pthreads
                    395: and X11, and extended features such as IPv6 support on a range of platforms.
                    396: 
1.266     martin    397: 1.1.1.  Why pkgsrc?
1.1       dsieger   398: 
                    399: pkgsrc provides the following key features:
                    400: 
                    401:   * Easy building of software from source as well as the creation and
                    402:     installation of binary packages. The source and latest patches are
                    403:     retrieved from a master or mirror download site, checksum verified, then
                    404:     built on your system. Support for binary-only distributions is available
                    405:     for both native platforms and NetBSD emulated platforms.
                    406: 
                    407:   * All packages are installed in a consistent directory tree, including
                    408:     binaries, libraries, man pages and other documentation.
                    409: 
1.104     sevan     410:   * Tracking of package dependencies automatically, including when performing
                    411:     updates, to ensure required packages are installed. The configuration files
                    412:     of various packages are handled automatically during updates, so local
                    413:     changes are preserved.
1.1       dsieger   414: 
                    415:   * Like NetBSD, pkgsrc is designed with portability in mind and consists of
                    416:     highly portable code. This allows the greatest speed of development when
1.26      spz       417:     porting to a new platform. This portability also ensures that pkgsrc is 
1.1       dsieger   418:     consistent across all platforms.
                    419: 
                    420:   * The installation prefix, acceptable software licenses, international
                    421:     encryption requirements and build-time options for a large number of
                    422:     packages are all set in a simple, central configuration file.
                    423: 
                    424:   * The entire source (not including the distribution files) is freely
                    425:     available under a BSD license, so you may extend and adapt pkgsrc to your
                    426:     needs. Support for local packages and patches is available right out of the
                    427:     box, so you can configure it specifically for your environment.
                    428: 
                    429: The following principles are basic to pkgsrc:
                    430: 
1.266     martin    431:   *    It should only work if it's right.        That means, if a package contains
1.1       dsieger   432:     bugs, it's better to find them and to complain about them rather than to
                    433:     just install the package and hope that it works. There are numerous checks
1.175     gutterid  434:     in pkgsrc that try to find such bugs: static analysis tools (pkgtools/
1.1       dsieger   435:     pkglint), build-time checks (portability of shell scripts), and
                    436:     post-installation checks (installed files, references to shared libraries,
                    437:     script interpreters).
                    438: 
1.266     martin    439:   *    If it works, it should work everywhere        Like NetBSD has been ported to
1.1       dsieger   440:     many hardware architectures, pkgsrc has been ported to many operating
                    441:     systems. Care is taken that packages behave the same on all platforms.
                    442: 
1.266     martin    443: 1.1.2.  Supported platforms
1.1       dsieger   444: 
                    445: pkgsrc consists of both a source distribution and a binary distribution for
                    446: these operating systems. After retrieving the required source or binaries, you
                    447: can be up and running with pkgsrc in just minutes!
                    448: 
                    449: pkgsrc was derived from FreeBSD's ports system, and initially developed for
                    450: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
                    451: platforms:
                    452: 
1.266     martin    453: Table  1.1.  Platforms supported by pkgsrc
1.1       dsieger   454: 
1.92      sevan     455: +-----------------------------------------------------------------------------+
1.229     gutterid  456: |              Platform               | Date Support  |         Notes         |
                    457: |                                     |     Added     |                       |
                    458: |-------------------------------------+---------------+-----------------------|
1.266     martin    459: |NetBSD                               |   Aug 1997    |                        |
1.229     gutterid  460: |-------------------------------------+---------------+-----------------------|
                    461: |Solaris                              |   Mar 1999    |README.Solaris         |
                    462: |-------------------------------------+---------------+-----------------------|
                    463: |Linux                                |   Jun 1999    |README.Linux           |
                    464: |-------------------------------------+---------------+-----------------------|
                    465: |Darwin / Mac OS X / OS X / macOS     |   Oct 2001    |README.macOS           |
                    466: |-------------------------------------+---------------+-----------------------|
                    467: |FreeBSD                              |   Nov 2002    |README.FreeBSD         |
                    468: |-------------------------------------+---------------+-----------------------|
                    469: |OpenBSD                              |   Nov 2002    |README.OpenBSD         |
                    470: |-------------------------------------+---------------+-----------------------|
                    471: |IRIX                                 |   Dec 2002    |README.IRIX            |
                    472: |-------------------------------------+---------------+-----------------------|
1.262     dholland  473: |BSD/OS                               |   Dec 2003    |Removed from pkgsrc Mar|
                    474: |                                     |               |         2025          |
1.229     gutterid  475: |-------------------------------------+---------------+-----------------------|
                    476: |AIX                                  |   Dec 2003    |README.AIX             |
                    477: |-------------------------------------+---------------+-----------------------|
1.264     wiz       478: |Interix (Microsoft Windows Services  |   Mar 2004    |Removed from pkgsrc Apr|
                    479: |for Unix)                            |               |         2025          |
1.229     gutterid  480: |-------------------------------------+---------------+-----------------------|
1.266     martin    481: |DragonFlyBSD                         |   Oct 2004    |                        |
1.229     gutterid  482: |-------------------------------------+---------------+-----------------------|
                    483: |OSF/1                                |   Nov 2004    |README.OSF1            |
                    484: |-------------------------------------+---------------+-----------------------|
                    485: |HP-UX                                |   Apr 2007    |README.HPUX            |
                    486: |-------------------------------------+---------------+-----------------------|
                    487: |Haiku                                |   Sep 2010    |README.Haiku           |
                    488: |-------------------------------------+---------------+-----------------------|
1.262     dholland  489: |MirBSD                               |   Jan 2011    |Removed from pkgsrc Mar|
                    490: |                                     |               |         2025          |
1.229     gutterid  491: |-------------------------------------+---------------+-----------------------|
                    492: |Minix3                               |   Nov 2011    |README.Minix3          |
                    493: |-------------------------------------+---------------+-----------------------|
                    494: |Cygwin                               |   Mar 2013    |README.Cygwin          |
                    495: |-------------------------------------+---------------+-----------------------|
1.261     maya      496: |GNU/kFreeBSD                         |   Jul 2013    |Removed from pkgsrc Mar|
                    497: |                                     |               |2025                   |
1.229     gutterid  498: |-------------------------------------+---------------+-----------------------|
                    499: |Bitrig                               |   Jun 2014    |Removed from pkgsrc Sep|
                    500: |                                     |               |2022                   |
1.92      sevan     501: +-----------------------------------------------------------------------------+
1.1       dsieger   502: 
                    503: 
1.266     martin    504: 1.2.  Overview
1.1       dsieger   505: 
                    506: This document is divided into three parts. The first, The pkgsrc user's guide,
                    507: describes how one can use one of the packages in the Package Collection, either
                    508: by installing a precompiled binary package, or by building one's own copy using
                    509: the NetBSD package system. The second part, The pkgsrc developer's guide,
                    510: explains how to prepare a package so it can be easily built by other NetBSD
                    511: users without knowing about the package's building details. The third part, The
                    512: pkgsrc infrastructure internals is intended for those who want to understand
                    513: how pkgsrc is implemented.
                    514: 
                    515: This document is available in various formats: HTML, PDF, PS, TXT.
                    516: 
1.266     martin    517: 1.3.  Terminology
1.1       dsieger   518: 
1.266     martin    519: There has been a lot of talk about    ports   ,    packages   , etc. so far. Here is a
1.1       dsieger   520: description of all the terminology used within this document.
                    521: 
                    522: Package
                    523: 
                    524:     A set of files and building instructions that describe what's necessary to
                    525:     build a certain piece of software using pkgsrc. Packages are traditionally
1.123     wiz       526:     stored under /usr/pkgsrc, but may be stored in any location, referred to as
                    527:     PKGSRCDIR.
1.1       dsieger   528: 
                    529: The NetBSD package system
                    530: 
1.266     martin    531:     This is the former name of    pkgsrc   . It is part of the NetBSD operating
1.1       dsieger   532:     system and can be bootstrapped to run on non-NetBSD operating systems as
                    533:     well. It handles building (compiling), installing, and removing of
                    534:     packages.
                    535: 
                    536: Distfile
                    537: 
                    538:     This term describes the file or files that are provided by the author of
                    539:     the piece of software to distribute his work. All the changes necessary to
                    540:     build on NetBSD are reflected in the corresponding package. Usually the
                    541:     distfile is in the form of a compressed tar-archive, but other types are
                    542:     possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
                    543: 
                    544: Port
                    545: 
                    546:     This is the term used by FreeBSD and OpenBSD people for what we call a
1.266     martin    547:     package. In NetBSD terminology,    port    refers to a different architecture.
1.1       dsieger   548: 
                    549: Precompiled/binary package
                    550: 
                    551:     A set of binaries built with pkgsrc from a distfile and stuffed together in
                    552:     a single .tgz file so it can be installed on machines of the same machine
                    553:     architecture without the need to recompile. Packages are usually generated
                    554:     in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
                    555: 
1.266     martin    556:     Sometimes, this is referred to by the term    package    too, especially in the
1.1       dsieger   557:     context of precompiled packages.
                    558: 
                    559: Program
                    560: 
                    561:     The piece of software to be installed which will be constructed from all
                    562:     the files in the distfile by the actions defined in the corresponding
                    563:     package.
                    564: 
1.266     martin    565: 1.3.1.  Roles involved in pkgsrc
1.1       dsieger   566: 
                    567: pkgsrc users
                    568: 
                    569:     The pkgsrc users are people who use the packages provided by pkgsrc.
                    570:     Typically they are system administrators. The people using the software
1.266     martin    571:     that is inside the packages (maybe called    end users   ) are not covered by
1.1       dsieger   572:     the pkgsrc guide.
                    573: 
                    574:     There are two kinds of pkgsrc users: Some only want to install pre-built
                    575:     binary packages. Others build the pkgsrc packages from source, either for
                    576:     installing them directly or for building binary packages themselves. For
1.266     martin    577:     pkgsrc users Part  I,    The pkgsrc user's guide    should provide all necessary
1.1       dsieger   578:     documentation.
                    579: 
                    580: package maintainers
                    581: 
1.266     martin    582:     A package maintainer creates packages as described in Part  II,    The pkgsrc
                    583:     developer's guide   .
1.1       dsieger   584: 
                    585: infrastructure developers
                    586: 
                    587:     These people are involved in all those files that live in the mk/ directory
1.266     martin    588:     and below. Only these people should need to read through Part  III,    The
                    589:     pkgsrc infrastructure internals   , though others might be curious, too.
1.1       dsieger   590: 
1.266     martin    591: 1.4.  Typography
1.1       dsieger   592: 
                    593: When giving examples for commands, shell prompts are used to show if the
1.266     martin    594: command should/can be issued as root, or if    normal    user privileges are
1.115     sevan     595: sufficient. We use a # for root's shell prompt, a % for users' shell prompt,
1.229     gutterid  596: assuming they use the C-shell or tcsh and a $ for Bourne shell and derivatives.
1.1       dsieger   597: 
1.266     martin    598: Part  I.  The pkgsrc user's guide
1.1       dsieger   599: 
                    600: Table of Contents
                    601: 
1.154     rillig    602: 2. Getting help
                    603: 3. Where to get pkgsrc and how to keep it up-to-date
                    604:     3.1. Getting pkgsrc for the first time
                    605:         3.1.1. As tar archive
                    606:         3.1.2. Via anonymous CVS
                    607:     3.2. Keeping pkgsrc up-to-date
                    608:         3.2.1. Via tar files
                    609:         3.2.2. Via CVS
                    610: 4. Using pkgsrc on systems other than NetBSD
                    611:     4.1. Binary distribution
                    612:     4.2. Bootstrapping pkgsrc
                    613: 5. Using pkgsrc
                    614:     5.1. Using binary packages
                    615:         5.1.1. Finding binary packages
                    616:         5.1.2. Installing binary packages
1.202     nia       617:         5.1.3. Updating packages
                    618:         5.1.4. Deinstalling packages
                    619:         5.1.5. Getting information about installed packages
                    620:         5.1.6. Checking for security vulnerabilities in installed packages
                    621:         5.1.7. Finding if newer versions of your installed packages are in
1.271     wiz       622:         pkgsrc
1.202     nia       623:         5.1.8. Other administrative functions
1.154     rillig    624:     5.2. Building packages from source
                    625:         5.2.1. Requirements
                    626:         5.2.2. Fetching distfiles
                    627:         5.2.3. How to build and install
                    628: 6. Configuring pkgsrc
                    629:     6.1. General configuration
                    630:     6.2. Variables affecting the build process
1.241     rillig    631:     6.3. Preferences for native or pkgsrc software
                    632:     6.4. Variables affecting the installation process
                    633:     6.5. Selecting and configuring the compiler
                    634:         6.5.1. Selecting the compiler
                    635:         6.5.2. Additional flags to the compiler (CFLAGS)
                    636:         6.5.3. Additional flags to the linker (LDFLAGS)
                    637:     6.6. Developer/advanced settings
                    638:     6.7. Selecting Build Options
1.154     rillig    639: 7. Creating binary packages
                    640:     7.1. Building a single binary package
                    641:     7.2. Settings for creation of binary packages
                    642: 8. Creating binary packages for everything in pkgsrc (bulk builds)
                    643:     8.1. Preparations
1.180     rillig    644:     8.2. Running a bulk build
1.154     rillig    645:         8.2.1. Configuration
1.272     wiz       646:     8.3. Speeding up bulk build scans
                    647:     8.4. Requirements of a full bulk build
                    648:     8.5. Bulk build variants
                    649:         8.5.1. Detect unknown configure options
                    650:         8.5.2. Detect classes of bugs by forcing compiler warnings
                    651:         8.5.3. Force compiler options only in the build phase
                    652:         8.5.4. Use custom directories
                    653:         8.5.5. Turn warnings into errors
                    654:         8.5.6. Reject packages for which pkglint reports errors
                    655:         8.5.7. Reject packages that contain forbidden strings
                    656:         8.5.8. Reject packages whose self-test fails
                    657:         8.5.9. Reject packages that use undefined shell variables
                    658:         8.5.10. Turn off verbose logging
                    659:     8.6. Creating a multiple CD-ROM packages collection
                    660:         8.6.1. Example of cdpack
1.154     rillig    661: 9. Directory layout of the installed files
                    662:     9.1. File system layout in ${LOCALBASE}
                    663:     9.2. File system layout in ${VARBASE}
                    664: 10. Frequently Asked Questions
                    665:     10.1. Are there any mailing lists for pkg-related discussion?
                    666:     10.2. Utilities for package management (pkgtools)
                    667:     10.3. How to use pkgsrc as non-root
                    668:     10.4. How to resume transfers when fetching distfiles?
                    669:     10.5. How can I install/use modular X.org from pkgsrc?
                    670:     10.6. How to fetch files from behind a firewall
                    671:     10.7. How to fetch files from HTTPS sites
                    672:     10.8. How do I tell make fetch to do passive FTP?
                    673:     10.9. How to fetch all distfiles at once
1.266     martin    674:     10.10. What does    Don't know how to make /usr/share/tmac/tmac.andoc    mean?
                    675:     10.11. What does    Could not find bsd.own.mk    mean?
1.221     nia       676:     10.12. Using 'sudo' or `priv` with pkgsrc
1.154     rillig    677:     10.13. How do I change the location of configuration files?
                    678:     10.14. Automated security checks
                    679:     10.15. Why do some packages ignore my CFLAGS?
                    680:     10.16. A package does not build. What shall I do?
1.266     martin    681:     10.17. What does    Makefile appears to contain unresolved cvs/rcs/??? merge
1.271     wiz       682:     conflicts    mean?
1.1       dsieger   683: 
1.266     martin    684: Chapter  2.  Getting help
1.154     rillig    685: 
                    686: To get help when using pkgsrc, the definitive source is this document, the
                    687: pkgsrc guide. If you don't find anything here, there are alternatives:
                    688: 
                    689:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
1.266     martin    690:     Run bmake help topic=    to get help for any topic, such as a variable name
1.154     rillig    691:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                    692:     like strcasecmp or any other topic.
                    693: 
1.266     martin    694:     The available help topics are listed in Appendix  E, Help topics.
1.154     rillig    695: 
1.163     rillig    696:   * To see the value of a single variable, run bmake show-var VARNAME=X.
                    697: 
                    698:   * To see the values of the most common variables, run bmake show-all. These
                    699:     variables are grouped by topic. To see the variables for a single topic,
                    700:     run bmake show-all-topic, for example bmake show-all-fetch.
                    701: 
1.154     rillig    702:   * The pkgsrc-users mailing list, to which you can subscribe and then ask your
                    703:     questions.
                    704: 
                    705:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                    706:     a specialized chat program such as XChat. Pick any user name and join the
                    707:     channel #pkgsrc.
                    708: 
1.266     martin    709: Chapter  3.  Where to get pkgsrc and how to keep it up-to-date
1.1       dsieger   710: 
                    711: Table of Contents
                    712: 
1.154     rillig    713: 3.1. Getting pkgsrc for the first time
                    714:     3.1.1. As tar archive
                    715:     3.1.2. Via anonymous CVS
                    716: 3.2. Keeping pkgsrc up-to-date
                    717:     3.2.1. Via tar files
                    718:     3.2.2. Via CVS
1.1       dsieger   719: 
                    720: Before you download and extract the files, you need to decide where you want to
                    721: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
                    722: usr/pkgsrc. You are though free to install the sources and binary packages
                    723: wherever you want in your filesystem, provided that the pathname does not
                    724: contain white-space or other characters that are interpreted specially by the
                    725: shell and some other programs. A safe bet is to use only letters, digits,
                    726: underscores and dashes.
                    727: 
1.266     martin    728: 3.1.  Getting pkgsrc for the first time
1.1       dsieger   729: 
1.25      wiz       730: Before you download any pkgsrc files, you should decide whether you want the 
1.1       dsieger   731: current branch or the stable branch. The latter is forked on a quarterly basis
                    732: from the current branch and only gets modified for security updates. The names
                    733: of the stable branches are built from the year and the quarter, for example
1.267     leot      734: 2025Q4.
1.1       dsieger   735: 
                    736: The second step is to decide how you want to download pkgsrc. You can get it as
1.24      wiz       737: a tar file or via CVS. Both ways are described here.
1.1       dsieger   738: 
1.52      asau      739: Note that tar archive contains CVS working copy. Thus you can switch to using
                    740: CVS at any later time.
1.1       dsieger   741: 
1.266     martin    742: 3.1.1.  As tar archive
1.52      asau      743: 
1.151     sevan     744: The primary download location for all pkgsrc files is https://cdn.NetBSD.org/
                    745: pub/pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same
                    746: location). There are a number of subdirectories for different purposes, which
1.266     martin    747: are described in detail in Appendix  D, Directory layout of the pkgsrc FTP
1.151     sevan     748: server.
1.1       dsieger   749: 
1.52      asau      750: The tar archive for the current branch is in the directory current and is
1.118     sevan     751: called pkgsrc.tar.gz. It is autogenerated weekly.
1.52      asau      752: 
                    753: To save download time we provide bzip2- and xz-compressed archives which are
                    754: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
                    755: 
                    756: You can fetch the same files using FTP.
1.1       dsieger   757: 
1.267     leot      758: The tar file for the stable branch 2025Q4 is in the directory pkgsrc-2025Q4 and
1.59      jnemeth   759: is also called pkgsrc.tar.gz.
1.1       dsieger   760: 
1.136     leot      761: To download the latest pkgsrc stable tarball, run:
1.12      weinem    762: 
1.267     leot      763: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2025Q4/pkgsrc.tar.gz
1.12      weinem    764: 
1.78      snj       765: If you prefer, you can also fetch it using "wget", "curl", or your web browser.
1.52      asau      766: 
1.12      weinem    767: Then, extract it with:
                    768: 
1.78      snj       769: $ tar -xzf pkgsrc.tar.gz -C /usr
1.12      weinem    770: 
                    771: This will create the directory pkgsrc/ in /usr/ and all the package source will
                    772: be stored under /usr/pkgsrc/.
                    773: 
                    774: To download pkgsrc-current, run:
                    775: 
                    776: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1       dsieger   777: 
1.266     martin    778: 3.1.2.  Via anonymous CVS
1.1       dsieger   779: 
1.24      wiz       780: To fetch a specific pkgsrc stable branch, run:
1.1       dsieger   781: 
1.267     leot      782: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2025Q4 -P pkgsrc
1.13      weinem    783: 
1.24      wiz       784: This will create the directory pkgsrc/ in your /usr/ directory and all the
                    785: package source will be stored under /usr/pkgsrc/.
                    786: 
                    787: To fetch the pkgsrc current branch, run:
1.1       dsieger   788: 
1.40      wiz       789: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   790: 
1.30      dholland  791: Refer to the list of available mirrors to choose a faster CVS mirror, if
                    792: needed.
1.1       dsieger   793: 
1.24      wiz       794: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1       dsieger   795: 
1.40      wiz       796: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   797: 
1.24      wiz       798: Refer to documentation on your command shell how to set CVS_RSH=ssh
                    799: permanently. For Bourne shells, you can set it in your .profile or better
                    800: globally in /etc/profile:
                    801: 
                    802: # set CVS remote shell command
                    803: CVS_RSH=ssh
                    804: export CVS_RSH
1.12      weinem    805: 
1.13      weinem    806: By default, CVS doesn't do things like most people would expect it to do. But
                    807: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12      weinem    808: directory and saving the following lines to it. This file will save you lots of
                    809: headache and some bug reports, so we strongly recommend it. You can find an
                    810: explanation of this file in the CVS documentation.
1.2       rillig    811: 
                    812: # recommended CVS configuration file from the pkgsrc guide
1.155     sevan     813: cvs -q
1.2       rillig    814: checkout -P
1.4       rillig    815: update -dP
                    816: diff -upN
1.2       rillig    817: rdiff -u
1.24      wiz       818: release -d
1.1       dsieger   819: 
1.266     martin    820: 3.2.  Keeping pkgsrc up-to-date
1.1       dsieger   821: 
                    822: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
                    823: have first installed it via a tar file). It saves bandwidth and hard disk
                    824: activity, compared to downloading the tar file again.
                    825: 
1.266     martin    826: 3.2.1.  Via tar files
1.1       dsieger   827: 
                    828: Warning
                    829: 
                    830: When updating from a tar file, you first need to completely remove the old
                    831: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
                    832: the mean time will not be removed on your local disk, resulting in
                    833: inconsistencies. When removing the old files, any changes that you have done to
                    834: the pkgsrc files will be lost after updating. Therefore updating via CVS is
                    835: strongly recommended.
                    836: 
                    837: Note that by default the distfiles and the binary packages are saved in the
                    838: pkgsrc tree, so don't forget to rescue them before updating. You can also
1.78      snj       839: configure pkgsrc to store distfiles and packages in directories outside the
1.266     martin    840: pkgsrc tree by setting the DISTDIR and PACKAGES variables. See Chapter  6, 
1.78      snj       841: Configuring pkgsrc for the details.
1.1       dsieger   842: 
                    843: To update pkgsrc from a tar file, download the tar file as explained above.
                    844: Then, make sure that you have not made any changes to the files in the pkgsrc
                    845: directory. Remove the pkgsrc directory and extract the new tar file. Done.
                    846: 
1.266     martin    847: 3.2.2.  Via CVS
1.1       dsieger   848: 
1.26      spz       849: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12      weinem    850: 
1.26      spz       851: $ cd /usr/pkgsrc && cvs update -dP
                    852: 
                    853: If you get error messages from rsh, you need to set CVS_RSH variable as
                    854: described above. E.g.:
                    855: 
                    856: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1       dsieger   857: 
1.266     martin    858: 3.2.2.1.  Switching between different pkgsrc branches
1.1       dsieger   859: 
                    860: When updating pkgsrc, the CVS program keeps track of the branch you selected.
                    861: But if you, for whatever reason, want to switch from the stable branch to the
1.266     martin    862: current one, you can do it by adding the option    -A    after the    update   
                    863: keyword. To switch from the current branch back to the stable branch, add the    
1.267     leot      864: -rpkgsrc-2025Q4    option.
1.1       dsieger   865: 
1.266     martin    866: 3.2.2.2.  What happens to my changes when updating?
1.1       dsieger   867: 
                    868: When you update pkgsrc, the CVS program will only touch those files that are
                    869: registered in the CVS repository. That means that any packages that you created
                    870: on your own will stay unmodified. If you change files that are managed by CVS,
                    871: later updates will try to merge your changes with those that have been done by
1.266     martin    872: others. See the CVS manual, chapter    update    for details.
1.1       dsieger   873: 
1.266     martin    874: Chapter  4.  Using pkgsrc on systems other than NetBSD
1.1       dsieger   875: 
                    876: Table of Contents
                    877: 
1.154     rillig    878: 4.1. Binary distribution
                    879: 4.2. Bootstrapping pkgsrc
1.1       dsieger   880: 
1.266     martin    881: 4.1.  Binary distribution
1.1       dsieger   882: 
1.266     martin    883: See Section  5.1,    Using binary packages   .
1.1       dsieger   884: 
1.266     martin    885: 4.2.  Bootstrapping pkgsrc
1.1       dsieger   886: 
1.44      asau      887: pkgsrc can be bootstrapped for use in two different modes: privileged and
                    888: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45      asau      889: programs are installed under one particular user and cannot utilise privileged
1.44      asau      890: operations (packages don't create special users and all special file
                    891: permissions like setuid are ignored).
                    892: 
1.1       dsieger   893: Installing the bootstrap kit from source should be as simple as:
                    894: 
1.60      asau      895: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   896: # cd pkgsrc/bootstrap
                    897: # ./bootstrap
                    898: 
                    899: 
1.266     martin    900: To bootstrap in unprivileged mode pass    --unprivileged    flag to bootstrap
1.44      asau      901: 
                    902: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
1.118     sevan     903: will be installed in, and /usr/pkg/pkgdb for the package database directory
                    904: where pkgsrc will do its internal bookkeeping, /var is used as varbase, where
1.44      asau      905: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
1.118     sevan     906: for prefix, ~/pkg/pkgdb for the package database, and ~/pkg/var for varbase.
1.44      asau      907: 
1.266     martin    908: You can change default layout using command-line arguments. Run    ./bootstrap
                    909: --help    to get details.
1.1       dsieger   910: 
                    911: Note
                    912: 
                    913: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
1.266     martin    914: For examples in this guide, use bmake instead of    make   .
1.1       dsieger   915: 
1.44      asau      916: Note
                    917: 
                    918: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
                    919: directories. Use bmake corresponding to the installation you're working with to
                    920: build and install packages.
                    921: 
1.266     martin    922: Chapter  5.  Using pkgsrc
1.1       dsieger   923: 
                    924: Table of Contents
                    925: 
1.154     rillig    926: 5.1. Using binary packages
                    927:     5.1.1. Finding binary packages
                    928:     5.1.2. Installing binary packages
1.202     nia       929:     5.1.3. Updating packages
                    930:     5.1.4. Deinstalling packages
                    931:     5.1.5. Getting information about installed packages
                    932:     5.1.6. Checking for security vulnerabilities in installed packages
                    933:     5.1.7. Finding if newer versions of your installed packages are in pkgsrc
                    934:     5.1.8. Other administrative functions
1.154     rillig    935: 5.2. Building packages from source
                    936:     5.2.1. Requirements
                    937:     5.2.2. Fetching distfiles
                    938:     5.2.3. How to build and install
1.1       dsieger   939: 
                    940: Basically, there are two ways of using pkgsrc. The first is to only install the
                    941: package tools and to use binary packages that someone else has prepared. This
1.266     martin    942: is the    pkg    in pkgsrc. The second way is to install the    src    of pkgsrc, too.
1.1       dsieger   943: Then you are able to build your own packages, and you can still use binary
                    944: packages from someone else.
                    945: 
1.266     martin    946: 5.1.  Using binary packages
1.1       dsieger   947: 
1.151     sevan     948: On the cdn.NetBSD.org site and mirrors, there are collections of binary
1.9       rillig    949: packages, ready to be installed. These binary packages have been built using
                    950: the default settings for the directories, that is:
                    951: 
                    952:   * /usr/pkg for LOCALBASE, where most of the files are installed,
                    953: 
                    954:   * /usr/pkg/etc for configuration files,
                    955: 
                    956:   * /var for VARBASE, where those files are installed that may change after
                    957:     installation.
                    958: 
                    959: If you cannot use these directories for whatever reasons (maybe because you're
                    960: not root), you cannot use these binary packages, but have to build the packages
1.266     martin    961: yourself, which is explained in Section  4.2,    Bootstrapping pkgsrc   .
1.1       dsieger   962: 
1.266     martin    963: 5.1.1.  Finding binary packages
1.1       dsieger   964: 
1.5       weinem    965: To install binary packages, you first need to know from where to get them. The
1.202     nia       966: first place where you should look is on the main pkgsrc CDN in the directory /
                    967: pub/pkgsrc/packages.
1.5       weinem    968: 
                    969: This directory contains binary packages for multiple platforms. First, select
1.226     gutterid  970: your operating system. Then, select your hardware architecture, and in the
1.266     martin    971: third step, the OS version and the    version    of pkgsrc.
1.9       rillig    972: 
1.226     gutterid  973: In this directory, you may find a file called bootstrap.tar.gz which contains
1.9       rillig    974: the package management tools. If the file is missing, it is likely that your
                    975: operating system already provides those tools. Download the file and extract it
                    976: in the / directory. It will create the directories /usr/pkg (containing the
1.118     sevan     977: tools for managing binary packages and the database of installed packages).
1.1       dsieger   978: 
1.266     martin    979: 5.1.2.  Installing binary packages
1.1       dsieger   980: 
1.85      wiz       981: In the directory from the last section, there is a subdirectory called All/,
1.9       rillig    982: which contains all the binary packages that are available for the platform,
1.202     nia       983: excluding those that may not be distributed via HTTP or FTP.
1.9       rillig    984: 
                    985: To install packages directly from an FTP or HTTP server, run the following
                    986: commands in a Bourne-compatible shell (be sure to su to root first):
                    987: 
1.202     nia       988: # PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
                    989: # PKG_PATH="https://cdn.NetBSD.org/pub/pkgsrc/packages"
1.169     rillig    990: # PKG_PATH="$PKG_PATH/OPSYS/ARCH/VERSIONS/All/"
1.9       rillig    991: # export PATH PKG_PATH
1.202     nia       992: # pkg_add pkgin
1.9       rillig    993: 
                    994: Instead of URLs, you can also use local paths, for example if you are
                    995: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
                    996: to install packages from multiple sources, you can separate them by a semicolon
                    997: in PKG_PATH.
                    998: 
                    999: After these preparations, installing a package is very easy:
                   1000: 
1.202     nia      1001: # pkgin search nginx
                   1002: nginx-1.19.6         Lightweight HTTP server and mail proxy server
                   1003: nginx-1.18.0nb8      Lightweight HTTP server and mail proxy server
                   1004: # pkgin install zsh nginx-1.19.6 vim
1.1       dsieger  1005: 
1.202     nia      1006: Note that pkgin is a user-friendly frontend to the pkg_* tools.
1.1       dsieger  1007: 
1.202     nia      1008: Any prerequisite packages needed to run the package in question will be
                   1009: installed, too, assuming they are present in the repository.
1.1       dsieger  1010: 
                   1011: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
                   1012: in your PATH so you can actually start the just installed program.
                   1013: 
1.266     martin   1014: 5.1.3.  Updating packages
1.1       dsieger  1015: 
1.202     nia      1016: To update binary packages, it is recommended that you use pkgin upgrade. This
                   1017: will compare the remote package repository to your locally installed packages
                   1018: and safely replace any older packages.
1.1       dsieger  1019: 
1.202     nia      1020: Note that pkgsrc is released as quarterly branches. If you are updating to a
                   1021: newer quarterly branch of pkgsrc, you may need to adjust the repository in /usr
                   1022: /pkg/etc/pkgin/repositories.conf.
1.1       dsieger  1023: 
1.266     martin   1024: 5.1.4.  Deinstalling packages
1.1       dsieger  1025: 
1.202     nia      1026: To deinstall a package, it does not matter whether it was installed from source
                   1027: code or from a binary package. Neither the pkgin or the pkg_delete command need
                   1028: to know.
1.1       dsieger  1029: 
1.202     nia      1030: To delete a package, you can just run pkgin remove package-name. The package
                   1031: name can be given with or without version number.
1.1       dsieger  1032: 
1.266     martin   1033: 5.1.5.  Getting information about installed packages
1.1       dsieger  1034: 
                   1035: The pkg_info shows information about installed packages or binary package
1.202     nia      1036: files. As with other management tools, it works with packages installed from
                   1037: source or binaries.
1.1       dsieger  1038: 
1.266     martin   1039: 5.1.6.  Checking for security vulnerabilities in installed packages
1.1       dsieger  1040: 
1.202     nia      1041: The pkgsrc Security Team and Packages Groups maintain a list of known
1.164     leot     1042: vulnerabilities to packages which are (or have been) included in pkgsrc. The
1.202     nia      1043: list is available from the NetBSD CDN at https://cdn.NetBSD.org/pub/NetBSD/
1.179     rillig   1044: packages/vulns/pkg-vulnerabilities.
1.1       dsieger  1045: 
1.202     nia      1046: Please note that not every "vulnerability" with a CVE assignment is exploitable
                   1047: in every configuration. Some bugs are marked as active simply because an fix
                   1048: was not marked as such. Operating system specific hardening and mitigation
                   1049: features may also reduce the impact of bugs.
                   1050: 
1.23      jakllsch 1051: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
                   1052: automatically, and a security audit of all packages installed on a system can
                   1053: take place.
                   1054: 
                   1055: There are two components to auditing. The first step, pkg_admin
                   1056: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
                   1057: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
                   1058: your installed packages are vulnerable. If a package is vulnerable, you will
                   1059: see output similar to the following:
1.1       dsieger  1060: 
                   1061: Package samba-2.0.9 has a local-root-shell vulnerability, see
1.174     leot     1062:     https://www.samba.org/samba/whatsnew/macroexploit.html
1.1       dsieger  1063: 
1.23      jakllsch 1064: You may wish to have the vulnerabilities file downloaded daily so that it
                   1065: remains current. This may be done by adding an appropriate entry to the root
                   1066: users crontab(5) entry. For example the entry
                   1067: 
1.121     sevan    1068: # Download vulnerabilities file
1.118     sevan    1069: 0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1.121     sevan    1070: # Audit the installed packages and email results to root
                   1071: 9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
                   1072:             root >/dev/null 2>&1
1.118     sevan    1073: 
                   1074: 
                   1075: will update the vulnerability list every day at 3AM, followed by an audit at
                   1076: 3:09AM. The result of the audit are then emailed to root. On NetBSD this may be
                   1077: accomplished instead by adding the following line to /etc/daily.conf:
                   1078: 
                   1079: fetch_pkg_vulnerabilities=YES
                   1080: 
1.23      jakllsch 1081: 
1.118     sevan    1082: to fetch the vulnerability list from the daily security script. The system is
                   1083: set to audit the packages by default but can be set explicitly, if desired (not
1.123     wiz      1084: required), by adding the following line to /etc/security.conf:
1.23      jakllsch 1085: 
1.118     sevan    1086: check_pkg_vulnerabilities=YES
1.23      jakllsch 1087: 
                   1088: 
1.118     sevan    1089: see daily.conf(5) and security.conf(5) for more details.
1.1       dsieger  1090: 
1.266     martin   1091: 5.1.7.  Finding if newer versions of your installed packages are in pkgsrc
1.1       dsieger  1092: 
1.266     martin   1093: Install pkgtools/lintpkgsrc and run lintpkgsrc with the    -i    argument to check
1.202     nia      1094: if any packages are stale, e.g.
1.1       dsieger  1095: 
                   1096: % lintpkgsrc -i
                   1097: ...
                   1098: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
                   1099: 
                   1100: 
1.266     martin   1101: 5.1.8.  Other administrative functions
1.1       dsieger  1102: 
                   1103: The pkg_admin executes various administrative functions on the package system.
                   1104: 
1.266     martin   1105: 5.2.  Building packages from source
1.1       dsieger  1106: 
                   1107: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25      wiz      1108: organized into categories. You can browse the online index of packages, or run 
1.1       dsieger  1109: make readme from the pkgsrc directory to build local README.html files for all
                   1110: packages, viewable with any web browser such as www/lynx or www/firefox.
                   1111: 
                   1112: The default prefix for installed packages is /usr/pkg. If you wish to change
                   1113: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
                   1114: use multiple different LOCALBASE definitions on the same system (inside a
                   1115: chroot is an exception).
                   1116: 
                   1117: The rest of this chapter assumes that the package is already in pkgsrc. If it
1.266     martin   1118: is not, see Part  II,    The pkgsrc developer's guide    for instructions how to
1.1       dsieger  1119: create your own packages.
                   1120: 
1.266     martin   1121: 5.2.1.  Requirements
1.1       dsieger  1122: 
                   1123: To build packages from source, you need a working C compiler. On NetBSD, you
1.266     martin   1124: need to install the    comp    and the    text    distribution sets. If you want to
                   1125: build X11-related packages, the    xbase    and    xcomp    distribution sets are
1.1       dsieger  1126: required, too.
                   1127: 
1.266     martin   1128: 5.2.2.  Fetching distfiles
1.1       dsieger  1129: 
                   1130: The first step for building a package is downloading the distfiles (i.e. the
                   1131: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
                   1132: them automatically.
                   1133: 
                   1134: If you have all files that you need in the distfiles directory, you don't need
                   1135: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
                   1136: and add:
                   1137: 
                   1138: DISTDIR=/cdrom/pkgsrc/distfiles
                   1139: 
                   1140: to your mk.conf.
                   1141: 
                   1142: By default a list of distribution sites will be randomly intermixed to prevent
                   1143: huge load on servers which holding popular packages (for example,
                   1144: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
                   1145: distfile all the mirrors will be tried in new (random) order. You can turn this
                   1146: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
                   1147: disabled).
                   1148: 
                   1149: You can overwrite some of the major distribution sites to fit to sites that are
                   1150: close to your own. By setting one or two variables you can modify the order in
                   1151: which the master sites are accessed. MASTER_SORT contains a whitespace
                   1152: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
                   1153: contains a whitespace delimited list of regular expressions. It has higher
                   1154: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
                   1155: some examples. This may save some of your bandwidth and time.
                   1156: 
                   1157: You can change these settings either in your shell's environment, or, if you
1.4       rillig   1158: want to keep the settings, by editing the mk.conf file, and adding the
1.1       dsieger  1159: definitions there.
                   1160: 
1.132     wiz      1161: If a package depends on many other packages (such as meta-pkgs/kde4), the build
1.1       dsieger  1162: process may alternate between periods of downloading source, and compiling. To
                   1163: ensure you have all the source downloaded initially you can run the command:
                   1164: 
                   1165: % make fetch-list | sh
                   1166: 
                   1167: which will output and run a set of shell commands to fetch the necessary files
                   1168: into the distfiles directory. You can also choose to download the files
                   1169: manually.
                   1170: 
1.266     martin   1171: 5.2.3.  How to build and install
1.1       dsieger  1172: 
                   1173: Once the software has downloaded, any patches will be applied, then it will be
                   1174: compiled for you. This may take some time depending on your computer, and how
                   1175: many other packages the software depends on and their compile time.
                   1176: 
                   1177: Note
                   1178: 
                   1179: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
1.266     martin   1180: command instead of    make    in the examples in this guide.
1.1       dsieger  1181: 
                   1182: For example, type
                   1183: 
                   1184: % cd misc/figlet
                   1185: % make
                   1186: 
                   1187: 
                   1188: at the shell prompt to build the various components of the package.
                   1189: 
                   1190: The next stage is to actually install the newly compiled program onto your
                   1191: system. Do this by entering:
                   1192: 
                   1193: % make install
                   1194: 
                   1195: 
                   1196: while you are still in the directory for whatever package you are installing.
                   1197: 
                   1198: Installing the package on your system may require you to be root. However,
                   1199: pkgsrc has a just-in-time-su feature, which allows you to only become root for
                   1200: the actual installation step.
                   1201: 
                   1202: That's it, the software should now be installed and setup for use. You can now
                   1203: enter:
                   1204: 
                   1205: % make clean
                   1206: 
                   1207: 
                   1208: to remove the compiled files in the work directory, as you shouldn't need them
                   1209: any more. If other packages were also added to your system (dependencies) to
                   1210: allow your program to compile, you can tidy these up also with the command:
                   1211: 
                   1212: % make clean-depends
                   1213: 
                   1214: 
                   1215: Taking the figlet utility as an example, we can install it on our system by
1.266     martin   1216: building as shown in Appendix  C, Build logs.
1.1       dsieger  1217: 
                   1218: The program is installed under the default root of the packages tree - /usr/
                   1219: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
                   1220: environment, and it will use that value as the root of your packages tree. So,
                   1221: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
                   1222: that you should use a directory which is dedicated to packages and not shared
                   1223: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
                   1224: not try to add any of your own files or directories (such as src/, obj/, or
                   1225: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
                   1226: between programs and other files installed by the package system and whatever
                   1227: else may have been installed there.
                   1228: 
1.4       rillig   1229: Some packages look in mk.conf to alter some configuration options at build
1.1       dsieger  1230: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
                   1231: be set there by default. Environment variables such as LOCALBASE can be set in
1.4       rillig   1232: mk.conf to save having to remember to set them each time you want to use
1.1       dsieger  1233: pkgsrc.
                   1234: 
1.266     martin   1235: Occasionally, people want to    look under the covers    to see what is going on
1.1       dsieger  1236: when a package is building or being installed. This may be for debugging
                   1237: purposes, or out of simple curiosity. A number of utility values have been
                   1238: added to help with this.
                   1239: 
                   1240:  1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
                   1241:     amount of information will be displayed. For example,
                   1242: 
                   1243:     make patch PKG_DEBUG_LEVEL=2
                   1244: 
1.266     martin   1245:     will show all the commands that are invoked, up to and including the    patch
                   1246:         stage.
1.1       dsieger  1247: 
                   1248:  2. If you want to know the value of a certain make(1) definition, then the
                   1249:     VARNAME definition should be used, in conjunction with the show-var target.
                   1250:     e.g. to show the expansion of the make(1) variable LOCALBASE:
                   1251: 
                   1252:     % make show-var VARNAME=LOCALBASE
                   1253:     /usr/pkg
                   1254:     %
                   1255: 
                   1256: 
                   1257: If you want to install a binary package that you've either created yourself
                   1258: (see next section), that you put into pkgsrc/packages manually or that is
                   1259: located on a remote FTP server, you can use the "bin-install" target. This
                   1260: target will install a binary package - if available - via pkg_add(1), else do a
                   1261: make package. The list of remote FTP sites searched is kept in the variable
                   1262: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
                   1263: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
                   1264: for more details.
                   1265: 
                   1266: A final word of warning: If you set up a system that has a non-standard setting
                   1267: for LOCALBASE, be sure to set that before any packages are installed, as you
                   1268: cannot use several directories for the same purpose. Doing so will result in
                   1269: pkgsrc not being able to properly detect your installed packages, and fail
                   1270: miserably. Note also that precompiled binary packages are usually built with
                   1271: the default LOCALBASE of /usr/pkg, and that you should not install any if you
                   1272: use a non-standard LOCALBASE.
                   1273: 
1.266     martin   1274: Chapter  6.  Configuring pkgsrc
1.1       dsieger  1275: 
                   1276: Table of Contents
                   1277: 
1.154     rillig   1278: 6.1. General configuration
                   1279: 6.2. Variables affecting the build process
1.241     rillig   1280: 6.3. Preferences for native or pkgsrc software
                   1281: 6.4. Variables affecting the installation process
                   1282: 6.5. Selecting and configuring the compiler
                   1283:     6.5.1. Selecting the compiler
                   1284:     6.5.2. Additional flags to the compiler (CFLAGS)
                   1285:     6.5.3. Additional flags to the linker (LDFLAGS)
                   1286: 6.6. Developer/advanced settings
                   1287: 6.7. Selecting Build Options
1.1       dsieger  1288: 
                   1289: The whole pkgsrc system is configured in a single file, usually called mk.conf.
                   1290: In which directory pkgsrc looks for that file depends on the installation. On
                   1291: NetBSD, when you use make(1) from the base system, it is in the directory /etc
                   1292: /. In all other cases the default location is ${PREFIX}/etc/, depending on
                   1293: where you told the bootstrap program to install the binary packages.
                   1294: 
                   1295: The format of the configuration file is that of the usual BSD-style Makefiles.
                   1296: The whole pkgsrc configuration is done by setting variables in this file. Note
                   1297: that you can define all kinds of variables, and no special error checking (for
1.112     rillig   1298: example for spelling mistakes) takes place.
1.1       dsieger  1299: 
1.266     martin   1300: 6.1.  General configuration
1.1       dsieger  1301: 
1.112     rillig   1302: The following variables apply to all pkgsrc packages. A complete list of the
                   1303: variables that can be configured by the user is available in mk/defaults/
                   1304: mk.conf, together with some comments that describe each variable's intent.
1.1       dsieger  1305: 
                   1306:   * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
                   1307:     not mix binary packages with different LOCALBASEs!
                   1308: 
1.266     martin   1309:   * CROSSBASE: Where    cross    category packages will be installed. The default
1.1       dsieger  1310:     is ${LOCALBASE}/cross.
                   1311: 
1.84      wiz      1312:   * X11BASE: Where X11 is installed on the system. The default is /usr/X11R7.
1.1       dsieger  1313: 
                   1314:   * DISTDIR: Where to store the downloaded copies of the original source
                   1315:     distributions used for building pkgsrc packages. The default is $
                   1316:     {PKGSRCDIR}/distfiles.
                   1317: 
                   1318:   * PKG_DBDIR: Where the database about installed packages is stored. The
1.118     sevan    1319:     default is /usr/pkg/pkgdb.
1.1       dsieger  1320: 
                   1321:   * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
                   1322:     value.
                   1323: 
                   1324:   * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
                   1325:     files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.118     sevan    1326:     respectively. The defaults is ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1.1       dsieger  1327:     {DIST_SUBDIR}/.
                   1328: 
                   1329:   * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
1.266     martin   1330:     with OS release (   2.0   , etc.) and architecture (   mipsel   , etc.).
1.1       dsieger  1331: 
1.23      jakllsch 1332:   * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
                   1333:     case-sensitive. Whenever you try to build a package whose license is not in
                   1334:     this list, you will get an error message. If the license condition is
                   1335:     simple enough, the error message will include specific instructions on how
                   1336:     to change this variable.
1.1       dsieger  1337: 
1.266     martin   1338: 6.2.  Variables affecting the build process
1.1       dsieger  1339: 
                   1340:   * PACKAGES: The top level directory for the binary packages. The default is $
                   1341:     {PKGSRCDIR}/packages.
                   1342: 
                   1343:   * WRKOBJDIR: The top level directory where, if defined, the separate working
                   1344:     directories will get created, and symbolically linked to from ${WRKDIR}
                   1345:     (see below). This is useful for building packages on several architectures,
                   1346:     then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
                   1347:     architecture. (It should be noted that PKGSRCDIR should not be set by the
1.266     martin   1348:     user     it is an internal definition which refers to the root of the pkgsrc
1.1       dsieger  1349:     tree. It is possible to have many pkgsrc tree instances.)
                   1350: 
                   1351:   * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.266     martin   1352:     Section  12.3,    patches/*    for more information.
1.1       dsieger  1353: 
                   1354:   * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
                   1355:     Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
                   1356:     up settings used by builds in /usr/src.
                   1357: 
1.266     martin   1358: 6.3.  Preferences for native or pkgsrc software
1.241     rillig   1359: 
                   1360: Whenever a package depends on a package that has a builtin.mk file, the
                   1361: dependent package can either use the built-in (native) version from the base
                   1362: system or the pkgsrc-provided version. This only affects dependencies, so it is
                   1363: still possible to build the pkgsrc package devel/pcre++ even when other
                   1364: packages depend on the native pcre++ version instead.
                   1365: 
1.266     martin   1366: To force using the pkgsrc-provided version for a particular package, define    
                   1367: PREFER_PKGSRC = package-ID    in mk.conf. To force using the native package,
                   1368: define    PREFER_NATIVE = package-ID   . In both cases, the package-ID is the one
1.241     rillig   1369: from the buildlink3.mk of the package. In most cases, this ID is the same as
                   1370: the directory name of the package, but for example, devel/pcre++ has the
1.266     martin   1371: package ID    pcrexx   .
1.241     rillig   1372: 
                   1373: For the packages that are not listed by their package ID, pkgsrc uses the
1.266     martin   1374: pkgsrc-provided version if PREFER_PKGSRC contains the word    yes   . Otherwise, if
                   1375: PREFER_NATIVE contains the word    yes   , pkgsrc uses the native version. For
1.241     rillig   1376: example, to require using the pkgsrc-provided versions for all but the most
                   1377: basic bits on a NetBSD system, you can set:
                   1378: 
                   1379: PREFER_PKGSRC=  yes
                   1380: PREFER_NATIVE=  getopt skey tcp_wrappers
                   1381: 
                   1382: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
                   1383: it is simply ignored in that list.
                   1384: 
                   1385: PREFER_PKGSRC and PREFER_NATIVE should be set during bootstrap to ensure that
                   1386: the bootstrap process does not use inapropriate native tools as dependencies
                   1387: for core packages.
                   1388: 
                   1389: # ./bootstrap --prefer-pkgsrc yes --prefer-native openssl
                   1390: 
                   1391: Switching between settings globally at a later date can introduce complications
                   1392: with dependency resolution. This is caused by packages built with the opposite
                   1393: preference being installed alongside each other. Hence, when changing any of
                   1394: these variables after bootstrap, you need to rebuild all packages depending on
                   1395: those whose preference has been changed. This is not trivial and should be
                   1396: avoided.
                   1397: 
1.266     martin   1398: When using pkgsrc on Linux systems, there is high risk of    leakage   , where
1.241     rillig   1399: programs installed by pkgsrc may inadvertently use a command or library not
                   1400: installed by pkgsrc, e.g. those installed by yum or apt. Such foreign
                   1401: dependencies may be installed, removed, or upgraded to a version incompatible
                   1402: with the pkgsrc package at any time, causing pkgsrc packages to subsequently
                   1403: malfunction. Pkgsrc cannot prevent this, as it has no control over other
                   1404: package managers. Another potential problem is that under Redhat Enterprise and
                   1405: related Linux systems, yum packages are only patched and never upgraded, so
                   1406: eventually they may become too outdated for use by pkgsrc. Even intentionally
                   1407: using foreign dependencies, not considered leakage, can lead to these problems,
                   1408: so it is generally discouraged. In order to minimize such problems,
1.266     martin   1409: PREFER_PKGSRC defaults to    yes    on Linux systems. This ensures that pkgsrc is
1.241     rillig   1410: aware of any changes to dependency packages and can rebuild or upgrade the
                   1411: entire dependency tree as needed. This default can be overridden by setting
1.266     martin   1412: --prefer-pkgsrc to a list of packages and --prefer-native to    yes   .
1.241     rillig   1413: 
1.266     martin   1414: 6.4.  Variables affecting the installation process
1.1       dsieger  1415: 
1.198     leot     1416:   * PKGSRC_KEEP_BIN_PKGS: By default, binary packages of built packages are
1.150     leot     1417:     preserved in ${PACKAGES}/All. Setting this variable to "no" prevents this.
1.1       dsieger  1418: 
1.107     jnemeth  1419: Packages have to support installation into a subdirectory of WRKDIR. This
                   1420: allows a package to be built, before the actual filesystem is touched. DESTDIR
                   1421: support exists in two variations:
1.4       rillig   1422: 
                   1423:   * Basic DESTDIR support means that the package installation and packaging is
                   1424:     still run as root.
                   1425: 
                   1426:   * Full DESTDIR support can run the complete build, installation and packaging
                   1427:     as normal user. Root privileges are only needed to add packages.
                   1428: 
                   1429: With basic DESTDIR support, make clean needs to be run as root.
                   1430: 
1.17      imil     1431: Considering the foo/bar package, DESTDIR full support can be tested using the
                   1432: following commands
                   1433: 
                   1434: $ id
                   1435: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
                   1436: $ mkdir $HOME/packages
                   1437: $ cd $PKGSRCDIR/foo/bar
                   1438: 
                   1439: Verify DESTDIR full support, no root privileges should be needed
                   1440: 
1.66      asau     1441: $ make stage-install
1.17      imil     1442: 
                   1443: Create a package without root privileges
                   1444: 
1.66      asau     1445: $ make PACKAGES=$HOME/packages package
1.17      imil     1446: 
                   1447: For the following command, you must be able to gain root privileges using su(1)
                   1448: 
1.66      asau     1449: $ make PACKAGES=$HOME/packages install
1.17      imil     1450: 
                   1451: Then, as a simple user
                   1452: 
                   1453: $ make clean
                   1454: 
1.266     martin   1455: 6.5.  Selecting and configuring the compiler
1.4       rillig   1456: 
1.266     martin   1457: 6.5.1.  Selecting the compiler
1.1       dsieger  1458: 
                   1459: By default, pkgsrc will use GCC to build packages. This may be overridden by
                   1460: setting the following variables in /etc/mk.conf:
                   1461: 
                   1462: PKGSRC_COMPILER:
                   1463: 
                   1464:     This is a list of values specifying the chain of compilers to invoke when
                   1465:     building packages. Valid values are:
                   1466: 
1.271     wiz      1467:       o ccc: Compaq C Compilers (Tru64)
1.66      asau     1468: 
1.271     wiz      1469:       o ccache: compiler cache (chainable)
1.66      asau     1470: 
1.271     wiz      1471:       o clang: Clang C and Objective-C compiler
1.66      asau     1472: 
1.271     wiz      1473:       o distcc: distributed C/C++ (chainable)
1.1       dsieger  1474: 
1.271     wiz      1475:       o f2c: Fortran 77 to C compiler (chainable)
1.66      asau     1476: 
1.271     wiz      1477:       o icc: Intel C++ Compiler (Linux)
1.66      asau     1478: 
1.271     wiz      1479:       o ido: SGI IRIS Development Option cc (IRIX 5)
1.1       dsieger  1480: 
1.271     wiz      1481:       o gcc: GNU C/C++ Compiler
1.1       dsieger  1482: 
1.271     wiz      1483:       o hp: HP-UX C/aC++ compilers
1.66      asau     1484: 
1.271     wiz      1485:       o mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1       dsieger  1486: 
1.271     wiz      1487:       o mipspro-ucode: Silicon Graphics, Inc. MIPSpro (o32)
1.1       dsieger  1488: 
1.271     wiz      1489:       o sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1       dsieger  1490: 
1.271     wiz      1491:       o xlc: IBM's XL C/C++ compiler suite
1.66      asau     1492: 
1.266     martin   1493:     The default is    gcc   . You can use ccache and/or distcc with an appropriate
                   1494:     PKGSRC_COMPILER setting, e.g.    ccache gcc   . This variable should always be
1.1       dsieger  1495:     terminated with a value for a real compiler. Note that only one real
1.266     martin   1496:     compiler should be listed (e.g.    sunpro gcc    is not allowed).
1.1       dsieger  1497: 
                   1498: GCC_REQD:
                   1499: 
                   1500:     This specifies the minimum version of GCC to use when building packages. If
                   1501:     the system GCC doesn't satisfy this requirement, then pkgsrc will build and
                   1502:     install one of the GCC packages to use instead.
                   1503: 
1.153     leot     1504: PYTHON_VERSION_DEFAULT:
1.114     maya     1505: 
                   1506:     Specifies which version of python to use when several options are
                   1507:     available.
                   1508: 
                   1509: PKGSRC_FORTRAN:
                   1510: 
1.176     gutterid 1511:     Specifies the Fortran compiler to use. The default is gfortran.
1.114     maya     1512: 
                   1513: GFORTRAN_VERSION:
                   1514: 
                   1515:     If PKGSRC_FORTRAN= gfortran is used, this option specifies which version to
                   1516:     use.
                   1517: 
1.266     martin   1518: 6.5.2.  Additional flags to the compiler (CFLAGS)
1.1       dsieger  1519: 
                   1520: If you wish to set the CFLAGS variable, please make sure to use the += operator
                   1521: instead of the = operator:
                   1522: 
                   1523: CFLAGS+=        -your -flags
                   1524: 
1.266     martin   1525: Using CFLAGS= (i.e. without the    +   ) may lead to problems with packages that
1.16      jnemeth  1526: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24      wiz      1527: package if you're interested in optimization specifically for the current CPU.
1.1       dsieger  1528: 
1.266     martin   1529: 6.5.3.  Additional flags to the linker (LDFLAGS)
1.1       dsieger  1530: 
                   1531: If you want to pass flags to the linker, both in the configure step and the
                   1532: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
                   1533: difference between the two is that LIBS will be appended to the command line,
                   1534: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
                   1535: machines depending on the setting of USE_IMAKE or the inclusion of mk/
                   1536: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
                   1537: settings, use the += operator:
                   1538: 
                   1539: LDFLAGS+=        -your -linkerflags
                   1540: 
1.266     martin   1541: 6.6.  Developer/advanced settings
1.1       dsieger  1542: 
                   1543:   * PKG_DEVELOPER: Run some sanity checks that package developers want:
                   1544: 
1.42      asau     1545:       + make sure patches apply with zero fuzz
1.1       dsieger  1546: 
1.42      asau     1547:       + run check-shlibs to see that all binaries will find their shared libs.
1.1       dsieger  1548: 
1.232     gutterid 1549:   * CHECK_FILES_STRICT: Also check VARBASE and PKG_SYSCONFDIR values in PLIST
                   1550:     entries.
                   1551: 
1.1       dsieger  1552:   * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
                   1553:     making and installing the package. The default value for this is 0, which
                   1554:     will not display the commands as they are executed (normal, default, quiet
                   1555:     operation); the value 1 will display all shell commands before their
                   1556:     invocation, and the value 2 will display both the shell commands before
1.112     rillig   1557:     their invocation, as well as their actual execution progress with set -x.
1.1       dsieger  1558: 
1.266     martin   1559: 6.7.  Selecting Build Options
1.1       dsieger  1560: 
                   1561: Some packages have build time options, usually to select between different
                   1562: dependencies, enable optional support for big dependencies or enable
                   1563: experimental features.
                   1564: 
                   1565: To see which options, if any, a package supports, and which options are
                   1566: mutually exclusive, run make show-options, for example:
                   1567: 
                   1568:     The following options are supported by this package:
                   1569:         ssl      Enable SSL support.
                   1570:     Exactly one of the following gecko options is required:
                   1571:         firefox  Use firefox as gecko rendering engine.
                   1572:         mozilla  Use mozilla as gecko rendering engine.
                   1573:     At most one of the following database options may be selected:
                   1574:         mysql    Enable support for MySQL database.
                   1575:         pgsql    Enable support for PostgreSQL database.
                   1576: 
                   1577:     These options are enabled by default: firefox
                   1578:     These options are currently enabled: mozilla ssl
                   1579: 
1.4       rillig   1580: The following variables can be defined in mk.conf to select which options to
                   1581: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1       dsieger  1582: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
                   1583: which can be used to select or disable options specifically for package pkgbase
1.266     martin   1584: . Options listed in these variables are selected, options preceded by    -    are
1.1       dsieger  1585: disabled. A few examples:
                   1586: 
1.4       rillig   1587: $ grep "PKG.*OPTION" mk.conf
1.1       dsieger  1588: PKG_DEFAULT_OPTIONS=    -arts -dvdread -esound
                   1589: PKG_OPTIONS.kdebase=    debug -sasl
                   1590: PKG_OPTIONS.apache=     suexec
                   1591: 
1.11      rillig   1592: It is important to note that options that were specifically suggested by the
1.19      snj      1593: package maintainer must be explicitly removed if you do not wish to include the
                   1594: option. If you are unsure you can view the current state with make show-options
                   1595: .
1.11      rillig   1596: 
1.1       dsieger  1597: The following settings are consulted in the order given, and the last setting
                   1598: that selects or disables an option is used:
                   1599: 
                   1600:  1. the default options as suggested by the package maintainer
                   1601: 
                   1602:  2. the options implied by the settings of legacy variables (see below)
                   1603: 
                   1604:  3. PKG_DEFAULT_OPTIONS
                   1605: 
                   1606:  4. PKG_OPTIONS.pkgbase
                   1607: 
                   1608: For groups of mutually exclusive options, the last option selected is used, all
                   1609: others are automatically disabled. If an option of the group is explicitly
                   1610: disabled, the previously selected option, if any, is used. It is an error if no
                   1611: option from a required group of options is selected, and building the package
                   1612: will fail.
                   1613: 
                   1614: Before the options framework was introduced, build options were selected by
1.4       rillig   1615: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
                   1616: transition to the options framework for the user, these legacy variables are
                   1617: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
                   1618: automatically. A warning is issued to prompt the user to update mk.conf to use
                   1619: the options framework directly. Support for the legacy variables will be
1.1       dsieger  1620: removed eventually.
                   1621: 
1.266     martin   1622: Chapter  7.  Creating binary packages
1.1       dsieger  1623: 
                   1624: Table of Contents
                   1625: 
1.154     rillig   1626: 7.1. Building a single binary package
                   1627: 7.2. Settings for creation of binary packages
1.1       dsieger  1628: 
1.266     martin   1629: 7.1.  Building a single binary package
1.1       dsieger  1630: 
                   1631: Once you have built and installed a package, you can create a binary package
                   1632: which can be installed on another system with pkg_add(1). This saves having to
                   1633: build the same package on a group of hosts and wasting CPU time. It also
                   1634: provides a simple means for others to install your package, should you
                   1635: distribute it.
                   1636: 
                   1637: To create a binary package, change into the appropriate directory in pkgsrc,
                   1638: and run make package:
                   1639: 
1.112     rillig   1640: $ cd misc/figlet
                   1641: $ make package
1.1       dsieger  1642: 
1.242     gutterid 1643: This will build your package (if not already done) and package it into a binary
                   1644: package. You can then use the pkg_* tools to manipulate it. Binary packages are
                   1645: created in PACKAGES, which defaults to /usr/pkgsrc/packages, in the form of a
1.266     martin   1646: compressed tar file. See Section  C.2,    Packaging figlet    for a continuation of
1.242     gutterid 1647: the above misc/figlet example.
1.1       dsieger  1648: 
1.266     martin   1649: See Chapter  23, Submitting and Committing for information on how to submit such
1.1       dsieger  1650: a binary package.
                   1651: 
1.266     martin   1652: 7.2.  Settings for creation of binary packages
1.1       dsieger  1653: 
1.266     martin   1654: See Section  13.17,    Other helpful targets   .
1.6       rillig   1655: 
1.266     martin   1656: Chapter  8.  Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig   1657: 
                   1658: Table of Contents
                   1659: 
1.154     rillig   1660: 8.1. Preparations
1.180     rillig   1661: 8.2. Running a bulk build
1.154     rillig   1662:     8.2.1. Configuration
1.272     wiz      1663: 8.3. Speeding up bulk build scans
                   1664: 8.4. Requirements of a full bulk build
                   1665: 8.5. Bulk build variants
                   1666:     8.5.1. Detect unknown configure options
                   1667:     8.5.2. Detect classes of bugs by forcing compiler warnings
                   1668:     8.5.3. Force compiler options only in the build phase
                   1669:     8.5.4. Use custom directories
                   1670:     8.5.5. Turn warnings into errors
                   1671:     8.5.6. Reject packages for which pkglint reports errors
                   1672:     8.5.7. Reject packages that contain forbidden strings
                   1673:     8.5.8. Reject packages whose self-test fails
                   1674:     8.5.9. Reject packages that use undefined shell variables
                   1675:     8.5.10. Turn off verbose logging
                   1676: 8.6. Creating a multiple CD-ROM packages collection
                   1677:     8.6.1. Example of cdpack
1.6       rillig   1678: 
1.175     gutterid 1679: For a number of reasons, you may want to build binary packages for a large
                   1680: selected set of packages in pkgsrc, or even for all pkgsrc packages. For
1.71      wiz      1681: instance, when you have multiple machines that should run the same software, it
                   1682: is wasted time if they all build their packages themselves from source. Or you
                   1683: may want to build a list of packages you want and check them before deploying
1.175     gutterid 1684: onto production systems. There is a way of getting a set of binary packages:
                   1685: the bulk build system, or pbulk ("p" stands for "parallel"). This chapter
                   1686: describes how to set it up.
1.71      wiz      1687: 
1.266     martin   1688: 8.1.  Preparations
1.71      wiz      1689: 
                   1690: First of all, you have to decide whether you build all packages or a limited
                   1691: set of them. Full bulk builds usually consume a lot more resources, both space
1.175     gutterid 1692: and time, than builds for some practical sets of packages. A number of
                   1693: particularly heavy packages exist that are not actually interesting to a wide
                   1694: audience. (The approximate resource consumption for a full bulk build is given
1.272     wiz      1695: in section Section  8.4,    Requirements of a full bulk build   .) For limited bulk
1.175     gutterid 1696: builds you need to make a list of packages you want to build. Note that all
                   1697: their dependencies will be built, so you don't need to track them manually.
1.71      wiz      1698: 
                   1699: During bulk builds various packages are installed and deinstalled in /usr/pkg
                   1700: (or whatever LOCALBASE is), so make sure that you don't need any package during
1.112     rillig   1701: the builds. Essentially, you should provide a fresh system, either a chroot
1.71      wiz      1702: environment or something even more restrictive, depending on what the operating
                   1703: system provides, or dedicate the whole physical machine. As a useful side
                   1704: effect this makes sure that bulk builds cannot break anything in your system.
                   1705: There have been numerous cases where certain packages tried to install files
                   1706: outside the LOCALBASE or wanted to edit some files in /etc.
1.6       rillig   1707: 
1.266     martin   1708: 8.2.  Running a bulk build
1.6       rillig   1709: 
1.180     rillig   1710: Running a bulk build works roughly as follows:
1.15      rillig   1711: 
                   1712:   * First, build the pbulk infrastructure in a fresh pkgsrc location.
                   1713: 
                   1714:   * Then, build each of the packages from a clean installation directory using
                   1715:     the infrastructure.
                   1716: 
1.266     martin   1717: 8.2.1.  Configuration
1.6       rillig   1718: 
1.112     rillig   1719: To simplify configuration, we provide the helper script mk/pbulk/pbulk.sh.
1.6       rillig   1720: 
1.68      asau     1721: In order to use it, prepare a clear system (real one, chroot environment, jail,
                   1722: zone, virtual machine). Configure network access to fetch distribution files.
1.112     rillig   1723: Create a user with name "pbulk".
1.68      asau     1724: 
                   1725: Fetch and extract pkgsrc. Use a command like one of these:
                   1726: 
1.151     sevan    1727: # (cd /usr && ftp -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
                   1728: # (cd /usr && fetch -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1.72      wiz      1729: # (cd /usr && cvs -Q -z3 -d anoncvs@anoncvs.NetBSD.org:/cvsroot get -P pkgsrc)
1.68      asau     1730: 
                   1731: Or any other way that fits (e.g., curl, wget).
                   1732: 
                   1733: Deploy and configure pbulk tools, e.g.:
                   1734: 
1.118     sevan    1735: # sh pbulk.sh -n # use native make, no bootstrap kit needed (for use on NetBSD)
1.68      asau     1736: # sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment
                   1737: # sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build
                   1738: 
                   1739: Note
                   1740: 
                   1741: mk.conf.frag is a fragment of mk.conf that contains settings you want to apply
                   1742: to packages you build. For instance,
                   1743: 
1.112     rillig   1744: PKG_DEVELOPER=          yes     # perform more checks
                   1745: X11_TYPE=               modular # use pkgsrc X11
                   1746: SKIP_LICENSE_CHECK=     yes     # accept all licences (useful
                   1747:                                 # when building all packages)
1.68      asau     1748: 
                   1749: If configured for limited list, replace the list in /usr/pbulk/etc/pbulk.list
1.112     rillig   1750: with your list of packages, one per line without empty lines or comments. E.g.:
1.68      asau     1751: 
                   1752: www/firefox
                   1753: mail/thunderbird
                   1754: misc/libreoffice4
                   1755: 
1.69      asau     1756: At this point you can also review configuration in /usr/pbulk/etc and make
                   1757: final amendments, if wanted.
                   1758: 
1.68      asau     1759: Start it:
                   1760: 
                   1761: # /usr/pbulk/bin/bulkbuild
                   1762: 
                   1763: After it finishes, you'll have /mnt filled with distribution files, binary
                   1764: packages, and reports, plain text summary in /mnt/bulklog/meta/report.txt
                   1765: 
                   1766: Note
                   1767: 
                   1768: The pbulk.sh script does not cover all possible use cases. While being ready to
                   1769: run, it serves as a good starting point to understand and build more complex
                   1770: setups. The script is kept small enough for better understanding.
                   1771: 
                   1772: Note
                   1773: 
                   1774: The pbulk.sh script supports running unprivileged bulk build and helps
1.205     wiz      1775: configuring distributed bulk builds. Distributed bulk builds support either
                   1776: building in worker chroots (each node is a path to a different chroot) that
                   1777: replicate the target system, including the pbulk prefix, or remote machines
                   1778: (each node is an IP address that must be accessible over SSH without a
                   1779: password).
1.15      rillig   1780: 
1.272     wiz      1781: 8.3.  Speeding up bulk build scans
                   1782: 
                   1783: At the start of a bulk build. pkgsrc is scanned for details about the packages
                   1784: to build. This is needed e.g. to build a dependency graph for building the
                   1785: packages in the correct order.
                   1786: 
                   1787: Basically, this calls make(1) once for each package. To speed this up, some
                   1788: variables can be pre-computed and others can be cached. This will greatly
                   1789: reduce the time needed for the scan part of a bulk build.
                   1790: 
                   1791: The fake pkgtools/varcache package provides a Makefile target to precompute
                   1792: some often-used variables for the build system that shouldn't change during one
                   1793: build. Redirect its output to a file and include it from mk.conf; for example:
                   1794: 
                   1795: $ cd pkgtools/varcache
                   1796: $ make show-varcache > /etc/varcache.mk
                   1797: $ echo .include "varcache.mk" >> /etc/mk.conf
                   1798: 
                   1799: 
                   1800: Some system information is needed quite early in the build and can not be
                   1801: cached this way. It must be set in the environment for the next speed-up:
                   1802: 
                   1803: $ export HOST_MACHINE_ARCH=`uname -m`
                   1804: $ export NATIVE_OPSYS=`uname -s`
                   1805: $ export NATIVE_OPSYS_VERSION=`uname -r | awk -F. '{major=int($1); minor=int($2); if (minor>=100) minor=99; patch=int($3); if (patch>=100) patch=99; printf "%02d%02d%02d", major, minor, patch}'`
                   1806: $ export NATIVE_OS_VERSION=`uname -r`
                   1807: 
                   1808: 
                   1809: Some settings that also affect the scan time strongly can be set in mk.conf:
                   1810: 
                   1811: NATIVE_PKG_TOOLS_BIN=/usr/sbin # location on NetBSD
                   1812: NO_PKGTOOLS_REQD_CHECK=yes     # assume pkg tools are up-to-date
                   1813: SKIP_LICENSE_CHECK=yes         # do not check license validity
                   1814: _SRC_TOP_=                     # bulk build is not running from inside /usr/src
                   1815: UNPRIVILEGED_USER=pbulk        # use the appropriate user for your system
                   1816: UNPRIVILEGED_GROUP=builder     # use the appropriate group for your system
                   1817: UNPRIVILEGED_GROUPS=builder    # use the appropriate groups for your system
                   1818: 
                   1819: Finally, some packages require information about build options of other
                   1820: packages. This information can be cached by setting PBULK_CACHE_DIRECTORY.
                   1821: 
                   1822: PBULK_CACHE_DIRECTORY=/tmp/pbulk_cache
                   1823: 
                   1824: For all of these: please make sure they are kept up-to-date for changes in your
                   1825: environment. The safest method is to re-create the varcache before each build,
                   1826: make sure the environment variables are still up-to-date, and to delete the
                   1827: PBULK_CACHE_DIRECTORY before builds.
                   1828: 
                   1829: 8.4.  Requirements of a full bulk build
1.71      wiz      1830: 
                   1831: A complete bulk build requires lots of disk space. Some of the disk space can
                   1832: be read-only, some other must be writable. Some can be on remote filesystems
                   1833: (such as NFS) and some should be local. Some can be temporary filesystems,
                   1834: others must survive a sudden reboot.
                   1835: 
1.205     wiz      1836:   * 70 GB for the distfiles (read-write, remote, temporary)
1.71      wiz      1837: 
1.205     wiz      1838:   * 60 GB for the binary packages (read-write, remote, permanent)
1.71      wiz      1839: 
                   1840:   * 1 GB for the pkgsrc tree (read-only, remote, permanent)
                   1841: 
                   1842:   * 5 GB for LOCALBASE (read-write, local, temporary)
                   1843: 
                   1844:   * 10 GB for the log files (read-write, remote, permanent)
                   1845: 
                   1846:   * 5 GB for temporary files (read-write, local, temporary)
                   1847: 
1.272     wiz      1848: 8.5.  Bulk build variants
1.178     rillig   1849: 
                   1850: To ensure that pkgsrc packages work in different configurations, it makes sense
                   1851: to run non-default bulk builds from time to time. This section lists some ideas
                   1852: for bulk builds that intentionally let packages fail if they don't follow the
                   1853: pkgsrc style.
                   1854: 
1.272     wiz      1855: 8.5.1.  Detect unknown configure options
1.178     rillig   1856: 
                   1857: Add the following line to mk.conf.
                   1858: 
                   1859: GNU_CONFIGURE_STRICT=   yes
                   1860: 
                   1861: When a package fails this additional check, the most common cause is that the
                   1862: configure option was valid for an older version of the package but does not
                   1863: apply anymore. In that case, just remove it.
                   1864: 
1.272     wiz      1865: 8.5.2.  Detect classes of bugs by forcing compiler warnings
1.178     rillig   1866: 
                   1867: The job of a compiler is not restricted to producing executable code, most
1.179     rillig   1868: compilers also detect typical programming mistakes. The pkgsrc compiler
                   1869: wrappers make it easy to force compiler options when the package is built. This
                   1870: can be used to find typical bugs across all packages that are in pkgsrc. By
                   1871: reporting these bugs upstream, the packages will be more reliable with the next
                   1872: updates.
1.178     rillig   1873: 
1.179     rillig   1874: Add some of the following lines to mk.conf:
1.178     rillig   1875: 
                   1876: CFLAGS+=        -Werror=char-subscripts
1.179     rillig   1877: CFLAGS+=        -Werror=implicit-function-declaration
1.178     rillig   1878: 
1.179     rillig   1879: When a package fails to build using these stricter compiler options, document
                   1880: the circumstances in which the compiler produced the error message. This
                   1881: includes:
1.178     rillig   1882: 
                   1883:   * The platform (MACHINE_PLATFORM)
                   1884: 
                   1885:   * The source file
                   1886: 
                   1887:   * An excerpt of the code. GCC and Clang already do this as part of the
                   1888:     diagnostic.
                   1889: 
1.179     rillig   1890:   * The exact error message from the compiler.
1.178     rillig   1891: 
1.179     rillig   1892: If a package produces these error messages, but the package is fine, record
                   1893: this in your local mk.conf, like this, to skip this check in the next builds:
1.178     rillig   1894: 
1.179     rillig   1895: .if ${PKGPATH} == category/package
1.178     rillig   1896: # Version ${VERSION} failed on ${MACHINE_PLATFORM}:
                   1897: # error message
                   1898: # code
1.179     rillig   1899: # Reason why the code does not need to be fixed.
1.178     rillig   1900: BUILDLINK_TRANSFORM+=   rm:-Werror=char-subscripts
1.179     rillig   1901: .endif
1.178     rillig   1902: 
                   1903: If the error messages from the compiler are valid and the code needs to be
1.179     rillig   1904: fixed, prepare a local patch (see LOCALPATCHES) and report the bug to the
                   1905: upstream authors of the package, providing them with the information you
                   1906: collected above.
1.178     rillig   1907: 
1.179     rillig   1908: Patches that are not essential for the package to work should only be reported
                   1909: upstream but not committed to pkgsrc, to make future updates easier.
                   1910: 
1.272     wiz      1911: 8.5.3.  Force compiler options only in the build phase
1.181     rillig   1912: 
                   1913: When adding custom compiler flags via CFLAGS, these apply to all phases of the
                   1914: package build process. Especially in the configure phase, adding -Werror leads
                   1915: to wrong decisions. The GNU configure scripts feed many small test programs to
                   1916: the C compiler to see whether certain headers are available, functions are
                   1917: defined in a library and programs can be run. In many cases these programs
                   1918: would not survive a strict compiler run with -Wall -Wextra -Werror.
                   1919: 
                   1920: The pkgsrc infrastructure is flexible enough to support compiler options being
                   1921: added between the configure and build phases. It's a little more complicated
                   1922: than the other examples in this section but still easy enough.
                   1923: 
                   1924: The basic idea is to use the pkgsrc compiler wrapper to inject the desired
                   1925: compiler options. The compiler wrapper's original task is to hide unwanted
                   1926: directories of include files and to normalize compiler options. It does this by
                   1927: wrapping the compiler command and rewriting the command line. To see this in
                   1928: action, run bmake patch in a package directory and examine the work/.cwrappers/
                   1929: config directory. It contains individual configurations for the C compiler and
                   1930: the related tools. The plan is to find a hook between the configure and build
                   1931: phases, and to modify these configuration files at that point.
                   1932: 
                   1933: To find this hook, have a look at mk/build/build.mk, which contains among
                   1934: others the pre-build-checks-hook. The word checks doesn't quite fit, but the
                   1935: pre-build-hook sounds good enough.
                   1936: 
                   1937: The code to be included in mk.conf is:
                   1938: 
                   1939: # Just a few example options.
                   1940: BUILD_ONLY_CFLAGS=      -Wall -Werror -O2 -DTEMPDIR='"/tmp"'
                   1941: 
                   1942: .if ${BUILD_ONLY_CFLAGS:U:M*}
                   1943: pre-build-checks-hook: add-build-only-cflags
                   1944: 
                   1945: add-build-only-cflags: .PHONY
                   1946:         ${RUN} cd ${CWRAPPERS_CONFIG_DIR};      \
                   1947:         ${TEST} ! -f ${.TARGET} || exit 0;      \
                   1948:         for flag in ${BUILD_ONLY_CFLAGS}; do    \
                   1949:                 ${ECHO} "append=$$flag" >> cc;  \
                   1950:         done;                                   \
                   1951:         > ${.TARGET}
                   1952: .endif
                   1953: 
                   1954: (When editing the mk.conf, make sure that the commands of the
                   1955: add-build-only-cflags target are indented with a tab, not with spaces.)
                   1956: 
                   1957: The condition in the .if statement contains the :U modifier to prevent parse
                   1958: errors if the variable should be undefined, possibly because it is only defined
                   1959: for a subset of the packages. The :M* modifier ensures that there is at least
                   1960: one compiler option, to prevent a syntax error in the shell parser.
                   1961: 
                   1962: The code around the ${.TARGET} variable ensures that the additional compiler
                   1963: options are only appended once, even if bmake build is run multiple times. To
                   1964: do this, it creates a marker file.
                   1965: 
                   1966: To verify that this setup works, run bmake configure in a package directory. Up
                   1967: to now, everything works as usual. Examine the directory work/.cwrappers/config
                   1968: to see that the compiler options from BUILD_ONLY_CFLAGS are not yet added to
                   1969: the file cc. Examine the tail of the work/.work.log file to see that the normal
                   1970: compiler options are used.
                   1971: 
                   1972: Now run bmake build. This will append the options to the file cc and will
                   1973: create the marker file in the same directory. After that, the build starts as
                   1974: usual, but with the added compiler options. Examine the tail of the file work
                   1975: /.work.log to see that the lines starting with [*] don't contain the compiler
                   1976: options, but the corresponding lines starting with <.> do end with these
                   1977: options.
                   1978: 
                   1979: Building packages using this setup variant and fixing the resulting bugs is the
1.272     wiz      1980: same as in Section  8.5.2,    Detect classes of bugs by forcing compiler warnings   
1.181     rillig   1981: .
                   1982: 
1.272     wiz      1983: 8.5.4.  Use custom directories
1.178     rillig   1984: 
                   1985: Some directories like PREFIX, VARBASE, PKG_SYSCONFDIR, PKGMANDIR, PKG_INFODIR
                   1986: can be configured in pkgsrc. Set these to arbitrary paths during bootstrap or
                   1987: afterwards in mk.conf.
                   1988: 
                   1989: PREFIX=         /a-random-uuid
                   1990: PKG_SYSCONFDIR= /a-random-uuid
                   1991: VARBASE=        /a-random-uuid
                   1992: PKGMANDIR=      a-random-uuid
                   1993: PKG_INFODIR=    a-random-uuid
                   1994: 
1.272     wiz      1995: 8.5.5.  Turn warnings into errors
1.178     rillig   1996: 
                   1997: When building a package, warnings are typically ignored since they just flow by
                   1998: and do not cause the build to fail immediately. To find these warnings,
                   1999: redefine them to errors in mk.conf.
                   2000: 
                   2001: DELAYED_WARNING_MSG=    ${DELAYED_ERROR_MSG} "(was warning)"
                   2002: WARNING_MSG=            ${FAIL_MSG} "(was warning)"
                   2003: 
                   2004: (There are many more classes of warnings in pkgsrc, and most of them can be
                   2005: redefined with a simple definition like above.
                   2006: 
1.179     rillig   2007: If a package suggests to add USE_TOOLS+=perl to the package Makefile, research
1.178     rillig   2008: whether the package actually needs Perl. If it does, add USE_TOOLS+=perl to the
                   2009: package Makefile, and if it doesn't, add TOOLS_BROKEN+=perl.
                   2010: 
1.272     wiz      2011: 8.5.6.  Reject packages for which pkglint reports errors
1.178     rillig   2012: 
                   2013: Using pkglint as part of the regular build process is mostly a waste of time.
                   2014: If you want to fix some of the warnings, just run pkglint recursively on the
                   2015: whole pkgsrc tree. This will take a few minutes (up to 10), which is much
                   2016: faster than a complete bulk build.
                   2017: 
1.272     wiz      2018: 8.5.7.  Reject packages that contain forbidden strings
1.178     rillig   2019: 
                   2020: To ensure that the binary packages don't contain references to the build
                   2021: directory, there is already CHECK_WRKREF. If that variable includes the item
                   2022: extra, it is possible to define additional patterns that must not appear in any
                   2023: installed file. This is specified in mk.conf.
                   2024: 
                   2025: CHECK_WRKREF=                   extra
                   2026: CHECK_WRKREF_EXTRA_DIRS+=       /usr/local
                   2027: CHECK_WRKREF_EXTRA_DIRS+=       /usr/pkg
                   2028: CHECK_WRKREF_EXTRA_DIRS+=       @[A-Z][A-Z]*@
                   2029: 
                   2030: The above patterns will probably generate many false positives, therefore the
                   2031: results need to be taken with a grain of salt.
                   2032: 
1.272     wiz      2033: 8.5.8.  Reject packages whose self-test fails
1.178     rillig   2034: 
                   2035: To run the test suites that come with each package, add this line to mk.conf.
                   2036: 
                   2037: PKGSRC_RUN_TEST=        yes
                   2038: 
                   2039: Be prepared that even the most basic packages fail this test. When doing a bulk
                   2040: build with this, it will often abort in the early phase where the packages are
                   2041: scanned for their dependencies since there are cyclic dependencies. There is
                   2042: still a lot to do in this area.
                   2043: 
1.272     wiz      2044: 8.5.9.  Reject packages that use undefined shell variables
1.178     rillig   2045: 
                   2046: To catch typos in the shell snippets from the Makefile fragments, add the -u
                   2047: flag to most of the commands by adding this line to mk.conf.
                   2048: 
                   2049: RUN=    @set -eu;
                   2050: 
1.181     rillig   2051: After that, ensure that none of the bulk build log files (even those for
                   2052: successfully built packages) contains the string parameter not set or whatever
                   2053: error message the command sh -ceu '$undefined' outputs.
                   2054: 
1.178     rillig   2055: See mk/misc/common.mk for the existing definition.
                   2056: 
1.272     wiz      2057: 8.5.10.  Turn off verbose logging
1.178     rillig   2058: 
                   2059: The build logs of a package are often quite long. This allows error messages or
                   2060: other interesting details to hide between the noise. To make the actual error
                   2061: message stand out more, add these lines to mk.conf.
                   2062: 
                   2063: GNU_CONFIGURE_QUIET=    yes
                   2064: MAKE_FLAGS+=            -s
                   2065: 
                   2066: The -s option works for both GNU Make and BSD Make. On exotic platforms with
                   2067: their own make, it may be a little different.
                   2068: 
1.272     wiz      2069: 8.6.  Creating a multiple CD-ROM packages collection
1.1       dsieger  2070: 
                   2071: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
                   2072: of the resulting binary packages to assist in installing packages on other
                   2073: machines. The pkgtools/cdpack package provides a simple tool for creating the
                   2074: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
                   2075: keeps all the dependencies for a given package on the same CD as that package.
                   2076: 
1.272     wiz      2077: 8.6.1.  Example of cdpack
1.1       dsieger  2078: 
                   2079: Complete documentation for cdpack is found in the cdpack(1) man page. The
                   2080: following short example assumes that the binary packages are left in /usr/
                   2081: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
                   2082: ISO 9660 images.
                   2083: 
                   2084: # mkdir /u2/images
                   2085: # pkg_add /usr/pkgsrc/packages/All/cdpack
                   2086: # cdpack /usr/pkgsrc/packages/All /u2/images
                   2087: 
                   2088: 
                   2089: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
                   2090: CD in the collection, then you need to create a directory which contains these
1.175     gutterid 2091: files, e.g.:
1.1       dsieger  2092: 
                   2093: # mkdir /tmp/common
                   2094: # echo "This is a README" > /tmp/common/README
                   2095: # echo "Another file" > /tmp/common/COPYING
                   2096: # mkdir /tmp/common/bin
                   2097: # echo "#!/bin/sh" > /tmp/common/bin/myscript
                   2098: # echo "echo Hello world" >> /tmp/common/bin/myscript
                   2099: # chmod 755 /tmp/common/bin/myscript
                   2100: 
                   2101: 
                   2102: Now create the images:
                   2103: 
                   2104: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
                   2105: 
                   2106: Each image will contain README, COPYING, and bin/myscript in their root
                   2107: directories.
                   2108: 
1.266     martin   2109: Chapter  9.  Directory layout of the installed files
1.1       dsieger  2110: 
                   2111: Table of Contents
                   2112: 
1.154     rillig   2113: 9.1. File system layout in ${LOCALBASE}
                   2114: 9.2. File system layout in ${VARBASE}
1.1       dsieger  2115: 
                   2116: The files that are installed by pkgsrc are organized in a way that is similar
                   2117: to what you find in the /usr directory of the base system. But some details are
                   2118: different. This is because pkgsrc initially came from FreeBSD and had adopted
                   2119: its file system hierarchy. Later it was largely influenced by NetBSD. But no
                   2120: matter which operating system you are using pkgsrc with, you can expect the
                   2121: same layout for pkgsrc.
                   2122: 
                   2123: There are mainly four root directories for pkgsrc, which are all configurable
                   2124: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
                   2125: default locations are:
                   2126: 
                   2127: LOCALBASE=              /usr/pkg
                   2128: PKG_SYSCONFBASE=        /usr/pkg/etc
                   2129: VARBASE=                /var
1.119     sevan    2130: PKG_DBDIR=              /usr/pkg/pkgdb
1.1       dsieger  2131: 
                   2132: In unprivileged mode (when pkgsrc has been installed as any other user), the
                   2133: default locations are:
                   2134: 
                   2135: LOCALBASE=              ${HOME}/pkg
                   2136: PKG_SYSCONFBASE=        ${HOME}/pkg/etc
                   2137: VARBASE=                ${HOME}/pkg/var
1.119     sevan    2138: PKG_DBDIR=              ${HOME}/pkg/pkgdb
1.1       dsieger  2139: 
                   2140: What these four directories are for, and what they look like is explained
                   2141: below.
                   2142: 
1.266     martin   2143:   * LOCALBASE corresponds to the /usr directory in the base system. It is the    
                   2144:     main    directory where the files are installed and contains the well-known
1.1       dsieger  2145:     subdirectories like bin, include, lib, share and sbin.
                   2146: 
                   2147:   * VARBASE corresponds to /var in the base system. Some programs (especially
                   2148:     games, network daemons) need write access to it during normal operation.
                   2149: 
                   2150:   * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
                   2151:     configuration files of the packages, as well as pkgsrc's mk.conf itself.
                   2152: 
1.266     martin   2153: 9.1.  File system layout in ${LOCALBASE}
1.1       dsieger  2154: 
                   2155: The following directories exist in a typical pkgsrc installation in $
                   2156: {LOCALBASE}.
                   2157: 
                   2158: bin
                   2159: 
                   2160:     Contains executable programs that are intended to be directly used by the
                   2161:     end user.
                   2162: 
                   2163: emul
                   2164: 
                   2165:     Contains files for the emulation layers of various other operating systems,
                   2166:     especially for NetBSD.
                   2167: 
                   2168: etc (the usual location of ${PKG_SYSCONFDIR})
                   2169: 
                   2170:     Contains the configuration files.
                   2171: 
                   2172: include
                   2173: 
                   2174:     Contains headers for the C and C++ programming languages.
                   2175: 
                   2176: info
                   2177: 
                   2178:     Contains GNU info files of various packages.
                   2179: 
                   2180: lib
                   2181: 
                   2182:     Contains shared and static libraries.
                   2183: 
                   2184: libdata
                   2185: 
                   2186:     Contains data files that don't change after installation. Other data files
                   2187:     belong into ${VARBASE}.
                   2188: 
                   2189: libexec
                   2190: 
                   2191:     Contains programs that are not intended to be used by end users, such as
                   2192:     helper programs or network daemons.
                   2193: 
                   2194: libexec/cgi-bin
                   2195: 
                   2196:     Contains programs that are intended to be executed as CGI scripts by a web
                   2197:     server.
                   2198: 
                   2199: man (the usual value of ${PKGMANDIR})
                   2200: 
                   2201:     Contains brief documentation in form of manual pages.
                   2202: 
                   2203: sbin
                   2204: 
                   2205:     Contains programs that are intended to be used only by the super-user.
                   2206: 
                   2207: share
                   2208: 
                   2209:     Contains platform-independent data files that don't change after
                   2210:     installation.
                   2211: 
                   2212: share/doc
                   2213: 
                   2214:     Contains documentation files provided by the packages.
                   2215: 
                   2216: share/examples
                   2217: 
                   2218:     Contains example files provided by the packages. Among others, the original
                   2219:     configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
                   2220:     installation.
                   2221: 
                   2222: share/examples/rc.d
                   2223: 
                   2224:     Contains the original files for rc.d scripts.
                   2225: 
                   2226: var (the usual location of ${VARBASE})
                   2227: 
                   2228:     Contains files that may be modified after installation.
                   2229: 
1.266     martin   2230: 9.2.  File system layout in ${VARBASE}
1.1       dsieger  2231: 
                   2232: db/pkg (the usual location of ${PKG_DBDIR})
                   2233: 
                   2234:     Contains information about the currently installed packages.
                   2235: 
                   2236: games
                   2237: 
                   2238:     Contains highscore files.
                   2239: 
                   2240: log
                   2241: 
                   2242:     Contains log files.
                   2243: 
                   2244: run
                   2245: 
                   2246:     Contains informational files about daemons that are currently running.
                   2247: 
1.266     martin   2248: Chapter  10.  Frequently Asked Questions
1.1       dsieger  2249: 
                   2250: Table of Contents
                   2251: 
1.154     rillig   2252: 10.1. Are there any mailing lists for pkg-related discussion?
                   2253: 10.2. Utilities for package management (pkgtools)
                   2254: 10.3. How to use pkgsrc as non-root
                   2255: 10.4. How to resume transfers when fetching distfiles?
                   2256: 10.5. How can I install/use modular X.org from pkgsrc?
                   2257: 10.6. How to fetch files from behind a firewall
                   2258: 10.7. How to fetch files from HTTPS sites
                   2259: 10.8. How do I tell make fetch to do passive FTP?
                   2260: 10.9. How to fetch all distfiles at once
1.266     martin   2261: 10.10. What does    Don't know how to make /usr/share/tmac/tmac.andoc    mean?
                   2262: 10.11. What does    Could not find bsd.own.mk    mean?
1.221     nia      2263: 10.12. Using 'sudo' or `priv` with pkgsrc
1.154     rillig   2264: 10.13. How do I change the location of configuration files?
                   2265: 10.14. Automated security checks
                   2266: 10.15. Why do some packages ignore my CFLAGS?
                   2267: 10.16. A package does not build. What shall I do?
1.266     martin   2268: 10.17. What does    Makefile appears to contain unresolved cvs/rcs/??? merge
1.271     wiz      2269: conflicts    mean?
1.1       dsieger  2270: 
                   2271: This section contains hints, tips & tricks on special things in pkgsrc that we
                   2272: didn't find a better place for in the previous chapters, and it contains items
                   2273: for both pkgsrc users and developers.
                   2274: 
1.266     martin   2275: 10.1.  Are there any mailing lists for pkg-related discussion?
1.1       dsieger  2276: 
                   2277: The following mailing lists may be of interest to pkgsrc users:
                   2278: 
                   2279:   * pkgsrc-users: This is a general purpose list for most issues regarding
                   2280:     pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
                   2281:     configuration, unexpected build failures, using particular packages,
                   2282:     upgrading pkgsrc installations, questions regarding the pkgsrc release
                   2283:     branches, etc. General announcements or proposals for changes that impact
                   2284:     the pkgsrc user community, e.g. major infrastructure changes, new features,
                   2285:     package removals, etc., may also be posted.
                   2286: 
                   2287:   * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
                   2288:     discussed.
                   2289: 
                   2290:   * pkgsrc-changes: This list is for those who are interested in getting a
                   2291:     commit message for every change committed to pkgsrc. It is also available
                   2292:     in digest form, meaning one daily message containing all commit messages
                   2293:     for changes to the package source tree in that 24 hour period.
                   2294: 
                   2295: To subscribe, do:
                   2296: 
                   2297: % echo subscribe listname | mail majordomo@NetBSD.org
                   2298: 
1.174     leot     2299: Archives for all these mailing lists are available from https://
1.1       dsieger  2300: mail-index.NetBSD.org/.
                   2301: 
1.266     martin   2302: 10.2.  Utilities for package management (pkgtools)
1.1       dsieger  2303: 
                   2304: The directory pkgsrc/pkgtools contains a number of useful utilities for both
                   2305: users and developers of pkgsrc. This section attempts only to make the reader
1.121     sevan    2306: aware of some of the utilities and when they might be useful, and not to
                   2307: duplicate the documentation that comes with each package.
1.1       dsieger  2308: 
                   2309: Utilities used by pkgsrc (automatically installed when needed):
                   2310: 
                   2311:   * pkgtools/x11-links: Symlinks for use by buildlink.
                   2312: 
                   2313: OS tool augmentation (automatically installed when needed):
                   2314: 
1.121     sevan    2315:   * pkgtools/digest: Calculates various kinds of checksums (including SHA3).
1.1       dsieger  2316: 
                   2317:   * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
                   2318: 
                   2319:   * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
                   2320: 
                   2321:   * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
                   2322:     for use on operating systems where pkg_install is not present.
                   2323: 
                   2324: Utilities used by pkgsrc (not automatically installed):
                   2325: 
                   2326:   * pkgtools/pkg_tarup: Create a binary package from an already-installed
                   2327:     package. Used by make replace to save the old package.
                   2328: 
                   2329:   * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
                   2330:     distfiles from multiple locations. It currently supports the following
                   2331:     methods: multiple CD-ROMs and network FTP/HTTP connections.
                   2332: 
                   2333:   * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24      wiz      2334:     current CPU and compiler.
1.1       dsieger  2335: 
                   2336: Utilities for keeping track of installed packages, being up to date, etc:
                   2337: 
1.65      wiz      2338:   * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
                   2339:     and upgrade binary packages easily.
                   2340: 
1.1       dsieger  2341:   * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
                   2342:     the latest pkgsrc entries.
                   2343: 
                   2344:   * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
                   2345:     strategy for updating.
                   2346: 
                   2347:   * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
                   2348:     graphviz).
                   2349: 
1.12      weinem   2350:   * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
                   2351: 
                   2352:   * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
                   2353:     complete pkgsrc system.
1.1       dsieger  2354: 
                   2355:   * pkgtools/pkgsurvey: Report what packages you have installed.
                   2356: 
                   2357: Utilities for people maintaining or creating individual packages:
                   2358: 
                   2359:   * pkgtools/pkgdiff: Automate making and maintaining patches for a package
                   2360:     (includes pkgdiff, pkgvi, mkpatches, etc.).
                   2361: 
1.65      wiz      2362:   * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1       dsieger  2363: 
                   2364: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
                   2365: 
                   2366:   * pkgtools/pkg_comp: Build packages in a chrooted area.
                   2367: 
                   2368:   * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
                   2369: 
1.266     martin   2370: 10.3.  How to use pkgsrc as non-root
1.1       dsieger  2371: 
1.108     rillig   2372: To install packages from source as a non-root user, download pkgsrc as
1.266     martin   2373: described in Chapter  3, Where to get pkgsrc and how to keep it up-to-date, cd
1.108     rillig   2374: into that directory and run the command ./bootstrap/bootstrap --unprivileged.
                   2375: 
                   2376: This will install the binary part of pkgsrc to ~/pkg and put the pkgsrc
                   2377: configuration mk.conf into ~/pkg/etc.
                   2378: 
                   2379: For more details, see mk/unprivileged.mk.
1.1       dsieger  2380: 
1.266     martin   2381: 10.4.  How to resume transfers when fetching distfiles?
1.1       dsieger  2382: 
                   2383: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4       rillig   2384: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
                   2385: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1       dsieger  2386: 
1.61      wiz      2387: You can also use a different program than the platform default program by
                   2388: changing the FETCH_USING variable. You can specify the program by using of ftp,
                   2389: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
                   2390: manual. A value of custom disables the system defaults and dependency tracking
                   2391: for the fetch program. In that case you have to provide FETCH_CMD,
                   2392: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1       dsieger  2393: 
1.16      jnemeth  2394: For example, if you want to use wget to download, you'll have to use something
                   2395: like:
1.1       dsieger  2396: 
1.16      jnemeth  2397: FETCH_USING=    wget
1.1       dsieger  2398: 
1.266     martin   2399: 10.5.  How can I install/use modular X.org from pkgsrc?
1.1       dsieger  2400: 
1.4       rillig   2401: If you want to use modular X.org from pkgsrc instead of your system's own X11
                   2402: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1       dsieger  2403: mk.conf:
                   2404: 
1.4       rillig   2405: X11_TYPE=modular
1.1       dsieger  2406: 
1.266     martin   2407: 10.6.  How to fetch files from behind a firewall
1.1       dsieger  2408: 
                   2409: If you are sitting behind a firewall which does not allow direct connections to
                   2410: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
                   2411: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
1.266     martin   2412: machine    orpheus.amdahl.com    is one of the firewalls, and it uses port 80 as
1.1       dsieger  2413: the proxy port number. So the proxy environment variables are:
                   2414: 
                   2415: ftp_proxy=ftp://orpheus.amdahl.com:80/
                   2416: http_proxy=http://orpheus.amdahl.com:80/
                   2417: 
1.266     martin   2418: 10.7.  How to fetch files from HTTPS sites
1.65      wiz      2419: 
                   2420: Some fetch tools are not prepared to support HTTPS by default (for example, the
                   2421: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
                   2422: openssl dependency that low in the dependency graph).
                   2423: 
1.266     martin   2424: Usually you won't notice, because distribution files are mirrored weekly to    
                   2425: ftp.NetBSD.org   , but that might not be often enough if you are following
                   2426: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to    curl    or
                   2427:    wget   , which are both compiled with HTTPS support by default. Of course, these
1.65      wiz      2428: tools need to be installed before you can use them this way.
                   2429: 
1.266     martin   2430: 10.8.  How do I tell make fetch to do passive FTP?
1.1       dsieger  2431: 
                   2432: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
                   2433: FETCH_CMD is assigned the first available command from the following list:
                   2434: 
                   2435:   * ${LOCALBASE}/bin/ftp
                   2436: 
                   2437:   * /usr/bin/ftp
                   2438: 
                   2439: On a default NetBSD installation, this will be /usr/bin/ftp, which
                   2440: automatically tries passive connections first, and falls back to active
                   2441: connections if the server refuses to do passive. For the other tools, add the
1.4       rillig   2442: following to your mk.conf file: PASSIVE_FETCH=1.
1.1       dsieger  2443: 
                   2444: Having that option present will prevent /usr/bin/ftp from falling back to
                   2445: active transfers.
                   2446: 
1.266     martin   2447: 10.9.  How to fetch all distfiles at once
1.1       dsieger  2448: 
                   2449: You would like to download all the distfiles in a single batch from work or
                   2450: university, where you can't run a make fetch. There is an archive of distfiles
                   2451: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
                   2452: 
                   2453: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
                   2454: subdirectories, carry the resulting list to your machine at work/school and use
                   2455: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
                   2456: don't forget to set FETCH_CMD to something that fetches a URL:
                   2457: 
                   2458: At home:
                   2459: 
                   2460: % cd /usr/pkgsrc
                   2461: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
                   2462: % scp /tmp/fetch.sh work:/tmp
                   2463: 
                   2464: At work:
                   2465: 
                   2466: % sh /tmp/fetch.sh
                   2467: 
                   2468: then tar up /tmp/distfiles and take it home.
                   2469: 
                   2470: If you have a machine running NetBSD, and you want to get all distfiles (even
                   2471: ones that aren't for your machine architecture), you can do so by using the
                   2472: above-mentioned make fetch-list approach, or fetch the distfiles directly by
                   2473: running:
                   2474: 
                   2475: % make mirror-distfiles
                   2476: 
                   2477: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
                   2478: everything by running:
                   2479: 
                   2480: % make fetch NO_SKIP=yes
                   2481: 
1.266     martin   2482: 10.10.  What does    Don't know how to make /usr/share/tmac/tmac.andoc    mean?
1.1       dsieger  2483: 
                   2484: When compiling the pkgtools/pkg_install package, you get the error from make
                   2485: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
1.266     martin   2486: that you don't have installed the    text    set (nroff, ...) from the NetBSD base
1.1       dsieger  2487: distribution on your machine. It is recommended to do that to format man pages.
                   2488: 
                   2489: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4       rillig   2490: NOMAN=YES either in the environment or in mk.conf.
1.1       dsieger  2491: 
1.266     martin   2492: 10.11.  What does    Could not find bsd.own.mk    mean?
1.1       dsieger  2493: 
                   2494: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
                   2495: machine. Please get and install it, by extracting it in /:
                   2496: 
                   2497: # cd /
                   2498: # tar --unlink -zxvpf .../comp.tgz
                   2499: 
                   2500: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
                   2501: release (determine via uname -r).
                   2502: 
1.266     martin   2503: 10.12.  Using 'sudo' or `priv` with pkgsrc
1.1       dsieger  2504: 
                   2505: When installing packages as non-root user and using the just-in-time su(1)
                   2506: feature of pkgsrc, it can become annoying to type in the root password for each
                   2507: required package installed. To avoid this, the sudo package can be used, which
1.221     nia      2508: does password caching over a limited time. To use it, install sudo or priv
                   2509: (either as binary package, from security/priv, or security/sudo) and then put
                   2510: the following into your mk.conf, somewhere after the definition of the
                   2511: LOCALBASE variable:
1.1       dsieger  2512: 
                   2513: .if exists(${LOCALBASE}/bin/sudo)
1.260     wiz      2514: SU_CMD=        ${LOCALBASE}/bin/sudo -E /bin/sh -c
1.1       dsieger  2515: .endif
                   2516: 
1.260     wiz      2517: Note the -E flag; that tells sudo to preserve the environment. Without this,
                   2518: the bin-install target will fail when building a package with a non-default
                   2519: python version.
                   2520: 
1.266     martin   2521: 10.13.  How do I change the location of configuration files?
1.1       dsieger  2522: 
                   2523: As the system administrator, you can choose where configuration files are
                   2524: installed. The default settings make all these files go into ${PREFIX}/etc or
                   2525: some of its subdirectories; this may be suboptimal depending on your
                   2526: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
                   2527: configuration of the provided packages).
                   2528: 
                   2529: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4       rillig   2530: (in mk.conf) to point to your preferred configuration directory; some common
                   2531: examples include /etc or /etc/pkg.
1.1       dsieger  2532: 
                   2533: Furthermore, you can change this value on a per-package basis by setting the
                   2534: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
                   2535: matches the name of the package you would like to modify, that is, the contents
                   2536: of PKGBASE.
                   2537: 
                   2538: Note that after changing these settings, you must rebuild and reinstall any
                   2539: affected packages.
                   2540: 
1.266     martin   2541: 10.14.  Automated security checks
1.1       dsieger  2542: 
                   2543: Please be aware that there can often be bugs in third-party software, and some
                   2544: of these bugs can leave a machine vulnerable to exploitation by attackers. In
                   2545: an effort to lessen the exposure, the NetBSD packages team maintains a database
                   2546: of known-exploits to packages which have at one time been included in pkgsrc.
                   2547: The database can be downloaded automatically, and a security audit of all
1.14      jmcneill 2548: packages installed on a system can take place. To do this, refer to the
                   2549: following two tools (installed as part of the pkgtools/pkg_install package):
1.1       dsieger  2550: 
1.21      snj      2551:  1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
                   2552:     security vulnerabilities information. This list is kept up to date by the
1.26      spz      2553:     pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1       dsieger  2554: 
1.177     leot     2555:     https://ftp.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities
1.1       dsieger  2556: 
1.21      snj      2557:  2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24      wiz      2558:     known vulnerability. If a vulnerable package is installed, it will be shown
                   2559:     by output to stdout, including a description of the type of vulnerability,
                   2560:     and a URL containing more information.
1.1       dsieger  2561: 
1.266     martin   2562: Use of these tools is strongly recommended! See Section  5.1.6,    Checking for
                   2563: security vulnerabilities in installed packages    for instructions on how to
1.121     sevan    2564: automate checking and reporting.
                   2565: 
                   2566: If this database is installed, pkgsrc builds will use it to perform a security
                   2567: check before building any package.
1.1       dsieger  2568: 
1.266     martin   2569: 10.15.  Why do some packages ignore my CFLAGS?
1.1       dsieger  2570: 
                   2571: When you add your own preferences to the CFLAGS variable in your mk.conf, these
                   2572: flags are passed in environment variables to the ./configure scripts and to
                   2573: make(1). Some package authors ignore the CFLAGS from the environment variable
                   2574: by overriding them in the Makefiles of their package.
                   2575: 
                   2576: Currently there is no solution to this problem. If you really need the package
                   2577: to use your CFLAGS you should run make patch in the package directory and then
                   2578: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
1.266     martin   2579: Usually you can remove these lines. But be aware that some    smart    programmers
1.1       dsieger  2580: write so bad code that it only works for the specific combination of CFLAGS
                   2581: they have chosen.
                   2582: 
1.172     rillig   2583: To find out where the CFLAGS are ignored, add the following lines to mk.conf:
                   2584: 
                   2585: CPPFLAGS+=              -Dpkgsrc___CPPFLAGS
                   2586: CFLAGS+=                -Dpkgsrc___CFLAGS
                   2587: CXXFLAGS+=              -Dpkgsrc___CXXFLAGS
                   2588: 
                   2589: Then run bmake show-all-configure show-all-build to see whether the above flags
                   2590: are passed to the actual build commands in general.
                   2591: 
                   2592: To find out whether the flags are passed to individual compiler commands, have
                   2593: a look at the file work/.work.log. In most cases, the flags from the original
                   2594: command lines (the lines starting with [*]) are passed unmodified to the actual
                   2595: compiler (the lines starting with <.>). If the flag is missing from the actual
                   2596: compiler command, it must have been removed by the pkgsrc compiler wrappers.
                   2597: 
1.266     martin   2598: 10.16.  A package does not build. What shall I do?
1.1       dsieger  2599: 
                   2600:  1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
                   2601:     is that people only update pkgsrc in parts, because of performance reasons.
                   2602:     Since pkgsrc is one large system, not a collection of many small systems,
                   2603:     there are sometimes changes that only work when the whole pkgsrc tree is
                   2604:     updated.
                   2605: 
1.266     martin   2606:  2. Make sure that you don't have any CVS conflicts. Search for    <<<<<<    or    
                   2607:     >>>>>>    in all your pkgsrc files.
1.1       dsieger  2608: 
1.25      wiz      2609:  3. Make sure that you don't have old copies of the packages extracted. Run 
1.1       dsieger  2610:     make clean clean-depends to verify this.
                   2611: 
1.108     rillig   2612:  4. If you are a package developer who wants to invest some work, have a look
1.266     martin   2613:     at Chapter  21, Making your package work.
1.108     rillig   2614: 
                   2615:  5. If the problem still exists, write a mail to the pkgsrc-users mailing list.
1.1       dsieger  2616: 
1.266     martin   2617: 10.17.  What does    Makefile appears to contain unresolved cvs/rcs/??? merge
                   2618: conflicts    mean?
1.1       dsieger  2619: 
                   2620: You have modified a file from pkgsrc, and someone else has modified that same
                   2621: file afterwards in the CVS repository. Both changes are in the same region of
                   2622: the file, so when you updated pkgsrc, the cvs command marked the conflicting
                   2623: changes in the file. Because of these markers, the file is no longer a valid
                   2624: Makefile.
                   2625: 
                   2626: Have a look at that file, and if you don't need your local changes anymore, you
                   2627: can remove that file and run cvs -q update -dP in that directory to download
                   2628: the current version.
                   2629: 
1.266     martin   2630: Part  II.  The pkgsrc developer's guide
1.1       dsieger  2631: 
                   2632: This part of the book deals with creating and modifying packages. It starts
1.266     martin   2633: with a    HOWTO   -like guide on creating a new package. The remaining chapters are
1.1       dsieger  2634: more like a reference manual for pkgsrc.
                   2635: 
                   2636: Table of Contents
                   2637: 
1.154     rillig   2638: 11. Getting help
1.184     rillig   2639: 12. Package components - files, directories and contents
                   2640:     12.1. Makefile
                   2641:     12.2. distinfo
                   2642:     12.3. patches/*
                   2643:         12.3.1. Structure of a single patch file
                   2644:         12.3.2. Creating patch files
                   2645:         12.3.3. Sources where the patch files come from
                   2646:         12.3.4. Patching guidelines
                   2647:         12.3.5. Feedback to the author
                   2648:     12.4. Other mandatory files
                   2649:     12.5. Optional files
                   2650:         12.5.1. Files affecting the binary package
                   2651:         12.5.2. Files affecting the build process
                   2652:         12.5.3. Files affecting nothing at all
                   2653:     12.6. work*
                   2654:     12.7. files/*
                   2655: 13. The build process
                   2656:     13.1. Introduction
                   2657:     13.2. Program location
                   2658:     13.3. Directories used during the build process
                   2659:     13.4. Running a phase
                   2660:     13.5. The fetch phase
                   2661:         13.5.1. What to fetch and where to get it from
                   2662:         13.5.2. How are the files fetched?
                   2663:     13.6. The checksum phase
                   2664:     13.7. The extract phase
                   2665:     13.8. The patch phase
                   2666:     13.9. The tools phase
                   2667:     13.10. The wrapper phase
                   2668:     13.11. The configure phase
                   2669:     13.12. The build phase
                   2670:     13.13. The test phase
                   2671:     13.14. The install phase
                   2672:     13.15. The package phase
                   2673:     13.16. Cleaning up
                   2674:     13.17. Other helpful targets
                   2675: 14. Creating a new pkgsrc package from scratch
                   2676:     14.1. Common types of packages
1.219     nia      2677:         14.1.1. Python modules and programs
                   2678:         14.1.2. R packages
                   2679:         14.1.3. TeXlive packages
1.184     rillig   2680:     14.2. Examples
                   2681:         14.2.1. How the www/nvu package came into pkgsrc
                   2682: 15. Programming in Makefiles
                   2683:     15.1. Caveats
                   2684:     15.2. Makefile variables
                   2685:         15.2.1. Naming conventions
                   2686:     15.3. Code snippets
                   2687:         15.3.1. Adding things to a list
                   2688:         15.3.2. Echoing a string exactly as-is
                   2689:         15.3.3. Passing CFLAGS to GNU configure scripts
                   2690:         15.3.4. Handling possibly empty variables
1.229     gutterid 2691:         15.3.5. Testing yes/no variables in conditions
1.184     rillig   2692: 16. Options handling
                   2693:     16.1. Global default options
                   2694:     16.2. Converting packages to use bsd.options.mk
                   2695:     16.3. Option Names
                   2696:     16.4. Determining the options of dependencies
                   2697: 17. Tools needed for building or running
                   2698:     17.1. Tools for pkgsrc builds
                   2699:     17.2. Tools needed by packages
                   2700:     17.3. Tools provided by platforms
                   2701: 18. Buildlink methodology
                   2702:     18.1. Converting packages to use buildlink3
                   2703:     18.2. Writing buildlink3.mk files
                   2704:         18.2.1. Anatomy of a buildlink3.mk file
                   2705:         18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
1.271     wiz      2706:         pkg in buildlink3.mk files
1.184     rillig   2707:     18.3. Writing builtin.mk files
                   2708:         18.3.1. Anatomy of a builtin.mk file
                   2709: 19. PLIST issues
                   2710:     19.1. RCS ID
                   2711:     19.2. Semi-automatic PLIST generation
                   2712:     19.3. Tweaking output of make print-PLIST
                   2713:     19.4. Variable substitution in PLIST
                   2714:     19.5. Man page compression
                   2715:     19.6. Changing PLIST source with PLIST_SRC
                   2716:     19.7. Platform-specific and differing PLISTs
                   2717:     19.8. Build-specific PLISTs
                   2718:     19.9. Sharing directories between packages
                   2719: 20. The pkginstall framework
                   2720:     20.1. Files and directories outside the installation prefix
                   2721:         20.1.1. Directory manipulation
                   2722:         20.1.2. File manipulation
                   2723:     20.2. Configuration files
                   2724:         20.2.1. How PKG_SYSCONFDIR is set
                   2725:         20.2.2. Telling the software where configuration files are
1.239     dholland 2726:         20.2.3. Patching installation
                   2727:         20.2.4. Declaring configuration files
                   2728:         20.2.5. Disabling handling of configuration files
1.184     rillig   2729:     20.3. System startup scripts
                   2730:         20.3.1. Disabling handling of system startup scripts
                   2731:     20.4. System users and groups
                   2732:     20.5. System shells
                   2733:         20.5.1. Disabling shell registration
                   2734:     20.6. Fonts
                   2735:         20.6.1. Disabling automatic update of the fonts databases
1.154     rillig   2736: 21. Making your package work
                   2737:     21.1. General operation
                   2738:         21.1.1. How to pull in user-settable variables from mk.conf
                   2739:         21.1.2. User interaction
                   2740:         21.1.3. Handling licenses
                   2741:         21.1.4. Restricted packages
                   2742:         21.1.5. Handling dependencies
                   2743:         21.1.6. Handling conflicts with other packages
                   2744:         21.1.7. Packages that cannot or should not be built
                   2745:         21.1.8. Packages which should not be deleted, once installed
                   2746:         21.1.9. Handling packages with security problems
                   2747:         21.1.10. How to handle incrementing versions when fixing an existing
1.271     wiz      2748:         package
1.154     rillig   2749:         21.1.11. Substituting variable text in the package files (the SUBST
1.271     wiz      2750:         framework)
1.154     rillig   2751:     21.2. The fetch phase
                   2752:         21.2.1. Packages whose distfiles aren't available for plain downloading
                   2753:         21.2.2. How to handle modified distfiles with the 'old' name
                   2754:         21.2.3. Packages hosted on github.com
                   2755:     21.3. The configure phase
                   2756:         21.3.1. Shared libraries - libtool
                   2757:         21.3.2. Using libtool on GNU packages that already support libtool
                   2758:         21.3.3. GNU Autoconf/Automake
1.223     nia      2759:         21.3.4. Meson / ninja
1.260     wiz      2760:         21.3.5. Determining the endianness
1.154     rillig   2761:     21.4. Programming languages
                   2762:         21.4.1. C, C++, and Fortran
                   2763:         21.4.2. Java
1.205     wiz      2764:         21.4.3. Go
1.223     nia      2765:         21.4.4. Rust
                   2766:         21.4.5. Packages containing Perl scripts
                   2767:         21.4.6. Packages containing shell scripts
                   2768:         21.4.7. Other programming languages
1.154     rillig   2769:     21.5. The build phase
                   2770:         21.5.1. Compiling C and C++ code conditionally
                   2771:         21.5.2. How to handle compiler bugs
1.172     rillig   2772:         21.5.3. No such file or directory
1.266     martin   2773:         21.5.4. Undefined reference to    ...   
1.172     rillig   2774:         21.5.5. Running out of memory
1.154     rillig   2775:     21.6. The install phase
                   2776:         21.6.1. Creating needed directories
                   2777:         21.6.2. Where to install documentation
                   2778:         21.6.3. Installing highscore files
                   2779:         21.6.4. Adding DESTDIR support to packages
                   2780:         21.6.5. Packages with hardcoded paths to other interpreters
1.203     nia      2781:         21.6.6. Packages installing Perl modules
1.254     wiz      2782:         21.6.7. Packages installing pkg-config files
                   2783:         21.6.8. Packages installing info files
                   2784:         21.6.9. Packages installing man pages
                   2785:         21.6.10. Packages installing X11 fonts
                   2786:         21.6.11. Packages installing SGML or XML data
                   2787:         21.6.12. Packages installing extensions to the MIME database
                   2788:         21.6.13. Packages using intltool
                   2789:         21.6.14. Packages installing startup scripts
                   2790:         21.6.15. Packages installing TeX modules
                   2791:         21.6.16. Packages supporting running binaries in emulation
                   2792:         21.6.17. Packages installing hicolor icons
                   2793:         21.6.18. Packages installing desktop files
1.154     rillig   2794:     21.7. Marking packages as having problems
1.184     rillig   2795: 22. GNOME packaging and porting
                   2796:     22.1. Meta packages
                   2797:     22.2. Packaging a GNOME application
                   2798:     22.3. Updating GNOME to a newer version
                   2799:     22.4. Patching guidelines
1.154     rillig   2800: 23. Submitting and Committing
                   2801:     23.1. Submitting binary packages
                   2802:     23.2. Submitting source packages (for non-NetBSD-developers)
                   2803:     23.3. General notes when adding, updating, or removing packages
                   2804:     23.4. Commit Messages
                   2805:     23.5. Committing: Adding a package to CVS
                   2806:     23.6. Updating a package to a newer version
                   2807:     23.7. Renaming a package in pkgsrc
                   2808:     23.8. Moving a package in pkgsrc
1.263     wiz      2809: 24. pkgsrc Policies
                   2810:     24.1. Packages for which updating is restricted
                   2811:         24.1.1. Limited Updates - ABI
                   2812:         24.1.2. Limited Updates - Bootstrap
                   2813: 25. Frequently Asked Questions
1.154     rillig   2814: 
1.266     martin   2815: Chapter  11.  Getting help
1.154     rillig   2816: 
                   2817: To get help when developing pkgsrc, the definitive source is this document, the
                   2818: pkgsrc guide. If you don't find anything here, there are alternatives:
                   2819: 
                   2820:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
1.266     martin   2821:     Run bmake help topic=    to get help for any topic, such as a variable name
1.154     rillig   2822:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                   2823:     like strcasecmp or any other topic.
                   2824: 
1.266     martin   2825:     The available help topics are listed in Appendix  E, Help topics.
1.154     rillig   2826: 
1.163     rillig   2827:   * To see the value of a single variable, run bmake show-var VARNAME=X.
                   2828: 
                   2829:   * To see the values of the most common variables, run bmake show-all. These
                   2830:     variables are grouped by topic. To see the variables for a single topic,
                   2831:     run bmake show-all-topic, for example bmake show-all-fetch.
                   2832: 
1.154     rillig   2833:   * The tech-pkg mailing list, to which you can subscribe and then ask your
                   2834:     questions.
                   2835: 
                   2836:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                   2837:     a specialized chat program such as XChat. Pick any user name and join the
                   2838:     channel #pkgsrc.
1.1       dsieger  2839: 
1.266     martin   2840: Chapter  12.  Package components - files, directories and contents
1.1       dsieger  2841: 
                   2842: Table of Contents
                   2843: 
1.184     rillig   2844: 12.1. Makefile
                   2845: 12.2. distinfo
                   2846: 12.3. patches/*
                   2847:     12.3.1. Structure of a single patch file
                   2848:     12.3.2. Creating patch files
                   2849:     12.3.3. Sources where the patch files come from
                   2850:     12.3.4. Patching guidelines
                   2851:     12.3.5. Feedback to the author
                   2852: 12.4. Other mandatory files
                   2853: 12.5. Optional files
                   2854:     12.5.1. Files affecting the binary package
                   2855:     12.5.2. Files affecting the build process
                   2856:     12.5.3. Files affecting nothing at all
                   2857: 12.6. work*
                   2858: 12.7. files/*
1.1       dsieger  2859: 
1.184     rillig   2860: Whenever you're preparing a package, there are a number of files involved which
                   2861: are described in the following sections.
1.1       dsieger  2862: 
1.266     martin   2863: 12.1.  Makefile
1.1       dsieger  2864: 
1.184     rillig   2865: Building, installation and creation of a binary package are all controlled by
                   2866: the package's Makefile. The Makefile describes various things about a package,
                   2867: for example from where to get it, how to configure, build, and install it.
1.1       dsieger  2868: 
1.184     rillig   2869: A package Makefile contains several sections that describe the package.
1.1       dsieger  2870: 
1.184     rillig   2871: In the first section there are the following variables, which should appear
                   2872: exactly in the order given here. The order and grouping of the variables is
                   2873: mostly historical and has no further meaning.
1.1       dsieger  2874: 
1.184     rillig   2875:   * DISTNAME is the basename of the distribution file to be downloaded from the
                   2876:     package's website.
1.1       dsieger  2877: 
1.184     rillig   2878:   * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
                   2879:     it if DISTNAME (which is the default) is not a good name for the package in
                   2880:     pkgsrc or DISTNAME is not provided (no distribution file is required).
                   2881:     Usually it is the pkgsrc directory name together with the version number.
                   2882:     It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
                   2883:     is, it starts with a letter or digit, and contains only letters, digits,
1.204     nia      2884:     dashes, underscores, dots and plus signs. New packages should have entirely
                   2885:     lower-case names, with the exception of some that must follow pre-existing
                   2886:     conventions (e.g. R packages begin with R-). You can use the :tl variable
                   2887:     modifier to lower-case the package name.
1.26      spz      2888: 
1.184     rillig   2889:   * CATEGORIES is a list of categories which the package fits in. You can
                   2890:     choose any of the top-level directories of pkgsrc for it.
1.1       dsieger  2891: 
1.184     rillig   2892:     Currently the following values are available for CATEGORIES. If more than
                   2893:     one is used, they need to be separated by spaces:
1.1       dsieger  2894: 
1.184     rillig   2895:     archivers     cross         geography     meta-pkgs     security
                   2896:     audio         databases     graphics      misc          shells
                   2897:     benchmarks    devel         ham           multimedia    sysutils
                   2898:     biology       editors       inputmethod   net           textproc
                   2899:     cad           emulators     lang          news          time
                   2900:     chat          finance       mail          parallel      wm
                   2901:     comms         fonts         math          pkgtools      www
                   2902:     converters    games         mbone         print         x11
1.1       dsieger  2903: 
1.184     rillig   2904:   * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
1.266     martin   2905:     are discussed in detail in Section  13.5,    The fetch phase   .
1.1       dsieger  2906: 
1.184     rillig   2907: The second section contains information about separately downloaded patches, if
                   2908: any.
1.1       dsieger  2909: 
1.184     rillig   2910:   * PATCHFILES: Name(s) of additional files that contain distribution patches.
                   2911:     There is no default. pkgsrc will look for them at PATCH_SITES. They will
                   2912:     automatically be uncompressed before patching if the names end with .gz or
                   2913:     .Z.
1.1       dsieger  2914: 
1.184     rillig   2915:   * PATCH_SITES: Primary location(s) for distribution patch files (see
                   2916:     PATCHFILES above) if not found locally.
1.1       dsieger  2917: 
1.184     rillig   2918:   * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
                   2919:     count to help find the correct files to patch. It defaults to -p0.
1.1       dsieger  2920: 
1.184     rillig   2921: The third section contains the following variables.
1.1       dsieger  2922: 
1.253     gutterid 2923:   * MAINTAINER is the email address of the person who is currently responsible
                   2924:     for this package. In theory, the maintainer will be aware of upstream
                   2925:     release, keep it updated, and generally resolve problems. Others
                   2926:     contemplating significant changes should ask the maintainer for advice or
                   2927:     review of a proposed change. This is not necessary for micro updates, bug
                   2928:     fixes, pkgsrc-wide changes affecting many packages, and other things
                   2929:     expected to be uncontroversial. It goes with this "should ask" that the
                   2930:     maintainer should respond to inquiries reasonably promptly (most of the
                   2931:     time), and either approve changes or provide reasons why not. Typically,
                   2932:     when packaging a new program, set MAINTAINER to yourself. If you don't
                   2933:     intend to maintain the package (especially if you feel you have no special
                   2934:     insight), set it to <pkgsrc-users@NetBSD.org>. This special value is a code
                   2935:     point indicating that there is no maintainer, but the variable is
                   2936:     mandatory, absent OWNER.
                   2937: 
                   2938:   * OWNER can be used instead of MAINTAINER in relatively rare circumstances
                   2939:     when the package is such that modifying it is riskier than normal. This is
                   2940:     a stronger form of being the maintainer, with an expectation that others
                   2941:     will ask for almost all changes, except revbumps and accommodating
                   2942:     structural changes. Someone who becomes OWNER has a strong obligation to
                   2943:     keep the package very well maintained, to answer queries promptly and to be
                   2944:     a steward of the package on behalf of users. In this case, MAINTAINER
                   2945:     should be omitted.
                   2946: 
                   2947:     Because of the friction that OWNER adds, PMC may downgrade it to MAINTAINER
                   2948:     at any time.
1.1       dsieger  2949: 
1.184     rillig   2950:   * HOMEPAGE is a URL where users can find more information about the package.
1.1       dsieger  2951: 
1.184     rillig   2952:   * COMMENT is a one-line description of the package (should not include the
                   2953:     package name).
1.1       dsieger  2954: 
1.184     rillig   2955:   * LICENSE indicates the license(s) applicable for the package. See
1.266     martin   2956:     Section  21.1.3,    Handling licenses    for further details.
1.1       dsieger  2957: 
1.184     rillig   2958: Other variables that affect the build:
1.1       dsieger  2959: 
1.184     rillig   2960:   * WRKSRC: The directory where the interesting distribution files of the
                   2961:     package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
                   2962:     most packages.
1.1       dsieger  2963: 
1.184     rillig   2964:     If a package doesn't create a subdirectory for itself (most GNU software
                   2965:     does, for instance), but extracts itself in the current directory, you
                   2966:     should set WRKSRC=${WRKDIR}.
1.1       dsieger  2967: 
1.184     rillig   2968:     If a package doesn't create a subdirectory with the name of DISTNAME but
                   2969:     some different name, set WRKSRC to point to the proper name in ${WRKDIR},
                   2970:     for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
                   2971:     other examples.
1.17      imil     2972: 
1.184     rillig   2973:     The name of the working directory created by pkgsrc is taken from the
                   2974:     WRKDIR_BASENAME variable. By default, its value is work. If you want to use
                   2975:     the same pkgsrc tree for building different kinds of binary packages, you
                   2976:     can change the variable according to your needs. Two other variables handle
                   2977:     common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
                   2978:     defined in mk.conf, the first component of the host's name is attached to
                   2979:     the directory name. If OBJMACHINE is defined, the platform name is
                   2980:     attached, which might look like work.i386 or work.sparc.
1.17      imil     2981: 
1.184     rillig   2982: Please pay attention to the following gotchas:
1.17      imil     2983: 
1.184     rillig   2984:   * Add MANCOMPRESSED if man pages are installed in compressed form by the
                   2985:     package. For packages using BSD-style makefiles which honor MANZ, there is
                   2986:     MANCOMPRESSED_IF_MANZ.
1.17      imil     2987: 
1.266     martin   2988:   * Replace /usr/local with    ${PREFIX}    in all files (see patches, below).
1.103     wiz      2989: 
1.266     martin   2990:   * If the package installs any info files, see Section  21.6.8,    Packages
                   2991:     installing info files   .
1.103     wiz      2992: 
1.266     martin   2993: 12.2.  distinfo
1.17      imil     2994: 
1.184     rillig   2995: The distinfo file contains the message digest, or checksum, of each distfile
                   2996: needed for the package. This ensures that the distfiles retrieved from the
                   2997: Internet have not been corrupted during transfer or altered by a malign force
                   2998: to introduce a security hole. To provide maximum security, all distfiles are
1.243     gutterid 2999: protected using two different message digest algorithms (BLAKE2s and SHA512),
                   3000: as well as the file size.
1.17      imil     3001: 
1.184     rillig   3002: The distinfo file also contains the checksums for all the patches found in the
1.266     martin   3003: patches directory (see Section  12.3,    patches/*   ). These checksums ensure that
1.184     rillig   3004: patches are only applied intentionally and that they don't accidentally change,
                   3005: e.g. when merging different changes together. They also make sure that new
                   3006: patches are actually added to CVS and old ones are removed. Too see whether the
                   3007: patches and the distinfo file match, run pkglint after changing the patches.
1.17      imil     3008: 
1.184     rillig   3009: To regenerate the distinfo file, use the make distinfo command.
1.17      imil     3010: 
1.184     rillig   3011: Some packages have different sets of distfiles depending on the platform, for
                   3012: example lang/openjdk8. These are kept in the same distinfo file and care should
                   3013: be taken when upgrading such a package to ensure distfile information is not
                   3014: lost.
1.17      imil     3015: 
1.266     martin   3016: 12.3.  patches/*
1.63      wiz      3017: 
1.184     rillig   3018: Some packages don't work out-of-the box on the various platforms that are
                   3019: supported by pkgsrc. These packages need to be patched to make them work. The
                   3020: patch files can be found in the patches/ directory.
1.17      imil     3021: 
1.184     rillig   3022: In the patch phase, these patches are applied to the files in WRKSRC directory
                   3023: after extracting them, in alphabetic order.
1.160     brook    3024: 
1.266     martin   3025: 12.3.1.  Structure of a single patch file
1.160     brook    3026: 
1.184     rillig   3027: The patch-* files should be in diff -bu format, and apply without a fuzz to
                   3028: avoid problems. (To force patches to apply with fuzz you can set
                   3029: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
                   3030: a single file, and no file should be patched by more than one patch file. This
                   3031: helps to keep future modifications simple.
1.160     brook    3032: 
1.184     rillig   3033: Each patch file is structured as follows: In the first line, there is the RCS
                   3034: Id of the patch itself. The second line should be empty for aesthetic reasons.
                   3035: After that, there should be a comment for each change that the patch does.
                   3036: There are a number of standard cases:
1.160     brook    3037: 
1.184     rillig   3038:   * Patches for commonly known vulnerabilities should mention the vulnerability
                   3039:     ID (CAN, CVE).
1.160     brook    3040: 
1.184     rillig   3041:   * Patches that change source code should mention the platform and other
                   3042:     environment (for example, the compiler) that the patch is needed for.
1.160     brook    3043: 
1.184     rillig   3044: The patch should be commented so that any developer who knows the code of the
                   3045: application can make some use of the patch. Special care should be taken for
                   3046: the upstream developers, since we generally want that they accept our patches,
                   3047: so we have less work in the future.
1.160     brook    3048: 
1.266     martin   3049: 12.3.2.  Creating patch files
1.160     brook    3050: 
1.184     rillig   3051: One important thing to mention is to pay attention that no RCS IDs get stored
                   3052: in the patch files, as these will cause problems when later checked into the
                   3053: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
                   3054: avoid these problems.
1.160     brook    3055: 
1.184     rillig   3056: For even more automation, we recommend using mkpatches from the same package to
1.222     gutterid 3057: make a whole set of patches. You just have to back up files before you edit
                   3058: them to filename.orig, e.g., with cp -p filename filename.orig or, easier, by
                   3059: using pkgvi again from the same package. If you upgrade a package this way, you
                   3060: can easily compare the new set of patches with the previously existing one with
1.184     rillig   3061: patchdiff. The files in patches are replaced by new files, so carefully check
                   3062: if you want to take all the changes.
1.160     brook    3063: 
1.184     rillig   3064: When you have finished a package, remember to generate the checksums for the
1.266     martin   3065: patch files by using the make makepatchsum command, see Section  12.2,
                   3066:    distinfo   .
1.1       dsieger  3067: 
1.184     rillig   3068: When adding a patch that corrects a problem in the distfile (rather than e.g.
                   3069: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
                   3070: report to the maintainer. This benefits non-pkgsrc users of the package, and
                   3071: usually makes it possible to remove the patch in future version.
1.1       dsieger  3072: 
1.184     rillig   3073: The file names of the patch files are usually of the form patch-
                   3074: path_to_file__with__underscores.c. Many packages still use the previous
                   3075: convention patch-[a-z][a-z], but new patches should be of the form containing
                   3076: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
                   3077: automatically.
1.1       dsieger  3078: 
1.222     gutterid 3079: When updating pre-existing patch files, if a file uses the old patch-[a-z][a-z]
                   3080: convention, it's best not to change it to the new form, as that will just cause
                   3081: churn that makes it harder to track changes to patching over time. Similarly,
                   3082: if a patch now applies at different line offsets, but still applies cleanly
                   3083: as-is, there's no need to update it, as that also unnecessarily complicates the
                   3084: patch history.
                   3085: 
1.266     martin   3086: 12.3.3.  Sources where the patch files come from
1.1       dsieger  3087: 
1.184     rillig   3088: If you want to share patches between multiple packages in pkgsrc, e.g. because
                   3089: they use the same distfiles, set PATCHDIR to the path where the patch files can
                   3090: be found, e.g.:
1.1       dsieger  3091: 
1.184     rillig   3092: PATCHDIR=       ../../editors/xemacs/patches
1.1       dsieger  3093: 
1.184     rillig   3094: Patch files that are distributed by the author or other maintainers can be
                   3095: listed in PATCHFILES.
1.1       dsieger  3096: 
1.184     rillig   3097: If it is desired to store any patches that should not be committed into pkgsrc,
                   3098: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
1.266     martin   3099: directory tree there is expected to have the same    category/package    structure
1.184     rillig   3100: as pkgsrc, and patches are expected to be stored inside these dirs (also known
                   3101: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
                   3102: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
                   3103: files in the named directory are expected to be patch files, and they are
                   3104: applied after pkgsrc patches are applied.
1.1       dsieger  3105: 
1.266     martin   3106: 12.3.4.  Patching guidelines
1.1       dsieger  3107: 
1.184     rillig   3108: When fixing a portability issue in the code do not use preprocessor magic to
                   3109: check for the current operating system nor platform. Doing so hurts portability
                   3110: to other platforms because the OS-specific details are not abstracted
                   3111: appropriately.
1.1       dsieger  3112: 
1.184     rillig   3113: The general rule to follow is: instead of checking for the operating system the
                   3114: application is being built on, check for the specific features you need. For
                   3115: example, instead of assuming that kqueue is available under NetBSD and using
                   3116: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
1.266     martin   3117: kqueue itself     yes, this generally involves patching the configure script.
1.184     rillig   3118: There is absolutely nothing that prevents some OSes from adopting interfaces
                   3119: from other OSes (e.g. Linux implementing kqueue), something that the above
                   3120: checks cannot take into account.
1.1       dsieger  3121: 
1.184     rillig   3122: Of course, checking for features generally involves more work on the
                   3123: developer's side, but the resulting changes are cleaner and there are chances
                   3124: they will work on many other platforms. Not to mention that there are higher
                   3125: chances of being later integrated into the mainstream sources. Remember: It
                   3126: doesn't work unless it is right!
1.1       dsieger  3127: 
1.184     rillig   3128: Some typical examples:
1.121     sevan    3129: 
1.266     martin   3130: Table  12.1.  Patching examples
1.1       dsieger  3131: 
1.184     rillig   3132: +-------------------------------------------------------------------------------------------+
                   3133: |  Where  |        Incorrect         |                       Correct                        |
                   3134: |---------+--------------------------+------------------------------------------------------|
                   3135: |         |case ${target_os} in      |                                                      |
                   3136: |configure|netbsd*) have_kvm=yes ;;  |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
                   3137: |script   |*)       have_kvm=no  ;;  |                                                      |
                   3138: |         |esac                      |                                                      |
                   3139: |---------+--------------------------+------------------------------------------------------|
                   3140: |C source |#if defined(__NetBSD__)   |#if defined(HAVE_SYS_EVENT_H)                         |
                   3141: |file     |#  include <sys/event.h>  |#  include <sys/event.h>                              |
                   3142: |         |#endif                    |#endif                                                |
                   3143: |---------+--------------------------+------------------------------------------------------|
                   3144: |         |int                       |int                                                   |
                   3145: |         |monitor_file(...)         |monitor_file(...)                                     |
                   3146: |         |{                         |{                                                     |
                   3147: |         |#if defined(__NetBSD__)   |#if defined(HAVE_KQUEUE)                              |
                   3148: |C source |        int fd = kqueue();|        int fd = kqueue();                            |
                   3149: |file     |        ...               |        ...                                           |
                   3150: |         |#else                     |#else                                                 |
                   3151: |         |        ...               |        ...                                           |
                   3152: |         |#endif                    |#endif                                                |
                   3153: |         |}                         |}                                                     |
                   3154: +-------------------------------------------------------------------------------------------+
1.1       dsieger  3155: 
                   3156: 
1.266     martin   3157: 12.3.5.  Feedback to the author
1.1       dsieger  3158: 
1.184     rillig   3159: Always, always, always feed back any portability fixes or improvements you do
                   3160: to a package to the mainstream developers. This is the only way to get their
                   3161: attention on portability issues and to ensure that future versions can be built
                   3162: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
                   3163: get the fixes straight from the packaged code.
1.1       dsieger  3164: 
1.184     rillig   3165: This generally involves cleaning up the patches (because sometimes the patches
                   3166: that are added to pkgsrc are quick hacks), filing bug reports in the
                   3167: appropriate trackers for the projects and working with the mainstream authors
                   3168: to accept your changes. It is extremely important that you do it so that the
                   3169: packages in pkgsrc are kept simple and thus further changes can be done without
                   3170: much hassle.
1.1       dsieger  3171: 
1.184     rillig   3172: When you have done this, please add a URL to the upstream bug report to the
                   3173: patch comment.
1.1       dsieger  3174: 
1.184     rillig   3175: Support the idea of free software!
1.1       dsieger  3176: 
1.266     martin   3177: 12.4.  Other mandatory files
1.1       dsieger  3178: 
1.184     rillig   3179: DESCR
1.1       dsieger  3180: 
1.184     rillig   3181:     A multi-line description of the piece of software. This should include any
                   3182:     credits where they are due. Please bear in mind that others do not share
                   3183:     your sense of humour (or spelling idiosyncrasies), and that others will
                   3184:     read everything that you write here.
1.1       dsieger  3185: 
1.184     rillig   3186: PLIST
1.1       dsieger  3187: 
1.184     rillig   3188:     This file governs the files that are installed on your system: all the
                   3189:     binaries, manual pages, etc. There are other directives which may be
                   3190:     entered in this file, to control the creation and deletion of directories,
1.266     martin   3191:     and the location of inserted files. See Chapter  19, PLIST issues for more
1.184     rillig   3192:     information.
1.1       dsieger  3193: 
1.266     martin   3194: 12.5.  Optional files
1.1       dsieger  3195: 
1.266     martin   3196: 12.5.1.  Files affecting the binary package
1.1       dsieger  3197: 
1.184     rillig   3198: INSTALL
1.1       dsieger  3199: 
1.184     rillig   3200:     This shell script is invoked twice by pkg_add(1). First time after package
                   3201:     extraction and before files are moved in place, the second time after the
                   3202:     files to install are moved in place. This can be used to do any custom
                   3203:     procedures not possible with @exec commands in PLIST. See pkg_add(1) and
1.266     martin   3204:     pkg_create(1) for more information. See also Section  20.1,    Files and
                   3205:     directories outside the installation prefix   . Please note that you can
1.184     rillig   3206:     modify variables in it easily by using FILES_SUBST in the package's
                   3207:     Makefile:
1.1       dsieger  3208: 
1.184     rillig   3209:     FILES_SUBST+=  SOMEVAR="somevalue"
1.1       dsieger  3210: 
1.266     martin   3211:     replaces "@SOMEVAR@" with    somevalue    in the INSTALL. By default,
1.184     rillig   3212:     substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
                   3213:     few others, type make help topic=FILES_SUBST for a complete list.
1.1       dsieger  3214: 
1.184     rillig   3215: DEINSTALL
1.1       dsieger  3216: 
1.184     rillig   3217:     This script is executed before and after any files are removed. It is this
                   3218:     script's responsibility to clean up any additional messy details around the
                   3219:     package's installation, since all pkg_delete knows is how to delete the
                   3220:     files created in the original distribution. See pkg_delete(1) and
                   3221:     pkg_create(1) for more information. The same methods to replace variables
                   3222:     can be used as for the INSTALL file.
1.1       dsieger  3223: 
1.184     rillig   3224: MESSAGE
1.1       dsieger  3225: 
1.198     leot     3226:     This file is displayed after installation of the package. While this was
                   3227:     used often in the past, it has two problems: the display will be missed if
1.257     jkoshy   3228:     many packages are installed at once, and the person installing the package
1.198     leot     3229:     and the one using or configuring it may be different. It should therefore
                   3230:     be used only in exceptional circumstances where lasting negative
                   3231:     consequences would result from someone not reading it.
                   3232: 
                   3233:     MESSAGE should not be used for:
                   3234: 
1.271     wiz      3235:       o exhortations to read the documentation
1.198     leot     3236: 
1.271     wiz      3237:       o reminders to install rc.d files and set variables
1.198     leot     3238: 
1.271     wiz      3239:       o anything that should be explained in the installation/configuration
1.198     leot     3240:         documentation that should come with the package
                   3241: 
                   3242:     If the documentation provided by upstream needs enhancing, create e.g.
                   3243:     files/README.pkgsrc and install it in the package's documentation
                   3244:     directory.
                   3245: 
                   3246:     Note that MESSAGE is shown for all operating systems and all init systems.
                   3247:     If a MESSAGE is necessary, it should be narrowed to only those operating
                   3248:     systems and init systems to which it applies.
                   3249: 
                   3250:     Note that you can modify variables in it easily by using MESSAGE_SUBST in
                   3251:     the package's Makefile:
1.1       dsieger  3252: 
1.184     rillig   3253:     MESSAGE_SUBST+=  SOMEVAR="somevalue"
1.1       dsieger  3254: 
1.266     martin   3255:     replaces "${SOMEVAR}" with    somevalue    in MESSAGE. By default, substitution
1.184     rillig   3256:     is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11BASE,
                   3257:     PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1       dsieger  3258: 
1.184     rillig   3259:     You can display a different or additional files by setting the MESSAGE_SRC
                   3260:     variable. Its default is MESSAGE, if the file exists.
1.1       dsieger  3261: 
1.184     rillig   3262: ALTERNATIVES
1.1       dsieger  3263: 
1.184     rillig   3264:     This file is used by the alternatives framework. It creates, configures,
                   3265:     and destroys generic wrappers used to run programs with similar interfaces.
                   3266:     See pkg_alternatives(8) from pkgtools/pkg_alternatives for more
                   3267:     information.
1.1       dsieger  3268: 
1.184     rillig   3269:     Each line of the file contains two filenames, first the wrapper and then
                   3270:     the alternative provided by the package. Both paths are relative to PREFIX.
1.1       dsieger  3271: 
1.266     martin   3272: 12.5.2.  Files affecting the build process
1.1       dsieger  3273: 
1.184     rillig   3274: Makefile.common
1.1       dsieger  3275: 
1.184     rillig   3276:     This file contains arbitrary things that could also go into a Makefile, but
                   3277:     its purpose is to be used by more than one package. This file should only
                   3278:     be used when the packages that will use the file are known in advance. For
                   3279:     other purposes it is often better to write a *.mk file and give it a good
                   3280:     name that describes what it does.
1.1       dsieger  3281: 
1.184     rillig   3282: buildlink3.mk
1.1       dsieger  3283: 
1.184     rillig   3284:     This file contains the dependency information for the buildlink3 framework
1.266     martin   3285:     (see Chapter  18, Buildlink methodology).
1.1       dsieger  3286: 
1.184     rillig   3287: hacks.mk
1.1       dsieger  3288: 
1.184     rillig   3289:     This file contains workarounds for compiler bugs and similar things. It is
                   3290:     included automatically by the pkgsrc infrastructure, so you don't need an
                   3291:     extra .include line for it.
1.1       dsieger  3292: 
1.184     rillig   3293: options.mk
1.1       dsieger  3294: 
1.184     rillig   3295:     This file contains the code for the package-specific options (see
1.266     martin   3296:     Chapter  16, Options handling) that can be selected by the user. If a
1.184     rillig   3297:     package has only one or two options, it is equally acceptable to put the
                   3298:     code directly into the Makefile.
1.1       dsieger  3299: 
1.266     martin   3300: 12.5.3.  Files affecting nothing at all
1.1       dsieger  3301: 
1.184     rillig   3302: README*
1.1       dsieger  3303: 
1.184     rillig   3304:     These files do not take place in the creation of a package and thus are
                   3305:     purely informative to the package developer.
1.1       dsieger  3306: 
1.184     rillig   3307: TODO
1.1       dsieger  3308: 
1.184     rillig   3309:     This file contains things that need to be done to make the package even
                   3310:     better.
1.1       dsieger  3311: 
1.266     martin   3312: 12.6.  work*
1.1       dsieger  3313: 
1.184     rillig   3314: When you type make, the distribution files are unpacked into the directory
                   3315: denoted by WRKDIR. It can be removed by running make clean. Besides the
                   3316: sources, this directory is also used to keep various timestamp files. The
                   3317: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
                   3318: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
1.1       dsieger  3319: 
1.266     martin   3320: 12.7.  files/*
1.80      wiz      3321: 
1.184     rillig   3322: If you have any files that you wish to be placed in the package prior to
                   3323: configuration or building, you can place these files here and use a ${CP}
1.266     martin   3324: command in the    post-extract    target to achieve this.
1.1       dsieger  3325: 
1.184     rillig   3326: If you want to share files in this way with other packages, set the FILESDIR
                   3327: variable to point to the other package's files directory, e.g.:
1.1       dsieger  3328: 
1.184     rillig   3329: FILESDIR=       ../../editors/xemacs/files
1.14      jmcneill 3330: 
1.266     martin   3331: Chapter  13.  The build process
1.1       dsieger  3332: 
1.184     rillig   3333: Table of Contents
1.1       dsieger  3334: 
1.184     rillig   3335: 13.1. Introduction
                   3336: 13.2. Program location
                   3337: 13.3. Directories used during the build process
                   3338: 13.4. Running a phase
                   3339: 13.5. The fetch phase
                   3340:     13.5.1. What to fetch and where to get it from
                   3341:     13.5.2. How are the files fetched?
                   3342: 13.6. The checksum phase
                   3343: 13.7. The extract phase
                   3344: 13.8. The patch phase
                   3345: 13.9. The tools phase
                   3346: 13.10. The wrapper phase
                   3347: 13.11. The configure phase
                   3348: 13.12. The build phase
                   3349: 13.13. The test phase
                   3350: 13.14. The install phase
                   3351: 13.15. The package phase
                   3352: 13.16. Cleaning up
                   3353: 13.17. Other helpful targets
1.1       dsieger  3354: 
1.266     martin   3355: 13.1.  Introduction
1.122     leot     3356: 
1.184     rillig   3357: This chapter gives a detailed description on how a package is built. Building a
                   3358: package is separated into different phases (for example fetch, build, install),
                   3359: all of which are described in the following sections. Each phase is split into
                   3360: so-called stages, which take the name of the containing phase, prefixed by one
                   3361: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
                   3362: actual work is done in the do-* stages.
1.1       dsieger  3363: 
1.184     rillig   3364: Never override the regular targets (like fetch), if you have to, override the
                   3365: do-* ones instead.
1.1       dsieger  3366: 
1.184     rillig   3367: The basic steps for building a program are always the same. First the program's
                   3368: source (distfile) must be brought to the local system and then extracted. After
                   3369: any pkgsrc-specific patches to compile properly are applied, the software can
                   3370: be configured, then built (usually by compiling), and finally the generated
                   3371: binaries, etc. can be put into place on the system.
1.1       dsieger  3372: 
1.184     rillig   3373: To get more details about what is happening at each step, you can set the
                   3374: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
                   3375: more details about the patch step.
1.1       dsieger  3376: 
1.266     martin   3377: 13.2.  Program location
1.1       dsieger  3378: 
1.184     rillig   3379: Before outlining the process performed by the NetBSD package system in the next
                   3380: section, here's a brief discussion on where programs are installed, and which
                   3381: variables influence this.
1.1       dsieger  3382: 
1.184     rillig   3383: The automatic variable PREFIX indicates where all files of the final program
                   3384: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
                   3385: pkgs in the cross category. The value of PREFIX needs to be put into the
                   3386: various places in the program's source where paths to these files are encoded.
1.266     martin   3387: See Section  12.3,    patches/*    and Section  21.3.1,    Shared libraries - libtool   
1.184     rillig   3388: for more details.
1.1       dsieger  3389: 
1.184     rillig   3390: When choosing which of these variables to use, follow the following rules:
1.1       dsieger  3391: 
1.184     rillig   3392:   * PREFIX always points to the location where the current pkg will be
1.266     martin   3393:     installed. When referring to a pkg's own installation path, use    ${PREFIX}   
1.184     rillig   3394:     .
1.1       dsieger  3395: 
1.223     nia      3396:   * LOCALBASE is where all pkgs are installed. If you need to construct a -I or
                   3397:     -L argument to the compiler to find includes and libraries installed by
1.266     martin   3398:     another pkg, use    ${LOCALBASE}   . The name LOCALBASE stems from FreeBSD,
1.223     nia      3399:     which installed all packages in /usr/local. As pkgsrc leaves /usr/local for
                   3400:     the system administrator, this variable is a misnomer.
1.1       dsieger  3401: 
1.184     rillig   3402:   * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
                   3403:     installed. When looking for standard X11 includes (not those installed by a
1.266     martin   3404:     package), use    ${X11BASE}   .
1.1       dsieger  3405: 
1.184     rillig   3406:   * X11-based packages using imake must set USE_IMAKE to be installed correctly
                   3407:     under LOCALBASE.
1.1       dsieger  3408: 
1.184     rillig   3409:   * Within ${PREFIX}, packages should install files according to hier(7), with
                   3410:     the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
                   3411:     man.
1.1       dsieger  3412: 
1.266     martin   3413: 13.3.  Directories used during the build process
1.2       rillig   3414: 
1.184     rillig   3415: When building a package, various directories are used to store source files,
                   3416: temporary files, pkgsrc-internal files, and so on. These directories are
                   3417: explained here.
1.1       dsieger  3418: 
1.184     rillig   3419: Some of the directory variables contain relative pathnames. There are two
                   3420: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
                   3421: used for directories that are pkgsrc-specific. WRKSRC is used for directories
                   3422: inside the package itself.
1.1       dsieger  3423: 
1.184     rillig   3424: PKGSRCDIR
1.1       dsieger  3425: 
1.184     rillig   3426:     This is an absolute pathname that points to the pkgsrc root directory.
                   3427:     Generally, you don't need it.
1.1       dsieger  3428: 
1.184     rillig   3429: PKGDIR
1.1       dsieger  3430: 
1.184     rillig   3431:     This is an absolute pathname that points to the current package.
1.1       dsieger  3432: 
1.184     rillig   3433: PKGPATH
1.1       dsieger  3434: 
1.184     rillig   3435:     This is a pathname relative to PKGSRCDIR that points to the current
1.228     gutterid 3436:     package. It is defined after including bsd.prefs.mk and can be used in
                   3437:     makefile fragments that are used by several packages to distinguish between
                   3438:     these packages. Other variables that would serve the same purpose are
                   3439:     PKGBASE and PKGNAME, but these are only defined after including bsd.pkg.mk,
                   3440:     which is too late.
                   3441: 
                   3442:     In mk.conf, the pkgsrc user can use PKGPATH to tweak variables like
                   3443:     MAKE_JOBS and CFLAGS.
1.1       dsieger  3444: 
1.184     rillig   3445: WRKDIR
1.1       dsieger  3446: 
1.184     rillig   3447:     This is an absolute pathname pointing to the directory where all work takes
                   3448:     place. The distfiles are extracted to this directory. It also contains
                   3449:     temporary directories and log files used by the various pkgsrc frameworks,
                   3450:     like buildlink or the wrappers.
1.1       dsieger  3451: 
1.184     rillig   3452: WRKSRC
1.1       dsieger  3453: 
1.184     rillig   3454:     This is an absolute pathname pointing to the directory where the distfiles
                   3455:     are extracted. It is usually a direct subdirectory of WRKDIR, and often
                   3456:     it's the only directory entry that isn't hidden. This variable may be
                   3457:     changed by a package Makefile.
1.1       dsieger  3458: 
1.184     rillig   3459: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
                   3460: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
                   3461: created in the pkgsrc entry's directory. If users would like to have their
                   3462: pkgsrc trees behave in a read-only manner, then the value of
                   3463: CREATE_WRKDIR_SYMLINK should be set to no.
1.1       dsieger  3464: 
1.266     martin   3465: 13.4.  Running a phase
1.1       dsieger  3466: 
1.184     rillig   3467: You can run a particular phase by typing make phase, where phase is the name of
                   3468: the phase. This will automatically run all phases that are required for this
                   3469: phase. The default phase is build, that is, when you run make without
                   3470: parameters in a package directory, the package will be built, but not
                   3471: installed.
1.1       dsieger  3472: 
1.266     martin   3473: 13.5.  The fetch phase
1.1       dsieger  3474: 
1.184     rillig   3475: The first step in building a package is to fetch the distribution files
                   3476: (distfiles) from the sites that are providing them. This is the task of the 
                   3477: fetch phase.
1.25      wiz      3478: 
1.266     martin   3479: 13.5.1.  What to fetch and where to get it from
1.1       dsieger  3480: 
1.184     rillig   3481: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
                   3482: name is derived from the DISTNAME variable, is fetched. The more complicated
                   3483: cases are described below.
1.1       dsieger  3484: 
1.184     rillig   3485: The variable DISTFILES specifies the list of distfiles that have to be fetched.
                   3486: Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
                   3487: {EXTRACT_SUFX}, so that most packages don't need to define it at all.
                   3488: EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
                   3489: your package requires additional distfiles to the default one, you cannot just
                   3490: append the additional filenames using the += operator, but you have write for
                   3491: example:
1.1       dsieger  3492: 
1.184     rillig   3493: DISTFILES=      ${DEFAULT_DISTFILES} additional-files.tar.gz
1.1       dsieger  3494: 
1.184     rillig   3495: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
                   3496: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
                   3497: can set SITES.distfile to the list of URLs where the file distfile (including
                   3498: the suffix) can be found.
1.1       dsieger  3499: 
1.184     rillig   3500: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
                   3501: DISTFILES+=     foo-file.tar.gz
                   3502: SITES.foo-file.tar.gz= \
                   3503: https://www.somewhere.com/somehow/ \
                   3504: https://www.somewhereelse.com/mirror/somehow/
1.1       dsieger  3505: 
1.184     rillig   3506: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
                   3507: gets the name of each distfile appended to it, without an intermediate slash.
                   3508: Therefore, all site values have to end with a slash or other separator
                   3509: character. This allows for example to set MASTER_SITES to a URL of a CGI script
                   3510: that gets the name of the distfile as a parameter. In this case, the definition
                   3511: would look like:
1.1       dsieger  3512: 
1.184     rillig   3513: MASTER_SITES=   https://www.example.com/download.cgi?file=
1.1       dsieger  3514: 
1.184     rillig   3515: The exception to this rule are URLs starting with a dash. In that case the URL
                   3516: is taken as is, fetched and the result stored under the name of the distfile.
                   3517: You can use this style for the case when the download URL style does not match
                   3518: the above common case. For example, if permanent download URL is a redirector
                   3519: to the real download URL, or the download file name is offered by an HTTP
                   3520: Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
                   3521: created instead of the default v1.0.0.tar.gz.
1.1       dsieger  3522: 
1.184     rillig   3523: DISTNAME=       foo-1.0.0
                   3524: MASTER_SITES=   -https://www.example.com/archive/v1.0.0.tar.gz
1.29      wiz      3525: 
1.184     rillig   3526: There are some predefined values for MASTER_SITES, which can be used in
                   3527: packages. The names of the variables should speak for themselves.
1.29      wiz      3528: 
1.260     wiz      3529: MASTER_SITE_APACHE          MASTER_SITE_BACKUP
                   3530: MASTER_SITE_CRATESIO        MASTER_SITE_CYGWIN
                   3531: MASTER_SITE_DEBIAN          MASTER_SITE_FREEBSD
                   3532: MASTER_SITE_FREEBSD_LOCAL   MASTER_SITE_GENTOO
                   3533: MASTER_SITE_GITHUB          MASTER_SITE_GITLAB
                   3534: MASTER_SITE_GNOME           MASTER_SITE_GNU
                   3535: MASTER_SITE_GNUPG           MASTER_SITE_GNUSTEP
                   3536: MASTER_SITE_HASKELL_HACKAGE MASTER_SITE_IFARCHIVE
                   3537: MASTER_SITE_KDE             MASTER_SITE_MOZILLA
                   3538: MASTER_SITE_MOZILLA_ALL     MASTER_SITE_MYSQL
                   3539: MASTER_SITE_NETLIB          MASTER_SITE_OPENBSD
                   3540: MASTER_SITE_OPENOFFICE      MASTER_SITE_OSDN
                   3541: MASTER_SITE_PERL_CPAN       MASTER_SITE_PGSQL
                   3542: MASTER_SITE_PYPI            MASTER_SITE_RUBYGEMS
                   3543: MASTER_SITE_R_CRAN          MASTER_SITE_SOURCEFORGE
                   3544: MASTER_SITE_SUNSITE         MASTER_SITE_SUSE
                   3545: MASTER_SITE_TEX_CTAN        MASTER_SITE_XCONTRIB
                   3546: MASTER_SITE_XEMACS          MASTER_SITE_XORG
1.1       dsieger  3547: 
1.184     rillig   3548: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
                   3549: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
                   3550: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
                   3551: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
                   3552: distfiles/LOCAL_PORTS/.
1.1       dsieger  3553: 
1.184     rillig   3554: If you choose one of these predefined sites, you may want to specify a
                   3555: subdirectory of that site. Since these macros may expand to more than one
                   3556: actual site, you must use the following construct to specify a subdirectory:
1.1       dsieger  3557: 
1.184     rillig   3558: MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
                   3559: MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
1.1       dsieger  3560: 
1.184     rillig   3561: Note the trailing slash after the subdirectory name.
1.1       dsieger  3562: 
1.266     martin   3563: 13.5.2.  How are the files fetched?
1.1       dsieger  3564: 
1.184     rillig   3565: The fetch phase makes sure that all the distfiles exist in a local directory
                   3566: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
                   3567: are fetched using commands of the form
1.1       dsieger  3568: 
1.184     rillig   3569: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
1.1       dsieger  3570: 
1.184     rillig   3571: where ${site} varies through several possibilities in turn: first,
                   3572: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
                   3573: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
                   3574: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
                   3575: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
                   3576: MASTER_SORT_AWK or MASTER_SORT_REGEX.
1.1       dsieger  3577: 
1.184     rillig   3578: The specific command and arguments used depend on the FETCH_USING parameter.
                   3579: The example above is for FETCH_USING=custom.
1.66      asau     3580: 
1.184     rillig   3581: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
                   3582: target to mirror the distfiles, if they are freely distributable. Packages
1.266     martin   3583: setting NO_SRC_ON_FTP (usually to    ${RESTRICTED}   ) will not have their
1.184     rillig   3584: distfiles mirrored.
1.1       dsieger  3585: 
1.266     martin   3586: 13.6.  The checksum phase
1.1       dsieger  3587: 
1.184     rillig   3588: After the distfile(s) are fetched, their checksum is generated and compared
                   3589: with the checksums stored in the distinfo file. If the checksums don't match,
                   3590: the build is aborted. This is to ensure the same distfile is used for building,
                   3591: and that the distfile wasn't changed, e.g. by some malign force, deliberately
                   3592: changed distfiles on the master distribution site or network lossage.
1.1       dsieger  3593: 
1.266     martin   3594: 13.7.  The extract phase
1.1       dsieger  3595: 
1.184     rillig   3596: When the distfiles are present on the local system, they need to be extracted,
                   3597: as they usually come in the form of some compressed archive format.
1.1       dsieger  3598: 
1.184     rillig   3599: By default, all DISTFILES are extracted. If you only need some of them, you can
                   3600: set the EXTRACT_ONLY variable to the list of those files.
1.1       dsieger  3601: 
1.184     rillig   3602: Extracting the files is usually done by a little program, mk/extract/extract,
                   3603: which already knows how to extract various archive formats, so most likely you
                   3604: will not need to change anything here. But if you need, the following variables
                   3605: may help you:
1.1       dsieger  3606: 
1.184     rillig   3607: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
1.1       dsieger  3608: 
1.184     rillig   3609:     Use these variables to override the default options for an extract command,
                   3610:     which are defined in mk/extract/extract.
1.1       dsieger  3611: 
1.184     rillig   3612: EXTRACT_USING
1.1       dsieger  3613: 
1.184     rillig   3614:     This variable can be set to bsdtar, gtar, nbtar (which is the default
                   3615:     value), pax, or an absolute pathname pointing to the command with which tar
                   3616:     archives should be extracted. It is preferred to choose bsdtar over gtar if
                   3617:     NetBSD's pax-as-tar is not good enough.
1.1       dsieger  3618: 
1.184     rillig   3619: If the extract program doesn't serve your needs, you can also override the
                   3620: EXTRACT_CMD variable, which holds the command used for extracting the files.
                   3621: This command is executed in the ${WRKSRC} directory. During execution of this
                   3622: command, the shell variable extract_file holds the absolute pathname of the
                   3623: file that is going to be extracted.
1.1       dsieger  3624: 
1.184     rillig   3625: And if that still does not suffice, you can override the do-extract target in
                   3626: the package Makefile.
1.1       dsieger  3627: 
1.266     martin   3628: 13.8.  The patch phase
1.1       dsieger  3629: 
1.184     rillig   3630: After extraction, all the patches named by the PATCHFILES, those present in the
                   3631: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
                   3632: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
                   3633: are uncompressed before they are applied, files ending in .orig or .rej are
                   3634: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
1.266     martin   3635: Section  12.3,    patches/*    for more details.
1.1       dsieger  3636: 
1.184     rillig   3637: By default patch(1) is given special arguments to make it fail if the expected
                   3638: text from the patch context is not found in the patched file. If that happens,
                   3639: fix the patch file by comparing it with the actual text in the file to be
                   3640: patched.
1.1       dsieger  3641: 
1.266     martin   3642: 13.9.  The tools phase
1.1       dsieger  3643: 
1.266     martin   3644: This is covered in Chapter  17, Tools needed for building or running.
1.1       dsieger  3645: 
1.266     martin   3646: 13.10.  The wrapper phase
1.1       dsieger  3647: 
1.184     rillig   3648: This phase creates wrapper programs for the compilers and linkers. The
                   3649: following variables can be used to tweak the wrappers.
1.1       dsieger  3650: 
1.184     rillig   3651: ECHO_WRAPPER_MSG
1.1       dsieger  3652: 
1.184     rillig   3653:     The command used to print progress messages. Does nothing by default. Set
                   3654:     to ${ECHO} to see the progress messages.
1.1       dsieger  3655: 
1.184     rillig   3656: WRAPPER_DEBUG
1.1       dsieger  3657: 
1.184     rillig   3658:     This variable can be set to yes (default) or no, depending on whether you
                   3659:     want additional information in the wrapper log file.
1.1       dsieger  3660: 
1.184     rillig   3661: WRAPPER_UPDATE_CACHE
1.1       dsieger  3662: 
1.184     rillig   3663:     This variable can be set to yes or no, depending on whether the wrapper
                   3664:     should use its cache, which will improve the speed. The default value is
                   3665:     yes, but is forced to no if the platform does not support it.
1.1       dsieger  3666: 
1.184     rillig   3667: WRAPPER_REORDER_CMDS
1.1       dsieger  3668: 
1.184     rillig   3669:     A list of reordering commands. A reordering command has the form reorder:l:
                   3670:     lib1:lib2. It ensures that that -llib1 occurs before -llib2.
1.1       dsieger  3671: 
1.266     martin   3672: 13.11.  The configure phase
1.1       dsieger  3673: 
1.184     rillig   3674: Most pieces of software need information on the header files, system calls, and
                   3675: library routines which are available on the platform they run on. The process
                   3676: of determining this information is known as configuration, and is usually
                   3677: automated. In most cases, a script is supplied with the distfiles, and its
                   3678: invocation results in generation of header files, Makefiles, etc.
1.1       dsieger  3679: 
1.184     rillig   3680: If the package contains a configure script, this can be invoked by setting
1.266     martin   3681: HAS_CONFIGURE to    yes   . If the configure script is a GNU autoconf script, you
                   3682: should set GNU_CONFIGURE to    yes    instead.
1.1       dsieger  3683: 
1.187     rillig   3684: In the do-configure stage, a rough equivalent of the following command is run.
                   3685: See mk/configure/configure.mk, target do-configure-script for the exact
                   3686: definition.
                   3687: 
                   3688: .for dir in ${CONFIGURE_DIRS}
                   3689:         cd ${WRKSRC} && cd ${dir} \
                   3690:         && env ${CONFIGURE_ENV} \
                   3691:             ${CONFIG_SHELL} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
1.184     rillig   3692: .endfor
1.1       dsieger  3693: 
1.266     martin   3694: CONFIGURE_DIRS (default:    .   ) is a list of pathnames relative to WRKSRC. In
1.184     rillig   3695: each of these directories, the configure script is run with the environment
                   3696: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
1.266     martin   3697: CONFIGURE_SCRIPT (default:    ./configure   ) and CONFIGURE_ARGS may all be changed
1.184     rillig   3698: by the package.
1.1       dsieger  3699: 
1.184     rillig   3700: If the program uses the Perl way of configuration (mainly Perl modules, but not
                   3701: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
                   3702: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
                   3703: (e.g., MAKE_PARAMS+=foo=bar
1.1       dsieger  3704: 
1.184     rillig   3705: If the program uses an Imakefile for configuration, the appropriate steps can
1.266     martin   3706: be invoked by setting USE_IMAKE to    yes   . If you only need xmkmf, add it to
1.184     rillig   3707: USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
                   3708: SCRIPTS_ENV variable.
1.1       dsieger  3709: 
1.184     rillig   3710: If the program uses cmake for configuration, the appropriate steps can be
1.233     wiz      3711: invoked by including ../../devel/cmake/build.mk. You can add variables to
                   3712: cmake's environment by adding them to the CONFIGURE_ENV variable and arguments
1.256     wiz      3713: to cmake by adding them to the CMAKE_CONFIGURE_ARGS variable. If you want to
                   3714: add arguments only for particular stages, you can use the CMAKE_CONFIGURE_ARGS,
1.233     wiz      3715: CMAKE_BUILD_ARGS, and CMAKE_INSTALL_ARGS variables. You can set the
                   3716: CONFIGURE_DIRS variable to the directories in which CMake should be run,
1.266     martin   3717: relative to WRKSRC. This defaults to to    .   .
1.1       dsieger  3718: 
1.256     wiz      3719: Any package using the now-deprecated USE_CMAKE=yes should be converted.
                   3720: Essentially, replace with an include of ../../devel/cmake/build.mk, prune
                   3721: creation of a build directory and settings to use it, and check/fix settings
                   3722: that intend to perform the build in a subdirectory.
                   3723: 
1.266     martin   3724: If there is no configure step at all, set NO_CONFIGURE to    yes   .
1.1       dsieger  3725: 
1.266     martin   3726: 13.12.  The build phase
1.1       dsieger  3727: 
1.187     rillig   3728: For building a package, a rough equivalent of the following code is executed;
                   3729: see mk/build/build.mk, target do-build for the exact definition.
1.154     rillig   3730: 
1.187     rillig   3731: .for dir in ${BUILD_DIRS}
                   3732:         cd ${WRKSRC} && cd ${dir} \
1.184     rillig   3733:         && env ${MAKE_ENV} \
1.187     rillig   3734:             ${MAKE_PROGRAM} ${MAKE_FLAGS} ${BUILD_MAKE_FLAGS} \
1.184     rillig   3735:                 -f ${MAKE_FILE} \
                   3736:                 ${BUILD_TARGET}
                   3737: .endfor
1.1       dsieger  3738: 
1.266     martin   3739: BUILD_DIRS (default:    .   ) is a list of pathnames relative to WRKSRC. In each of
1.184     rillig   3740: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
                   3741: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
                   3742: and BUILD_TARGET may all be changed by the package.
1.1       dsieger  3743: 
1.266     martin   3744: The default value of MAKE_PROGRAM is    gmake    if USE_TOOLS contains    gmake   ,    
                   3745: make    otherwise. The default value of MAKE_FILE is    Makefile   , and BUILD_TARGET
                   3746: defaults to    all   .
1.1       dsieger  3747: 
1.266     martin   3748: If there is no build step at all, set NO_BUILD to    yes   .
1.1       dsieger  3749: 
1.266     martin   3750: 13.13.  The test phase
1.1       dsieger  3751: 
1.273   ! wiz      3752: The test phase is for running a program's self tests. Dependencies that are
        !          3753: only required for testing can be specified using TEST_DEPENDS.
        !          3754: 
        !          3755: For packages using make(1) for building, you can set TEST_TARGET. Often, the
        !          3756: proper value is    check    or    test   . If more elaborate steps are needed, you can
        !          3757: define a do-test target.
        !          3758: 
        !          3759: To run the tests, call    make test   .
        !          3760: 
        !          3761: When building a package, the tests are not run automatically, except if
        !          3762: PKGSRC_RUN_TEST is set to    yes   .
1.1       dsieger  3763: 
1.266     martin   3764: 13.14.  The install phase
1.1       dsieger  3765: 
1.184     rillig   3766: Once the build stage has completed, the final step is to install the software
                   3767: in public directories, so users can access the programs and files.
1.1       dsieger  3768: 
1.187     rillig   3769: In the install phase, a rough equivalent of the following code is executed; see
                   3770: mk/install/install.mk, target do-install for the exact definition.
                   3771: Additionally, before and after this code, several consistency checks are run
                   3772: against the files-to-be-installed, see mk/check/*.mk for details.
                   3773: 
                   3774: .for dir in ${INSTALL_DIRS}
                   3775:         cd ${WRKSRC} && cd ${dir} \
                   3776:         && env ${INSTALL_ENV} ${MAKE_ENV} \
                   3777:             ${MAKE_PROGRAM} ${MAKE_FLAGS} ${INSTALL_MAKE_FLAGS} \
                   3778:                 -f ${MAKE_FILE} ${INSTALL_TARGET}
1.184     rillig   3779: .endfor
1.1       dsieger  3780: 
1.184     rillig   3781: The variable's meanings are analogous to the ones in the build phase.
1.266     martin   3782: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is    install    by default,
                   3783: plus    install.man    if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
1.184     rillig   3784: defined.
1.1       dsieger  3785: 
1.184     rillig   3786: In the install phase, the following variables are useful. They are all
                   3787: variations of the install(1) command that have the owner, group and permissions
                   3788: preset. INSTALL is the plain install command. The specialized variants,
                   3789: together with their intended use, are:
1.1       dsieger  3790: 
1.184     rillig   3791: INSTALL_PROGRAM_DIR
1.1       dsieger  3792: 
1.184     rillig   3793:     directories that contain binaries
1.1       dsieger  3794: 
1.184     rillig   3795: INSTALL_SCRIPT_DIR
1.1       dsieger  3796: 
1.184     rillig   3797:     directories that contain scripts
1.1       dsieger  3798: 
1.184     rillig   3799: INSTALL_LIB_DIR
1.1       dsieger  3800: 
1.184     rillig   3801:     directories that contain shared and static libraries
1.1       dsieger  3802: 
1.184     rillig   3803: INSTALL_DATA_DIR
1.108     rillig   3804: 
1.184     rillig   3805:     directories that contain data files
1.108     rillig   3806: 
1.184     rillig   3807: INSTALL_MAN_DIR
1.108     rillig   3808: 
1.184     rillig   3809:     directories that contain man pages
1.108     rillig   3810: 
1.184     rillig   3811: INSTALL_GAME_DIR
1.108     rillig   3812: 
1.184     rillig   3813:     directories that contain data files for games
1.108     rillig   3814: 
1.184     rillig   3815: INSTALL_PROGRAM
1.108     rillig   3816: 
1.184     rillig   3817:     binaries that can be stripped from debugging symbols
1.108     rillig   3818: 
1.184     rillig   3819: INSTALL_SCRIPT
1.108     rillig   3820: 
1.184     rillig   3821:     binaries that cannot be stripped
1.108     rillig   3822: 
1.184     rillig   3823: INSTALL_GAME
1.108     rillig   3824: 
1.184     rillig   3825:     game binaries
1.108     rillig   3826: 
1.184     rillig   3827: INSTALL_LIB
1.108     rillig   3828: 
1.184     rillig   3829:     shared and static libraries
1.108     rillig   3830: 
1.184     rillig   3831: INSTALL_DATA
1.108     rillig   3832: 
1.184     rillig   3833:     data files
1.1       dsieger  3834: 
1.184     rillig   3835: INSTALL_GAME_DATA
1.1       dsieger  3836: 
1.184     rillig   3837:     data files for games
1.108     rillig   3838: 
1.184     rillig   3839: INSTALL_MAN
1.108     rillig   3840: 
1.184     rillig   3841:     man pages
1.1       dsieger  3842: 
1.184     rillig   3843: Some other variables are:
1.1       dsieger  3844: 
1.184     rillig   3845: INSTALL_UNSTRIPPED
1.1       dsieger  3846: 
1.184     rillig   3847:     If set to yes, do not run strip(1) when installing binaries. Any debugging
                   3848:     sections and symbols present in binaries will be preserved.
1.1       dsieger  3849: 
1.184     rillig   3850: INSTALLATION_DIRS
1.1       dsieger  3851: 
1.184     rillig   3852:     A list of directories relative to PREFIX that are created by pkgsrc at the
                   3853:     beginning of the install phase. The package is supposed to create all
                   3854:     needed directories itself before installing files to it and list all other
                   3855:     directories here.
1.1       dsieger  3856: 
1.184     rillig   3857: In the rare cases that a package shouldn't install anything, set NO_INSTALL to 
1.266     martin   3858:    yes   . This is mostly relevant for packages in the regress category.
1.1       dsieger  3859: 
1.266     martin   3860: 13.15.  The package phase
1.121     sevan    3861: 
1.184     rillig   3862: Once the install stage has completed, a binary package of the installed files
                   3863: can be built. These binary packages can be used for quick installation without
                   3864: previous compilation, e.g. by the make bin-install or by using pkg_add.
1.1       dsieger  3865: 
1.184     rillig   3866: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
                   3867: created in ${PACKAGES}/category, one for each category in the CATEGORIES
                   3868: variable. PACKAGES defaults to pkgsrc/packages.
1.1       dsieger  3869: 
1.266     martin   3870: 13.16.  Cleaning up
1.1       dsieger  3871: 
1.184     rillig   3872: Once you're finished with a package, you can clean the work directory by
                   3873: running make clean. If you want to clean the work directories of all
                   3874: dependencies too, use make clean-depends.
1.1       dsieger  3875: 
1.266     martin   3876: 13.17.  Other helpful targets
1.1       dsieger  3877: 
1.184     rillig   3878: pre/post-*
1.1       dsieger  3879: 
1.184     rillig   3880:     For any of the main targets described in the previous section (configure,
1.266     martin   3881:     build, install, etc.), two auxiliary targets exist with    pre-    and    post-   
1.184     rillig   3882:     used as a prefix for the main target's name. These targets are invoked
                   3883:     before and after the main target is called, allowing extra configuration or
                   3884:     installation steps be performed from a package's Makefile, for example,
                   3885:     which a program's configure script or install target omitted.
                   3886: 
                   3887:     About 5% of the pkgsrc packages define their custom post-extract target,
                   3888:     another 5% define pre-configure, and 10% define post-install. The other pre
                   3889:     /post-* targets are defined even less often.
1.1       dsieger  3890: 
1.184     rillig   3891: do-*
1.182     leot     3892: 
1.184     rillig   3893:     Should one of the main targets do the wrong thing, and should there be no
                   3894:     variable to fix this, you can redefine it with the do-* target. (Note that
                   3895:     redefining the target itself instead of the do-* target is a bad idea, as
                   3896:     the pre-* and post-* targets won't be called anymore, etc.)
1.1       dsieger  3897: 
1.184     rillig   3898:     About 15% of the pkgsrc packages override the default do-install, the other
                   3899:     do-* targets are overridden even less often.
1.1       dsieger  3900: 
1.184     rillig   3901: reinstall
1.1       dsieger  3902: 
1.184     rillig   3903:     If you did a make install and you noticed some file was not installed
                   3904:     properly, you can repeat the installation with this target, which will
1.266     martin   3905:     ignore the    already installed    flag.
1.1       dsieger  3906: 
1.184     rillig   3907:     This is the default value of DEPENDS_TARGET except in the case of make
1.266     martin   3908:     update and make package, where the defaults are    package    and    update   ,
1.184     rillig   3909:     respectively.
1.1       dsieger  3910: 
1.184     rillig   3911: deinstall
1.1       dsieger  3912: 
1.184     rillig   3913:     This target does a pkg_delete(1) in the current directory, effectively
                   3914:     de-installing the package. The following variables can be used to tune the
                   3915:     behaviour:
1.1       dsieger  3916: 
1.184     rillig   3917:     PKG_VERBOSE
1.1       dsieger  3918: 
1.184     rillig   3919:         Add a "-v" to the pkg_delete(1) command.
1.1       dsieger  3920: 
1.184     rillig   3921:     DEINSTALLDEPENDS
1.1       dsieger  3922: 
1.184     rillig   3923:         Remove all packages that require (depend on) the given package. This
                   3924:         can be used to remove any packages that may have been pulled in by a
                   3925:         given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
1.266     martin   3926:         pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding    -R
                   3927:             to the pkg_delete(1) command line.
1.1       dsieger  3928: 
1.184     rillig   3929: bin-install
1.1       dsieger  3930: 
1.184     rillig   3931:     Install a binary package from local disk and via FTP from a list of sites
                   3932:     (see the BINPKG_SITES variable), and do a make package if no binary package
                   3933:     is available anywhere. The arguments given to pkg_add can be set via
                   3934:     BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
1.1       dsieger  3935: 
1.184     rillig   3936: install-clean
1.1       dsieger  3937: 
1.184     rillig   3938:     This target removes the state files for the "install" and later phases so
                   3939:     that the "install" target may be re-invoked. This can be used after editing
                   3940:     the PLIST to install the package without rebuilding it.
1.1       dsieger  3941: 
1.184     rillig   3942: build-clean
1.18      mishka   3943: 
1.184     rillig   3944:     This target removes the state files for the "build" and later phases so
                   3945:     that the "build" target may be re-invoked.
1.18      mishka   3946: 
1.184     rillig   3947: update
1.18      mishka   3948: 
1.184     rillig   3949:     This target causes the current package to be updated to the latest version.
                   3950:     The package and all depending packages first get de-installed, then current
                   3951:     versions of the corresponding packages get compiled and installed. This is
                   3952:     similar to manually noting which packages are currently installed, then
                   3953:     performing a series of make deinstall and make install (or whatever
                   3954:     UPDATE_TARGET is set to) for these packages.
1.18      mishka   3955: 
1.266     martin   3956:     You can use the    update    target to resume package updating in case a
1.184     rillig   3957:     previous make update was interrupted for some reason. However, in this
                   3958:     case, make sure you don't call make clean or otherwise remove the list of
                   3959:     dependent packages in WRKDIR. Otherwise, you lose the ability to
                   3960:     automatically update the current package along with the dependent packages
                   3961:     you have installed.
1.121     sevan    3962: 
1.184     rillig   3963:     Resuming an interrupted make update will only work as long as the package
                   3964:     tree remains unchanged. If the source code for one of the packages to be
                   3965:     updated has been changed, resuming make update will most certainly fail!
1.1       dsieger  3966: 
1.184     rillig   3967:     The following variables can be used either on the command line or in
                   3968:     mk.conf to alter the behaviour of make update:
1.1       dsieger  3969: 
1.184     rillig   3970:     UPDATE_TARGET
1.1       dsieger  3971: 
1.184     rillig   3972:         Install target to recursively use for the updated package and the
1.266     martin   3973:         dependent packages. Defaults to DEPENDS_TARGET if set,    install   
                   3974:         otherwise for make update. Other good targets are    package    or    
                   3975:         bin-install   . Do not set this to    update    or you will get stuck in an
1.184     rillig   3976:         endless loop!
1.1       dsieger  3977: 
1.184     rillig   3978:     NOCLEAN
1.1       dsieger  3979: 
1.184     rillig   3980:         Don't clean up after updating. Useful if you want to leave the work
                   3981:         sources of the updated packages around for inspection or other
1.266     martin   3982:         purposes. Be sure you eventually clean up the source tree (see the    
                   3983:         clean-update    target below) or you may run into troubles with old
1.184     rillig   3984:         source code still lying around on your next make or make update.
1.1       dsieger  3985: 
1.184     rillig   3986:     REINSTALL
1.1       dsieger  3987: 
1.184     rillig   3988:         Deinstall each package before installing (making DEPENDS_TARGET). This
1.266     martin   3989:         may be necessary if the    clean-update    target (see below) was called
1.184     rillig   3990:         after interrupting a running make update.
1.1       dsieger  3991: 
1.184     rillig   3992:     DEPENDS_TARGET
1.1       dsieger  3993: 
1.184     rillig   3994:         Allows you to disable recursion and hardcode the target for packages.
1.266     martin   3995:         The default is    update    for the update target, facilitating a recursive
1.184     rillig   3996:         update of prerequisite packages. Only set DEPENDS_TARGET if you want to
                   3997:         disable recursive updates. Use UPDATE_TARGET instead to just set a
                   3998:         specific target for each package to be installed during make update
                   3999:         (see above).
1.1       dsieger  4000: 
1.184     rillig   4001: clean-update
1.1       dsieger  4002: 
1.184     rillig   4003:     Clean the source tree for all packages that would get updated if make
                   4004:     update was called from the current directory. This target should not be
                   4005:     used if the current package (or any of its depending packages) have already
                   4006:     been de-installed (e.g., after calling make update) or you may lose some
                   4007:     packages you intended to update. As a rule of thumb: only use this target 
                   4008:     before the first time you run make update and only if you have a dirty
                   4009:     package tree (e.g., if you used NOCLEAN).
1.86      wiz      4010: 
1.184     rillig   4011:     If you are unsure about whether your tree is clean, you can either perform
                   4012:     a make clean at the top of the tree, or use the following sequence of
                   4013:     commands from the directory of the package you want to update (before
                   4014:     running make update for the first time, otherwise you lose all the packages
                   4015:     you wanted to update!):
1.86      wiz      4016: 
1.184     rillig   4017:     # make clean-update
                   4018:     # make clean CLEANDEPENDS=YES
                   4019:     # make update
1.86      wiz      4020: 
                   4021: 
1.184     rillig   4022:     The following variables can be used either on the command line or in
                   4023:     mk.conf to alter the behaviour of make clean-update:
1.86      wiz      4024: 
1.184     rillig   4025:     CLEAR_DIRLIST
1.86      wiz      4026: 
1.184     rillig   4027:         After make clean, do not reconstruct the list of directories to update
                   4028:         for this package. Only use this if make update successfully installed
                   4029:         all packages you wanted to update. Normally, this is done automatically
                   4030:         on make update, but may have been suppressed by the NOCLEAN variable
                   4031:         (see above).
1.1       dsieger  4032: 
1.184     rillig   4033: replace
1.1       dsieger  4034: 
1.184     rillig   4035:     Update the installation of the current package. This differs from update in
                   4036:     that it does not replace dependent packages. You will need to install
                   4037:     pkgtools/pkg_tarup for this target to work.
1.1       dsieger  4038: 
1.184     rillig   4039:     Be careful when using this target! There are no guarantees that dependent
                   4040:     packages will still work, in particular they will most certainly break if
                   4041:     you make replace a library package whose shared library major version
                   4042:     changed between your installed version and the new one. For this reason,
                   4043:     this target is not officially supported and only recommended for advanced
                   4044:     users.
1.1       dsieger  4045: 
1.184     rillig   4046: info
1.1       dsieger  4047: 
1.184     rillig   4048:     This target invokes pkg_info(1) for the current package. You can use this
                   4049:     to check which version of a package is installed.
1.86      wiz      4050: 
1.184     rillig   4051: index
1.1       dsieger  4052: 
1.184     rillig   4053:     This is a top-level command, i.e. it should be used in the pkgsrc
                   4054:     directory. It creates a database of all packages in the local pkgsrc tree,
                   4055:     including dependencies, comment, maintainer, and some other useful
                   4056:     information. Individual entries are created by running make describe in the
                   4057:     packages' directories. This index file is saved as pkgsrc/INDEX. It can be
                   4058:     displayed in verbose format by running make print-index. You can search in
                   4059:     it with make search key=something. You can extract a list of all packages
                   4060:     that depend on a particular one by running make show-deps PKG=somepackage.
1.1       dsieger  4061: 
1.184     rillig   4062:     Running this command takes a very long time, some hours even on fast
                   4063:     machines!
1.1       dsieger  4064: 
1.184     rillig   4065: readme
1.1       dsieger  4066: 
1.199     nia      4067:     This target generates a index.html file, which can be viewed using a
1.184     rillig   4068:     browser such as www/firefox or www/links. The generated files contain
                   4069:     references to any packages which are in the PACKAGES directory on the local
                   4070:     host. The generated files can be made to refer to URLs based on
                   4071:     FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
1.199     nia      4072:     index.html files which pointed to binary packages on the local machine, in
1.184     rillig   4073:     the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
                   4074:     FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
                   4075:     subdirectories will be searched for all the binary packages.
1.1       dsieger  4076: 
1.184     rillig   4077:     The target can be run at the toplevel or in category directories, in which
                   4078:     case it descends recursively.
1.1       dsieger  4079: 
1.184     rillig   4080: readme-all
1.1       dsieger  4081: 
1.184     rillig   4082:     This is a top-level command, run it in pkgsrc. Use this target to create a
                   4083:     file README-all.html which contains a list of all packages currently
                   4084:     available in the NetBSD Packages Collection, together with the category
                   4085:     they belong to and a short description. This file is compiled from the
1.199     nia      4086:     pkgsrc/*/index.html files, so be sure to run this after a make readme.
1.1       dsieger  4087: 
1.184     rillig   4088: cdrom-readme
1.1       dsieger  4089: 
1.266     martin   4090:     This is very much the same as the    readme    target (see above), but is to be
1.184     rillig   4091:     used when generating a pkgsrc tree to be written to a CD-ROM. This target
1.199     nia      4092:     also produces index.html files, and can be made to refer to URLs based on
1.184     rillig   4093:     CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
1.1       dsieger  4094: 
1.184     rillig   4095: show-distfiles
1.1       dsieger  4096: 
1.184     rillig   4097:     This target shows which distfiles and patchfiles are needed to build the
                   4098:     package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
                   4099:     patches/*).
1.1       dsieger  4100: 
1.184     rillig   4101: show-downlevel
1.1       dsieger  4102: 
1.184     rillig   4103:     This target shows nothing if the package is not installed. If a version of
                   4104:     this package is installed, but is not the version provided in this version
                   4105:     of pkgsrc, then a warning message is displayed. This target can be used to
                   4106:     show which of your installed packages are downlevel, and so the old
                   4107:     versions can be deleted, and the current ones added.
1.1       dsieger  4108: 
1.184     rillig   4109: show-pkgsrc-dir
1.1       dsieger  4110: 
1.184     rillig   4111:     This target shows the directory in the pkgsrc hierarchy from which the
                   4112:     package can be built and installed. This may not be the same directory as
                   4113:     the one from which the package was installed. This target is intended to be
                   4114:     used by people who may wish to upgrade many packages on a single host, and
1.266     martin   4115:     can be invoked from the top-level pkgsrc Makefile by using the    
                   4116:     show-host-specific-pkgs    target.
1.1       dsieger  4117: 
1.184     rillig   4118: show-installed-depends
1.1       dsieger  4119: 
1.184     rillig   4120:     This target shows which installed packages match the current package's
                   4121:     DEPENDS. Useful if out of date dependencies are causing build problems.
1.1       dsieger  4122: 
1.184     rillig   4123: print-build-depends-list
1.1       dsieger  4124: 
1.184     rillig   4125:     This target shows the list of packages that the current package depends on
                   4126:     for building.
1.1       dsieger  4127: 
1.184     rillig   4128: print-run-depends-list
1.1       dsieger  4129: 
1.184     rillig   4130:     This target shows the list of packages that the current package depends on
                   4131:     for running.
1.1       dsieger  4132: 
1.184     rillig   4133: check-shlibs
1.1       dsieger  4134: 
1.184     rillig   4135:     After a package is installed, check all its binaries and (on ELF platforms)
                   4136:     shared libraries to see if they find the shared libs they need. Run by
                   4137:     default if PKG_DEVELOPER is set in mk.conf.
1.1       dsieger  4138: 
1.184     rillig   4139: print-PLIST
1.1       dsieger  4140: 
1.266     martin   4141:     After a    make install    from a new or upgraded pkg, this prints out an
1.184     rillig   4142:     attempt to generate a new PLIST from a find -newer work/.extract_done. An
                   4143:     attempt is made to care for shared libs etc., but it is strongly
                   4144:     recommended to review the result before putting it into PLIST. On upgrades,
                   4145:     it's useful to diff the output of this command against an already existing
                   4146:     PLIST file.
1.1       dsieger  4147: 
1.184     rillig   4148:     If the package installs files via tar(1) or other methods that don't update
                   4149:     file access times, be sure to add these files manually to your PLIST, as
1.266     martin   4150:     the    find -newer    command used by this target won't catch them!
1.56      ryoon    4151: 
1.266     martin   4152:     See Section  19.3,    Tweaking output of make print-PLIST    for more
1.184     rillig   4153:     information on this target.
1.1       dsieger  4154: 
1.255     wiz      4155: rebuild
                   4156: 
                   4157:     If you did a make build and you noticed some further modifications of
                   4158:     sources are needed, you can repeat the build with this target, which will
1.266     martin   4159:     ignore the    already built    flag. This target is helpful while working with
1.255     wiz      4160:     patches.
                   4161: 
                   4162: repackage
                   4163: 
                   4164:     If you did a make package and you noticed some further modifications of
                   4165:     sources are needed, you can repeat the package with this target, which will
1.266     martin   4166:     ignore the    already packaged    flag. This target is helpful while working
1.255     wiz      4167:     with patches, PLIST* files etc.
                   4168: 
                   4169: retest
                   4170: 
                   4171:     If you did a make test and you noticed some further modifications of
                   4172:     sources are needed, you can repeat the test with this target, which will
1.266     martin   4173:     ignore the    already tested    flag. This target is helpful while working with
1.255     wiz      4174:     patches.
                   4175: 
1.266     martin   4176: Chapter  14.  Creating a new pkgsrc package from scratch
1.1       dsieger  4177: 
1.184     rillig   4178: Table of Contents
1.1       dsieger  4179: 
1.184     rillig   4180: 14.1. Common types of packages
1.219     nia      4181:     14.1.1. Python modules and programs
                   4182:     14.1.2. R packages
                   4183:     14.1.3. TeXlive packages
1.184     rillig   4184: 14.2. Examples
                   4185:     14.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  4186: 
1.184     rillig   4187: When you find a package that is not yet in pkgsrc, you most likely have a URL
                   4188: from where you can download the source code. Starting with this URL, creating a
                   4189: package involves only a few steps.
1.1       dsieger  4190: 
1.184     rillig   4191:  1. In your mk.conf, set PKG_DEVELOPER=yes to enable the basic quality checks.
1.1       dsieger  4192: 
1.184     rillig   4193:  2. Install the package meta-pkgs/pkg_developer, which among others will
                   4194:     install the utilities url2pkg, pkglint, pkgvi and mkpatches:
1.1       dsieger  4195: 
1.184     rillig   4196:     $ cd /usr/pkgsrc
                   4197:     $ (cd meta-pkgs/pkg_developer && bmake update)
1.1       dsieger  4198: 
1.184     rillig   4199:  3. Choose one of the top-level directories as the category in which you want
                   4200:     to place your package. You can also create a directory of your own (maybe
1.219     nia      4201:     called local). Change into that category directory:
1.1       dsieger  4202: 
1.219     nia      4203:     $ cd category
1.1       dsieger  4204: 
1.219     nia      4205:  4. Run the program url2pkg, passing as argument the URL of the distribution
                   4206:     file (in most cases a .tar.gz file). This will download the distribution
                   4207:     file and create the necessary files of the package, based on what's in the
                   4208:     distribution file:
1.1       dsieger  4209: 
1.184     rillig   4210:     $ url2pkg https://www.example.org/packages/package-1.0.tar.gz
1.1       dsieger  4211: 
1.184     rillig   4212:  5. Examine the extracted files to determine the dependencies of your package.
                   4213:     Ideally, this is mentioned in some README file, but things may differ. For
                   4214:     each of these dependencies, look where it exists in pkgsrc, and if there is
                   4215:     a file called buildlink3.mk in that directory, add a line to your package
                   4216:     Makefile which includes that file just before the last line. If the
                   4217:     buildlink3.mk file does not exist, it must be created first. The
                   4218:     buildlink3.mk file makes sure that the package's include files and
                   4219:     libraries are provided.
1.1       dsieger  4220: 
1.219     nia      4221:     If you just need binaries from a dependent package, add a DEPENDS line to
                   4222:     the Makefile, which specifies the version of the dependency and where it
                   4223:     can be found in pkgsrc. This line should be placed in the third paragraph.
                   4224:     If the dependency is only needed for building the package, but not when
                   4225:     using it, use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The
                   4226:     difference between TOOL_DEPENDS and BUILD_DEPENDS occurs when
                   4227:     cross-compiling: TOOL_DEPENDS are native packages, i.e. packages for the
                   4228:     platform where the package is built; BUILD_DEPENDS are target packages,
                   4229:     i.e. packages for the platform for which the package is built. There is
                   4230:     also TEST_DEPENDS, which specifies a dependency used only for testing the
                   4231:     resulting package built, using the upstream project's included test suite,
                   4232:     on the native platform. Your package may then look like this:
1.1       dsieger  4233: 
1.184     rillig   4234:     [...]
1.1       dsieger  4235: 
1.184     rillig   4236:     TOOL_DEPENDS+=  libxslt-[0-9]*:../../textproc/libxslt
                   4237:     DEPENDS+=       screen-[0-9]*:../../misc/screen
                   4238:     DEPENDS+=       screen>=4.0:../../misc/screen
1.1       dsieger  4239: 
1.184     rillig   4240:     [...]
1.1       dsieger  4241: 
1.184     rillig   4242:     .include "../../category/package/buildlink3.mk"
                   4243:     .include "../../devel/glib2/buildlink3.mk"
                   4244:     .include "../../mk/bsd.pkg.mk"
1.1       dsieger  4245: 
1.184     rillig   4246:  6. Run pkglint to see what things still need to be done to make your package a
1.266     martin   4247:        good    one. If you don't know what pkglint's warnings want to tell you, try
1.184     rillig   4248:     pkglint --explain or pkglint -e, which outputs additional explanations.
1.1       dsieger  4249: 
1.184     rillig   4250:  7. In many cases the package is not yet ready to build. You can find
1.266     martin   4251:     instructions for the most common cases in the next section, Section  14.1,
                   4252:        Common types of packages   . After you have followed the instructions over
1.184     rillig   4253:     there, you can hopefully continue here.
1.1       dsieger  4254: 
1.184     rillig   4255:  8. Run bmake clean to clean the working directory from the extracted files.
1.219     nia      4256:     Besides these files, a lot of cache files and other system information have
                   4257:     been saved in the working directory, which may have become outdated after
                   4258:     you edited the Makefile.
1.1       dsieger  4259: 
1.184     rillig   4260:  9. Now, run bmake to build the package. For the various things that can go
1.266     martin   4261:     wrong in this phase, consult Chapter  21, Making your package work.
1.1       dsieger  4262: 
1.184     rillig   4263:     If the extracted files from the package need to be fixed, run multiple
                   4264:     rounds of these commands:
1.1       dsieger  4265: 
1.219     nia      4266:     $ bmake
1.184     rillig   4267:     $ pkgvi ${WRKSRC}/some/file/that/does/not/compile
                   4268:     $ mkpatches
1.219     nia      4269:     $ bmake mps
                   4270:     $ bmake clean
1.1       dsieger  4271: 
1.184     rillig   4272: 10. When the package builds fine, the next step is to install the package. Run 
                   4273:     bmake install and hope that everything works.
1.1       dsieger  4274: 
1.184     rillig   4275: 11. Up to now, the file PLIST, which contains a list of the files that are
                   4276:     installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
                   4277:     generate a probably correct list. Check the file using your preferred text
                   4278:     editor to see if the list of files looks plausible.
1.1       dsieger  4279: 
1.184     rillig   4280: 12. Run pkglint again to see if the generated PLIST contains garbage or not.
1.1       dsieger  4281: 
1.184     rillig   4282: 13. When you ran bmake install, the package had been registered in the database
                   4283:     of installed files, but with an empty list of files. To fix this, run bmake
                   4284:     deinstall and bmake install again. Now the package is registered with the
                   4285:     list of files from PLIST.
1.48      wiz      4286: 
1.219     nia      4287: 14. Run bmake clean update to run everything from above again in a single step,
1.184     rillig   4288:     making sure that the PLIST is correct and the whole package is created as
                   4289:     intended.
1.48      wiz      4290: 
1.219     nia      4291: 15. Run pkglint to see if there's anything left to do.
1.48      wiz      4292: 
1.266     martin   4293: 16. Commit the package to pkgsrc-wip or main pkgsrc; see Chapter  23, Submitting
1.184     rillig   4294:     and Committing.
1.50      wiz      4295: 
1.266     martin   4296: 14.1.  Common types of packages
1.1       dsieger  4297: 
1.266     martin   4298: 14.1.1.  Python modules and programs
1.1       dsieger  4299: 
1.184     rillig   4300: Python modules and programs packages are easily created using a set of
                   4301: predefined variables.
1.1       dsieger  4302: 
1.184     rillig   4303: If some Python versions are not supported by the software, set the
                   4304: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
                   4305: supported, e.g.
1.1       dsieger  4306: 
1.184     rillig   4307: PYTHON_VERSIONS_INCOMPATIBLE=       27
1.1       dsieger  4308: 
1.249     gutterid 4309: If the packaged software is a Python module, include ../../lang/python/
1.258     wiz      4310: wheel.mk. Note per PEP-518, the minimum and default requirement to create .whl
                   4311: files is devel/py-setuptools; however, there are various other possible tools
                   4312: that projects can use. Thus inclusion of wheel.mk does not imply these defaults
                   4313: are defined as TOOL_DEPENDS. Whatever the project specifically requires as
                   4314: packaging tools must be defined in the package Makefile.
1.1       dsieger  4315: 
1.266     martin   4316: The package directory should be called    py-software    and PKGNAME should be set
                   4317: to    ${PYPKGPREFIX}-${DISTNAME}   , e.g.
1.1       dsieger  4318: 
1.184     rillig   4319: DISTNAME=   foopymodule-1.2.10
                   4320: PKGNAME=    ${PYPKGPREFIX}-${DISTNAME}
1.1       dsieger  4321: 
1.226     gutterid 4322: For software in PyPi, the name should match what PyPi specifies for "pip
                   4323: install software".
                   4324: 
1.266     martin   4325: If it is an application, include    ../../lang/python/application.mk   . In order
1.184     rillig   4326: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
                   4327: variable and set it to the list of files (paths relative to WRKSRC) that must
                   4328: be corrected. For example:
1.1       dsieger  4329: 
1.184     rillig   4330: REPLACE_PYTHON=   *.py
1.1       dsieger  4331: 
1.266     martin   4332: 14.1.2.  R packages
1.1       dsieger  4333: 
1.184     rillig   4334: Simple R packages from CRAN are handled automatically by R2pkg, which is
                   4335: available in pkgtools/R2pkg. Individual packages (and optionally their
                   4336: dependencies) may be created and updated. R packages generally follow the same
                   4337: form, and most of the relevant information needed is contained in a DESCRIPTION
                   4338: file as part of each R package on CRAN. Consequently, R2pkg downloads that
                   4339: information and creates or updates a package in the canonical form. The
                   4340: resulting package should be reviewed for correctness.
1.1       dsieger  4341: 
1.266     martin   4342: 14.1.3.  TeXlive packages
1.1       dsieger  4343: 
1.184     rillig   4344: TeXlive packages from CTAN are handled automatically by texlive2pkg, which is
                   4345: available in pkgtools/texlive2pkg.
1.1       dsieger  4346: 
1.266     martin   4347: If the TeXlive package name is not known, it may be useful to search CTAN. A    
                   4348: Contained in    field on the package page typically identifies the basename of
1.184     rillig   4349: the package file in the TeXlive archive.
1.1       dsieger  4350: 
1.184     rillig   4351: If the TeXlive package name is known, download the files from the TeXlive
                   4352: archive. For package foo, you will need to download foo.tar.xz. Most TeXlive
                   4353: packages also have associated documentation packages, so download
                   4354: foo.doc.tar.xz at the same time. These files should be placed in the
                   4355: appropriate category directory, which is often but not always print. Then run
                   4356: the following command in the category directory.
1.1       dsieger  4357: 
1.184     rillig   4358: texlive2pkg foo.tar.xz foo.doc.tar.xz
1.1       dsieger  4359: 
1.184     rillig   4360: This will create two packages, tex-foo and tex-foo-doc. Be sure to check that
                   4361: both packages are correct.
1.1       dsieger  4362: 
1.184     rillig   4363: Finally, CTAN currently does not include version information in package
                   4364: filenames and changes their contents periodically when updates occur.
                   4365: Consequently, pkgsrc avoids downloading distfiles directly from CTAN and
                   4366: instead relies on the pkgsrc archives. For each new or updated TeXlive package,
                   4367: e.g., the main one and the corresponding documentation, upload the distfiles
                   4368: with the following command in each package directory.
1.1       dsieger  4369: 
1.184     rillig   4370: make upload-distfiles
1.117     sevan    4371: 
1.266     martin   4372: 14.2.  Examples
1.117     sevan    4373: 
1.266     martin   4374: 14.2.1.  How the www/nvu package came into pkgsrc
1.1       dsieger  4375: 
1.266     martin   4376: 14.2.1.1.  The initial package
1.1       dsieger  4377: 
1.266     martin   4378: Looking at the file pkgsrc/doc/TODO, I saw that the    nvu    package has not yet
1.184     rillig   4379: been imported into pkgsrc. As the description says it has to do with the web,
1.266     martin   4380: the obvious choice for the category is    www   .
1.1       dsieger  4381: 
1.184     rillig   4382: $ mkdir www/nvu
                   4383: $ cd www/nvu
1.1       dsieger  4384: 
1.184     rillig   4385: The web site says that the sources are available as a tar file, so I fed that
                   4386: URL to the url2pkg program:
1.1       dsieger  4387: 
1.184     rillig   4388: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
1.1       dsieger  4389: 
1.184     rillig   4390: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
1.266     martin   4391: package name should not have the word    sources    in it. I also filled in the
1.184     rillig   4392: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
                   4393: that:
1.1       dsieger  4394: 
1.184     rillig   4395: # $NetBSD $
                   4396: #
1.1       dsieger  4397: 
1.184     rillig   4398: DISTNAME=       nvu-1.0-sources
                   4399: PKGNAME=        nvu-1.0
                   4400: CATEGORIES=     www
                   4401: MASTER_SITES=   http://cvs.nvu.com/download/
                   4402: EXTRACT_SUFX=   .tar.bz2
1.1       dsieger  4403: 
1.184     rillig   4404: MAINTAINER=     rillig@NetBSD.org
                   4405: HOMEPAGE=       http://cvs.nvu.com/
                   4406: COMMENT=        Web Authoring System
1.1       dsieger  4407: 
1.184     rillig   4408: # url2pkg-marker (please do not remove this line.)
                   4409: .include "../../mk/bsd.pkg.mk"
1.1       dsieger  4410: 
1.184     rillig   4411: On the first line of output above, an artificial space has been added between
                   4412: NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
                   4413: the guide.
1.1       dsieger  4414: 
1.184     rillig   4415: Then, I quit the editor and watched pkgsrc downloading a large source archive:
1.1       dsieger  4416: 
1.184     rillig   4417: url2pkg> Running "make makesum" ...
                   4418: => Required installed package digest>=20010302: digest-20060826 found
                   4419: => Fetching nvu-1.0-sources.tar.bz2
                   4420: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
                   4421: 100% |*************************************| 28992 KB  150.77 KB/s00:00 ETA
                   4422: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
                   4423: url2pkg> Running "make extract" ...
                   4424: => Required installed package digest>=20010302: digest-20060826 found
                   4425: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   4426: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   4427: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
                   4428: ===> Installing dependencies for nvu-1.0
                   4429: ===> Overriding tools for nvu-1.0
                   4430: ===> Extracting for nvu-1.0
                   4431: url2pkg> Adjusting the Makefile.
1.1       dsieger  4432: 
1.184     rillig   4433: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
1.1       dsieger  4434: 
1.184     rillig   4435: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
1.1       dsieger  4436: 
1.266     martin   4437: 14.2.1.2.  Fixing all kinds of problems to make the package work
1.1       dsieger  4438: 
1.184     rillig   4439: Now that the package has been extracted, let's see what's inside it. The
                   4440: package has a README.txt, but that only says something about mozilla, so it's
                   4441: probably useless for seeing what dependencies this package has. But since there
                   4442: is a GNU configure script in the package, let's hope that it will complain
                   4443: about everything it needs.
1.1       dsieger  4444: 
1.184     rillig   4445: $ bmake
                   4446: => Required installed package digest>=20010302: digest-20060826 found
                   4447: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   4448: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   4449: ===> Patching for nvu-1.0
                   4450: ===> Creating toolchain wrappers for nvu-1.0
                   4451: ===> Configuring for nvu-1.0
                   4452: [...]
                   4453: configure: error: Perl 5.004 or higher is required.
                   4454: [...]
                   4455: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
                   4456: [...]
1.1       dsieger  4457: 
1.184     rillig   4458: That worked quite well. So I opened the package Makefile in my editor, and
1.266     martin   4459: since it already has a USE_TOOLS line, I just appended    perl    to it. Since the
1.184     rillig   4460: dependencies of the package have changed now, and since a perl wrapper is
1.266     martin   4461: automatically installed in the    tools    phase, I need to build the package from
1.184     rillig   4462: scratch.
1.1       dsieger  4463: 
1.184     rillig   4464: $ bmake clean
                   4465: ===> Cleaning for nvu-1.0
                   4466: $ bmake
                   4467: [...]
                   4468: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
                   4469: GNU Make.  You will not be able to build Mozilla without GNU Make.
                   4470: [...]
1.1       dsieger  4471: 
1.266     martin   4472: So I added    gmake    to the USE_TOOLS line and tried again (from scratch).
1.1       dsieger  4473: 
1.184     rillig   4474: [...]
                   4475: checking for GTK - version >= 1.2.0... no
                   4476: *** Could not run GTK test program, checking why...
                   4477: [...]
1.1       dsieger  4478: 
1.184     rillig   4479: Now to the other dependencies. The first question is: Where is the GTK package
                   4480: hidden in pkgsrc?
1.1       dsieger  4481: 
1.184     rillig   4482: $ echo ../../*/gtk*
                   4483: [many packages ...]
                   4484: $ echo ../../*/gtk
                   4485: ../../x11/gtk
                   4486: $ echo ../../*/gtk2
                   4487: ../../x11/gtk2
                   4488: $ echo ../../*/gtk2/bui*
                   4489: ../../x11/gtk2/buildlink3.mk
1.1       dsieger  4490: 
1.184     rillig   4491: The first try was definitely too broad. The second one had exactly one result,
                   4492: which is very good. But there is one pitfall with GNOME packages. Before GNOME
                   4493: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
                   4494: able to continue to use these packages, the GNOME 2 packages were imported as
1.266     martin   4495: separate packages, and their names usually have a    2    appended. So I checked
1.184     rillig   4496: whether this was the case here, and indeed it was.
1.1       dsieger  4497: 
1.184     rillig   4498: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
                   4499: easy. I just inserted an .include line before the last line of the package
                   4500: Makefile, so that it now looks like this:
1.1       dsieger  4501: 
1.184     rillig   4502: [...]
                   4503: .include "../../x11/gtk2/buildlink3.mk"
                   4504: .include "../../mk/bsd.pkg.mk
1.1       dsieger  4505: 
1.184     rillig   4506: After another bmake clean && bmake, the answer was:
1.108     rillig   4507: 
1.184     rillig   4508: [...]
                   4509: checking for gtk-config... /home/roland/pkg/bin/gtk-config
                   4510: checking for GTK - version >= 1.2.0... no
                   4511: *** Could not run GTK test program, checking why...
                   4512: *** The test program failed to compile or link. See the file config.log for the
                   4513: *** exact error that occured. This usually means GTK was incorrectly installed
                   4514: *** or that you have moved GTK since it was installed. In the latter case, you
                   4515: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
                   4516: configure: error: Test for GTK failed.
                   4517: [...]
1.1       dsieger  4518: 
1.266     martin   4519: In this particular case, the assumption that    every package prefers GNOME 2   
1.184     rillig   4520: had been wrong. The first of the lines above told me that this package really
                   4521: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
                   4522: it would have looked for pkg-config instead of gtk-config. So I changed the x11
                   4523: /gtk2 to x11/gtk in the package Makefile, and tried again.
1.1       dsieger  4524: 
1.184     rillig   4525: [...]
                   4526: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\"  [...]
                   4527: In file included from xpidl.c:42:
                   4528: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
                   4529: In file included from xpidl.c:42:
                   4530: xpidl.h:132: error: parse error before "IDL_ns"
                   4531: [...]
1.1       dsieger  4532: 
1.184     rillig   4533: The package still does not find all of its dependencies. Now the question is:
                   4534: Which package provides the libIDL/IDL.h header file?
1.1       dsieger  4535: 
1.184     rillig   4536: $ echo ../../*/*idl*
                   4537: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
                   4538: $ echo ../../*/*IDL*
                   4539: ../../net/libIDL
1.1       dsieger  4540: 
1.184     rillig   4541: Let's take the one from the second try. So I included the ../../net/libIDL/
                   4542: buildlink3.mk file and tried again. But the error didn't change. After digging
                   4543: through some of the code, I concluded that the build process of the package was
                   4544: broken and couldn't have ever worked, but since the Mozilla source tree is
                   4545: quite large, I didn't want to fix it. So I added the following to the package
                   4546: Makefile and tried again:
1.1       dsieger  4547: 
1.184     rillig   4548: CPPFLAGS+=              -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
                   4549: BUILDLINK_TRANSFORM+=   l:IDL:IDL-2
1.1       dsieger  4550: 
1.184     rillig   4551: The latter line is needed because the package expects the library libIDL.so,
                   4552: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
                   4553: that on the fly.
1.1       dsieger  4554: 
1.184     rillig   4555: The next problem was related to a recent change of the FreeType interface. I
                   4556: looked up in www/seamonkey which patch files were relevant for this issue and
                   4557: copied them to the patches directory. Then I retried, fixed the patches so that
                   4558: they applied cleanly and retried again. This time, everything worked.
1.1       dsieger  4559: 
1.266     martin   4560: 14.2.1.3.  Installing the package
1.1       dsieger  4561: 
1.184     rillig   4562: $ bmake CHECK_FILES=no install
                   4563: [...]
                   4564: $ bmake print-PLIST >PLIST
                   4565: $ bmake deinstall
                   4566: $ bmake install
1.1       dsieger  4567: 
1.266     martin   4568: Chapter  15.  Programming in Makefiles
1.1       dsieger  4569: 
1.184     rillig   4570: Table of Contents
1.1       dsieger  4571: 
1.184     rillig   4572: 15.1. Caveats
                   4573: 15.2. Makefile variables
                   4574:     15.2.1. Naming conventions
                   4575: 15.3. Code snippets
                   4576:     15.3.1. Adding things to a list
                   4577:     15.3.2. Echoing a string exactly as-is
                   4578:     15.3.3. Passing CFLAGS to GNU configure scripts
                   4579:     15.3.4. Handling possibly empty variables
1.229     gutterid 4580:     15.3.5. Testing yes/no variables in conditions
1.1       dsieger  4581: 
1.184     rillig   4582: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
                   4583: part of the pkgsrc system. Using the make(1) system as a programming language
                   4584: for a big system like pkgsrc requires some discipline to keep the code correct
                   4585: and understandable.
1.1       dsieger  4586: 
1.184     rillig   4587: The basic ingredients for Makefile programming are variables and shell
                   4588: commands. Among these shell commands may even be more complex ones like awk(1)
                   4589: programs. To make sure that every shell command runs as intended it is
                   4590: necessary to quote all variables correctly when they are used.
1.1       dsieger  4591: 
1.184     rillig   4592: This chapter describes some patterns that appear quite often in Makefiles,
                   4593: including the pitfalls that come along with them.
1.1       dsieger  4594: 
1.266     martin   4595: 15.1.  Caveats
1.1       dsieger  4596: 
1.184     rillig   4597:   * When you are creating a file as a target of a rule, always write the data
                   4598:     to a temporary file first and finally rename that file. Otherwise there
                   4599:     might occur an error in the middle of generating the file, and when the
                   4600:     user runs make(1) for the second time, the file exists and will not be
                   4601:     regenerated properly. Example:
1.1       dsieger  4602: 
1.184     rillig   4603:     wrong:
                   4604:             @echo "line 1" > ${.TARGET}
                   4605:             @echo "line 2" >> ${.TARGET}
                   4606:             @false
1.1       dsieger  4607: 
1.184     rillig   4608:     correct:
                   4609:             @echo "line 1" > ${.TARGET}.tmp
                   4610:             @echo "line 2" >> ${.TARGET}.tmp
                   4611:             @false
                   4612:             @mv ${.TARGET}.tmp ${.TARGET}
1.1       dsieger  4613: 
1.184     rillig   4614:     When you run make wrong twice, the file wrong will exist, although there
                   4615:     was an error message in the first run. On the other hand, running make
                   4616:     correct gives an error message twice, as expected.
1.1       dsieger  4617: 
1.184     rillig   4618:     You might remember that make(1) sometimes removes ${.TARGET} in case of
                   4619:     error, but this only happens when it is interrupted, for example by
                   4620:     pressing Ctrl+C. This does not happen when one of the commands fails (like
                   4621:     false(1) above).
1.1       dsieger  4622: 
1.266     martin   4623: 15.2.  Makefile variables
1.1       dsieger  4624: 
1.184     rillig   4625: Makefile variables contain strings that can be processed using the five
                   4626: operators =, +=, ?=, := and !=, which are described in the make(1) man page.
1.1       dsieger  4627: 
1.184     rillig   4628: When a variable's value is parsed from a Makefile, the hash character # and the
                   4629: backslash character \ are handled specially. If a backslash is the last
                   4630: character in a line, that backslash is removed from the line and the line
                   4631: continues with the next line of the file.
1.1       dsieger  4632: 
1.184     rillig   4633: The # character starts a comment that reaches until the end of the line. To get
                   4634: an actual # character, such as in a URL, write \# instead.
1.1       dsieger  4635: 
1.184     rillig   4636: The evaluation of variables either happens immediately or lazy. It happens
                   4637: immediately when the variable occurs on the right-hand side of the := or the !=
                   4638: operator, in a .if condition or a .for loop. In the other cases, it is
                   4639: evaluated lazily.
1.1       dsieger  4640: 
1.184     rillig   4641: Some of the modifiers split the string into words and then operate on the
                   4642: words, others operate on the string as a whole. When a string is split into
                   4643: words, double quotes and single quotes are interpreted as delimiters, just like
                   4644: in sh(1).
1.1       dsieger  4645: 
1.266     martin   4646: 15.2.1.  Naming conventions
1.1       dsieger  4647: 
1.184     rillig   4648:   * All variable names starting with an underscore are reserved for use by the
                   4649:     pkgsrc infrastructure. They shall not be used by packages.
1.1       dsieger  4650: 
1.184     rillig   4651:   * In .for loops you should use lowercase variable names for the iteration
                   4652:     variables.
1.1       dsieger  4653: 
1.184     rillig   4654:   * All list variables should have a plural name, such as PKG_OPTIONS or
                   4655:     DISTFILES.
1.1       dsieger  4656: 
1.266     martin   4657: 15.3.  Code snippets
1.1       dsieger  4658: 
1.266     martin   4659: 15.3.1.  Adding things to a list
1.1       dsieger  4660: 
1.184     rillig   4661: When adding a string that possibly contains whitespace or quotes to a list
                   4662: (example 1), it must be quoted using the :Q modifier.
1.1       dsieger  4663: 
1.184     rillig   4664: When adding another list to a list (example 2), it must not be quoted, since
                   4665: its elements are already quoted.
1.1       dsieger  4666: 
1.184     rillig   4667: STRING=         foo * bar `date`
                   4668: LIST=           # empty
                   4669: ANOTHER_LIST=   a=b c=d
1.1       dsieger  4670: 
1.184     rillig   4671: LIST+=          ${STRING:Q}       # 1
                   4672: LIST+=          ${ANOTHER_LIST}   # 2
1.1       dsieger  4673: 
1.266     martin   4674: 15.3.2.  Echoing a string exactly as-is
1.1       dsieger  4675: 
1.184     rillig   4676: Echoing a string containing special characters needs special work.
1.1       dsieger  4677: 
1.184     rillig   4678: STRING=         foo bar <    > * `date` $$HOME ' "
                   4679: EXAMPLE_ENV=    string=${STRING:Q} x=multiple\ quoted\ words
1.1       dsieger  4680: 
1.184     rillig   4681: all:
                   4682:         echo ${STRING}                  # 1
                   4683:         echo ${STRING:Q}                # 2
                   4684:         printf '%s\n' ${STRING:Q}''     # 3
                   4685:         env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"'   # 4
1.1       dsieger  4686: 
1.184     rillig   4687: Example 1 leads to a syntax error in the shell, as the characters are just
                   4688: copied.
1.1       dsieger  4689: 
1.184     rillig   4690: Example 2 quotes the string so that the shell interprets it correctly. But the
                   4691: echo command may additionally interpret strings with a leading dash or those
                   4692: containing backslashes.
1.1       dsieger  4693: 
1.184     rillig   4694: Example 3 can handle arbitrary strings, since printf(1) only interprets the
                   4695: format string, but not the next argument. The trailing single quotes handle the
                   4696: case when the string is empty. In that case, the :Q modifier would result in an
                   4697: empty string too, which would then be skipped by the shell. For printf(1) this
                   4698: doesn't make a difference, but other programs may care.
1.1       dsieger  4699: 
1.184     rillig   4700: In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
                   4701: has already been done when adding elements to the list.
1.1       dsieger  4702: 
1.266     martin   4703: 15.3.3.  Passing CFLAGS to GNU configure scripts
1.1       dsieger  4704: 
1.184     rillig   4705: When passing CFLAGS or similar variables to a GNU-style configure script
                   4706: (especially those that call other configure scripts), it must not have leading
                   4707: or trailing whitespace, since otherwise the configure script gets confused. To
                   4708: trim leading and trailing whitespace, use the :M modifier, as in the following
                   4709: example:
1.1       dsieger  4710: 
1.184     rillig   4711: CPPFLAGS=               # empty
                   4712: CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX}\"
                   4713: CPPFLAGS+=              ${MY_CPPFLAGS}
1.1       dsieger  4714: 
1.184     rillig   4715: CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
1.1       dsieger  4716: 
1.184     rillig   4717: all:
                   4718:         echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
                   4719:         echo x${CONFIGURE_ARGS:Q}x      # properly trimmed
1.1       dsieger  4720: 
1.184     rillig   4721: In this example, CPPFLAGS has both leading and trailing whitespace because the
                   4722: += operator always adds a space.
1.1       dsieger  4723: 
1.266     martin   4724: 15.3.4.  Handling possibly empty variables
1.1       dsieger  4725: 
1.184     rillig   4726: When a possibly empty variable is used in a shell program, it may lead to a
                   4727: syntax error.
1.1       dsieger  4728: 
1.184     rillig   4729: EGFILES=        # empty
1.1       dsieger  4730: 
1.184     rillig   4731: install-examples:   # produces a syntax error in the shell
                   4732:         for egfile in ${EGFILES}; do            \
                   4733:                 echo "Installing $$egfile";     \
                   4734:         done
1.1       dsieger  4735: 
1.184     rillig   4736: The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
                   4737: with an empty string by make(1). To fix this syntax error, use one of the
                   4738: snippets below.
1.1       dsieger  4739: 
1.229     gutterid 4740: EGFILES=        # empty
1.1       dsieger  4741: 
1.184     rillig   4742: install-examples:
                   4743:         for egfile in ${EGFILES} ""; do         \
                   4744:                 [ -n "$$egfile" ] || continue;  \
                   4745:                 echo "Installing $$egfile";     \
                   4746:         done
1.1       dsieger  4747: 
1.184     rillig   4748: In this case, an empty string is appended to the iteration list (to prevent the
                   4749: syntax error) and filtered out later.
1.1       dsieger  4750: 
1.184     rillig   4751: EGFILES=        # empty
1.1       dsieger  4752: 
1.184     rillig   4753: install-examples:
                   4754: .for egfile in ${EGFILES}
                   4755:         echo "Installing ${egfile}"
                   4756: .endfor
1.1       dsieger  4757: 
1.184     rillig   4758: If one of the filenames contains special characters, it should be enclosed in
                   4759: single or double quotes.
1.1       dsieger  4760: 
1.184     rillig   4761: To have a shell command test whether a make variable is empty, use the
                   4762: following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
1.1       dsieger  4763: 
1.266     martin   4764: 15.3.5.  Testing yes/no variables in conditions
1.229     gutterid 4765: 
                   4766: When a variable can have the values yes or no, use the following pattern to
                   4767: test the variable:
                   4768: 
                   4769: .if ${VAR:U:tl} == "yes"
                   4770: # do something
                   4771: .endif
                   4772: 
                   4773: The :U modifier is only necessary if the variable can be undefined. If the
                   4774: variable is guaranteed to be defined, the :U can be omitted.
                   4775: 
                   4776: The :tl modifier converts the variable value to lowercase, allowing for the
                   4777: values yes, Yes, YES.
                   4778: 
1.266     martin   4779: Chapter  16.  Options handling
1.1       dsieger  4780: 
                   4781: Table of Contents
                   4782: 
1.184     rillig   4783: 16.1. Global default options
                   4784: 16.2. Converting packages to use bsd.options.mk
                   4785: 16.3. Option Names
                   4786: 16.4. Determining the options of dependencies
1.1       dsieger  4787: 
                   4788: Many packages have the ability to be built to support different sets of
                   4789: features. bsd.options.mk is a framework in pkgsrc that provides generic
                   4790: handling of those options that determine different ways in which the packages
                   4791: can be built. It's possible for the user to specify exactly which sets of
                   4792: options will be built into a package or to allow a set of global default
                   4793: options apply.
                   4794: 
1.7       rillig   4795: There are two broad classes of behaviors that one might want to control via
                   4796: options. One is whether some particular feature is enabled in a program that
                   4797: will be built anyway, often by including or not including a dependency on some
                   4798: other package. The other is whether or not an additional program will be built
                   4799: as part of the package. Generally, it is better to make a split package for
                   4800: such additional programs instead of using options, because it enables binary
                   4801: packages to be built which can then be added separately. For example, the foo
                   4802: package might have minimal dependencies (those packages without which foo
                   4803: doesn't make sense), and then the foo-gfoo package might include the GTK
                   4804: frontend program gfoo. This is better than including a gtk option to foo that
                   4805: adds gfoo, because either that option is default, in which case binary users
                   4806: can't get foo without gfoo, or not default, in which case they can't get gfoo.
                   4807: With split packages, they can install foo without having GTK, and later decide
                   4808: to install gfoo (pulling in GTK at that time). This is an advantage to source
                   4809: users too, avoiding the need for rebuilds.
                   4810: 
                   4811: Plugins with widely varying dependencies should usually be split instead of
                   4812: options.
                   4813: 
                   4814: It is often more work to maintain split packages, especially if the upstream
                   4815: package does not support this. The decision of split vs. option should be made
                   4816: based on the likelihood that users will want or object to the various pieces,
                   4817: the size of the dependencies that are included, and the amount of work.
                   4818: 
                   4819: A further consideration is licensing. Non-free parts, or parts that depend on
                   4820: non-free dependencies (especially plugins) should almost always be split if
                   4821: feasible.
                   4822: 
1.266     martin   4823: 16.1.  Global default options
1.1       dsieger  4824: 
                   4825: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
                   4826: the options that should be built into every package if that option is
1.4       rillig   4827: supported. This variable should be set in mk.conf.
1.1       dsieger  4828: 
1.266     martin   4829: 16.2.  Converting packages to use bsd.options.mk
1.1       dsieger  4830: 
                   4831: The following example shows how bsd.options.mk should be used by the
                   4832: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
                   4833: e.g. options.mk, that is included by the main package Makefile.
                   4834: 
                   4835: PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
                   4836: PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
                   4837: PKG_OPTIONS_OPTIONAL_GROUPS=    database
                   4838: PKG_OPTIONS_GROUP.database=     mysql pgsql
                   4839: PKG_SUGGESTED_OPTIONS=          wibble-foo
                   4840: PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
                   4841: PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
                   4842: 
                   4843: .include "../../mk/bsd.prefs.mk"
                   4844: 
                   4845: # this package was previously named wibble2
                   4846: .if defined(PKG_OPTIONS.wibble2)
                   4847: PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
                   4848: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
                   4849:         "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
                   4850: .endif
                   4851: 
                   4852: .include "../../mk/bsd.options.mk"
                   4853: 
                   4854: # Package-specific option-handling
                   4855: 
                   4856: ###
                   4857: ### FOO support
                   4858: ###
                   4859: .if !empty(PKG_OPTIONS:Mwibble-foo)
                   4860: CONFIGURE_ARGS+=    --enable-foo
                   4861: .endif
                   4862: 
                   4863: ###
                   4864: ### LDAP support
                   4865: ###
                   4866: .if !empty(PKG_OPTIONS:Mldap)
                   4867: .  include "../../databases/openldap-client/buildlink3.mk"
                   4868: CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
                   4869: .endif
                   4870: 
                   4871: ###
                   4872: ### database support
                   4873: ###
                   4874: .if !empty(PKG_OPTIONS:Mmysql)
                   4875: .  include "../../mk/mysql.buildlink3.mk"
                   4876: .endif
                   4877: .if !empty(PKG_OPTIONS:Mpgsql)
                   4878: .  include "../../mk/pgsql.buildlink3.mk"
                   4879: .endif
                   4880: 
                   4881: The first section contains the information about which build options are
                   4882: supported by the package, and any default options settings if needed.
                   4883: 
                   4884:  1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
                   4885:     to override the default options. It should be set to PKG_OPTIONS.pkgbase.
                   4886:     Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
                   4887:     the point where the options are processed.
                   4888: 
                   4889:  2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
                   4890: 
                   4891:  3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
                   4892:     exclusive options. The options in each group are listed in
                   4893:     PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
                   4894:     the group takes precedence over all other options in the group. Options
                   4895:     from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
                   4896: 
                   4897:  4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
                   4898:     building the packages will fail if no option from the group is selected.
                   4899: 
                   4900:  5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
                   4901:     one option from each set must be selected. The options in each set are
                   4902:     listed in PKG_OPTIONS_SET.setname. Options from the sets will be
                   4903:     automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
                   4904:     fail if no option from the set is selected.
                   4905: 
                   4906:  6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
                   4907:     default.
                   4908: 
1.266     martin   4909:  7. PKG_OPTIONS_LEGACY_VARS is a list of    USE_VARIABLE:option    pairs that map
1.4       rillig   4910:     legacy mk.conf variables to their option counterparts. Pairs should be
1.266     martin   4911:     added with    +=    to keep the listing of global legacy variables. A warning
1.1       dsieger  4912:     will be issued if the user uses a legacy variable.
                   4913: 
1.266     martin   4914:  8. PKG_OPTIONS_LEGACY_OPTS is a list of    old-option:new-option    pairs that map
1.1       dsieger  4915:     options that have been renamed to their new counterparts. Pairs should be
1.266     martin   4916:     added with    +=    to keep the listing of global legacy options. A warning
1.1       dsieger  4917:     will be issued if the user uses a legacy option.
                   4918: 
                   4919:  9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
                   4920:     used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
                   4921:     PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
                   4922: 
                   4923: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
                   4924:     variables or options used, and what to use instead.
                   4925: 
                   4926: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
                   4927: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
                   4928: options, use PKG_SUGGESTED_OPTIONS.
                   4929: 
                   4930: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
                   4931: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
                   4932: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
                   4933: options if none of them is supported on the current platform), PKG_OPTIONS is
                   4934: set to the empty list and the package is otherwise treated as not using the
                   4935: options framework.
                   4936: 
                   4937: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
                   4938: list of selected build options, properly filtered to remove unsupported and
                   4939: duplicate options.
                   4940: 
                   4941: The remaining sections contain the logic that is specific to each option. The
                   4942: correct way to check for an option is to check whether it is listed in
                   4943: PKG_OPTIONS:
                   4944: 
                   4945: .if !empty(PKG_OPTIONS:Moption)
                   4946: 
1.266     martin   4947: 16.3.  Option Names
1.1       dsieger  4948: 
                   4949: Options that enable similar features in different packages (like optional
                   4950: support for a library) should use a common name in all packages that support it
                   4951: (like the name of the library). If another package already has an option with
                   4952: the same meaning, use the same name.
                   4953: 
                   4954: Options that enable features specific to one package, where it's unlikely that
                   4955: another (unrelated) package has the same (or a similar) optional feature,
                   4956: should use a name prefixed with pkgname-.
                   4957: 
                   4958: If a group of related packages share an optional feature specific to that
1.266     martin   4959: group, prefix it with the name of the    main    package (e. g.
1.1       dsieger  4960: djbware-errno-hack).
                   4961: 
                   4962: For new options, add a line to mk/defaults/options.description. Lines have two
                   4963: fields, separated by tab. The first field is the option name, the second its
                   4964: description. The description should be a whole sentence (starting with an
                   4965: uppercase letter and ending with a period) that describes what enabling the
1.266     martin   4966: option does. E. g.    Enable ispell support.    The file is sorted by option names.
1.1       dsieger  4967: 
1.266     martin   4968: 16.4.  Determining the options of dependencies
1.7       rillig   4969: 
                   4970: When writing buildlink3.mk files, it is often necessary to list different
                   4971: dependencies based on the options with which the package was built. For
                   4972: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
                   4973: A typical example looks like this:
                   4974: 
                   4975: pkgbase := libpurple
                   4976: .include "../../mk/pkg-build-options.mk"
                   4977: 
                   4978: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
                   4979: ...
                   4980: .endif
                   4981: 
                   4982: Including pkg-build-options.mk here will set the variable
                   4983: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
                   4984: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
                   4985: pkg-build-options.mk for more details.
                   4986: 
1.266     martin   4987: Chapter  17.  Tools needed for building or running
1.184     rillig   4988: 
                   4989: Table of Contents
                   4990: 
                   4991: 17.1. Tools for pkgsrc builds
                   4992: 17.2. Tools needed by packages
                   4993: 17.3. Tools provided by platforms
                   4994: 
                   4995: The USE_TOOLS definition is used both internally by pkgsrc and also for
                   4996: individual packages to define what commands are needed for building a package
                   4997: (like TOOL_DEPENDS) or for later run-time of an installed packaged (such as
                   4998: DEPENDS). If the native system provides an adequate tool, then in many cases, a
                   4999: pkgsrc package will not be used.
                   5000: 
                   5001: When building a package, the replacement tools are made available in a
                   5002: directory (as symlinks or wrapper scripts) that is early in the executable
                   5003: search path. Just like the buildlink system, this helps with consistent builds.
                   5004: 
                   5005: A tool may be needed to help build a specific package. For example, perl, GNU
                   5006: make (gmake) or yacc may be needed.
                   5007: 
                   5008: Also a tool may be needed, for example, because the native system's supplied
                   5009: tool may be inefficient for building a package with pkgsrc. For example, a
                   5010: package may need GNU awk, bison (instead of yacc) or a better sed.
                   5011: 
                   5012: The tools used by a package can be listed by running make show-tools.
                   5013: 
1.266     martin   5014: 17.1.  Tools for pkgsrc builds
1.184     rillig   5015: 
                   5016: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
                   5017: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
                   5018: seen by running: make show-var VARNAME=USE_TOOLS.
                   5019: 
                   5020: If a package needs a specific program to build then the USE_TOOLS variable can
                   5021: be used to define the tools needed.
                   5022: 
1.266     martin   5023: 17.2.  Tools needed by packages
1.184     rillig   5024: 
                   5025: In the following examples, the :run means that it is needed at run-time (and
                   5026: becomes a DEPENDS). The default is a build dependency which can be set with
                   5027: :build. (So in this example, it is the same as gmake:build and
                   5028: pkg-config:build.)
                   5029: 
                   5030: USE_TOOLS+=     gmake perl:run pkg-config
                   5031: 
                   5032: When using the tools framework, a TOOLS_PATH.foo variable is defined which
                   5033: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
1.266     martin   5034: could be    /bin/bash    on Linux systems.
1.184     rillig   5035: 
                   5036: If you always need a pkgsrc version of the tool at run-time, then just use
                   5037: DEPENDS instead.
                   5038: 
1.266     martin   5039: 17.3.  Tools provided by platforms
1.184     rillig   5040: 
                   5041: When improving or porting pkgsrc to a new platform, have a look at (or create)
                   5042: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
                   5043: tools.${OPSYS}.mk which defines the name of the common tools. For example:
                   5044: 
                   5045: .if exists(/usr/bin/bzcat)
                   5046: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
                   5047: .elif exists(/usr/bin/bzip2)
                   5048: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
                   5049: .endif
                   5050: 
                   5051: TOOLS_PLATFORM.true?=           true                    # shell builtin
                   5052: 
1.266     martin   5053: Chapter  18.  Buildlink methodology
1.1       dsieger  5054: 
                   5055: Table of Contents
                   5056: 
1.184     rillig   5057: 18.1. Converting packages to use buildlink3
                   5058: 18.2. Writing buildlink3.mk files
                   5059:     18.2.1. Anatomy of a buildlink3.mk file
                   5060:     18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.271     wiz      5061:     buildlink3.mk files
1.184     rillig   5062: 18.3. Writing builtin.mk files
                   5063:     18.3.1. Anatomy of a builtin.mk file
                   5064: 
                   5065: Buildlink is a framework in pkgsrc that controls what headers and libraries are
                   5066: seen by a package's configure and build processes. This is implemented in a two
                   5067: step process:
                   5068: 
                   5069:  1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
                   5070:     default is a subdirectory of WRKDIR.
                   5071: 
                   5072:  2. Create wrapper scripts that are used in place of the normal compiler tools
                   5073:     that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
                   5074:     references to BUILDLINK_DIR. The wrapper scripts also make native compiler
                   5075:     on some operating systems look like GCC, so that packages that expect GCC
                   5076:     won't require modifications to build with those native compilers.
                   5077: 
                   5078: This normalizes the environment in which a package is built so that the package
                   5079: may be built consistently despite what other software may be installed. Please
                   5080: note that the normal system header and library paths, e.g. /usr/include, /usr/
                   5081: lib, etc., are always searched -- buildlink3 is designed to insulate the
                   5082: package build from non-system-supplied software.
                   5083: 
1.266     martin   5084: 18.1.  Converting packages to use buildlink3
1.1       dsieger  5085: 
1.266     martin   5086: The process of converting packages to use the buildlink3 framework (   bl3ifying   
1.184     rillig   5087: ) is fairly straightforward. The things to keep in mind are:
1.1       dsieger  5088: 
1.184     rillig   5089:  1. Ensure that the build always calls the wrapper scripts instead of the
                   5090:     actual toolchain. Some packages are tricky, and the only way to know for
                   5091:     sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
                   5092:     invoked.
1.1       dsieger  5093: 
1.184     rillig   5094:  2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
                   5095:     standalone shells, etc., because the code to symlink files into $
1.266     martin   5096:     {BUILDLINK_DIR} looks for files relative to    pkg_info -qp pkgname   .
1.1       dsieger  5097: 
1.184     rillig   5098:  3. Remember that only the buildlink3.mk files that you list in a package's
                   5099:     Makefile are added as dependencies for that package.
1.1       dsieger  5100: 
1.184     rillig   5101: If a dependency on a particular package is required for its libraries and
                   5102: headers, then we replace:
1.1       dsieger  5103: 
1.184     rillig   5104: DEPENDS+=       foo>=1.1.0:../../category/foo
1.1       dsieger  5105: 
1.184     rillig   5106: with
1.1       dsieger  5107: 
1.184     rillig   5108: .include "../../category/foo/buildlink3.mk"
1.1       dsieger  5109: 
1.184     rillig   5110: The buildlink3.mk files usually define the required dependencies. If you need a
                   5111: newer version of the dependency when using buildlink3.mk files, then you can
                   5112: define it in your Makefile; for example:
1.1       dsieger  5113: 
1.184     rillig   5114: BUILDLINK_API_DEPENDS.foo+=   foo>=1.1.0
                   5115: .include "../../category/foo/buildlink3.mk"
1.1       dsieger  5116: 
1.184     rillig   5117: There are several buildlink3.mk files in pkgsrc/mk that handle special package
                   5118: issues:
1.1       dsieger  5119: 
1.184     rillig   5120:   * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
                   5121:     implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
1.1       dsieger  5122: 
1.184     rillig   5123:   * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
                   5124:     this will take care to install the devel/ncurses package.
1.1       dsieger  5125: 
1.184     rillig   5126:   * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
                   5127:     a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
                   5128:     implementation.
1.1       dsieger  5129: 
1.184     rillig   5130:   * motif.buildlink3.mk checks for a system-provided Motif installation or adds
1.270     wiz      5131:     a dependency on x11/motif. The user can set MOTIF_TYPE to    dt    or    motif   
                   5132:     to choose which Motif version will be used.
1.1       dsieger  5133: 
1.184     rillig   5134:   * readline.buildlink3.mk checks for a system-provided GNU readline or
                   5135:     editline (libedit) installation, or adds a dependency on devel/readline,
                   5136:     devel/editline. The user can set READLINE_DEFAULT to choose readline
                   5137:     implementation. If your package really needs GNU readline library, its
                   5138:     Makefile should include devel/readline/buildlink3.mk instead of
                   5139:     readline.buildlink3.mk.
1.1       dsieger  5140: 
1.184     rillig   5141:   * oss.buildlink3.mk defines several variables that may be used by packages
                   5142:     that use the Open Sound System (OSS) API.
1.1       dsieger  5143: 
1.184     rillig   5144:   * pgsql.buildlink3.mk will accept any of the Postgres versions in the
                   5145:     variable PGSQL_VERSIONS_ACCEPTED and default to the version
                   5146:     PGSQL_VERSION_DEFAULT. See the file for more information.
1.1       dsieger  5147: 
1.184     rillig   5148:   * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
                   5149:     pthreads or adds a dependency on devel/pth as needed.
1.1       dsieger  5150: 
1.184     rillig   5151:   * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
                   5152:     widgets library.
1.1       dsieger  5153: 
1.184     rillig   5154: The comments in those buildlink3.mk files provide a more complete description
                   5155: of how to use them properly.
1.1       dsieger  5156: 
1.266     martin   5157: 18.2.  Writing buildlink3.mk files
1.1       dsieger  5158: 
1.184     rillig   5159: A package's buildlink3.mk file is included by Makefiles to indicate the need to
                   5160: compile and link against header files and libraries provided by the package. A
                   5161: buildlink3.mk file should always provide enough information to add the correct
                   5162: type of dependency relationship and include any other buildlink3.mk files that
                   5163: it needs to find headers and libraries that it needs in turn.
1.1       dsieger  5164: 
1.184     rillig   5165: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
                   5166: pkgtools/createbuildlink package is highly recommended. For most packages, the
                   5167: following command will generate a good starting point for buildlink3.mk files:
1.1       dsieger  5168: 
1.184     rillig   5169: % cd pkgsrc/category/pkgdir
                   5170: % createbuildlink >buildlink3.mk
1.1       dsieger  5171: 
                   5172: 
1.266     martin   5173: 18.2.1.  Anatomy of a buildlink3.mk file
1.1       dsieger  5174: 
1.184     rillig   5175: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
                   5176: tiff:
1.14      jmcneill 5177: 
1.184     rillig   5178: BUILDLINK_TREE+=        tiff
1.1       dsieger  5179: 
1.184     rillig   5180: .if !defined(TIFF_BUILDLINK3_MK)
                   5181: TIFF_BUILDLINK3_MK:=
1.1       dsieger  5182: 
1.184     rillig   5183: BUILDLINK_API_DEPENDS.tiff+=    tiff>=3.6.1
                   5184: BUILDLINK_ABI_DEPENDS.tiff+=    tiff>=3.7.2nb1
                   5185: BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
1.1       dsieger  5186: 
1.184     rillig   5187: .include "../../devel/zlib/buildlink3.mk"
                   5188: .include "../../graphics/jpeg/buildlink3.mk"
                   5189: .endif # TIFF_BUILDLINK3_MK
1.1       dsieger  5190: 
1.184     rillig   5191: BUILDLINK_TREE+=        -tiff
1.1       dsieger  5192: 
1.184     rillig   5193: The header and footer manipulate BUILDLINK_TREE, which is common across all
                   5194: buildlink3.mk files and is used to track the dependency tree.
1.1       dsieger  5195: 
1.184     rillig   5196: The main section is protected from multiple inclusion and controls how the
                   5197: dependency on pkg is added. Several important variables are set in the section:
1.1       dsieger  5198: 
1.185     wiz      5199:   * BUILDLINK_API_DEPENDS.pkg is the dependency version recorded in the
1.184     rillig   5200:     installed package; this should always be set using += to ensure that we're
                   5201:     appending to any pre-existing list of values. This variable should be set
1.185     wiz      5202:     to the last version of the package that had an backwards-incompatible API
1.184     rillig   5203:     change.
1.1       dsieger  5204: 
1.184     rillig   5205:   * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
1.1       dsieger  5206: 
1.184     rillig   5207:   * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
1.236     gutterid 5208:     BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
1.266     martin   5209:     is selected by setting BUILDLINK_DEPMETHOD.pkg to    build   . By default, the
1.236     gutterid 5210:     full dependency is used.
1.1       dsieger  5211: 
1.184     rillig   5212:   * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
                   5213:     of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
1.266     martin   5214:     library search paths. These default to    include    and    lib    respectively.
1.1       dsieger  5215: 
1.184     rillig   5216:   * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
                   5217:     to add to CPPFLAGS, which are passed on to the configure and build phases.
1.266     martin   5218:     The    -I    option should be avoided and instead be handled using
1.184     rillig   5219:     BUILDLINK_INCDIRS.pkg as above.
1.66      asau     5220: 
1.184     rillig   5221: The following variables are all optionally defined within this second section
                   5222: (protected against multiple inclusion) and control which package files are
                   5223: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
                   5224: symlinking:
1.23      jakllsch 5225: 
1.184     rillig   5226:   * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
                   5227:     {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
                   5228:     *.h.
1.1       dsieger  5229: 
1.184     rillig   5230:   * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
                   5231:     to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
                   5232:     resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
                   5233:     takes the +CONTENTS of a pkg and filters it through $
                   5234:     {BUILDLINK_CONTENTS_FILTER.pkg}.
1.1       dsieger  5235: 
1.184     rillig   5236:   * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
                   5237:     filters +CONTENTS input into a list of files relative to $
                   5238:     {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
                   5239:     outputs the contents of the include and lib directories in the package
                   5240:     +CONTENTS.
1.1       dsieger  5241: 
1.184     rillig   5242:   * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
                   5243:     used to transform the name of the source filename into a destination
                   5244:     filename, e.g. -e "s|/curses.h|/ncurses.h|g".
1.1       dsieger  5245: 
1.184     rillig   5246: This section can additionally include any buildlink3.mk needed for pkg's
                   5247: library dependencies. Including these buildlink3.mk files means that the
                   5248: headers and libraries for these dependencies are also symlinked into $
                   5249: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
                   5250: are only added for directly include buildlink3.mk files.
1.1       dsieger  5251: 
1.184     rillig   5252: When providing a buildlink3.mk and including other buildlink3.mk files in it,
                   5253: please only add necessary ones, i.e., those whose libraries or header files are
                   5254: automatically exposed when the package is use.
1.1       dsieger  5255: 
1.184     rillig   5256: In particular, if only an executable (bin/foo) is linked against a library,
                   5257: that library does not need to be propagated in the buildlink3.mk file.
1.1       dsieger  5258: 
1.184     rillig   5259: The following steps should help you decide if a buildlink3.mk file needs to be
                   5260: included:
1.1       dsieger  5261: 
1.184     rillig   5262:   * Look at the installed header files: What headers do they include? The
                   5263:     packages providing these files must be buildlinked.
1.1       dsieger  5264: 
1.184     rillig   5265:   * Run ldd on all installed libraries and look against what other libraries
                   5266:     they link. Some of the packages providing these probably need to be
                   5267:     buildlinked; however, it's not automatic, since e.g. GTK on some systems
                   5268:     pulls in the X libraries, so they will show up in the ldd output, while on
                   5269:     others (like OS X) it won't. ldd output can thus only be used as a hint.
1.1       dsieger  5270: 
1.266     martin   5271: 18.2.2.  Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.184     rillig   5272: buildlink3.mk files
1.16      jnemeth  5273: 
1.185     wiz      5274: Both variables set lower bounds for a version of this package. The two
                   5275: variables differ in that one describes source compatibility (API) and the other
                   5276: binary compatibility (ABI). The difference is that a change in the API breaks
                   5277: compilation of programs while changes in the ABI stop compiled programs from
                   5278: running.
                   5279: 
                   5280: The BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk should be changed
                   5281: very rarely. (One possible scenario: If all packages using this package need a
                   5282: higher version than defined in the buildlink3.mk, BUILDLINK_API_DEPENDS.pkg
                   5283: could be updated to that higher version.)
                   5284: 
                   5285: On the other hand, changes to BUILDLINK_ABI_DEPENDS.pkg are more common. The
                   5286: variable will need to be updated every time the major version of one of its
                   5287: shared libraries is changed, or any other change where a binary built against
                   5288: the previous version of the package will not run against the new version any
                   5289: longer.
                   5290: 
                   5291: In such a case, the package's BUILDLINK_ABI_DEPENDS.pkg must be increased to
                   5292: require the new package version. Then the PKGREVISION of all packages foo that
                   5293: depend on this package need to be increased, and if they have buildlink3.mk
                   5294: files, BUILDLINK_ABI_DEPENDS.foo in their buildlink3.mk files must be increased
                   5295: to the new version as well. This is required so that a package will pull in the
                   5296: versions of the packages that use the new ABI and that the packages'
                   5297: PKGREVISIONs uniquely identify the packages built against the new ABI. The
                   5298: pkgtools/revbump package can help with these updates.
1.1       dsieger  5299: 
1.266     martin   5300: See Section  21.1.5,    Handling dependencies    for more information about
1.185     wiz      5301: dependencies on other packages, including the BUILDLINK_API_DEPENDS
                   5302: definitions.
1.1       dsieger  5303: 
1.184     rillig   5304: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
1.185     wiz      5305: BUILDLINK_ABI_DEPENDS.pkg in a buildlink3.mk file as we don't want to cause
                   5306: unneeded package deletions and rebuilds. In many cases, new versions of
                   5307: packages work just fine with older dependencies.
1.1       dsieger  5308: 
1.211     gutterid 5309: Also, it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
1.184     rillig   5310: BUILDLINK_API_DEPENDS.pkg.
1.1       dsieger  5311: 
1.211     gutterid 5312: Note there is also the distinction that users are able to disable enforcement
                   5313: of ABI dependencies using the USE_ABI_DEPENDS variable, but there is no
                   5314: equivalent option for API dependencies.
                   5315: 
1.266     martin   5316: 18.3.  Writing builtin.mk files
1.1       dsieger  5317: 
1.184     rillig   5318: Some packages in pkgsrc install headers and libraries that coincide with
                   5319: headers and libraries present in the base system. Aside from a buildlink3.mk
                   5320: file, these packages should also include a builtin.mk file that includes the
                   5321: necessary checks to decide whether using the built-in software or the pkgsrc
                   5322: software is appropriate.
1.1       dsieger  5323: 
1.184     rillig   5324: The only requirements of a builtin.mk file for pkg are:
1.1       dsieger  5325: 
1.266     martin   5326:  1. It should set USE_BUILTIN.pkg to either    yes    or    no    after it is included.
1.1       dsieger  5327: 
1.184     rillig   5328:  2. It should not override any USE_BUILTIN.pkg which is already set before the
                   5329:     builtin.mk file is included.
1.1       dsieger  5330: 
1.184     rillig   5331:  3. It should be written to allow multiple inclusion. This is very important
                   5332:     and takes careful attention to Makefile coding.
1.1       dsieger  5333: 
1.266     martin   5334: 18.3.1.  Anatomy of a builtin.mk file
1.1       dsieger  5335: 
1.184     rillig   5336: The following is the recommended template for builtin.mk files:
1.1       dsieger  5337: 
1.184     rillig   5338: .if !defined(IS_BUILTIN.foo)
                   5339: #
                   5340: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
                   5341: # genuinely exists in the system or not.
                   5342: #
                   5343: IS_BUILTIN.foo?=        no
1.1       dsieger  5344: 
1.184     rillig   5345: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
                   5346: # version can be determined.
                   5347: #
                   5348: .  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
                   5349: BUILTIN_PKG.foo?=       foo-1.0
                   5350: .  endif
                   5351: .endif  # IS_BUILTIN.foo
1.1       dsieger  5352: 
1.184     rillig   5353: .if !defined(USE_BUILTIN.foo)
                   5354: USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
                   5355: .  if defined(BUILTIN_PKG.foo)
                   5356: .    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
                   5357: .      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
                   5358: USE_BUILTIN.foo!=                                                       \
                   5359:         ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}            \
                   5360:         && ${ECHO} "yes" || ${ECHO} "no"
                   5361: .      endif
                   5362: .    endfor
                   5363: .  endif
                   5364: .endif  # USE_BUILTIN.foo
1.1       dsieger  5365: 
1.184     rillig   5366: CHECK_BUILTIN.foo?=     no
                   5367: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
                   5368: #
                   5369: # Here we place code that depends on whether USE_BUILTIN.foo is set to
                   5370: # "yes" or "no".
                   5371: #
                   5372: .endif  # CHECK_BUILTIN.foo
1.1       dsieger  5373: 
1.184     rillig   5374: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
                   5375: base system. This should not be a base system software with similar
1.266     martin   5376: functionality to pkg; it should only be    yes    if the actual package is included
1.184     rillig   5377: as part of the base system. This variable is only used internally within the
                   5378: builtin.mk file.
1.1       dsieger  5379: 
1.184     rillig   5380: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
1.266     martin   5381: system if it exists (if IS_BUILTIN.pkg is    yes   ). This variable is only used
1.184     rillig   5382: internally within the builtin.mk file.
1.1       dsieger  5383: 
1.184     rillig   5384: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
                   5385: The code in this section must make the determination whether the built-in
                   5386: software is adequate to satisfy the dependencies listed in
                   5387: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
                   5388: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg 
                   5389: must be set to the correct value by the end of the builtin.mk file. Note that
1.266     martin   5390: USE_BUILTIN.pkg may be    yes    even if IS_BUILTIN.pkg is    no    because we may make
1.184     rillig   5391: the determination that the built-in version of the software is similar enough
                   5392: to be used as a replacement.
1.1       dsieger  5393: 
1.184     rillig   5394: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
                   5395: the value of USE_BUILTIN.pkg set in the previous section. This typically
                   5396: includes, e.g., adding additional dependency restrictions and listing
                   5397: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
1.1       dsieger  5398: 
1.266     martin   5399: Chapter  19.  PLIST issues
1.1       dsieger  5400: 
1.184     rillig   5401: Table of Contents
1.1       dsieger  5402: 
1.184     rillig   5403: 19.1. RCS ID
                   5404: 19.2. Semi-automatic PLIST generation
                   5405: 19.3. Tweaking output of make print-PLIST
                   5406: 19.4. Variable substitution in PLIST
                   5407: 19.5. Man page compression
                   5408: 19.6. Changing PLIST source with PLIST_SRC
                   5409: 19.7. Platform-specific and differing PLISTs
                   5410: 19.8. Build-specific PLISTs
                   5411: 19.9. Sharing directories between packages
1.1       dsieger  5412: 
1.266     martin   5413: The PLIST file contains a package's    packing list   , i.e. a list of files that
1.184     rillig   5414: belong to the package (relative to the ${PREFIX} directory it's been installed
                   5415: in) plus some additional statements - see the pkg_create(1) man page for a full
                   5416: list. This chapter addresses some issues that need attention when dealing with
                   5417: the PLIST file (or files, see below!).
1.1       dsieger  5418: 
1.266     martin   5419: 19.1.  RCS ID
1.1       dsieger  5420: 
1.184     rillig   5421: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
1.1       dsieger  5422: 
1.184     rillig   5423: @comment $NetBSD $
1.1       dsieger  5424: 
1.184     rillig   5425: An artificial space has been added between NetBSD and $, this is a workaround
                   5426: here to prevent CVS expanding to the filename of the guide. When adding the RCS
                   5427: ID the space should be omitted.
1.38      wiz      5428: 
1.266     martin   5429: 19.2.  Semi-automatic PLIST generation
1.1       dsieger  5430: 
1.184     rillig   5431: You can use the make print-PLIST command to output a PLIST that matches any new
1.266     martin   5432: files since the package was extracted. See Section  13.17,    Other helpful
                   5433: targets    for more information on this target.
1.11      rillig   5434: 
1.266     martin   5435: 19.3.  Tweaking output of make print-PLIST
1.1       dsieger  5436: 
1.184     rillig   5437: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
                   5438: used to filter the output of print-PLIST. You can append any chunk of AWK
                   5439: scripting you like to it, but be careful with quoting.
1.1       dsieger  5440: 
1.184     rillig   5441: For example, to get all files inside the libdata/foo directory removed from the
                   5442: resulting PLIST:
1.1       dsieger  5443: 
1.184     rillig   5444: PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
1.1       dsieger  5445: 
1.185     wiz      5446: The PRINT_PLIST_AWK transformations are evaluated after the file list and
                   5447: directory list are sorted. EARLY_PRINT_PLIST_AWK is like PRINT_PLIST_AWK except
                   5448: it operates before the file list and directory list are sorted.
                   5449: 
1.266     martin   5450: 19.4.  Variable substitution in PLIST
1.1       dsieger  5451: 
1.184     rillig   5452: A number of variables are substituted automatically in PLISTs when a package is
                   5453: installed on a system. This includes the following variables:
1.1       dsieger  5454: 
1.184     rillig   5455: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
1.1       dsieger  5456: 
1.184     rillig   5457:     Some packages like emacs and perl embed information about which
                   5458:     architecture they were built on into the pathnames where they install their
                   5459:     files. To handle this case, PLIST will be preprocessed before actually
1.266     martin   5460:     used, and the symbol    ${MACHINE_ARCH}    will be replaced by what uname -p
1.184     rillig   5461:     gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
                   5462:     PLIST somewhere - use this on packages that have GNU autoconf-created
                   5463:     configure scripts.
1.1       dsieger  5464: 
1.184     rillig   5465:     Legacy note
1.1       dsieger  5466: 
1.266     martin   5467:     There used to be a symbol    $ARCH    that was replaced by the output of uname
1.184     rillig   5468:     -m, but that's no longer supported and has been removed.
1.1       dsieger  5469: 
1.184     rillig   5470: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
1.1       dsieger  5471: 
1.184     rillig   5472:     Some packages want to embed the OS name and version into some paths. To do
                   5473:     this, use these variables in the PLIST:
1.1       dsieger  5474: 
1.271     wiz      5475:       o ${OPSYS} - output of    uname -s   
1.1       dsieger  5476: 
1.271     wiz      5477:       o ${LOWER_OPSYS} - lowercase common name (eg.    solaris   )
1.1       dsieger  5478: 
1.271     wiz      5479:       o ${OS_VERSION} -    uname -r   
1.1       dsieger  5480: 
1.184     rillig   5481: For a list of values which are replaced by default, the output of make help
                   5482: topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
                   5483: PLIST_SUBST should help.
1.1       dsieger  5484: 
1.184     rillig   5485: If you want to change other variables not listed above, you can add variables
                   5486: and their expansions to this variable in the following way, similar to
1.266     martin   5487: MESSAGE_SUBST (see Section  12.5,    Optional files   ):
1.1       dsieger  5488: 
1.184     rillig   5489: PLIST_SUBST+=   SOMEVAR="somevalue"
1.1       dsieger  5490: 
1.266     martin   5491: This replaces all occurrences of    ${SOMEVAR}    in the PLIST with    somevalue   .
1.1       dsieger  5492: 
1.184     rillig   5493: The PLIST_VARS variable can be used to simplify the common case of
                   5494: conditionally including some PLIST entries. It can be done by adding
                   5495: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
1.266     martin   5496: entry should be included. This will substitute    ${PLIST.foo}    in the PLIST with
                   5497: either    ""    or    "@comment "   . For example, in Makefile:
1.1       dsieger  5498: 
1.184     rillig   5499: PLIST_VARS+=    foo
                   5500: .if condition
                   5501: PLIST.foo=      yes
                   5502: .else
1.1       dsieger  5503: 
1.184     rillig   5504: And then in PLIST:
1.1       dsieger  5505: 
1.184     rillig   5506: @comment $NetBSD $
                   5507: bin/bar
                   5508: man/man1/bar.1
                   5509: ${PLIST.foo}bin/foo
                   5510: ${PLIST.foo}man/man1/foo.1
                   5511: ${PLIST.foo}share/bar/foo.data
1.1       dsieger  5512: 
1.184     rillig   5513: An artificial space has been added between NetBSD and $, this is a workaround
                   5514: here to prevent CVS expanding to the filename of the guide. When adding the RCS
1.195     gutterid 5515: ID the space should be omitted.
1.1       dsieger  5516: 
1.266     martin   5517: 19.5.  Man page compression
1.1       dsieger  5518: 
1.184     rillig   5519: Man pages should be installed in compressed form if MANZ is set (in
                   5520: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
1.266     martin   5521: suffix    .gz    is appended/removed automatically for man pages according to MANZ
1.184     rillig   5522: and MANCOMPRESSED being set or not, see above for details. This modification of
                   5523: the PLIST file is done on a copy of it, not PLIST itself.
1.100     leot     5524: 
1.266     martin   5525: 19.6.  Changing PLIST source with PLIST_SRC
1.100     leot     5526: 
1.184     rillig   5527: To use one or more files as source for the PLIST used in generating the binary
                   5528: package, set the variable PLIST_SRC to the names of that file(s). The files are
                   5529: later concatenated using cat(1), and the order of things is important. The
                   5530: default for PLIST_SRC is ${PKGDIR}/PLIST.
1.1       dsieger  5531: 
1.266     martin   5532: 19.7.  Platform-specific and differing PLISTs
1.1       dsieger  5533: 
1.184     rillig   5534: Some packages decide to install a different set of files based on the operating
                   5535: system being used. These differences can be automatically handled by using the
                   5536: following files:
1.1       dsieger  5537: 
1.184     rillig   5538:   * PLIST.common
1.1       dsieger  5539: 
1.184     rillig   5540:   * PLIST.${OPSYS}
1.1       dsieger  5541: 
1.184     rillig   5542:   * PLIST.${MACHINE_ARCH}
1.1       dsieger  5543: 
1.184     rillig   5544:   * PLIST.${OPSYS}-${MACHINE_ARCH}
1.1       dsieger  5545: 
1.184     rillig   5546:   * PLIST.common_end
1.1       dsieger  5547: 
1.266     martin   5548: 19.8.  Build-specific PLISTs
1.1       dsieger  5549: 
1.184     rillig   5550: Some packages decide to generate hard-to-guess file names during installation
                   5551: that are hard to wire down.
1.1       dsieger  5552: 
1.184     rillig   5553: In such cases, you can set the GENERATE_PLIST variable to shell code terminated
                   5554: (with a semicolon) that will output PLIST entries which will be appended to the
                   5555: PLIST
1.1       dsieger  5556: 
1.184     rillig   5557: You can find one example in editors/xemacs:
1.1       dsieger  5558: 
1.184     rillig   5559: GENERATE_PLIST+=        ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
1.1       dsieger  5560: 
1.184     rillig   5561: which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
1.1       dsieger  5562: 
1.266     martin   5563: 19.9.  Sharing directories between packages
1.1       dsieger  5564: 
1.266     martin   5565: A    shared directory    is a directory where multiple (and unrelated) packages
1.184     rillig   5566: install files. These directories were problematic because you had to add
                   5567: special tricks in the PLIST to conditionally remove them, or have some
                   5568: centralized package handle them.
1.106     tnn      5569: 
1.184     rillig   5570: In pkgsrc, it is now easy: Each package should create directories and install
                   5571: files as needed; pkg_delete will remove any directories left empty after
                   5572: uninstalling a package.
1.106     tnn      5573: 
1.184     rillig   5574: If a package needs an empty directory to work, create the directory during
                   5575: installation as usual, and also add an entry to the PLIST:
1.1       dsieger  5576: 
1.184     rillig   5577: @pkgdir path/to/empty/directory
1.1       dsieger  5578: 
1.184     rillig   5579: or take a look at MAKE_DIRS and OWN_DIRS.
1.1       dsieger  5580: 
1.266     martin   5581: Chapter  20.  The pkginstall framework
1.1       dsieger  5582: 
1.184     rillig   5583: Table of Contents
1.1       dsieger  5584: 
1.184     rillig   5585: 20.1. Files and directories outside the installation prefix
                   5586:     20.1.1. Directory manipulation
                   5587:     20.1.2. File manipulation
                   5588: 20.2. Configuration files
                   5589:     20.2.1. How PKG_SYSCONFDIR is set
                   5590:     20.2.2. Telling the software where configuration files are
1.239     dholland 5591:     20.2.3. Patching installation
                   5592:     20.2.4. Declaring configuration files
                   5593:     20.2.5. Disabling handling of configuration files
1.184     rillig   5594: 20.3. System startup scripts
                   5595:     20.3.1. Disabling handling of system startup scripts
                   5596: 20.4. System users and groups
                   5597: 20.5. System shells
                   5598:     20.5.1. Disabling shell registration
                   5599: 20.6. Fonts
                   5600:     20.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  5601: 
1.184     rillig   5602: This chapter describes the framework known as pkginstall, whose key features
                   5603: are:
1.1       dsieger  5604: 
1.184     rillig   5605:   * Generic installation and manipulation of directories and files outside the
                   5606:     pkgsrc-handled tree, LOCALBASE.
1.1       dsieger  5607: 
1.184     rillig   5608:   * Automatic handling of configuration files during installation, provided
                   5609:     that packages are correctly designed.
1.1       dsieger  5610: 
1.184     rillig   5611:   * Generation and installation of system startup scripts.
1.1       dsieger  5612: 
1.184     rillig   5613:   * Registration of system users and groups.
1.1       dsieger  5614: 
1.184     rillig   5615:   * Registration of system shells.
1.1       dsieger  5616: 
1.184     rillig   5617:   * Automatic updating of fonts databases.
1.1       dsieger  5618: 
1.184     rillig   5619: The following sections inspect each of the above points in detail.
1.1       dsieger  5620: 
1.184     rillig   5621: You may be thinking that many of the things described here could be easily done
                   5622: with simple code in the package's post-installation target (post-install). This
                   5623: is incorrect, as the code in them is only executed when building from source.
                   5624: Machines using binary packages could not benefit from it at all (as the code
                   5625: itself could be unavailable). Therefore, the only way to achieve any of the
                   5626: items described above is by means of the installation scripts, which are
                   5627: automatically generated by pkginstall.
1.1       dsieger  5628: 
1.266     martin   5629: 20.1.  Files and directories outside the installation prefix
1.95      wiz      5630: 
1.184     rillig   5631: As you already know, the PLIST file holds a list of files and directories that
                   5632: belong to a package. The names used in it are relative to the installation
                   5633: prefix (${PREFIX}), which means that it cannot register files outside this
                   5634: directory (absolute path names are not allowed). Despite this restriction, some
                   5635: packages need to install files outside this location; e.g., under ${VARBASE} or
                   5636: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
                   5637: installation time by using installation scripts.
1.95      wiz      5638: 
1.184     rillig   5639: The generic installation scripts are shell scripts that can contain arbitrary
                   5640: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
                   5641: which defaults to INSTALL. A similar variable exists for package removal
                   5642: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
                   5643: commands, so they have the potential to create and manage files anywhere in the
                   5644: file system.
1.95      wiz      5645: 
1.184     rillig   5646: Using these general installation files is not recommended, but may be needed in
                   5647: some special cases. One reason for avoiding them is that the user has to trust
                   5648: the packager that there is no unwanted or simply erroneous code included in the
                   5649: installation script. Also, previously there were many similar scripts for the
                   5650: same functionality, and fixing a common error involved finding and changing all
                   5651: of them.
1.95      wiz      5652: 
1.184     rillig   5653: The pkginstall framework offers another, standardized way. It provides generic
                   5654: scripts to abstract the manipulation of such files and directories based on
                   5655: variables set in the package's Makefile. The rest of this section describes
                   5656: these variables.
1.1       dsieger  5657: 
1.266     martin   5658: 20.1.1.  Directory manipulation
1.1       dsieger  5659: 
1.184     rillig   5660: The following variables can be set to request the creation of directories
                   5661: anywhere in the file system:
1.1       dsieger  5662: 
1.184     rillig   5663:   * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
                   5664:     and should attempt to be destroyed by the installation scripts. The
                   5665:     difference between the two is that the latter prompts the administrator to
                   5666:     remove any directories that may be left after deinstallation (because they
                   5667:     were not empty), while the former does not. Example:
1.1       dsieger  5668: 
1.184     rillig   5669:     MAKE_DIRS+=             ${VARBASE}/foo/private
1.1       dsieger  5670: 
1.184     rillig   5671:   * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
                   5672:     which directories should be created and should attempt to be destroyed by
                   5673:     the installation scripts. Each tuple holds the following values, separated
                   5674:     by spaces: the directory name, its owner, its group and its numerical mode.
                   5675:     For example:
1.1       dsieger  5676: 
1.184     rillig   5677:     MAKE_DIRS_PERMS+=       ${VARBASE}/foo/private \
                   5678:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  5679: 
1.184     rillig   5680:     The difference between the two is exactly the same as their non-PERMS
                   5681:     counterparts.
1.1       dsieger  5682: 
1.266     martin   5683: 20.1.2.  File manipulation
1.1       dsieger  5684: 
1.184     rillig   5685: Creating non-empty files outside the installation prefix is tricky because the
                   5686: PLIST forces all files to be inside it. To overcome this problem, the only
1.239     dholland 5687: solution is to extract the file in a known place (i.e., inside the installation
                   5688: prefix) and copy it to the appropriate location during installation (done by
                   5689: the installation scripts generated by pkginstall). We will call the former the 
                   5690: reference file in the following paragraphs, which describe the variables that
                   5691: can be used to automatically and consistently handle files outside the
                   5692: installation prefix:
                   5693: 
                   5694:   * REQD_FILES is a list of pairs of reference and target files. At
                   5695:     installation time, the reference file is copied to the target if and only
                   5696:     if the latter does not exist. Upon deinstallation, the reference file is
1.184     rillig   5697:     removed provided that it was not modified by the installation.
1.1       dsieger  5698: 
1.239     dholland 5699:   * REQD_FILES_PERMS contains tuples describing reference files and targets,
                   5700:     including owner, group, and numeric permissions that should be set. For
                   5701:     example:
1.1       dsieger  5702: 
1.184     rillig   5703:     REQD_FILES_PERMS+=      ${PREFIX}/share/somefile ${VARBASE}/somefile \
                   5704:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  5705: 
1.239     dholland 5706:   * CONF_FILES and CONF_FILES_PERMS have the same syntax as REQD_FILES and
                   5707:     REQD_FILES_PERMS respectively. The difference is that these variables are
                   5708:     specifically intended for handling configuration files, for which
1.266     martin   5709:     additional conventions and constraints apply. See Section  20.2,
                   5710:        Configuration files    for further discussion. Note in particular that while
1.239     dholland 5711:     handling of configuration files can be disabled by the user (see
1.266     martin   5712:     Section  20.2.5,    Disabling handling of configuration files   ), this setting
1.239     dholland 5713:     does not affect REQD_FILES and REQD_FILES_PERMS.
                   5714: 
                   5715: To install an empty file, one can use these macros and /dev/null as the
                   5716: reference file.
1.1       dsieger  5717: 
1.266     martin   5718: 20.2.  Configuration files
1.1       dsieger  5719: 
1.239     dholland 5720: There are two principles that govern the handling of configuration files in
                   5721: pkgsrc: first, the user's configuration must not be lost or overwritten by
                   5722: upgrades or reinstallations; and second, the default configuration should
                   5723: always be available for reference. To that end, pkgsrc has a framework
                   5724: specifically for handling configuration files. In general, configuration files
                   5725: are installed into ${PREFIX}/share/examples, and copied from there to the
                   5726: pertinent etc directory as a separate step and only as needed.
                   5727: 
                   5728: To make this work, there are three things that need to happen, any of which may
                   5729: require patching. First, the package must be told to read its configuration
                   5730: from the correct place at runtime; this place is ${PKG_SYSCONFDIR} (or possibly
                   5731: a subdirectory of it) which is often but not always ${PREFIX}/etc. Second, the
                   5732: package must be taught to install its default configuration files in ${PREFIX}/
                   5733: share/examples/${PKGBASE}; this is the point at which patching often becomes
                   5734: required because it is not the same place as the runtime location. Third, the
                   5735: configuration files need to be declared in the package makefile; this is the
                   5736: easy part.
                   5737: 
                   5738: With those elements in place, the right things will happen: the package install
                   5739: phase and resulting binary package will not touch ${PKG_SYSCONFDIR}, and the
                   5740: default configuration will be copied into place by the pkgsrc framework only if
                   5741: not already present. Similarly, upon deinstall the configuration will not be
                   5742: removed if it has been modified. (This means that in the case of reinstallation
                   5743: and upgrades, unmodified configuration files are updated but modifications are
                   5744: never discarded.)
                   5745: 
                   5746: The following sections describe how to make these things happen and document
                   5747: other relevant knobs available in the pkgsrc infrastructure.
1.1       dsieger  5748: 
1.266     martin   5749: 20.2.1.  How PKG_SYSCONFDIR is set
1.1       dsieger  5750: 
1.184     rillig   5751: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
                   5752: shall be installed. Its contents are set based upon the following variables:
1.1       dsieger  5753: 
1.184     rillig   5754:   * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
1.239     dholland 5755:     etc although it may be overridden by the user to point to their preferred
1.184     rillig   5756:     location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
1.1       dsieger  5757: 
1.184     rillig   5758:   * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
                   5759:     configuration files for the package being built shall be installed. The
                   5760:     definition of this variable only makes sense in the package's Makefile
                   5761:     (i.e., it is not user-customizable).
1.1       dsieger  5762: 
1.184     rillig   5763:     As an example, consider the Apache package, www/apache24, which places its
                   5764:     configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
                   5765:     should be set in the package Makefile.
1.1       dsieger  5766: 
1.184     rillig   5767:   * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
                   5768:     package's configuration directory (if different from PKG_SYSCONFBASE). It
                   5769:     defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
1.1       dsieger  5770: 
1.184     rillig   5771:   * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
                   5772:     configuration files for the package identified by PKG_SYSCONFVAR's shall be
                   5773:     placed.
1.1       dsieger  5774: 
1.184     rillig   5775: Based on the above variables, pkginstall determines the value of
1.239     dholland 5776: PKG_SYSCONFDIR, which is the only variable that may be used within a package to
1.184     rillig   5777: refer to its configuration directory. The algorithm used to set its value is
                   5778: basically the following:
1.1       dsieger  5779: 
1.184     rillig   5780:  1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
1.1       dsieger  5781: 
1.184     rillig   5782:  2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
                   5783:     package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
                   5784:     {PKG_SYSCONFSUBDIR}.
1.1       dsieger  5785: 
1.184     rillig   5786:  3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
1.1       dsieger  5787: 
1.184     rillig   5788: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
1.239     dholland 5789: OWN_DIRS. This causes it to be automatically created if needed. See
1.266     martin   5790: Section  20.1.1,    Directory manipulation    for further details. This does not
1.239     dholland 5791: apply to subdirectories of ${PKG_SYSCONFDIR}; they must be manually created
                   5792: with OWN_DIRS or MAKE_DIRS.
1.1       dsieger  5793: 
1.266     martin   5794: 20.2.2.  Telling the software where configuration files are
1.1       dsieger  5795: 
1.184     rillig   5796: Given that pkgsrc (and users!) expect configuration files to be in a known
1.239     dholland 5797: place, you need to teach each package where to install its files. In some cases
                   5798: you will have to patch the package Makefiles to achieve it. If you are lucky,
                   5799: though, it may be as easy as passing an extra flag to the configuration script.
                   5800: This is the case for packages using GNU autoconf:
1.1       dsieger  5801: 
1.184     rillig   5802: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1       dsieger  5803: 
1.184     rillig   5804: Note that this specifies where the package has to look for its configuration
1.239     dholland 5805: files, not where they will be installed. Fortunately, there is a different way
1.240     gutterid 5806: to specify the latter, as seen in the next section, although the combination is
                   5807: rather confusing at first glance.
1.1       dsieger  5808: 
1.266     martin   5809: 20.2.3.  Patching installation
1.1       dsieger  5810: 
1.239     dholland 5811: As discussed above, packages themselves must not touch the contents of $
1.184     rillig   5812: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
                   5813: will, out of the box, mess with the contents of that directory. So what is the
                   5814: correct procedure to fix this issue?
1.1       dsieger  5815: 
1.184     rillig   5816: You must teach the package (usually by manually patching it) to install any
                   5817: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
                   5818: This way, the PLIST registers them and the administrator always has the
                   5819: original copies available.
1.1       dsieger  5820: 
1.239     dholland 5821: It turns out that for packages using GNU autoconf it is possible to create the
                   5822: desired effect by setting sysconfdir on the make command line at install time.
                   5823: Consider this example taken from mail/mutt:
                   5824: 
                   5825: EGDIR=                  ${PREFIX}/share/examples/mutt
                   5826: INSTALL_MAKE_FLAGS=     ${MAKE_FLAGS} sysconfdir=${EGDIR}
                   5827: 
                   5828: Note that the EGDIR variable, though commonly used for this purpose, is local
                   5829: to that package and has no meaning outside it.
1.1       dsieger  5830: 
1.266     martin   5831: 20.2.4.  Declaring configuration files
1.1       dsieger  5832: 
1.239     dholland 5833: Once the required configuration files are in place (i.e., under the examples
                   5834: hierarchy), the pkginstall framework can use them as reference copies during
                   5835: the package installation to update what is in ${PKG_SYSCONFDIR}. To achieve
                   5836: this, the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
1.266     martin   5837: Section  20.1.2,    File manipulation    for further information about their syntax
1.239     dholland 5838: and their purpose. Here is an example, taken from the mail/mutt package:
                   5839: 
                   5840: EGDIR=                  ${PREFIX}/share/examples/mutt
                   5841: CONF_FILES=             ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
                   5842: 
                   5843: Note that (as in the previous section's example) the EGDIR variable is specific
                   5844: to the package and has no meaning outside it.
                   5845: 
                   5846: For reference, the complete example from Mutt is as follows:
                   5847: 
                   5848: CONFIGURE_ARGS+=        --sysconfdir=${PKG_SYSCONFDIR}
                   5849: EGDIR=                  ${PREFIX}/share/examples/mutt
                   5850: CONF_FILES=             ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
                   5851: INSTALLATION_DIRS+=     ${EGDIR}
                   5852: INSTALL_MAKE_FLAGS=     ${MAKE_FLAGS} sysconfdir=${EGDIR}
1.1       dsieger  5853: 
1.266     martin   5854: 20.2.5.  Disabling handling of configuration files
1.1       dsieger  5855: 
1.184     rillig   5856: The automatic copying of config files can be toggled by setting the environment
                   5857: variable PKG_CONFIG prior to package installation.
1.1       dsieger  5858: 
1.266     martin   5859: 20.3.  System startup scripts
1.1       dsieger  5860: 
1.184     rillig   5861: System startup scripts are special files because they must be installed in a
                   5862: place known by the underlying OS, usually outside the installation prefix.
1.266     martin   5863: Therefore, the same rules described in Section  20.1,    Files and directories
                   5864: outside the installation prefix    apply, and the same solutions can be used.
1.184     rillig   5865: However, pkginstall provides a special mechanism to handle these files.
1.1       dsieger  5866: 
1.184     rillig   5867: In order to provide system startup scripts, the package has to:
1.1       dsieger  5868: 
1.184     rillig   5869:  1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
1.223     nia      5870:     Considering the print/cups-base package as an example, it has a cupsd.sh in
                   5871:     its files directory.
1.95      wiz      5872: 
1.184     rillig   5873:  2. Tell pkginstall to handle it, appending the name of the script, without its
                   5874:     extension, to the RCD_SCRIPTS variable. Continuing the previous example:
1.95      wiz      5875: 
1.184     rillig   5876:     RCD_SCRIPTS+=   cupsd
1.95      wiz      5877: 
1.184     rillig   5878: Once this is done, pkginstall will do the following steps for each script in an
                   5879: automated fashion:
1.95      wiz      5880: 
1.184     rillig   5881:  1. Process the file found in the files directory applying all the
                   5882:     substitutions described in the FILES_SUBST variable.
1.1       dsieger  5883: 
1.184     rillig   5884:  2. Copy the script from the files directory to the examples hierarchy, $
1.239     dholland 5885:     {PREFIX}/share/examples/rc.d/. Note that this reference file must be
1.184     rillig   5886:     explicitly registered in the PLIST.
1.1       dsieger  5887: 
1.184     rillig   5888:  3. Add code to the installation scripts to copy the startup script from the
                   5889:     examples hierarchy into the system-wide startup scripts directory.
1.1       dsieger  5890: 
1.266     martin   5891: 20.3.1.  Disabling handling of system startup scripts
1.1       dsieger  5892: 
1.184     rillig   5893: The automatic copying of config files can be toggled by setting the environment
                   5894: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
                   5895: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
                   5896: rc.d/, no matter what the value of this variable is.
1.1       dsieger  5897: 
1.266     martin   5898: 20.4.  System users and groups
1.1       dsieger  5899: 
1.184     rillig   5900: If a package needs to create special users and/or groups during installation,
                   5901: it can do so by using the pkginstall framework.
1.1       dsieger  5902: 
1.184     rillig   5903: Users can be created by adding entries to the PKG_USERS variable. Each entry
                   5904: has the following syntax:
1.1       dsieger  5905: 
1.184     rillig   5906: user:group
1.1       dsieger  5907: 
1.184     rillig   5908: Further specification of user details may be done by setting per-user
                   5909: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
                   5910: user's description or comment. PKG_HOME.user is the user's home directory, and
                   5911: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
                   5912: and defaults to /sbin/nologin if not specified.
1.1       dsieger  5913: 
1.184     rillig   5914: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
                   5915: whose syntax is:
1.1       dsieger  5916: 
1.184     rillig   5917: group
1.1       dsieger  5918: 
1.184     rillig   5919: The numeric GID of the group may be set by defining PKG_GID.group.
1.1       dsieger  5920: 
1.184     rillig   5921: If a package needs to create the users and groups at an earlier stage, then it
                   5922: can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
                   5923: the phase before which the users and groups are created. In this case, the
                   5924: numeric UIDs and GIDs of the created users and groups are automatically
                   5925: hardcoded into the final installation scripts.
1.1       dsieger  5926: 
1.266     martin   5927: 20.5.  System shells
1.1       dsieger  5928: 
1.184     rillig   5929: Packages that install system shells should register them in the shell database,
                   5930: /etc/shells, to make things easier to the administrator. This must be done from
                   5931: the installation scripts to keep binary packages working on any system.
                   5932: pkginstall provides an easy way to accomplish this task.
1.1       dsieger  5933: 
1.184     rillig   5934: When a package provides a shell interpreter, it has to set the PKG_SHELL
                   5935: variable to its absolute file name. This will add some hooks to the
                   5936: installation scripts to handle it. Consider the following example, taken from
                   5937: shells/zsh:
1.1       dsieger  5938: 
1.184     rillig   5939: PKG_SHELL=      ${PREFIX}/bin/zsh
1.1       dsieger  5940: 
1.266     martin   5941: 20.5.1.  Disabling shell registration
1.1       dsieger  5942: 
1.184     rillig   5943: The automatic registration of shell interpreters can be disabled by the
                   5944: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
1.1       dsieger  5945: 
1.266     martin   5946: 20.6.  Fonts
1.1       dsieger  5947: 
1.184     rillig   5948: Packages that install X11 fonts should update the database files that index the
                   5949: fonts within each fonts directory. This can easily be accomplished within the
                   5950: pkginstall framework.
1.1       dsieger  5951: 
1.184     rillig   5952: When a package installs X11 fonts, it must list the directories in which fonts
1.266     martin   5953: are installed in the FONTS_DIRS.type variables, where type can be one of    ttf   ,
                   5954:    type1    or    x11   . This will add hooks to the installation scripts to run the
1.184     rillig   5955: appropriate commands to update the fonts database files within each of those
                   5956: directories. For convenience, if the directory path is relative, it is taken to
                   5957: be relative to the package's installation prefix. Consider the following
                   5958: example, taken from fonts/dbz-ttf:
1.1       dsieger  5959: 
1.184     rillig   5960: FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
1.1       dsieger  5961: 
1.266     martin   5962: 20.6.1.  Disabling automatic update of the fonts databases
1.1       dsieger  5963: 
1.184     rillig   5964: The automatic update of fonts databases can be disabled by the administrator by
                   5965: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
1.1       dsieger  5966: 
1.266     martin   5967: Chapter  21.  Making your package work
1.1       dsieger  5968: 
                   5969: Table of Contents
                   5970: 
1.154     rillig   5971: 21.1. General operation
                   5972:     21.1.1. How to pull in user-settable variables from mk.conf
                   5973:     21.1.2. User interaction
                   5974:     21.1.3. Handling licenses
                   5975:     21.1.4. Restricted packages
                   5976:     21.1.5. Handling dependencies
                   5977:     21.1.6. Handling conflicts with other packages
                   5978:     21.1.7. Packages that cannot or should not be built
                   5979:     21.1.8. Packages which should not be deleted, once installed
                   5980:     21.1.9. Handling packages with security problems
                   5981:     21.1.10. How to handle incrementing versions when fixing an existing
1.271     wiz      5982:     package
1.154     rillig   5983:     21.1.11. Substituting variable text in the package files (the SUBST
1.271     wiz      5984:     framework)
1.154     rillig   5985: 21.2. The fetch phase
                   5986:     21.2.1. Packages whose distfiles aren't available for plain downloading
                   5987:     21.2.2. How to handle modified distfiles with the 'old' name
                   5988:     21.2.3. Packages hosted on github.com
                   5989: 21.3. The configure phase
                   5990:     21.3.1. Shared libraries - libtool
                   5991:     21.3.2. Using libtool on GNU packages that already support libtool
                   5992:     21.3.3. GNU Autoconf/Automake
1.223     nia      5993:     21.3.4. Meson / ninja
1.260     wiz      5994:     21.3.5. Determining the endianness
1.154     rillig   5995: 21.4. Programming languages
                   5996:     21.4.1. C, C++, and Fortran
                   5997:     21.4.2. Java
1.205     wiz      5998:     21.4.3. Go
1.223     nia      5999:     21.4.4. Rust
                   6000:     21.4.5. Packages containing Perl scripts
                   6001:     21.4.6. Packages containing shell scripts
                   6002:     21.4.7. Other programming languages
1.154     rillig   6003: 21.5. The build phase
                   6004:     21.5.1. Compiling C and C++ code conditionally
                   6005:     21.5.2. How to handle compiler bugs
1.172     rillig   6006:     21.5.3. No such file or directory
1.266     martin   6007:     21.5.4. Undefined reference to    ...   
1.172     rillig   6008:     21.5.5. Running out of memory
1.154     rillig   6009: 21.6. The install phase
                   6010:     21.6.1. Creating needed directories
                   6011:     21.6.2. Where to install documentation
                   6012:     21.6.3. Installing highscore files
                   6013:     21.6.4. Adding DESTDIR support to packages
                   6014:     21.6.5. Packages with hardcoded paths to other interpreters
1.203     nia      6015:     21.6.6. Packages installing Perl modules
1.254     wiz      6016:     21.6.7. Packages installing pkg-config files
                   6017:     21.6.8. Packages installing info files
                   6018:     21.6.9. Packages installing man pages
                   6019:     21.6.10. Packages installing X11 fonts
                   6020:     21.6.11. Packages installing SGML or XML data
                   6021:     21.6.12. Packages installing extensions to the MIME database
                   6022:     21.6.13. Packages using intltool
                   6023:     21.6.14. Packages installing startup scripts
                   6024:     21.6.15. Packages installing TeX modules
                   6025:     21.6.16. Packages supporting running binaries in emulation
                   6026:     21.6.17. Packages installing hicolor icons
                   6027:     21.6.18. Packages installing desktop files
1.154     rillig   6028: 21.7. Marking packages as having problems
1.1       dsieger  6029: 
1.266     martin   6030: 21.1.  General operation
1.1       dsieger  6031: 
                   6032: One appealing feature of pkgsrc is that it runs on many different platforms. As
                   6033: a result, it is important to ensure, where possible, that packages in pkgsrc
                   6034: are portable. This chapter mentions some particular details you should pay
                   6035: attention to while working on pkgsrc.
                   6036: 
1.266     martin   6037: 21.1.1.  How to pull in user-settable variables from mk.conf
1.1       dsieger  6038: 
                   6039: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4       rillig   6040: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
                   6041: those variables in the preprocessor directives of make(1) (for example .if or
                   6042: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
                   6043: loads the user preferences.
1.1       dsieger  6044: 
                   6045: But note that some variables may not be completely defined after ../../mk/
                   6046: bsd.prefs.mk has been included, as they may contain references to variables
1.108     rillig   6047: that are not yet defined. In shell commands (the lines in Makefile that are
                   6048: indented with a tab) this is no problem, since variables are only expanded when
                   6049: they are used. But in the preprocessor directives mentioned above and in
                   6050: dependency lines (of the form target: dependencies) the variables are expanded
                   6051: at load time.
1.1       dsieger  6052: 
                   6053: Note
                   6054: 
1.108     rillig   6055: To check whether a variable can be used at load time, run pkglint -Wall on your
                   6056: package.
1.1       dsieger  6057: 
1.266     martin   6058: 21.1.2.  User interaction
1.1       dsieger  6059: 
                   6060: Occasionally, packages require interaction from the user, and this can be in a
                   6061: number of ways:
                   6062: 
                   6063:   * When fetching the distfiles, some packages require user interaction such as
                   6064:     entering username/password or accepting a license on a web page.
                   6065: 
                   6066:   * When extracting the distfiles, some packages may ask for passwords.
                   6067: 
                   6068:   * help to configure the package before it is built
                   6069: 
                   6070:   * help during the build process
                   6071: 
                   6072:   * help during the installation of a package
                   6073: 
1.108     rillig   6074: A package can set the INTERACTIVE_STAGE variable to define which stages need
                   6075: interaction. This should be done in the package's Makefile, e.g.:
1.1       dsieger  6076: 
                   6077: INTERACTIVE_STAGE=      configure install
                   6078: 
                   6079: The user can then decide to skip this package by setting the BATCH variable.
1.108     rillig   6080: Packages that require interaction are also excluded from bulk builds.
1.1       dsieger  6081: 
1.266     martin   6082: 21.1.3.  Handling licenses
1.1       dsieger  6083: 
                   6084: Authors of software can choose the licence under which software can be copied.
1.111     sevan    6085: The Free Software Foundation has declared some licenses "Free", and the Open
                   6086: Source Initiative has a definition of "Open Source".
                   6087: 
                   6088: By default, pkgsrc allows packages with Free or Open Source licenses to be
                   6089: built. To allow packages with other licenses to be built as well, the pkgsrc
                   6090: user needs to add these licenses to the ACCEPTABLE_LICENSES variable in mk.conf
                   6091: . Note that this variable only affects which packages may be built, while the
                   6092: license terms often also restrict the actual use of the package and its
                   6093: redistribution.
1.1       dsieger  6094: 
                   6095: One might want to only install packages with a BSD license, or the GPL, and not
1.20      jnemeth  6096: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
1.111     sevan    6097: variable. The pkgsrc user can override the default by setting the
                   6098: ACCEPTABLE_LICENSES variable with "=" instead of "+=". The licenses accepted by
                   6099: default are defined in the DEFAULT_ACCEPTABLE_LICENSES variable in the file
                   6100: pkgsrc/mk/license.mk.
1.1       dsieger  6101: 
                   6102: The license tag mechanism is intended to address copyright-related issues
                   6103: surrounding building, installing and using a package, and not to address
1.20      jnemeth  6104: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
                   6105: redistribution restrictions should set these tags.
1.1       dsieger  6106: 
                   6107: Denoting that a package may be copied according to a particular license is done
                   6108: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
                   6109: string identifying the license, e.g. in graphics/xv:
                   6110: 
                   6111: LICENSE=        xv-license
                   6112: 
                   6113: When trying to build, the user will get a notice that the package is covered by
                   6114: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
                   6115: 
                   6116: % make
                   6117: ===> xv-3.10anb9 has an unacceptable license: xv-license.
                   6118: ===>     To view the license, enter "/usr/bin/make show-license".
                   6119: ===>     To indicate acceptance, add this line to your /etc/mk.conf:
                   6120: ===>     ACCEPTABLE_LICENSES+=xv-license
                   6121: *** Error code 1
                   6122: 
1.260     wiz      6123: In case a package requires multiple licenses, you can add all of them to the
                   6124: LICENSE variable, connected with the upper-case keyword AND. If the user has a
                   6125: choice between multiple licenses, you can add them connected with the
                   6126: upper-case keyword OR, for example:
                   6127: 
                   6128: LICENSE=        isc AND apache-2.0
                   6129: LICENSE=        2-clause-bsd OR ruby-license
                   6130: 
1.1       dsieger  6131: The license can be viewed with make show-license, and if the user so chooses,
1.4       rillig   6132: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1       dsieger  6133: should not in the future fail because of that license:
                   6134: 
                   6135: ACCEPTABLE_LICENSES+=xv-license
                   6136: 
1.111     sevan    6137: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
                   6138: is deprecated because it does not crisply refer to a particular license text.
                   6139: Another problem with such usage is that it does not enable a user to tell
                   6140: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
                   6141: for all packages with that tag.
                   6142: 
1.266     martin   6143: 21.1.3.1.  Adding a package with a new license
1.1       dsieger  6144: 
1.49      rodent   6145: When adding a package with a new license, the following steps are required:
                   6146: 
1.111     sevan    6147:  1. Check whether the license qualifies as Free or Open Source by referencing
                   6148:     Various Licenses and Comments about Them and Licenses by Name | Open Source
                   6149:     Initiative. If this is the case, the filename in pkgsrc/licenses/ does not
                   6150:     need the -license suffix, and the license name should be added to:
1.49      rodent   6151: 
                   6152:       + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
                   6153: 
                   6154:       + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
                   6155:         license.c
                   6156: 
                   6157:  2. The license text should be added to pkgsrc/licenses for displaying. A list
                   6158:     of known licenses can be seen in this directory.
1.1       dsieger  6159: 
1.266     martin   6160: 21.1.3.2.  Change to the license
1.1       dsieger  6161: 
1.111     sevan    6162: When the license changes (in a way other than formatting), make sure that the
                   6163: new license has a different name (e.g., append the version number if it exists,
                   6164: or the date). Just because a user told pkgsrc to build programs under a
                   6165: previous version of a license does not mean that pkgsrc should build programs
                   6166: under the new licenses. The higher-level point is that pkgsrc does not evaluate
                   6167: licenses for reasonableness; the only test is a mechanistic test of whether a
                   6168: particular text has been approved by either of two bodies (FSF or OSI).
1.1       dsieger  6169: 
1.266     martin   6170: 21.1.4.  Restricted packages
1.1       dsieger  6171: 
1.111     sevan    6172: Some licenses restrict how software may be re-distributed. By declaring the
                   6173: restrictions, package tools can automatically refrain from e.g. placing binary
                   6174: packages on FTP sites.
                   6175: 
                   6176: There are four possible restrictions, which are the cross product of sources
                   6177: (distfiles) and binaries not being placed on FTP sites and CD-ROMs. Because
                   6178: this is rarely the exact language in any license, and because non-Free licenses
                   6179: tend to be different from each other, pkgsrc adopts a definition of FTP and
                   6180: CD-ROM. "FTP" means making the source or binary file available over the
                   6181: Internet at no charge. "CD-ROM" means making the source or binary available on
                   6182: some kind of media, together with other source and binary packages, which is
                   6183: sold for a distribution charge.
1.1       dsieger  6184: 
                   6185: In order to encode these restrictions, the package system defines five make
                   6186: variables that can be set to note these restrictions:
                   6187: 
                   6188:   * RESTRICTED
                   6189: 
                   6190:     This variable should be set whenever a restriction exists (regardless of
                   6191:     its kind). Set this variable to a string containing the reason for the
                   6192:     restriction. It should be understood that those wanting to understand the
                   6193:     restriction will have to read the license, and perhaps seek advice of
                   6194:     counsel.
                   6195: 
                   6196:   * NO_BIN_ON_CDROM
                   6197: 
                   6198:     Binaries may not be placed on CD-ROM containing other binary packages, for
                   6199:     which a distribution charge may be made. In this case, set this variable to
                   6200:     ${RESTRICTED}.
                   6201: 
                   6202:   * NO_BIN_ON_FTP
                   6203: 
                   6204:     Binaries may not made available on the Internet without charge. In this
                   6205:     case, set this variable to ${RESTRICTED}. If this variable is set, binary
                   6206:     packages will not be included on ftp.NetBSD.org.
                   6207: 
                   6208:   * NO_SRC_ON_CDROM
                   6209: 
                   6210:     Distfiles may not be placed on CD-ROM, together with other distfiles, for
                   6211:     which a fee may be charged. In this case, set this variable to $
                   6212:     {RESTRICTED}.
                   6213: 
                   6214:   * NO_SRC_ON_FTP
                   6215: 
                   6216:     Distfiles may not made available via FTP at no charge. In this case, set
                   6217:     this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
                   6218:     will not be mirrored on ftp.NetBSD.org.
                   6219: 
1.111     sevan    6220: Please note that packages will be removed from pkgsrc when the distfiles are
1.33      wiz      6221: not distributable and cannot be obtained for a period of one full quarter
1.111     sevan    6222: branch. Packages with manual/interactive fetch must have a maintainer and it is
                   6223: his/her responsibility to ensure this.
1.33      wiz      6224: 
1.266     martin   6225: 21.1.5.  Handling dependencies
1.1       dsieger  6226: 
1.175     gutterid 6227: Your package may depend on some other package being present, and there are
                   6228: various ways of expressing this dependency. pkgsrc supports the DEPENDS,
                   6229: BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS definitions, the USE_TOOLS
                   6230: definition, as well as dependencies via buildlink3.mk, which is the preferred
                   6231: way to handle dependencies, and which uses the variables named above. See
1.266     martin   6232: Chapter  18, Buildlink methodology for more information.
1.175     gutterid 6233: 
                   6234: The basic difference is that the DEPENDS definition registers that
                   6235: pre-requisite in the binary package so it will be pulled in when the binary
                   6236: package is later installed, whilst the BUILD_DEPENDS, TOOL_DEPENDS, and
                   6237: TEST_DEPENDS definitions do not, marking a dependency that is only needed for
1.266     martin   6238: building or testing the resulting package. See also Chapter  14, Creating a new
1.175     gutterid 6239: pkgsrc package from scratch for more information.
                   6240: 
                   6241: This means that if you only need a package present whilst you are building or
                   6242: testing, it should be noted as a TOOL_DEPENDS, BUILD_DEPENDS, or TEST_DEPENDS.
                   6243: When cross-compiling, TOOL_DEPENDS are native packages, i.e. packages for the
                   6244: architecture where the package is built; BUILD_DEPENDS are target packages,
                   6245: i.e., packages for the architecture for which the package is built.
1.1       dsieger  6246: 
1.175     gutterid 6247: The format for a DEPENDS, BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS
                   6248: definition is:
1.1       dsieger  6249: 
                   6250: <pre-req-package-name>:../../<category>/<pre-req-package>
                   6251: 
1.266     martin   6252: Please note that the    pre-req-package-name    may include any of the wildcard
1.1       dsieger  6253: version numbers recognized by pkg_info(1).
                   6254: 
1.55      wiz      6255:  1. If your package needs another package's binaries or libraries to build and
1.1       dsieger  6256:     run, and if that package has a buildlink3.mk file available, use it:
                   6257: 
                   6258:     .include "../../graphics/jpeg/buildlink3.mk"
                   6259: 
1.55      wiz      6260:  2. If your package needs another package's binaries or libraries only for
                   6261:     building, and if that package has a buildlink3.mk file available, use it:
                   6262: 
                   6263:     .include "../../graphics/jpeg/buildlink3.mk"
                   6264: 
                   6265:     but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
                   6266:     This case is rather rare.
                   6267: 
                   6268:  3. If your package needs binaries from another package to build, use the
1.156     leot     6269:     TOOL_DEPENDS definition:
                   6270: 
                   6271:     TOOL_DEPENDS+= itstool-[0-9]*:../../textproc/itstool
1.1       dsieger  6272: 
1.156     leot     6273:  4. If your package needs static libraries to link against, header files to
                   6274:     include, etc. from another package to build, use the BUILD_DEPENDS
                   6275:     definition.
1.1       dsieger  6276: 
1.156     leot     6277:  5. If your package needs a library with which to link and there is no
1.26      spz      6278:     buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
                   6279:     because the include files and libraries will be hidden from the compiler.
1.1       dsieger  6280: 
1.156     leot     6281:  6. If your package needs some executable to be able to run correctly and if
1.26      spz      6282:     there's no buildlink3.mk file, this is specified using the DEPENDS
                   6283:     variable. The print/lyx package needs to be able to execute the latex
1.129     wiz      6284:     binary from the tex-latex-bin package when it runs, and that is specified:
1.1       dsieger  6285: 
1.129     wiz      6286:     DEPENDS+=        tex-latex-bin-[0-9]*:../../print/tex-latex-bin
1.1       dsieger  6287: 
1.175     gutterid 6288:  7. If your package includes a test suite that has extra dependencies only
1.266     martin   6289:     required for this purpose (frequently this can be run as a    make test   
1.175     gutterid 6290:     target), use the TEST_DEPENDS variable.
                   6291: 
                   6292:  8. You can use wildcards in package dependencies. Note that such wildcard
1.26      spz      6293:     dependencies are retained when creating binary packages. The dependency is
                   6294:     checked when installing the binary package and any package which matches
                   6295:     the pattern will be used. Wildcard dependencies should be used with care.
1.1       dsieger  6296: 
1.266     martin   6297:     The    -[0-9]*    should be used instead of    -*    to avoid potentially ambiguous
                   6298:     matches such as    tk-postgresql    matching a    tk-*    DEPENDS.
1.1       dsieger  6299: 
                   6300:     Wildcards can also be used to specify that a package will only build
                   6301:     against a certain minimum version of a pre-requisite:
                   6302: 
1.26      spz      6303:     DEPENDS+=       ImageMagick>=6.0:../../graphics/ImageMagick
1.1       dsieger  6304: 
1.26      spz      6305:     This means that the package will build using version 6.0 of ImageMagick or
                   6306:     newer. Such a dependency may be warranted if, for example, the command line
                   6307:     options of an executable have changed.
                   6308: 
1.183     wiz      6309:     If you need to depend on minimum versions of libraries, set
                   6310:     BUILDLINK_API_DEPENDS.pkg to the appropriate pattern before including its
                   6311:     buildlink3.mk file, e.g.
                   6312: 
                   6313:     BUILDLINK_API_DEPENDS.jpeg+=    jpeg>=9.0
                   6314:     .include "../../graphics/jpeg/buildlink3.mk"
1.1       dsieger  6315: 
                   6316:     For security fixes, please update the package vulnerabilities file. See
1.266     martin   6317:     Section  21.1.9,    Handling packages with security problems    for more
1.1       dsieger  6318:     information.
                   6319: 
                   6320: If your package needs files from another package to build, add the relevant
                   6321: distribution files to DISTFILES, so they will be extracted automatically. See
                   6322: the print/ghostscript package for an example. (It relies on the jpeg sources
                   6323: being present in source form during the build.)
                   6324: 
1.266     martin   6325: 21.1.6.  Handling conflicts with other packages
1.1       dsieger  6326: 
1.226     gutterid 6327: Your package may conflict with other packages users might already have
                   6328: installed on their system, e.g., if your package installs the same set of files
1.227     wiz      6329: as another package in the pkgsrc tree.
1.1       dsieger  6330: 
1.142     leot     6331: For example, x11/libXaw3d and x11/Xaw-Xpm install the same shared library, thus
                   6332: you set in pkgsrc/x11/libXaw3d/Makefile:
1.1       dsieger  6333: 
1.142     leot     6334: CONFLICTS=      Xaw-Xpm-[0-9]*
1.1       dsieger  6335: 
1.142     leot     6336: and in pkgsrc/x11/Xaw-Xpm/Makefile:
1.1       dsieger  6337: 
1.142     leot     6338: CONFLICTS=      libXaw3d-[0-9]*
1.1       dsieger  6339: 
1.142     leot     6340: pkg_add(1) is able to detect attempts to install packages that conflict with
                   6341: existing packages and abort. However, in many situations this is too late in
                   6342: the process. Binary package managers will not know about the conflict until
                   6343: they attempt to install the package after already downloading it and all its
                   6344: dependencies. Users may also waste time building a package and its dependencies
                   6345: only to find out at the end that it conflicts with another package they have
                   6346: installed.
                   6347: 
                   6348: To avoid these issues CONFLICTS entries should be added in all cases where it
                   6349: is known that packages conflict with each other. These CONFLICTS entries are
                   6350: exported in pkg_summary(5) files and consumed by binary package managers to
                   6351: inform users that packages cannot be installed onto the target system.
1.1       dsieger  6352: 
1.266     martin   6353: 21.1.7.  Packages that cannot or should not be built
1.1       dsieger  6354: 
                   6355: There are several reasons why a package might be instructed to not build under
                   6356: certain circumstances. If the package builds and runs on most platforms, the
1.83      dholland 6357: exceptions should be noted with BROKEN_ON_PLATFORM. If the package builds and
                   6358: runs on a small handful of platforms, set BROKEN_EXCEPT_ON_PLATFORM instead.
                   6359: Both BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM are OS triples
                   6360: (OS-version-platform) that can use glob-style wildcards.
                   6361: 
1.114     maya     6362: If a package is not appropriate for some platforms (as opposed to merely
1.83      dholland 6363: broken), a different set of variables should be used as this affects failure
                   6364: reporting and statistics. If the package is appropriate for most platforms, the
                   6365: exceptions should be noted with NOT_FOR_PLATFORM. If the package is appropriate
                   6366: for only a small handful of platforms (often exactly one), set
                   6367: ONLY_FOR_PLATFORM instead. Both ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS
                   6368: triples (OS-version-platform) that can use glob-style wildcards.
1.1       dsieger  6369: 
                   6370: Some packages are tightly bound to a specific version of an operating system,
                   6371: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
                   6372: with other versions of the OS, and should be uploaded to a version specific
                   6373: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
1.266     martin   6374: to    yes   . This variable is not currently used by any of the package system
1.1       dsieger  6375: internals, but may be used in the future.
                   6376: 
                   6377: If the package should be skipped (for example, because it provides
                   6378: functionality already provided by the system), set PKG_SKIP_REASON to a
                   6379: descriptive message. If the package should fail because some preconditions are
                   6380: not met, set PKG_FAIL_REASON to a descriptive message.
                   6381: 
1.266     martin   6382: 21.1.8.  Packages which should not be deleted, once installed
1.1       dsieger  6383: 
                   6384: To ensure that a package may not be deleted, once it has been installed, the
                   6385: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.266     martin   6386: carried into any binary package that is made from this pkgsrc entry. A    
                   6387: preserved    package will not be deleted using pkg_delete(1) unless the    -f   
1.1       dsieger  6388: option is used.
                   6389: 
1.266     martin   6390: 21.1.9.  Handling packages with security problems
1.1       dsieger  6391: 
1.247     wiz      6392: When a vulnerability is found, this should be noted in pkgsrc/doc/
                   6393: pkg-vulnerabilities. Entries in that file consist of three parts:
1.205     wiz      6394: 
                   6395:   * package version pattern
                   6396: 
                   6397:   * type of vulnerability (please cut'n'paste an existing one where possible)
                   6398: 
                   6399:   * URL providing additional information about the issue
                   6400: 
                   6401: For the package version pattern please always use `<' to mark an upper bound
                   6402: (not `<='!). This will avoid possible problems due unrelated PKGREVISION bumps
                   6403: not related to security fixes. Lower bounds can be added too, using '>' or '>=
1.266     martin   6404: '. For example,    foo>=1<1.2    would mark versions 1.0 (included) to 1.2
                   6405: (excluded) of    foo    as affected by the security issue.
1.205     wiz      6406: 
                   6407: Entries should always be added at the bottom of the file.
                   6408: 
                   6409: When fixing packages, please modify the upper bound of the corresponding entry.
                   6410: To continue the previous example, if a fix was backported to version 1.1nb2,
1.266     martin   6411: change the previous pattern to    foo>=1<1.1nb2   .
1.205     wiz      6412: 
                   6413: To locally test a package version pattern against a PKGNAME you can use the 
                   6414: pkg_admin pmatch command.
                   6415: 
                   6416: The URL should be as permanent as possible and provide as much information
                   6417: about the issue as possible. CVE entries are preferred.
                   6418: 
                   6419: After committing that file, ask pkgsrc-security@NetBSD.org to update the file
                   6420: on ftp.NetBSD.org.
1.1       dsieger  6421: 
                   6422: After fixing the vulnerability by a patch, its PKGREVISION should be increased
                   6423: (this is of course not necessary if the problem is fixed by using a newer
1.32      wiz      6424: release of the software), and the pattern in the pkg-vulnerabilities file must
                   6425: be updated.
1.1       dsieger  6426: 
                   6427: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
                   6428: submit a pullup request!
                   6429: 
                   6430: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
                   6431: a weekly cron job.
                   6432: 
1.205     wiz      6433: In case a security issue is disputed, please contact
                   6434: pkgsrc-security@NetBSD.org.
                   6435: 
1.266     martin   6436: 21.1.10.  How to handle incrementing versions when fixing an existing package
1.1       dsieger  6437: 
                   6438: When making fixes to an existing package it can be useful to change the version
                   6439: number in PKGNAME. To avoid conflicting with future versions by the original
1.266     martin   6440: author, a    nb1   ,    nb2   , ... suffix can be used on package versions by setting
                   6441: PKGREVISION=1 (2, ...). The    nb    is treated like a    .    by the package tools.
1.1       dsieger  6442: e.g.
                   6443: 
                   6444: DISTNAME=       foo-17.42
                   6445: PKGREVISION=    9
                   6446: 
1.266     martin   6447: will result in a PKGNAME of    foo-17.42nb9   . If you want to use the original
                   6448: value of PKGNAME without the    nbX    suffix, e.g. for setting DIST_SUBDIR, use
1.1       dsieger  6449: PKGNAME_NOREV.
                   6450: 
                   6451: When a new release of the package is released, the PKGREVISION should be
                   6452: removed, e.g. on a new minor release of the above package, things should be
                   6453: like:
                   6454: 
                   6455: DISTNAME=       foo-17.43
                   6456: 
                   6457: PKGREVISION should be incremented for any non-trivial change in the resulting
                   6458: binary package. Without a PKGREVISION bump, someone with the previous version
                   6459: installed has no way of knowing that their package is out of date. Thus,
                   6460: changes without increasing PKGREVISION are essentially labeled "this is so
                   6461: trivial that no reasonable person would want to upgrade", and this is the rough
                   6462: test for when increasing PKGREVISION is appropriate. Examples of changes that
                   6463: do not merit increasing PKGREVISION are:
                   6464: 
1.14      jmcneill 6465:   * Changing HOMEPAGE, MAINTAINER, OWNER, or comments in Makefile.
1.1       dsieger  6466: 
                   6467:   * Changing build variables if the resulting binary package is the same.
                   6468: 
                   6469:   * Changing DESCR.
                   6470: 
                   6471:   * Adding PKG_OPTIONS if the default options don't change.
                   6472: 
                   6473: Examples of changes that do merit an increase to PKGREVISION include:
                   6474: 
                   6475:   * Security fixes
                   6476: 
                   6477:   * Changes or additions to a patch file
                   6478: 
                   6479:   * Changes to the PLIST
                   6480: 
1.12      weinem   6481:   * A dependency is changed or renamed.
                   6482: 
1.1       dsieger  6483: PKGREVISION must also be incremented when dependencies have ABI changes.
                   6484: 
1.266     martin   6485: 21.1.11.  Substituting variable text in the package files (the SUBST framework)
1.1       dsieger  6486: 
1.180     rillig   6487: When you want to replace the same text in multiple files, or multiple times in
                   6488: the same file, it is cumbersome to maintain a patch file for this. This is
                   6489: where the SUBST framework steps in. It provides an easy-to-use interface for
                   6490: replacing text in files. It just needs the following information:
1.172     rillig   6491: 
1.180     rillig   6492:   * In which phase of the package build cycle should the replacement happen?
1.172     rillig   6493: 
1.180     rillig   6494:   * In which files should the replacement happen?
1.172     rillig   6495: 
                   6496:   * Which text should be replaced with what?
                   6497: 
1.180     rillig   6498: This information is encoded in a block of SUBST variables. A minimal example
                   6499: is:
                   6500: 
                   6501: SUBST_CLASSES+=         paths
                   6502: SUBST_STAGE.paths=      pre-configure
                   6503: SUBST_FILES.paths=      src/*.c
                   6504: SUBST_SED.paths=        -e 's,/usr/local,${PREFIX},g'
                   6505: 
                   6506: Translated into English, it means: In the pre-configure stage (that is, after
                   6507: applying the patches from the patches/ directory and before running the
                   6508: configure script and the portability check), replace the text /usr/local with
                   6509: the content of the variable PREFIX.
                   6510: 
                   6511: Each SUBST block starts by appending an identifier to SUBST_CLASSES (note the +
                   6512: =). This identifier can be chosen freely by the package. If there should ever
                   6513: be duplicate identifiers, the pkgsrc infrastructure will catch this and fail
                   6514: early, so don't worry about name collisions.
                   6515: 
                   6516: Except for SUBST_CLASSES, all variables in a SUBST block are parameterized
                   6517: using this identifier. In the remainder of this section, these parameterized
                   6518: variables are written as SUBST_STAGE.*.
                   6519: 
                   6520: SUBST_CLASSES+=         paths
                   6521: SUBST_STAGE.paths=      pre-configure
                   6522: SUBST_MESSAGE.paths=    Fixing absolute paths.
                   6523: SUBST_FILES.paths=      src/*.c
                   6524: SUBST_FILES.paths+=     scripts/*.sh
                   6525: SUBST_SED.paths=        -e 's,"/usr/local,"${PREFIX},g'
                   6526: SUBST_SED.paths+=       -e 's,"/var/log,"${VARBASE}/log,g'
                   6527: SUBST_VARS.paths=       LOCALBASE PREFIX PKGVERSION
                   6528: 
                   6529: To get a complete picture about the SUBST substitutions, run bmake
                   6530: show-all-subst. If something doesn't work as expected, run pkglint on the
                   6531: package, which detects several typical mistakes surrounding the SUBST blocks.
                   6532: For any questions that might remain after this, have a look at mk/subst.mk.
                   6533: 
1.266     martin   6534: 21.1.11.1.  Choosing the time where the substitutions happen
1.180     rillig   6535: 
                   6536: The SUBST_STAGE.* is one of {pre,do,post}-
                   6537: {extract,patch,configure,build,test,install}. Of these, pre-configure is used
                   6538: most often, by far. The most popular stages are, in chronological order:
                   6539: 
                   6540: post-extract
                   6541: 
                   6542:     The substitutions are applied immediately after the distfiles are
                   6543:     extracted. Running bmake extract on the package will leave no traces of the
                   6544:     original files.
                   6545: 
                   6546:     When the substitution applies to files for which there is also a patch in
                   6547:     the patches/ directory, this means that the patches will be computed based
                   6548:     on the result of the substitution. When these patches are sent to the
                   6549:     upstream maintainer later, to be fixed in the upstream package, these
                   6550:     patches may no longer match what the upstream author is used to. Because of
                   6551:     this, pre-configure is often a better choice.
                   6552: 
                   6553: pre-configure
                   6554: 
                   6555:     The substitutions are applied after the patches from the patches/
                   6556:     directory. This makes it possible to run bmake patch on the package, after
                   6557:     which the patches can be edited using the tools pkgvi and mkpatches from
                   6558:     the pkgtools/pkgdiff package.
                   6559: 
                   6560:     When updating the patches, it is helpful to explicitly separate the bmake
                   6561:     patch from the bmake configure, and to only edit the patches between these
                   6562:     commands. Otherwise the substitutions from the SUBST block will end up in
                   6563:     the patch file. When this happens in really obvious ways, pkglint will
                   6564:     complain about patches that contain a hard-coded /usr/pkg instead of the
                   6565:     correct and intended @PREFIX@, but it can only detect these really obvious
                   6566:     cases.
                   6567: 
                   6568: do-configure
                   6569: 
                   6570:     This stage should only be used if the package defines a pre-configure
                   6571:     action itself, and the substitution must happen after that. Typical
                   6572:     examples are packages that use the pre-configure stage to regenerate the
                   6573:     GNU configure script from configure.ac.
                   6574: 
                   6575: post-configure
                   6576: 
                   6577:     This stage is used to fix up any mistakes by the configure stage.
                   6578: 
                   6579: pre-build
                   6580: 
                   6581:     This stage should only be used for substitutions that are clearly related
                   6582:     to building the package, not for fixing the configuration. Substitutions
                   6583:     for pathnames (such as replacing /usr/local with ${PREFIX}) or user names
                   6584:     (such as replacing @MY_USER@ with the actual username) belong in
                   6585:     pre-configure or post-configure instead.
                   6586: 
                   6587: post-build
                   6588: 
                   6589:     Just as with pre-build, this stage should only be used for substitutions
                   6590:     that are clearly related to building the package, not for fixing the
                   6591:     configuration. Substitutions for pathnames (such as replacing /usr/local
                   6592:     with ${PREFIX}) or user names (such as replacing @MY_USER@ with the actual
                   6593:     username) belong in pre-configure or post-configure instead.
                   6594: 
                   6595:     A typical use is to update pkg-config files to include the rpath compiler
                   6596:     options.
                   6597: 
                   6598: pre-install
                   6599: 
                   6600:     In general, the install phase should be as simple as possible. As with the
                   6601:     pre-build and post-build stages, it should not be used to fix pathnames or
                   6602:     user names, these belong in pre-configure instead. There are only few
                   6603:     legitimate use cases for applying substitutions in this stage.
                   6604: 
1.266     martin   6605: 21.1.11.2.  Choosing the files where the substitutions happen
1.180     rillig   6606: 
                   6607: The SUBST_FILES.* variable contains a list of filename patterns. These patterns
                   6608: are relative to WRKSRC since that is where most substitutions happen. A typical
                   6609: example is:
                   6610: 
                   6611: SUBST_FILES.path=       Makefile */Makefile */*/Makefile *.[ch]
                   6612: 
                   6613: The above patterns, especially the last, are quite broad. The SUBST
                   6614: implementation checks that each filename pattern that is mentioned here has an
                   6615: effect. For example, if none of the */*/Makefile files contains the patterns to
                   6616: be found and substituted, that filename pattern is redundant and should be left
1.181     rillig   6617: out. By default, the SUBST framework will complain with an error message. If
                   6618: the text to be substituted occurs in some of the files from a single pattern,
                   6619: but not in all of them, that is totally ok, and the SUBST framework will only
                   6620: print an INFO message for those files.
1.180     rillig   6621: 
                   6622: If there is a good reason for having redundant filename patterns, set
1.181     rillig   6623: SUBST_NOOP_OK.* to yes.
1.180     rillig   6624: 
                   6625: Another popular way of choosing the files for the substitutions is via a shell
                   6626: command, like this:
                   6627: 
1.181     rillig   6628: C_FILES_CMD=            cd ${WRKSRC} && ${FIND} . -name '*.c'
1.180     rillig   6629: SUBST_FILES.path=       ${C_FILES_CMD:sh}
                   6630: 
                   6631: The variable name C_FILES_CMD in this example is freely chosen and independent
                   6632: of the SUBST framework.
                   6633: 
                   6634: In this variant, the SUBST_FILES.* variable lists each file individually.
                   6635: Thereby chances are higher that there are filename patterns in which no
                   6636: substitution happens. Since the SUBST framework cannot know whether the
                   6637: filename patterns in SUBST_FILES.* have been explicitly listed in the Makefile
                   6638: (where any redundant filename pattern would be suspicious) or been generated by
                   6639: a shell command (in which redundant filename patterns are more likely and to be
                   6640: expected), it will complain about these redundant filename patterns. Therefore,
                   6641: SUBST blocks that use a shell command to generate the list of filename patterns
                   6642: often need to set SUBST_NOOP_OK.* to yes.
                   6643: 
1.266     martin   6644: 21.1.11.3.  Choosing what to substitute
1.180     rillig   6645: 
                   6646: In most cases, the substitutions are given using one or more sed(1) commands,
                   6647: like this:
                   6648: 
                   6649: SUBST_SED.path=         -e 's|/usr/local|${PREFIX}|g'
                   6650: 
                   6651: Each of the sed commands needs to be preceded by the -e option and should be
                   6652: specified on a line of its own, to avoid hiding short sed commands at the end
                   6653: of a line.
                   6654: 
                   6655: Since the sed commands often contain shell metacharacters as the separator (the
                   6656: | in the above example), it is common to enclose them in single quotes.
                   6657: 
                   6658: A common substitution is to replace placeholders of the form @VARNAME@ with
                   6659: their pkgsrc counterpart variable ${VARNAME}. A typical example is:
                   6660: 
                   6661: SUBST_VARS.path=        PREFIX
                   6662: 
1.181     rillig   6663: This type of substitutions is typically done by the GNU configure scripts
                   6664: during the do-configure stage, but in some cases these need to be overridden.
                   6665: The same pattern is also used when a package defines patches that replace
                   6666: previously hard-coded paths like /usr/local with a @PREFIX@ placeholder first,
                   6667: which then gets substituted by the actual ${PREFIX} in the pre-configure stage.
                   6668: In many of these cases, it works equally well to just use the SUBST framework
                   6669: to directly replace /usr/local with ${PREFIX}, thereby omitting the
                   6670: intermediate patch file.
1.180     rillig   6671: 
                   6672: If the above is not flexible enough, it is possible to not use sed at all for
                   6673: the substitution but to specify an entirely different command, like this:
                   6674: 
                   6675: SUBST_FILTER_CMD.path=  LC_ALL=C ${TR} -d '\r'
1.1       dsieger  6676: 
1.180     rillig   6677: This is used for the few remaining packages in which the distributed files use
                   6678: Windows-style line endings that need to be converted to UNIX-style line
                   6679: endings.
1.1       dsieger  6680: 
1.266     martin   6681: 21.1.11.4.  Other SUBST variables
1.172     rillig   6682: 
1.180     rillig   6683: When a SUBST block is applied during a package build, a message is logged. The
                   6684: default message is fine for most purposes but can be overridden by setting
                   6685: SUBST_MESSAGE.* to an individual message.
1.1       dsieger  6686: 
1.266     martin   6687: 21.2.  The fetch phase
1.1       dsieger  6688: 
1.266     martin   6689: 21.2.1.  Packages whose distfiles aren't available for plain downloading
1.1       dsieger  6690: 
                   6691: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
                   6692: a make fetch will call files/getsite.sh with the name of each file to download
                   6693: as an argument, expecting it to output the URL of the directory from which to
                   6694: download it. graphics/ns-cult3d is an example of this usage.
                   6695: 
                   6696: If the download can't be automated, because the user must submit personal
                   6697: information to apply for a password, or must pay for the source, or whatever,
                   6698: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
                   6699: before aborting the build. Example:
                   6700: 
                   6701: FETCH_MESSAGE=  "Please download the files"
                   6702: FETCH_MESSAGE+= "    "${DISTFILES:Q}
                   6703: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
                   6704: 
1.266     martin   6705: 21.2.2.  How to handle modified distfiles with the 'old' name
1.1       dsieger  6706: 
                   6707: Sometimes authors of a software package make some modifications after the
                   6708: software was released, and they put up a new distfile without changing the
                   6709: package's version number. If a package is already in pkgsrc at that time, the
                   6710: checksum will no longer match. The contents of the new distfile should be
                   6711: compared against the old one before changing anything, to make sure the
                   6712: distfile was really updated on purpose, and that no trojan horse or so crept
                   6713: in. Please mention that the distfiles were compared and what was found in your
1.54      rodent   6714: commit message.
                   6715: 
                   6716: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
1.109     wiz      6717: directory name, usually based on PKGNAME_NOREV (but take care with python or
                   6718: ruby packages, where PKGNAME includes a variable prefix). All DISTFILES and
                   6719: PATCHFILES for this package will be put in that subdirectory of the local
1.266     martin   6720: distfiles directory. (See Section  21.1.10,    How to handle incrementing versions
                   6721: when fixing an existing package    for more details.) In case this happens more
1.109     wiz      6722: often, PKGNAME can be used (thus including the nbX suffix) or a date stamp can
                   6723: be appended, like ${PKGNAME_NOREV}-YYYYMMDD.
1.54      rodent   6724: 
                   6725: DIST_SUBDIR is also used when a distfile's name does not contain a version and
                   6726: the distfile is apt to change. In cases where the likelihood of this is very
                   6727: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
                   6728: removed unless the distfile name changes, even if a package is being moved or
                   6729: renamed.
                   6730: 
                   6731: Do not forget regenerating the distinfo file after that, since it contains the
                   6732: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
                   6733: installed package is different. Furthermore, a mail to the package's authors
                   6734: seems appropriate telling them that changing distfiles after releases without
                   6735: changing the file names is not good practice.
1.1       dsieger  6736: 
1.266     martin   6737: 21.2.3.  Packages hosted on github.com
1.88      tnn      6738: 
1.90      tnn      6739: Helper methods exist for packages hosted on github.com which will often have
                   6740: distfile names that clash with other packages, for example 1.0.tar.gz. Use one
                   6741: of the three recipes from below:
1.88      tnn      6742: 
1.266     martin   6743: 21.2.3.1.  Fetch based on a tagged release
1.88      tnn      6744: 
1.189     bacon    6745: If your distfile URL looks similar to https://github.com/username/example/
                   6746: archive/v1.0.zip, then you are packaging a tagged release.
1.88      tnn      6747: 
1.189     bacon    6748: DISTNAME=       example-1.0
1.90      tnn      6749: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
1.189     bacon    6750: #GITHUB_PROJECT= example    # can be omitted if same as DISTNAME
1.90      tnn      6751: GITHUB_TAG=     v${PKGVERSION_NOREV}
1.88      tnn      6752: EXTRACT_SUFX=   .zip
                   6753: 
1.230     gutterid 6754: Here, DISTNAME combined with use of GITHUB_TAG leads the file fetching
                   6755: infrastructure to save the resulting file locally as example-1.0.zip.
                   6756: 
1.266     martin   6757: 21.2.3.2.  Fetch based on a specific commit before the first release
1.189     bacon    6758: 
                   6759: If your distfile looks similar to https://github.com/username/example/archive/
                   6760: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit before the first
                   6761: release, then set the package version to 0.0.0.N, where N is the number of
                   6762: commits to the repository, and set GITHUB_TAG to the commit hash. This will
                   6763: (almost) ensure that the first tagged release will have a version greater than
                   6764: this one so that package upgrades will function properly.
                   6765: 
                   6766: DISTNAME=       example-0.0.0.347
                   6767: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6768: #GITHUB_PROJECT= example    # can be omitted if same as DISTNAME
                   6769: GITHUB_TAG=     988881adc9fc3655077dc2d4d757d480b5ea0e11
                   6770: 
1.266     martin   6771: 21.2.3.3.  Fetch based on a specific commit after a release
1.88      tnn      6772: 
1.189     bacon    6773: If your distfile looks similar to https://github.com/username/example/archive/
                   6774: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit after a release,
                   6775: then include the last release version and the commit count since that release
                   6776: in the package version and set GITHUB_TAG to the commit hash. The latest
                   6777: release and commit count are shown in the output of "git describe --tags":
                   6778: 
                   6779: # git clone https://github.com/username/example
                   6780: # cd example
                   6781: # git describe --tags
                   6782: 1.2.3-5-g988881a
1.88      tnn      6783: 
1.189     bacon    6784: DISTNAME=       example-1.2.3.5
                   6785: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6786: #GITHUB_PROJECT= example    # can be omitted if same as DISTNAME
1.90      tnn      6787: GITHUB_TAG=     988881adc9fc3655077dc2d4d757d480b5ea0e11
1.88      tnn      6788: 
1.266     martin   6789: 21.2.3.4.  Fetch based on release
1.88      tnn      6790: 
1.189     bacon    6791: If your distfile URL looks similar to https://github.com/username/example/
                   6792: releases/download/rel-1.6/offensive-1.6.zip, then you are packaging a release.
1.88      tnn      6793: 
1.90      tnn      6794: DISTNAME=       offensive-1.6
1.88      tnn      6795: PKGNAME=        ${DISTNAME:S/offensive/proper/}
1.90      tnn      6796: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
1.189     bacon    6797: GITHUB_PROJECT= example
1.90      tnn      6798: GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
                   6799: EXTRACT_SUFX=   .zip
1.88      tnn      6800: 
1.266     martin   6801: 21.3.  The configure phase
1.1       dsieger  6802: 
1.266     martin   6803: 21.3.1.  Shared libraries - libtool
1.1       dsieger  6804: 
                   6805: pkgsrc supports many different machines, with different object formats like
                   6806: a.out and ELF, and varying abilities to do shared library and dynamic loading
                   6807: at all. To accompany this, varying commands and options have to be passed to
                   6808: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
                   6809: especially if you don't have all the machines at your hand to test things. The
1.266     martin   6810: devel/libtool pkg can help here, as it just    knows    how to build both static
1.1       dsieger  6811: and dynamic libraries from a set of source files, thus being
                   6812: platform-independent.
                   6813: 
                   6814: Here's how to use libtool in a package in seven simple steps:
                   6815: 
                   6816:  1. Add USE_LIBTOOL=yes to the package Makefile.
                   6817: 
1.266     martin   6818:  2. For library objects, use    ${LIBTOOL} --mode=compile ${CC}    in place of    $
                   6819:     {CC}   . You could even add it to the definition of CC, if only libraries are
1.1       dsieger  6820:     being built in a given Makefile. This one command will build both PIC and
                   6821:     non-PIC library objects, so you need not have separate shared and
                   6822:     non-shared library rules.
                   6823: 
1.266     martin   6824:  3. For the linking of the library, remove any    ar   ,    ranlib   , and    ld
                   6825:     -Bshareable    commands, and instead use:
1.1       dsieger  6826: 
                   6827:     ${LIBTOOL} --mode=link \
                   6828:         ${CC} -o ${.TARGET:.a=.la} \
                   6829:             ${OBJS:.o=.lo} \
                   6830:             -rpath ${PREFIX}/lib \
                   6831:             -version-info major:minor
                   6832: 
                   6833:     Note that the library is changed to have a .la extension, and the objects
                   6834:     are changed to have a .lo extension. Change OBJS as necessary. This
                   6835:     automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
1.266     martin   6836:     necessary) in the build directory. Be sure to include    -version-info   ,
1.1       dsieger  6837:     especially when major and minor are zero, as libtool will otherwise strip
                   6838:     off the shared library version.
                   6839: 
                   6840:     From the libtool manual:
                   6841: 
                   6842:     So, libtool library versions are described by three integers:
                   6843: 
                   6844:     CURRENT
                   6845:     The most recent interface number that this library implements.
                   6846: 
                   6847:     REVISION
                   6848:     The implementation number of the CURRENT interface.
                   6849: 
                   6850:     AGE
                   6851:     The difference between the newest and oldest interfaces that
                   6852:     this library implements.  In other words, the library implements
                   6853:     all the interface numbers in the range from number `CURRENT -
                   6854:     AGE' to `CURRENT'.
                   6855: 
                   6856:     If two libraries have identical CURRENT and AGE numbers, then the
                   6857:     dynamic linker chooses the library with the greater REVISION number.
                   6858: 
1.266     martin   6859:     The    -release    option will produce different results for a.out and ELF
                   6860:     (excluding symlinks) in only one case. An ELF library of the form    
                   6861:     libfoo-release.so.x.y    will have a symlink of    libfoo.so.x.y    on an a.out
1.1       dsieger  6862:     platform. This is handled automatically.
                   6863: 
1.266     martin   6864:     The    -rpath argument    is the install directory of the library being built.
1.1       dsieger  6865: 
                   6866:     In the PLIST, include only the .la file, the other files will be added
                   6867:     automatically.
                   6868: 
                   6869:  4. When linking shared object (.so) files, i.e. files that are loaded via
1.266     martin   6870:     dlopen(3), NOT shared libraries, use    -module -avoid-version    to prevent
1.1       dsieger  6871:     them getting version tacked on.
                   6872: 
                   6873:     The PLIST file gets the foo.so entry.
                   6874: 
                   6875:  5. When linking programs that depend on these libraries before they are
1.266     martin   6876:     installed, preface the cc(1) or ld(1) line with    ${LIBTOOL} --mode=link   ,
1.1       dsieger  6877:     and it will find the correct libraries (static or shared), but please be
                   6878:     aware that libtool will not allow you to specify a relative path in -L
1.266     martin   6879:     (such as    -L../somelib   ), because it expects you to change that argument to
1.1       dsieger  6880:     be the .la file. e.g.
                   6881: 
                   6882:     ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
                   6883: 
                   6884:     should be changed to:
                   6885: 
                   6886:     ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
                   6887: 
                   6888:     and it will do the right thing with the libraries.
                   6889: 
1.266     martin   6890:  6. When installing libraries, preface the install(1) or cp(1) command with    $
                   6891:     {LIBTOOL} --mode=install   , and change the library name to .la. e.g.
1.1       dsieger  6892: 
1.23      jakllsch 6893:     ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1       dsieger  6894: 
                   6895:     This will install the static .a, shared library, any needed symlinks, and
                   6896:     run ldconfig(8).
                   6897: 
                   6898:  7. In your PLIST, include only the .la file (this is a change from previous
                   6899:     behaviour).
                   6900: 
1.266     martin   6901: 21.3.2.  Using libtool on GNU packages that already support libtool
1.1       dsieger  6902: 
                   6903: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
                   6904: own libtool in most cases. For older libtool using packages, libtool is made by
                   6905: ltconfig script during the do-configure step; you can check the libtool script
                   6906: location by doing make configure; find work*/ -name libtool.
                   6907: 
                   6908: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
1.266     martin   6909: override. By default, it is set to    libtool */libtool */*/libtool   . If this
1.1       dsieger  6910: does not match the location of the package's libtool script(s), set it as
                   6911: appropriate.
                   6912: 
                   6913: If you do not need *.a static libraries built and installed, then use
                   6914: SHLIBTOOL_OVERRIDE instead.
                   6915: 
                   6916: If your package makes use of the platform-independent library for loading
                   6917: dynamic shared objects, that comes with libtool (libltdl), you should include
                   6918: devel/libltdl/buildlink3.mk.
                   6919: 
                   6920: Some packages use libtool incorrectly so that the package may not work or build
                   6921: in some circumstances. Some of the more common errors are:
                   6922: 
                   6923:   * The inclusion of a shared object (-module) as a dependent library in an
                   6924:     executable or library. This in itself isn't a problem if one of two things
                   6925:     has been done:
                   6926: 
                   6927:      1. The shared object is named correctly, i.e. libfoo.la, not foo.la
                   6928: 
                   6929:      2. The -dlopen option is used when linking an executable.
                   6930: 
                   6931:   * The use of libltdl without the correct calls to initialisation routines.
                   6932:     The function lt_dlinit() should be called and the macro
                   6933:     LTDL_SET_PRELOADED_SYMBOLS included in executables.
                   6934: 
1.266     martin   6935: 21.3.3.  GNU Autoconf/Automake
1.1       dsieger  6936: 
                   6937: If a package needs GNU autoconf or automake to be executed to regenerate the
1.223     nia      6938: configure script and Makefile.in makefile templates from configure.ac and
                   6939: Makefile.am, then they should be executed in a pre-configure target:
1.1       dsieger  6940: 
1.223     nia      6941: USE_TOOLS+=     autoconf automake autoreconf
                   6942: GNU_CONFIGURE=  yes
1.1       dsieger  6943: ...
                   6944: 
                   6945: pre-configure:
1.223     nia      6946:         set -e; cd ${WRKSRC} && autoreconf -fi
1.1       dsieger  6947: ...
                   6948: 
1.223     nia      6949: Packages which use GNU Automake will sometimes require GNU Make (gmake in
                   6950: USE_TOOLS), but not always. Note that autoreconf only needs to be executed if
                   6951: configure.ac or Makefiles are modified, or configure is not present.
1.1       dsieger  6952: 
                   6953: There are times when the configure process makes additional changes to the
                   6954: generated files, which then causes the build process to try to re-execute the
                   6955: automake sequence. This is prevented by touching various files in the configure
                   6956: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
                   6957: NO in the package Makefile.
                   6958: 
1.266     martin   6959: 21.3.4.  Meson / ninja
1.223     nia      6960: 
                   6961: Packages using Meson to configure need to include:
                   6962: 
                   6963: .include "../../devel/meson/build.mk"
                   6964: 
                   6965: In nearly all cases (any program with dependencies), pkg-config needs to be
                   6966: added to USE_TOOLS. If the package installs translation files for non-English
                   6967: languages, also add msgfmt and xgettext:
                   6968: 
                   6969: USE_TOOLS+=     pkg-config msgfmt xgettext
                   6970: 
                   6971: If any options need to be passed to Meson, use MESON_ARGS instead of
                   6972: CONFIGURE_ARGS:
                   6973: 
                   6974: MESON_ARGS+=    -Dx11=false
                   6975: 
1.266     martin   6976: 21.3.5.  Determining the endianness
1.260     wiz      6977: 
                   6978: To determine the endianness of the target platform, have a look at mk/
                   6979: endian.mk.
                   6980: 
1.266     martin   6981: 21.4.  Programming languages
1.1       dsieger  6982: 
1.266     martin   6983: 21.4.1.  C, C++, and Fortran
1.1       dsieger  6984: 
1.244     gutterid 6985: Compilers for the C and C++ languages come with the NetBSD base system. By
1.223     nia      6986: default, pkgsrc assumes that a package is written in C and will hide all other
1.266     martin   6987: compilers (via the wrapper framework, see Chapter  18, Buildlink methodology).
1.1       dsieger  6988: 
1.243     gutterid 6989: To declare which languages should be made available through pkgsrc's compiler
                   6990: wrappers, use the USE_LANGUAGES variable. Allowed values currently are:
1.212     wiz      6991: 
1.244     gutterid 6992: c, c++, fortran, fortran77, java, objc, obj-c++, and ada.
1.212     wiz      6993: 
1.266     martin   6994: (and any combination). The default is    c   . Packages using GNU configure
1.212     wiz      6995: scripts, even if written in C++, usually need a C compiler for the configure
1.244     gutterid 6996: phase.
1.243     gutterid 6997: 
1.250     jnemeth  6998: To declare which features a package requires from the compiler, set either
1.243     gutterid 6999: USE_CC_FEATURES or USE_CXX_FEATURES. Allowed values for USE_CC_FEATURES are
                   7000: currently:
                   7001: 
                   7002: c11, c99, has_include
                   7003: 
                   7004: Allowed values for USE_CXX_FEATURES are currently:
                   7005: 
                   7006: c++11, c++14, c++17, c++20, has_include, regex, filesystem,
                   7007: charconv, parallelism_ts, unique_ptr, put_time,
                   7008: is_trivially_copy_constructible
1.1       dsieger  7009: 
1.251     gutterid 7010: Note at present these variables only affect use of GCC, not other compilers.
                   7011: 
1.244     gutterid 7012: Language variants like gnu99 and c++11 can be specified in FORCE_C_STD and
                   7013: FORCE_CXX_STD if the package does not explicitly set -std=... when compiling
                   7014: (i.e. the package assumes the compiler defaults to C++11 or some other
                   7015: standard). This is a common bug in upstream build systems.
                   7016: 
                   7017: Allowed values for FORCE_C_STD are currently:
                   7018: 
                   7019: c90, c99, c11, gnu90, gnu99, gnu11
                   7020: 
                   7021: Allowed values for FORCE_CXX_STD are currently:
                   7022: 
                   7023: c++03, c++11, c++14, c++17, c++20,
                   7024: gnu++03, gnu++11, gnu++14, gnu++17, gnu++20
                   7025: 
1.251     gutterid 7026: Note at present these variables only affect use of GCC and Clang.
                   7027: 
1.266     martin   7028: 21.4.2.  Java
1.1       dsieger  7029: 
                   7030: If a program is written in Java, use the Java framework in pkgsrc. The package
                   7031: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
                   7032: variables:
                   7033: 
                   7034:   * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
1.266     martin   7035:     set to    run   , then there is only a runtime dependency on the JDK. The
                   7036:     default is    yes   , which also adds a build dependency on the JDK.
1.1       dsieger  7037: 
                   7038:   * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
1.266     martin   7039:     supported values are    yes   ,    1.4   , and    1.5   .    yes    accepts any Java2
                   7040:     implementation,    1.4    insists on versions 1.4 or above, and    1.5    only
1.1       dsieger  7041:     accepts versions 1.5 or above. This variable is not set by default.
                   7042: 
1.25      wiz      7043:   * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
                   7044:     implementation dependency. It may be used to set JAVA_HOME to a good value
                   7045:     if the program needs this variable to be defined.
                   7046: 
1.266     martin   7047: 21.4.3.  Go
1.205     wiz      7048: 
                   7049: If a program is written in Go and has any dependencies on other Go modules,
                   7050: have the package include ../../lang/go/go-module.mk.
                   7051: 
                   7052:  1. Generate a list of those dependencies with make clean && make patch && make
                   7053:     show-go-modules > go-modules.mk.
                   7054: 
1.223     nia      7055:  2. Prepend .include "go-modules.mk" to any other .includes.
                   7056: 
                   7057:  3. Incorporate these modules in distinfo with make makesum.
1.205     wiz      7058: 
1.266     martin   7059: 21.4.4.  Rust
1.205     wiz      7060: 
1.223     nia      7061: If a program is written in Rust and uses Cargo to build, have the package
                   7062: include ../../lang/rust/cargo.mk.
1.205     wiz      7063: 
1.223     nia      7064:  1. Generate a list of those dependencies with make CARGO_ARGS="build
                   7065:     --release" build && make print-cargo-depends > cargo-depends.mk.
1.205     wiz      7066: 
1.223     nia      7067:  2. Prepend .include "cargo-depends.mk" to any other .includes.
1.205     wiz      7068: 
                   7069:  3. Incorporate these modules in distinfo with make makesum.
                   7070: 
1.266     martin   7071: 21.4.5.  Packages containing Perl scripts
1.1       dsieger  7072: 
1.266     martin   7073: If your package contains interpreted Perl scripts, add    perl    to the USE_TOOLS
1.1       dsieger  7074: variable and set REPLACE_PERL to ensure that the proper interpreter path is
                   7075: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
1.74      wiz      7076: you want adjusted. Every occurrence of */bin/perl in a she-bang line will be
1.210     gutterid 7077: replaced with the full path to the Perl executable.
1.1       dsieger  7078: 
1.210     gutterid 7079: If a particular version of Perl is needed, set the PERL5_REQD variable to the
1.266     martin   7080: version number. The default is    5.0   .
1.1       dsieger  7081: 
1.266     martin   7082: See Section  21.6.6,    Packages installing Perl modules    for information about
1.210     gutterid 7083: handling Perl modules.
                   7084: 
                   7085: There is also the REPLACE_PERL6 variable for the language now known as Raku.
1.1       dsieger  7086: 
1.266     martin   7087: 21.4.6.  Packages containing shell scripts
1.41      wiz      7088: 
                   7089: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
1.225     gutterid 7090: shell she-bangs in files. Please use the appropriate one, preferring REPLACE_SH
                   7091: when this shell is sufficient. Each should contain a list of scripts, relative
                   7092: to WRKSRC, that you want adjusted. Every occurrence of the matching shell in a
                   7093: she-bang line will be replaced with the full path to the shell executable. When
                   7094: using REPLACE_BASH, don't forget to add bash to USE_TOOLS.
1.41      wiz      7095: 
1.266     martin   7096: 21.4.7.  Other programming languages
1.1       dsieger  7097: 
1.210     gutterid 7098: There are further similar REPLACE variables available, e.g., REPLACE_AWK for
                   7099: packages containing awk scripts, and REPLACE_R for R. These two, like the
1.211     gutterid 7100: others noted above, have their actions defined centrally in mk/configure/
                   7101: replace-interpreter.mk. Other languages define the actions of these variables
                   7102: within their own dedicated part of the tree, e.g., REPLACE_PHP is actioned in
1.245     gutterid 7103: lang/php/replace.mk, and REPLACE_PYTHON is actioned in lang/python/
1.211     gutterid 7104: application.mk. For other languages, consult the mk files found within their
1.216     gutterid 7105: specific directories (the naming convention varies), or check the list found in
1.266     martin   7106: Appendix  E, Help topics.
1.210     gutterid 7107: 
                   7108: Currently, special handling for other languages varies in pkgsrc. If a compiler
                   7109: package provides a buildlink3.mk file, include that, otherwise just add a
                   7110: (build) dependency on the appropriate compiler package.
1.1       dsieger  7111: 
1.266     martin   7112: 21.5.  The build phase
1.1       dsieger  7113: 
                   7114: The most common failures when building a package are that some platforms do not
                   7115: provide certain header files, functions or libraries, or they provide the
                   7116: functions in a library that the original package author didn't know. To work
                   7117: around this, you can rewrite the source code in most cases so that it does not
                   7118: use the missing functions or provides a replacement function.
                   7119: 
1.266     martin   7120: 21.5.1.  Compiling C and C++ code conditionally
1.1       dsieger  7121: 
                   7122: If a package already comes with a GNU configure script, the preferred way to
                   7123: fix the build failure is to change the configure script, not the code. In the
                   7124: other cases, you can utilize the C preprocessor, which defines certain macros
                   7125: depending on the operating system and hardware architecture it compiles for.
                   7126: These macros can be queried using for example #if defined(__i386). Almost every
                   7127: operating system, hardware architecture and compiler has its own macro. For
                   7128: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
                   7129: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
                   7130: GCC.
                   7131: 
                   7132: The list of the following macros for hardware and operating system depends on
                   7133: the compiler that is used. For example, if you want to conditionally compile
                   7134: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
                   7135: Use __sun instead.
                   7136: 
1.266     martin   7137: 21.5.1.1.  C preprocessor macros to identify the operating system
1.1       dsieger  7138: 
1.223     nia      7139: To distinguish between specific NetBSD versions, you should use the following
                   7140: code.
                   7141: 
                   7142: #ifdef __NetBSD__
                   7143: #include <sys/param.h>
                   7144: #if __NetBSD_Prereq__(9,99,17)
                   7145: /* use a newer feature */
                   7146: #else
                   7147: /* older code */
                   7148: #endif
                   7149: #endif
                   7150: 
                   7151: #ifndef _WIN32
                   7152: /* Unix-like specific code */
                   7153: #endif
                   7154: 
1.1       dsieger  7155: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
                   7156: should use the following code.
                   7157: 
                   7158: #include <sys/param.h>
                   7159: #if (defined(BSD) && BSD >= 199306)
                   7160: /* BSD-specific code goes here */
                   7161: #else
                   7162: /* non-BSD-specific code goes here */
                   7163: #endif
                   7164: 
1.223     nia      7165: You can also test for the following macros:
1.1       dsieger  7166: 
1.46      obache   7167: Cygwin      __CYGWIN__
                   7168: DragonFly   __DragonFly__
1.1       dsieger  7169: FreeBSD     __FreeBSD__
1.46      obache   7170: Haiku       __HAIKU__
1.1       dsieger  7171: IRIX        __sgi (TODO: get a definite source for this)
1.223     nia      7172: Linux       __linux
1.83      dholland 7173: Mac OS X    __APPLE__
1.46      obache   7174: Minix3      __minix
1.1       dsieger  7175: NetBSD      __NetBSD__
                   7176: OpenBSD     __OpenBSD__
                   7177: Solaris     sun, __sun
                   7178: 
1.266     martin   7179: 21.5.1.2.  C preprocessor macros to identify the hardware architecture
1.1       dsieger  7180: 
                   7181: i386        i386, __i386, __i386__
1.223     nia      7182: x86-64      __amd64__, __x86_64__
                   7183: ARM         __arm__
1.1       dsieger  7184: MIPS        __mips
                   7185: SPARC       sparc, __sparc
1.223     nia      7186: PowerPC     __powerpc
1.1       dsieger  7187: 
1.266     martin   7188: 21.5.1.3.  C preprocessor macros to identify the compiler
1.1       dsieger  7189: 
                   7190: GCC         __GNUC__ (major version), __GNUC_MINOR__
                   7191: MIPSpro     _COMPILER_VERSION (0x741 for MIPSpro 7.41)
                   7192: SunPro      __SUNPRO_C (0x570 for Sun C 5.7)
                   7193: SunPro C++  __SUNPRO_CC (0x580 for Sun C++ 5.8)
                   7194: 
1.266     martin   7195: 21.5.2.  How to handle compiler bugs
1.1       dsieger  7196: 
                   7197: Some source files trigger bugs in the compiler, based on combinations of
                   7198: compiler version and architecture and almost always relation to optimisation
                   7199: being enabled. Common symptoms are gcc internal errors or never finishing
                   7200: compiling a file.
                   7201: 
                   7202: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
1.87      tnn      7203: disabling optimisation for that combination of file, MACHINE_ARCH and compiler.
                   7204: 
                   7205: This used to be a big problem in the past, but is rarely needed now as compiler
                   7206: technology has matured. If you still need to add a compiler specific
                   7207: workaround, please do so in the file hacks.mk and describe the symptom and
                   7208: compiler version as detailed as possible.
1.1       dsieger  7209: 
1.266     martin   7210: 21.5.3.  No such file or directory
1.172     rillig   7211: 
                   7212: Compilation sometimes fails with an error message like this:
                   7213: 
                   7214: .../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10:
                   7215:     fatal error: pango/pango.h: No such file or directory
                   7216: 
                   7217: The proper way to fix this problem depends on the type of the header, which is
                   7218: described in the following sections.
                   7219: 
1.266     martin   7220: 21.5.3.1.  Headers from other packages
1.172     rillig   7221: 
                   7222: If the header name looks like it comes from a different package, that other
                   7223: package should be included via the buildlink3 framework.
                   7224: 
                   7225: First, look whether the header is somewhere in the buildlink3 directory below
                   7226: WRKDIR. In the above case of the missing Pango header:
                   7227: 
                   7228: $ find work/.buildlink/ -print | grep -F pango/pango.h
                   7229: 
                   7230: In the case of Pango, the output is:
                   7231: 
                   7232: work/.buildlink/include/pango-1.0/pango/pango.h
                   7233: 
                   7234: If the pango/pango.h file were placed directly in the .buildlink directory, it
                   7235: would have been found automatically. There is an extra pango-1.0 path component
                   7236: though, which means that the compiler command line must contain an option of
                   7237: the form -I${BUILDLINK3_PREFIX.pango}/include/pango-1.0. In most cases this
                   7238: option is generated by the configure script, which can be examined using:
                   7239: 
                   7240: $ $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile
                   7241: -I/usr/pkg/include/pango-1.0
                   7242: -I/usr/pkg/include/pango-1.0
                   7243: -I/usr/pkg/include/pango-1.0
                   7244: -I/usr/pkg/include/pango-1.0
                   7245: -I/usr/pkg/include/pango-1.0
                   7246: 
                   7247: This looks good. These options are transformed by the buildlink wrapper to
                   7248: refer to the correct path inside work/.buildlink.
                   7249: 
                   7250: Since the compilation fails though, examine the compiler command lines in work
                   7251: /.work.log to see whether the -I option is included in the particular command
                   7252: line.
                   7253: 
                   7254: To further analyze the situation, run bmake build-env, which sets up an
                   7255: interactive, realistic environment including all the pkgsrc wrapper commands
                   7256: and environment variables. From there, try to compile some simple example
                   7257: programs that use the header.
                   7258: 
1.266     martin   7259: 21.5.3.2.  Headers generated during the build
1.172     rillig   7260: 
                   7261: If the name of the header seems to come from the package itself, and if the
                   7262: build is run with parallel jobs, the package may have some undeclared
                   7263: dependencies between the .c and the .h files, and a C file is compiled before
                   7264: its required header is generated.
                   7265: 
                   7266: To see whether the build runs with parallel jobs, run bmake show-all-build |
                   7267: grep JOBS. Its output looks like this:
                   7268: 
                   7269:   usr   MAKE_JOBS=              7
                   7270:   pkg   MAKE_JOBS_SAFE          # undefined
                   7271:   def   _MAKE_JOBS_N=           7
                   7272: 
                   7273: In this case the pkgsrc user has asked pkgsrc to build packages with 7 jobs in
                   7274: parallel (MAKE_JOBS). The package could have disabled parallel builds by
                   7275: setting MAKE_JOBS_SAFE to no, but in this case it hasn't.
                   7276: 
                   7277: To see whether the build failure is caused by parallel builds, first save the
                   7278: exact error message and a bit of context, maybe you need it later for reporting
                   7279: a bug. Next, run:
                   7280: 
                   7281: MAKE_JOBS_SAFE=no bmake clean build
                   7282: 
                   7283: If that succeeds, file a bug report against the pkgsrc package, including the
                   7284: exact error message and the contents of your mk.conf file.
                   7285: 
1.266     martin   7286: 21.5.3.3.  Symlinks
1.173     rillig   7287: 
                   7288: Pkgsrc does not work reliably if any of LOCALBASE, VARBASE or WRKDIR contains a
                   7289: symlink. Since 2019Q2, the pkgsrc bootstrap program prevents installing pkgsrc
                   7290: in symlink-based directories. Existing pkgsrc installations are not checked for
                   7291: symlinks though.
                   7292: 
                   7293: The "No such file or directory" error messages are a typical symptom of
                   7294: symlinks, and it's quite difficult to find out that this is the actual cause.
                   7295: 
1.266     martin   7296: 21.5.3.4.  Stale working directories
1.173     rillig   7297: 
                   7298: When building a hierarchy of packages, it may happen that one package is built
                   7299: and then pkgsrc is updated. This situation can provoke various hard to diagnose
                   7300: build errors. To clean up the situation:
                   7301: 
1.223     nia      7302: $ (cd ../../ && cat mk/bsd.pkg.mk >/dev/null && rm -rf */*/work)
1.173     rillig   7303: 
1.223     nia      7304: (The only purpose of the bsd.pkg.mk is to prevent running this command in the
                   7305: wrong directory.)
1.173     rillig   7306: 
                   7307: If you have set WRKOBJDIR in mk.conf, remove that directory as well.
                   7308: 
1.266     martin   7309: 21.5.3.5.  Other possible reasons
1.173     rillig   7310: 
                   7311: On platforms other than BSD, third-party packages are installed in /usr/
                   7312: include, together with the base system. This means that pkgsrc cannot
                   7313: distinguish between headers provided by the base system (which it needs) and
                   7314: headers from third-party packages (which are often included in pkgsrc as well).
                   7315: This can lead to subtle version mismatches.
                   7316: 
                   7317: In pkgsrc installations that have been active for several years, it may happen
                   7318: that some files are manually deleted. To exclude this unlikely reason, run 
                   7319: pkg_admin check.
                   7320: 
                   7321: It may help to run pkg_admin rebuild-tree to check/fix dependencies.
                   7322: 
1.266     martin   7323: If all of the above doesn't help, see Chapter  2, Getting help for contact
1.173     rillig   7324: information. Be prepared to describe what you have tried so far and what any
                   7325: error messages were.
                   7326: 
1.266     martin   7327: 21.5.4.  Undefined reference to    ...   
1.1       dsieger  7328: 
                   7329: This error message often means that a package did not link to a shared library
                   7330: it needs. The following functions are known to cause this error message over
                   7331: and over.
                   7332: 
                   7333: +-----------------------------------------------------+
                   7334: |        Function         |Library |Affected platforms|
                   7335: |-------------------------+--------+------------------|
                   7336: |accept, bind, connect    |-lsocket|Solaris           |
                   7337: |-------------------------+--------+------------------|
                   7338: |crypt                    |-lcrypt |DragonFly, NetBSD |
                   7339: |-------------------------+--------+------------------|
                   7340: |dlopen, dlsym            |-ldl    |Linux             |
                   7341: |-------------------------+--------+------------------|
                   7342: |gethost*                 |-lnsl   |Solaris           |
                   7343: |-------------------------+--------+------------------|
                   7344: |inet_aton                |-lresolv|Solaris           |
                   7345: |-------------------------+--------+------------------|
                   7346: |nanosleep, sem_*, timer_*|-lrt    |Solaris           |
                   7347: |-------------------------+--------+------------------|
                   7348: |openpty                  |-lutil  |Linux             |
                   7349: +-----------------------------------------------------+
                   7350: 
1.223     nia      7351: To fix these linker errors, it is often sufficient to add LIBS.OperatingSystem+
                   7352: = -lfoo to the package Makefile and then run bmake clean; bmake.
1.1       dsieger  7353: 
1.266     martin   7354: 21.5.4.1.  The SunPro compiler and inline functions
1.1       dsieger  7355: 
                   7356: When you are using the SunPro compiler, there is another possibility. That
                   7357: compiler cannot handle the following code:
                   7358: 
                   7359: extern int extern_func(int);
                   7360: 
                   7361: static inline int
                   7362: inline_func(int x)
                   7363: {
                   7364:         return extern_func(x);
                   7365: }
                   7366: 
                   7367: int main(void)
                   7368: {
                   7369:         return 0;
                   7370: }
                   7371: 
                   7372: It generates the code for inline_func even if that function is never used. This
                   7373: code then refers to extern_func, which can usually not be resolved. To solve
                   7374: this problem you can try to tell the package to disable inlining of functions.
                   7375: 
1.266     martin   7376: 21.5.4.2.  Missing atomic functions
1.228     gutterid 7377: 
                   7378: When building for older machine architectures (e.g., i386, PowerPC), builds may
                   7379: fail because the package expects modern 64-bit atomic functions which the
                   7380: underlying hardware either doesn't support, or will only support with specific
                   7381: compiler flags. This is generally handled via inclusion of mk/atomic64.mk.
                   7382: 
1.266     martin   7383: 21.5.5.  Running out of memory
1.1       dsieger  7384: 
                   7385: Sometimes packages fail to build because the compiler runs into an operating
                   7386: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
1.266     martin   7387: told to unlimit the resources. The allowed values are any combination of    
                   7388: cputime   ,    datasize   ,    memorysize   ,    stacksize    and    virtualsize   . Setting this
1.223     nia      7389: variable is similar to running the shell builtin ulimit command to raise the
                   7390: maximum data segment size or maximum stack size of a process, respectively, to
                   7391: their hard limits.
1.1       dsieger  7392: 
1.266     martin   7393: 21.6.  The install phase
1.1       dsieger  7394: 
1.266     martin   7395: 21.6.1.  Creating needed directories
1.1       dsieger  7396: 
                   7397: The BSD-compatible install supplied with some operating systems cannot create
                   7398: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
                   7399: like this:
                   7400: 
                   7401: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
                   7402: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
                   7403: 
1.266     martin   7404: Instead of running the install commands directly, you can also append    dir1
                   7405: dir2    to the INSTALLATION_DIRS variable, which will automatically do the right
1.223     nia      7406: thing.
1.1       dsieger  7407: 
1.266     martin   7408: 21.6.2.  Where to install documentation
1.1       dsieger  7409: 
                   7410: In general, documentation should be installed into ${PREFIX}/share/doc/$
1.223     nia      7411: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME_NOREV} (the latter includes the
                   7412: version number of the package).
1.1       dsieger  7413: 
                   7414: Many modern packages using GNU autoconf allow to set the directory where HTML
1.266     martin   7415: documentation is installed with the    --with-html-dir    option. Sometimes using
1.1       dsieger  7416: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
1.223     nia      7417: share/doc/html or other places. In pkgsrc, the HTML documentation should go
                   7418: into the package-specific directory, just like any other documentation.
1.1       dsieger  7419: 
                   7420: An exception to the above is that library API documentation generated with the
                   7421: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
                   7422: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
                   7423: can be recognized from files ending in .devhelp or .devhelp2. (It is also
                   7424: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
                   7425: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
                   7426: then, no additional subdirectory level is allowed in this case. This is usually
1.266     martin   7427: achieved by using    --with-html-dir=${PREFIX}/share/doc   . ${PREFIX}/share/
1.1       dsieger  7428: gtk-doc is preferred though.)
                   7429: 
1.266     martin   7430: 21.6.3.  Installing highscore files
1.1       dsieger  7431: 
                   7432: Certain packages, most of them in the games category, install a score file that
                   7433: allows all users on the system to record their highscores. In order for this to
                   7434: work, the binaries need to be installed setgid and the score files owned by the
1.36      wiz      7435: appropriate group and/or owner (traditionally the "games" user/group). Set
                   7436: USE_GAMESGROUP to yes to support this. The following variables, documented in
                   7437: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
1.100     leot     7438: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER. Other useful variables are:
                   7439: GAMEDIR_PERMS, GAMEDATA_PERMS and SETGID_GAMES_PERMS.
                   7440: 
                   7441: An example that illustrates some of the variables described above is games/
                   7442: moon-buggy. OWN_DIRS_PERMS is used to properly set directory permissions of the
                   7443: directory where the scorefile is saved, REQD_FILES_PERMS is used to create a
                   7444: dummy scorefile (mbscore) with the proper permissions and SPECIAL_PERMS is used
                   7445: to install setgid the game binary:
                   7446: 
                   7447: USE_GAMESGROUP=         yes
                   7448: 
                   7449: BUILD_DEFS+=            VARBASE
                   7450: 
                   7451: OWN_DIRS_PERMS+=        ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
                   7452: REQD_FILES_PERMS+=      /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
                   7453: SPECIAL_PERMS+=         ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
                   7454: 
                   7455: Various INSTALL_* variables are also available: INSTALL_GAME to install setgid
                   7456: game binaries, INSTALL_GAME_DIR to install game directories that are needed to
                   7457: be accessed by setgid games and INSTALL_GAME_DATA to install scorefiles.
1.1       dsieger  7458: 
1.14      jmcneill 7459: A package should therefore never hard code file ownership or access permissions
1.100     leot     7460: but rely on *_PERMS as described above or alternatively on INSTALL_GAME,
                   7461: INSTALL_GAME_DATA and INSTALL_GAME_DIR to set these correctly.
1.1       dsieger  7462: 
1.266     martin   7463: 21.6.4.  Adding DESTDIR support to packages
1.4       rillig   7464: 
1.14      jmcneill 7465: DESTDIR support means that a package installs into a staging directory, not the
                   7466: final location of the files. Then a binary package is created which can be used
                   7467: for installation as usual. There are two ways: Either the package must install
1.266     martin   7468: as root (   destdir   ) or the package can install as non-root user (   user-destdir   
1.25      wiz      7469: ).
1.14      jmcneill 7470: 
1.266     martin   7471:   * PKG_DESTDIR_SUPPORT has to be set to    destdir    or    user-destdir   . By
                   7472:     default PKG_DESTDIR_SUPPORT is set to    user-destdir    to help catching more
1.113     leot     7473:     potential packaging problems. If bsd.prefs.mk is included in the Makefile,
                   7474:     PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14      jmcneill 7475: 
1.4       rillig   7476:   * All installation operations have to be prefixed with ${DESTDIR}.
                   7477: 
                   7478:   * automake gets this DESTDIR mostly right automatically. Many manual rules
                   7479:     and pre/post-install often are incorrect; fix them.
                   7480: 
1.17      imil     7481:   * If files are installed with special owner/group use SPECIAL_PERMS.
1.4       rillig   7482: 
                   7483:   * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
                   7484: 
1.266     martin   7485: 21.6.5.  Packages with hardcoded paths to other interpreters
1.1       dsieger  7486: 
                   7487: Your package may also contain scripts with hardcoded paths to other
1.203     nia      7488: interpreters besides (or as well as) Perl. To correct the full pathname to the
1.1       dsieger  7489: script interpreter, you need to set the following definitions in your Makefile
                   7490: (we shall use tclsh in this example):
                   7491: 
                   7492: REPLACE_INTERPRETER+=   tcl
                   7493: REPLACE.tcl.old=        .*/bin/tclsh
                   7494: REPLACE.tcl.new=        ${PREFIX}/bin/tclsh
                   7495: REPLACE_FILES.tcl=      # list of tcl scripts which need to be fixed,
                   7496: # relative to ${WRKSRC}, just as in REPLACE_PERL
                   7497: 
1.266     martin   7498: 21.6.6.  Packages installing Perl modules
1.1       dsieger  7499: 
                   7500: Makefiles of packages providing perl5 modules should include the Makefile
                   7501: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
                   7502: standard perl configuration for such modules as well as various hooks to tune
                   7503: this configuration. See comments in this file for details.
                   7504: 
                   7505: Perl5 modules will install into different places depending on the version of
                   7506: perl used during the build process. To address this, pkgsrc will append lines
                   7507: to the PLIST corresponding to the files listed in the installed .packlist file
                   7508: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48      wiz      7509: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
                   7510: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1       dsieger  7511: 
1.48      wiz      7512: PERL5_PACKLIST= auto/Pg/.packlist
1.1       dsieger  7513: 
1.48      wiz      7514: The perl5 config variables installarchlib, installscript, installvendorbin,
                   7515: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
                   7516: and installvendorman3dir represent those locations in which components of perl5
                   7517: modules may be installed, provided as variable with uppercase and prefixed with
                   7518: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
                   7519: have a packlist. These variables are also substituted for in the PLIST as
                   7520: uppercase prefixed with PERL5_SUB_.
1.1       dsieger  7521: 
1.266     martin   7522: 21.6.7.  Packages installing pkg-config files
1.254     wiz      7523: 
                   7524: Some packages, usually those providing libraries, install pkg-config files so
                   7525: that their headers and libraries can easily be found. The file names end with
                   7526: .pc.
                   7527: 
                   7528: Most of the time, these files only provide the linker flags for the library,
                   7529: but do not include the flags for setting the rpath so the libraries can also be
                   7530: found at runtime. Since this is so common, pkgsrc provides PKGCONFIG_OVERRIDE
                   7531: for this. Many packages generate the .pc from .pc.in, in that case add those
                   7532: files to the PKGCONFIG_OVERRIDE variable:
                   7533: 
                   7534: PKGCONFIG_OVERRIDE+=   foo.pc.in
                   7535: 
                   7536: 
                   7537: For packages using meson, the files are generated during build and you also
                   7538: need to change the phase in which the replacement is done. For example:
                   7539: 
                   7540: PKGCONFIG_OVERRIDE+=            output/meson-private/foo.pc
                   7541: PKGCONFIG_OVERRIDE_STAGE=       post-build
                   7542: 
                   7543: 
1.266     martin   7544: 21.6.8.  Packages installing info files
1.1       dsieger  7545: 
1.266     martin   7546: Some packages install info files or use the    makeinfo    or    install-info   
1.1       dsieger  7547: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
                   7548: and DEINSTALL scripts will be generated to handle registration of the info
1.266     martin   7549: files in the Info directory file. The    install-info    command used for the info
1.1       dsieger  7550: files registration is either provided by the system, or by a special purpose
                   7551: package automatically added as dependency if needed.
                   7552: 
                   7553: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
1.266     martin   7554: located. PKGINFODIR defaults to    info    and can be overridden by the user.
1.1       dsieger  7555: 
                   7556: The info files for the package should be listed in the package PLIST; however
                   7557: any split info files need not be listed.
                   7558: 
1.266     martin   7559: A package which needs the    makeinfo    command at build time must add    makeinfo   
                   7560: to USE_TOOLS in its Makefile. If a minimum version of the    makeinfo    command is
1.1       dsieger  7561: needed it should be noted with the TEXINFO_REQD variable in the package
                   7562: Makefile. By default, a minimum version of 3.12 is required. If the system does
                   7563: not provide a makeinfo command or if it does not match the required minimum, a
                   7564: build dependency on the devel/gtexinfo package will be added automatically.
                   7565: 
                   7566: The build and installation process of the software provided by the package
                   7567: should not use the install-info command as the registration of info files is
1.25      wiz      7568: the task of the package INSTALL script, and it must use the appropriate 
1.1       dsieger  7569: makeinfo command.
                   7570: 
                   7571: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
                   7572: the install-info and makeinfo commands in a directory listed early in PATH.
                   7573: 
                   7574: The script overriding install-info has no effect except the logging of a
                   7575: message. The script overriding makeinfo logs a message and according to the
                   7576: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
                   7577: error.
                   7578: 
1.266     martin   7579: 21.6.9.  Packages installing man pages
1.1       dsieger  7580: 
                   7581: All packages that install manual pages should install them into the same
                   7582: directory, so that there is one common place to look for them. In pkgsrc, this
                   7583: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.266     martin   7584: packages. The default for PKGMANDIR is    man   . Another often-used value is    
                   7585: share/man   .
1.1       dsieger  7586: 
                   7587: Note
                   7588: 
                   7589: The support for a custom PKGMANDIR is far from complete.
                   7590: 
                   7591: The PLIST files can just use man/ as the top level directory for the man page
                   7592: file entries, and the pkgsrc framework will convert as needed. In all other
                   7593: places, the correct PKGMANDIR must be used.
                   7594: 
1.266     martin   7595: Packages that are configured with GNU_CONFIGURE set as    yes   , by default will
1.1       dsieger  7596: use the ./configure --mandir switch to set where the man pages should be
                   7597: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
                   7598: {PKGMANDIR}.
                   7599: 
                   7600: Packages that use GNU_CONFIGURE but do not use --mandir, can set
1.266     martin   7601: CONFIGURE_HAS_MANDIR to    no   . Or if the ./configure script uses a non-standard
1.1       dsieger  7602: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
                   7603: 
1.266     martin   7604: See Section  19.5,    Man page compression    for information on installation of
1.1       dsieger  7605: compressed manual pages.
                   7606: 
1.266     martin   7607: 21.6.10.  Packages installing X11 fonts
1.1       dsieger  7608: 
                   7609: If a package installs font files, you will need to rebuild the fonts database
                   7610: in the directory where they get installed at installation and deinstallation
                   7611: time. This can be automatically done by using the pkginstall framework.
                   7612: 
                   7613: You can list the directories where fonts are installed in the FONTS_DIRS.type
1.266     martin   7614: variables, where type can be one of    ttf   ,    type1    or    x11   . Also make sure
1.1       dsieger  7615: that the database file fonts.dir is not listed in the PLIST.
                   7616: 
                   7617: Note that you should not create new directories for fonts; instead use the
                   7618: standard ones to avoid that the user needs to manually configure his X server
                   7619: to find them.
                   7620: 
1.266     martin   7621: 21.6.11.  Packages installing SGML or XML data
1.1       dsieger  7622: 
                   7623: If a package installs SGML or XML data files that need to be registered in
                   7624: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
                   7625: extra steps:
                   7626: 
                   7627:  1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
                   7628:     care of registering those files in system-wide catalogs at installation and
                   7629:     deinstallation time.
                   7630: 
                   7631:  2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
                   7632:     package.
                   7633: 
                   7634:  3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
                   7635:     package.
                   7636: 
                   7637:  4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
                   7638:     These come in groups of three strings; see xmlcatmgr(1) for more
                   7639:     information (specifically, arguments recognized by the 'add' action). Note
                   7640:     that you will normally not use this variable.
                   7641: 
                   7642:  5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
                   7643:     come in groups of three strings; see xmlcatmgr(1) for more information
                   7644:     (specifically, arguments recognized by the 'add' action). Note that you
                   7645:     will normally not use this variable.
                   7646: 
1.266     martin   7647: 21.6.12.  Packages installing extensions to the MIME database
1.1       dsieger  7648: 
                   7649: If a package provides extensions to the MIME database by installing .xml files
                   7650: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
                   7651: ensure that the database is kept consistent with respect to these new files:
                   7652: 
                   7653:  1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
                   7654:     buildlink3.mk file from this same directory, which is reserved for
                   7655:     inclusion from other buildlink3.mk files). It takes care of rebuilding the
                   7656:     MIME database at installation and deinstallation time, and disallows any
                   7657:     access to it directly from the package.
                   7658: 
1.25      wiz      7659:  2. Check the PLIST and remove any entries under the share/mime directory, 
1.1       dsieger  7660:     except for files saved under share/mime/packages. The former are handled
                   7661:     automatically by the update-mime-database program, but the latter are
                   7662:     package-dependent and must be removed by the package that installed them in
                   7663:     the first place.
                   7664: 
                   7665:  3. Remove any share/mime/* directories from the PLIST. They will be handled by
                   7666:     the shared-mime-info package.
                   7667: 
1.266     martin   7668: 21.6.13.  Packages using intltool
1.1       dsieger  7669: 
                   7670: If a package uses intltool during its build, add intltool to the USE_TOOLS,
                   7671: which forces it to use the intltool package provided by pkgsrc, instead of the
                   7672: one bundled with the distribution file.
                   7673: 
                   7674: This tracks intltool's build-time dependencies and uses the latest available
                   7675: version; this way, the package benefits of any bug fixes that may have appeared
                   7676: since it was released.
                   7677: 
1.266     martin   7678: 21.6.14.  Packages installing startup scripts
1.1       dsieger  7679: 
1.256     wiz      7680: If a package contains an rc.d script, it won't be copied into the startup
                   7681: directory (/etc/rc.d) by default, but you can enable copying by setting the
                   7682: option PKG_RCD_SCRIPTS=YES in mk.conf. With PKG_RCD_SCRIPTS=YES, rc.d scripts
                   7683: will be copied into /etc/rc.d when a package is installed, but only if the
                   7684: target does not already exist. Copies in /etc/rc.d will be automatically
                   7685: removed only if they have not been modified.
                   7686: 
                   7687: Note that this alone does not enable the service: It must still be added to /
                   7688: etc/rc.conf.
1.1       dsieger  7689: 
1.266     martin   7690: 21.6.15.  Packages installing TeX modules
1.1       dsieger  7691: 
                   7692: If a package installs TeX packages into the texmf tree, the ls-R database of
                   7693: the tree needs to be updated.
                   7694: 
                   7695: Note
                   7696: 
1.23      jakllsch 7697: Except the main TeX packages such as kpathsea, packages should install files
                   7698: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1       dsieger  7699: 
1.23      jakllsch 7700:  1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
                   7701:     ls-R database at installation and deinstallation time.
1.1       dsieger  7702: 
1.23      jakllsch 7703:  2. If your package installs files into a texmf tree other than the one at $
                   7704:     {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
                   7705:     trees that need database update.
1.1       dsieger  7706: 
                   7707:     If your package also installs font map files that need to be registered
1.30      dholland 7708:     using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
                   7709:     and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then 
                   7710:     updmap will be run automatically at installation/deinstallation to enable/
                   7711:     disable font map files for TeX output drivers.
1.1       dsieger  7712: 
                   7713:  3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30      dholland 7714:     be removed only by the kpathsea package.
1.1       dsieger  7715: 
1.266     martin   7716: 21.6.16.  Packages supporting running binaries in emulation
1.1       dsieger  7717: 
                   7718: There are some packages that provide libraries and executables for running
                   7719: binaries from a one operating system on a different one (if the latter supports
                   7720: it). One example is running Linux binaries on NetBSD.
                   7721: 
                   7722: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
                   7723: 
                   7724: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
                   7725: if all libraries for each installed executable can be found by the dynamic
                   7726: linker. Since the standard dynamic linker is run, this fails for emulation
                   7727: packages, because the libraries used by the emulation are not in the standard
                   7728: directories.
                   7729: 
1.266     martin   7730: 21.6.17.  Packages installing hicolor icons
1.1       dsieger  7731: 
                   7732: If a package installs images under the share/icons/hicolor and/or updates the
                   7733: share/icons/hicolor/icon-theme.cache database, you need to take some extra
                   7734: steps to make sure that the shared theme directory is handled appropriately and
                   7735: that the cache database is rebuilt:
                   7736: 
                   7737:  1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
                   7738: 
                   7739:  2. Check the PLIST and remove the entry that refers to the theme cache.
                   7740: 
                   7741:  3. Ensure that the PLIST does not remove the shared icon directories from the
                   7742:     share/icons/hicolor hierarchy because they will be handled automatically.
                   7743: 
                   7744: The best way to verify that the PLIST is correct with respect to the last two
                   7745: points is to regenerate it using make print-PLIST.
                   7746: 
1.266     martin   7747: 21.6.18.  Packages installing desktop files
1.1       dsieger  7748: 
                   7749: If a package installs .desktop files under share/applications and these include
1.54      rodent   7750: MIME information (MimeType key), you need to take extra steps to ensure that
                   7751: they are registered into the MIME database:
1.1       dsieger  7752: 
                   7753:  1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
                   7754: 
                   7755:  2. Check the PLIST and remove the entry that refers to the share/applications/
                   7756:     mimeinfo.cache file. It will be handled automatically.
                   7757: 
                   7758: The best way to verify that the PLIST is correct with respect to the last point
                   7759: is to regenerate it using make print-PLIST.
                   7760: 
1.266     martin   7761: 21.7.  Marking packages as having problems
1.1       dsieger  7762: 
1.23      jakllsch 7763: In some cases one does not have the time to solve a problem immediately. In
                   7764: this case, one can plainly mark a package as broken. For this, one just sets
                   7765: the variable BROKEN to the reason why the package is broken (similar to the
1.162     rillig   7766: PKG_FAIL_REASON variable). A user trying to build the package will immediately
                   7767: be shown this message, and the build will not be even tried.
1.1       dsieger  7768: 
1.23      jakllsch 7769: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1       dsieger  7770: 
1.266     martin   7771: Chapter  22.  GNOME packaging and porting
1.184     rillig   7772: 
                   7773: Table of Contents
                   7774: 
                   7775: 22.1. Meta packages
                   7776: 22.2. Packaging a GNOME application
                   7777: 22.3. Updating GNOME to a newer version
                   7778: 22.4. Patching guidelines
                   7779: 
                   7780: Quoting GNOME's web site:
                   7781: 
                   7782:     The GNOME project provides two things: The GNOME desktop environment, an
                   7783:     intuitive and attractive desktop for users, and the GNOME development
                   7784:     platform, an extensive framework for building applications that integrate
                   7785:     into the rest of the desktop.
                   7786: 
                   7787: pkgsrc provides a seamless way to automatically build and install a complete
                   7788: GNOME environment under many different platforms. We can say with confidence
                   7789: that pkgsrc is one of the most advanced build and packaging systems for GNOME
                   7790: due to its included technologies buildlink3, the wrappers and tools framework
                   7791: and automatic configuration file management. Lots of efforts are put into
                   7792: achieving a completely clean deinstallation of installed software components.
                   7793: 
                   7794: Given that pkgsrc is NetBSD's official packaging system, the above also means
                   7795: that great efforts are put into making GNOME work under this operating system.
                   7796: 
                   7797: This chapter is aimed at pkgsrc developers and other people interested in
                   7798: helping our GNOME porting and packaging efforts. It provides instructions on
                   7799: how to manage the existing packages and some important information regarding
                   7800: their internals.
                   7801: 
1.266     martin   7802: 22.1.  Meta packages
1.184     rillig   7803: 
                   7804: pkgsrc includes three GNOME-related meta packages:
                   7805: 
                   7806:   * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
                   7807:     includes the necessary bits to get it to boot correctly, although it may
                   7808:     lack important functionality for daily operation. The idea behind this
                   7809:     package is to let end users build their own configurations on top of this
                   7810:     one, first installing this meta package to achieve a functional setup and
                   7811:     then adding individual applications.
                   7812: 
                   7813:   * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
                   7814:     desktop as defined by the GNOME project; this is based on the components
                   7815:     distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
                   7816:     directories of the official FTP server. Developer-only tools found in those
                   7817:     directories are not installed unless required by some other component to
                   7818:     work properly. Similarly, packages from the bindings set (bindings/x.y/
                   7819:     x.y.z/sources) are not pulled in unless required as a dependency for an
                   7820:     end-user component. This package "extends" meta-pkgs/gnome-base.
                   7821: 
                   7822:   * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
                   7823:     component when fetched from the CVS repository. These are required to let
                   7824:     the autogen.sh scripts work appropriately.
                   7825: 
                   7826: In all these packages, the DEPENDS lines are sorted in a way that eases
                   7827: updates: a package may depend on other packages listed before it but not on any
                   7828: listed after it. It is very important to keep this order to ease updates so... 
                   7829: do not change it to alphabetical sorting!
                   7830: 
1.266     martin   7831: 22.2.  Packaging a GNOME application
1.184     rillig   7832: 
                   7833: Almost all GNOME applications are written in C and use a common set of tools as
                   7834: their build system. Things get different with the new bindings to other
                   7835: languages (such as Python), but the following will give you a general idea on
                   7836: the minimum required tools:
                   7837: 
                   7838:   * Almost all GNOME applications use the GNU Autotools as their build system.
                   7839:     As a general rule you will need to tell this to your package:
                   7840: 
1.223     nia      7841:     GNU_CONFIGURE=  yes
                   7842:     USE_LIBTOOL=    yes
                   7843:     USE_TOOLS+=     gmake
1.184     rillig   7844: 
                   7845:   * If the package uses pkg-config to detect dependencies, add this tool to the
                   7846:     list of required utilities:
                   7847: 
1.223     nia      7848:     USE_TOOLS+=     pkg-config
1.184     rillig   7849: 
                   7850:     Also use pkgtools/verifypc at the end of the build process to ensure that
                   7851:     you did not miss to specify any dependency in your package and that the
                   7852:     version requirements are all correct.
                   7853: 
                   7854:   * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
                   7855:     handle dependencies and to force the package to use the latest available
                   7856:     version.
                   7857: 
                   7858:   * If the package uses gtk-doc (a documentation generation utility), do not
                   7859:     add a dependency on it. The tool is rather big and the distfile should come
                   7860:     with pregenerated documentation anyway; if it does not, it is a bug that
                   7861:     you ought to report. For such packages you should disable gtk-doc (unless
                   7862:     it is the default):
                   7863: 
1.223     nia      7864:     CONFIGURE_ARGS+=        --disable-gtk-doc
1.184     rillig   7865: 
                   7866:     The default location of installed HTML files (share/gtk-doc/<package-name>)
                   7867:     is correct and should not be changed unless the package insists on
                   7868:     installing them somewhere else. Otherwise programs as devhelp will not be
                   7869:     able to open them. You can do that with an entry similar to:
1.1       dsieger  7870: 
1.223     nia      7871:     CONFIGURE_ARGS+=        --with-html-dir=${PREFIX}/share/gtk-doc/...
1.1       dsieger  7872: 
1.184     rillig   7873: GNOME uses multiple shared directories and files under the installation prefix
                   7874: to maintain databases. In this context, shared means that those exact same
                   7875: directories and files are used among several different packages, leading to
                   7876: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
                   7877: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
                   7878: your file lists and omitting shared files from them. If you find yourself doing
                   7879: those, your package is most likely incorrect.
1.1       dsieger  7880: 
1.184     rillig   7881: The following table lists the common situations that result in using shared
                   7882: directories or files. For each of them, the appropriate solution is given.
                   7883: After applying the solution be sure to regenerate the package's file list with 
                   7884: make print-PLIST and ensure it is correct.
1.1       dsieger  7885: 
1.266     martin   7886: Table  22.1.  PLIST handling for GNOME packages
1.1       dsieger  7887: 
1.184     rillig   7888: +-----------------------------------------------------------------------------+
                   7889: |             If the package...             |             Then...             |
                   7890: |-------------------------------------------+---------------------------------|
1.266     martin   7891: |Installs icons under the share/icons/      |See Section  21.6.17,    Packages   |
                   7892: |hicolor hierarchy or updates share/icons/  |installing hicolor icons   .       |
1.184     rillig   7893: |hicolor/icon-theme.cache.                  |                                 |
                   7894: |-------------------------------------------+---------------------------------|
1.266     martin   7895: |                                           |See Section  21.6.12,    Packages   |
1.184     rillig   7896: |Installs files under share/mime/packages.  |installing extensions to the MIME|
1.266     martin   7897: |                                           |database   .                       |
1.184     rillig   7898: |-------------------------------------------+---------------------------------|
1.266     martin   7899: |Installs .desktop files under share/       |See Section  21.6.18,    Packages   |
                   7900: |applications and these include MIME        |installing desktop files   .       |
1.184     rillig   7901: |information.                               |                                 |
                   7902: +-----------------------------------------------------------------------------+
1.1       dsieger  7903: 
                   7904: 
1.266     martin   7905: 22.3.  Updating GNOME to a newer version
1.1       dsieger  7906: 
1.184     rillig   7907: When seeing GNOME as a whole, there are two kinds of updates:
1.1       dsieger  7908: 
1.184     rillig   7909: Major update
1.1       dsieger  7910: 
1.184     rillig   7911:     Given that there is still a very long way for GNOME 3 (if it ever appears),
                   7912:     we consider a major update one that goes from a 2.X version to a 2.Y one,
                   7913:     where Y is even and greater than X. These are hard to achieve because they
                   7914:     introduce lots of changes in the components' code and almost all GNOME
                   7915:     distfiles are updated to newer versions. Some of them can even break API
                   7916:     and ABI compatibility with the previous major version series. As a result,
                   7917:     the update needs to be done all at once to minimize breakage.
1.1       dsieger  7918: 
1.184     rillig   7919:     A major update typically consists of around 80 package updates and the
                   7920:     addition of some new ones.
1.1       dsieger  7921: 
1.184     rillig   7922: Minor update
1.1       dsieger  7923: 
1.184     rillig   7924:     We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
                   7925:     one where Y is greater than X. These are easy to achieve because they do
                   7926:     not update all GNOME components, can be done in an incremental way and do
                   7927:     not break API nor ABI compatibility.
1.1       dsieger  7928: 
1.184     rillig   7929:     A minor update typically consists of around 50 package updates, although
                   7930:     the numbers here may vary a lot.
1.1       dsieger  7931: 
1.184     rillig   7932: In order to update the GNOME components in pkgsrc to a new stable release
                   7933: (either major or minor), the following steps should be followed:
1.1       dsieger  7934: 
1.184     rillig   7935:  1. Get a list of all the tarballs that form the new release by using the
                   7936:     following commands. These will leave the full list of the components'
                   7937:     distfiles into the list.txt file:
1.1       dsieger  7938: 
1.184     rillig   7939:     % echo ls "*.tar.bz2" | \
                   7940:         ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
                   7941:         awk '{ print $9 }' >list.txt
                   7942:     % echo ls "*.tar.bz2" | \
                   7943:         ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
                   7944:         awk '{ print $9 }' >>list.txt
1.1       dsieger  7945: 
1.184     rillig   7946:  2. Open each meta package's Makefile and bump their version to the release you
                   7947:     are updating them to. The three meta packages should be always consistent
                   7948:     with versioning. Obviously remove any PKGREVISIONs that might be in them.
1.1       dsieger  7949: 
1.184     rillig   7950:  3. For each meta package, update all its DEPENDS lines to match the latest
                   7951:     versions as shown by the above commands. Do not list any newer version
                   7952:     (even if found in the FTP) because the meta packages are supposed to list
                   7953:     the exact versions that form a specific GNOME release. Exceptions are
                   7954:     permitted here if a newer version solves a serious issue in the overall
                   7955:     desktop experience; these typically come in the form of a revision bump in
                   7956:     pkgsrc, not in newer versions from the developers.
1.1       dsieger  7957: 
1.184     rillig   7958:     Packages not listed in the list.txt file should be updated to the latest
                   7959:     version available (if found in pkgsrc). This is the case, for example, of
                   7960:     the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
                   7961:     package.
1.1       dsieger  7962: 
1.184     rillig   7963:  4. Generate a patch from the modified meta packages and extract the list of
                   7964:     "new" lines. This will provide you an outline on what packages need to be
                   7965:     updated in pkgsrc and in what order:
1.1       dsieger  7966: 
1.184     rillig   7967:     % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
1.1       dsieger  7968: 
1.184     rillig   7969:  5. For major desktop updates it is recommended to zap all your installed
                   7970:     packages and start over from scratch at this point.
1.1       dsieger  7971: 
1.184     rillig   7972:  6. Now comes the longest step by far: iterate over the contents of todo.txt
                   7973:     and update the packages listed in it in order. For major desktop updates
                   7974:     none of these should be committed until the entire set is completed because
                   7975:     there are chances of breaking not-yet-updated packages.
1.1       dsieger  7976: 
1.184     rillig   7977:  7. Once the packages are up to date and working, commit them to the tree one
                   7978:     by one with appropriate log messages. At the end, commit the three meta
                   7979:     package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
                   7980:     and pkgsrc/doc/TODO files.
1.1       dsieger  7981: 
1.266     martin   7982: 22.4.  Patching guidelines
1.1       dsieger  7983: 
1.184     rillig   7984: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
                   7985: it is very important that you always, always, always feed back any portability
                   7986: fixes you do to a GNOME package to the mainstream developers (see
1.266     martin   7987: Section  12.3.5,    Feedback to the author   ). This is the only way to get their
1.184     rillig   7988: attention on portability issues and to ensure that future versions can be built
                   7989: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
                   7990: updates are. Those developers in charge of issuing major GNOME updates will be
                   7991: grateful if you do that.
1.1       dsieger  7992: 
1.200     cirnatda 7993: The most common places to report bugs are the GNOME's GitLab and the
                   7994: freedesktop.org's GitLab. Not all components use these to track bugs, but most
                   7995: of them do. Do not be short on your reports: always provide detailed
1.184     rillig   7996: explanations of the current failure, how it can be improved to achieve maximum
1.200     cirnatda 7997: portability and, if at all possible, provide a patch against the main Git
                   7998: branch. The more verbose you are, the higher chances of your patch being
                   7999: accepted.
1.1       dsieger  8000: 
1.184     rillig   8001: Also, please avoid using preprocessor magic to fix portability issues. While
                   8002: the FreeBSD GNOME people are doing a great job in porting GNOME to their
                   8003: operating system, the official GNOME sources are now plagued by conditionals
                   8004: that check for __FreeBSD__ and similar macros. This hurts portability. Please
1.266     martin   8005: see our patching guidelines (Section  12.3.4,    Patching guidelines   ) for more
1.184     rillig   8006: details.
1.1       dsieger  8007: 
1.266     martin   8008: Chapter  23.  Submitting and Committing
1.1       dsieger  8009: 
                   8010: Table of Contents
                   8011: 
1.154     rillig   8012: 23.1. Submitting binary packages
                   8013: 23.2. Submitting source packages (for non-NetBSD-developers)
                   8014: 23.3. General notes when adding, updating, or removing packages
                   8015: 23.4. Commit Messages
                   8016: 23.5. Committing: Adding a package to CVS
                   8017: 23.6. Updating a package to a newer version
                   8018: 23.7. Renaming a package in pkgsrc
                   8019: 23.8. Moving a package in pkgsrc
1.1       dsieger  8020: 
1.266     martin   8021: 23.1.  Submitting binary packages
1.1       dsieger  8022: 
                   8023: Our policy is that we accept binaries only from pkgsrc developers to guarantee
                   8024: that the packages don't contain any trojan horses etc. This is not to annoy
                   8025: anyone but rather to protect our users! You're still free to put up your
                   8026: home-made binary packages and tell the world where to get them. NetBSD
1.266     martin   8027: developers doing bulk builds and wanting to upload them please see Chapter  8, 
1.66      asau     8028: Creating binary packages for everything in pkgsrc (bulk builds).
1.1       dsieger  8029: 
1.266     martin   8030: 23.2.  Submitting source packages (for non-NetBSD-developers)
1.1       dsieger  8031: 
1.266     martin   8032: Firstly, you can import new packages into pkgsrc-wip (   pkgsrc work-in-progress   
1.218     nia      8033: ); see the homepage at https://pkgsrc.org/wip/ for details.
                   8034: 
                   8035: Next, check that your package is complete, compiles and runs well; see
1.266     martin   8036: Chapter  14, Creating a new pkgsrc package from scratch and the rest of this
1.218     nia      8037: document. Run the pkgtools/pkglint tool and fix any errors that appear.
                   8038: 
                   8039: Finally, send a report to the pkgsrc bug tracking system, either with the
                   8040: send-pr(1) command, or if you don't have that, go to the web page https://
                   8041: www.NetBSD.org/support/send-pr.html, which contains some instructions and a
                   8042: link to a form where you can submit packages. The sysutils/gtk-send-pr package
                   8043: is also available as a substitute for either of the above two tools.
1.1       dsieger  8044: 
1.266     martin   8045: In the form of the problem report, the category should be    pkg   , the synopsis
1.1       dsieger  8046: should include the package name and version number, and the description field
                   8047: should contain a short description of your package (contents of the COMMENT
1.218     nia      8048: variable or DESCR file are OK).
1.1       dsieger  8049: 
1.266     martin   8050: 23.3.  General notes when adding, updating, or removing packages
1.1       dsieger  8051: 
                   8052: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
                   8053: CHANGES-YYYY. It's very important to keep this file up to date and conforming
                   8054: to the existing format, because it will be used by scripts to automatically
                   8055: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
                   8056: doc/TODO file and remove the entry for the package you updated or removed, in
                   8057: case it was mentioned there.
                   8058: 
                   8059: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
                   8060: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
                   8061: that result from a dependency being updated should not be mentioned. In all
                   8062: other cases it's the developer's decision.
                   8063: 
                   8064: There is a make target that helps in creating proper CHANGES-YYYY entries: make
                   8065: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
                   8066: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
                   8067: (to avoid having to resolve conflicts later-on) and then to cd to the package
                   8068: directory. For package updates, make changes-entry is enough. For new packages,
                   8069: or package moves or removals, set the CTYPE variable on the command line to
1.4       rillig   8070: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23      jakllsch 8071: your local login name is not the same as your NetBSD login name. The target
                   8072: also automatically removes possibly existing entries for the package in the
                   8073: TODO file. Don't forget to commit the changes, e.g. by using make
1.66      asau     8074: commit-changes-entry! If you are not using a checkout directly from
1.23      jakllsch 8075: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
                   8076: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1       dsieger  8077: 
1.266     martin   8078: 23.4.  Commit Messages
1.130     wiz      8079: 
                   8080: For several years, there have been mirrors of pkgsrc in fossil, git, and hg.
1.257     jkoshy   8081: Standard practice when using these tools is to make the first line of a commit
1.130     wiz      8082: message function as a summary that can be read without the rest, such as is
                   8083: commonly done with "git log --oneline". For this reason, we have the following
                   8084: guidelines for pkgsrc commit messages:
                   8085: 
1.131     wiz      8086:   * Start the commit message with a line that explains the big picture in 65
1.130     wiz      8087:     characters or less. When a commit is for one package, include the name of
                   8088:     the package. For updates, include the version to which it is updated.
                   8089: 
                   8090:   * Leave the next line empty.
                   8091: 
                   8092:   * Then come the details for the commit (changes in that package, reason for a
                   8093:     change) and any relevant PRs. Wrap this section.
                   8094: 
                   8095: Here is an example:
                   8096: 
1.238     wiz      8097: libxslt: update to 1.0.30
1.130     wiz      8098: 
1.238     wiz      8099: Changes since 1.0.29:
                   8100: ...
1.130     wiz      8101: 
                   8102: Here is another example:
                   8103: 
1.238     wiz      8104: mk/bsd.pkg.mk: enable SSP by default on NetBSD
1.130     wiz      8105: 
1.238     wiz      8106: (rationale)
1.130     wiz      8107: 
1.266     martin   8108: Commit messages are final: no    cvs admin    is allowed on the pkgsrc repository
1.130     wiz      8109: to change commit messages.
                   8110: 
1.266     martin   8111: 23.5.  Committing: Adding a package to CVS
1.1       dsieger  8112: 
                   8113: This section is only of interest for pkgsrc developers with write access to the
1.34      wiz      8114: pkgsrc repository.
                   8115: 
1.266     martin   8116: When the package is finished,    cvs add    the files. Start by adding the
1.34      wiz      8117: directory and then files in the directory. Don't forget to add the new package
                   8118: to the category's Makefile. Make sure you don't forget any files; you can check
1.266     martin   8119: by running    cvs status   . An example:
1.34      wiz      8120: 
                   8121: $ cd .../pkgsrc/category
                   8122: $ cvs add pkgname
                   8123: $ cd pkgname
                   8124: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
                   8125: $ cvs add patches/p*
                   8126: $ cvs status | less
1.35      wiz      8127: $ cvs commit
1.34      wiz      8128: $ cd ..
1.236     gutterid 8129: $ vi Makefile # add SUBDIR+=pkgname line
1.35      wiz      8130: $ cvs commit Makefile
1.66      asau     8131: $ cd pkgname
1.73      jnemeth  8132: $ make CTYPE=Added commit-changes-entry
1.1       dsieger  8133: 
                   8134: The commit message of the initial import should include part of the DESCR file,
                   8135: so people reading the mailing lists know what the package is/does.
                   8136: 
1.34      wiz      8137: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
                   8138: 
1.266     martin   8139: Previously,    cvs import    was suggested, but it was much easier to get wrong
                   8140: than    cvs add   .
1.1       dsieger  8141: 
1.266     martin   8142: 23.6.  Updating a package to a newer version
1.1       dsieger  8143: 
                   8144: Please always put a concise, appropriate and relevant summary of the changes
                   8145: between old and new versions into the commit log when updating a package. There
                   8146: are various reasons for this:
                   8147: 
                   8148:   * A URL is volatile, and can change over time. It may go away completely or
                   8149:     its information may be overwritten by newer information.
                   8150: 
                   8151:   * Having the change information between old and new versions in our CVS
                   8152:     repository is very useful for people who use either cvs or anoncvs.
                   8153: 
                   8154:   * Having the change information between old and new versions in our CVS
                   8155:     repository is very useful for people who read the pkgsrc-changes mailing
                   8156:     list, so that they can make tactical decisions about when to upgrade the
                   8157:     package.
                   8158: 
                   8159: Please also recognize that, just because a new version of a package has been
                   8160: released, it should not automatically be upgraded in the CVS repository. We
                   8161: prefer to be conservative in the packages that are included in pkgsrc -
                   8162: development or beta packages are not really the best thing for most places in
                   8163: which pkgsrc is used. Please use your judgement about what should go into
                   8164: pkgsrc, and bear in mind that stability is to be preferred above new and
                   8165: possibly untested features.
                   8166: 
1.266     martin   8167: 23.7.  Renaming a package in pkgsrc
1.21      snj      8168: 
                   8169: Renaming packages is not recommended.
                   8170: 
1.175     gutterid 8171: When renaming packages, be sure to fix any references to the old name in other
1.21      snj      8172: Makefiles, options, buildlink files, etc.
                   8173: 
1.175     gutterid 8174: Also, when renaming a package, please add the package name and version pattern
1.167     leot     8175: (s) of the previous package to SUPERSEDES. This may be repeated for multiple
                   8176: renames. The new package would be an exact replacement. Example:
                   8177: 
                   8178: SUPERSEDES+=    p5-IO-Compress-Zlib<2.017
                   8179: SUPERSEDES+=    optcomp-[0-9]*
1.21      snj      8180: 
1.266     martin   8181: Note that    successor    in the CHANGES-YYYY file doesn't necessarily mean that it
1.21      snj      8182: supersedes, as that successor may not be an exact replacement but is a
                   8183: suggestion for the replaced functionality.
                   8184: 
1.266     martin   8185: 23.8.  Moving a package in pkgsrc
1.21      snj      8186: 
                   8187: It is preferred that packages are not renamed or moved, but if needed please
                   8188: follow these steps.
1.1       dsieger  8189: 
                   8190:  1. Make a copy of the directory somewhere else.
                   8191: 
                   8192:  2. Remove all CVS dirs.
                   8193: 
                   8194:     Alternatively to the first two steps you can also do:
                   8195: 
                   8196:     % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
                   8197: 
                   8198:     and use that for further work.
                   8199: 
1.266     martin   8200:  3. Fix CATEGORIES and any DEPENDS paths that just did    ../package    instead of 
                   8201:        ../../category/package   .
1.1       dsieger  8202: 
1.21      snj      8203:  4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
                   8204:     previous category/package pathname. The PREV_PKGPATH can be used by tools
                   8205:     for doing an update using pkgsrc building; for example, it can search the
                   8206:     pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
                   8207:     the corresponding new PKGPATH for that moved package. Note that it may have
                   8208:     multiple matches, so the tool should also check on the PKGBASE too. The
                   8209:     PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
                   8210:     PKGBASE stays the same.
                   8211: 
1.237     gutterid 8212:  5. cvs add the modified package in the new place.
1.1       dsieger  8213: 
1.21      snj      8214:  6. Check if any package depends on it:
1.1       dsieger  8215: 
                   8216:     % cd /usr/pkgsrc
                   8217:     % grep /package */*/Makefile* */*/buildlink*
                   8218: 
1.21      snj      8219:  7. Fix paths in packages from step 5 to point to new location.
1.1       dsieger  8220: 
1.21      snj      8221:  8. cvs rm (-f) the package at the old location.
1.1       dsieger  8222: 
1.21      snj      8223:  9. Remove from oldcategory/Makefile.
1.1       dsieger  8224: 
1.21      snj      8225: 10. Add to newcategory/Makefile.
1.1       dsieger  8226: 
1.21      snj      8227: 11. Commit the changed and removed files:
1.1       dsieger  8228: 
                   8229:     % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
                   8230: 
                   8231:     (and any packages from step 5, of course).
                   8232: 
1.266     martin   8233: Chapter  24.  pkgsrc Policies
1.263     wiz      8234: 
                   8235: Table of Contents
                   8236: 
                   8237: 24.1. Packages for which updating is restricted
                   8238:     24.1.1. Limited Updates - ABI
                   8239:     24.1.2. Limited Updates - Bootstrap
                   8240: 
1.266     martin   8241: 24.1.  Packages for which updating is restricted
1.263     wiz      8242: 
                   8243: In the past, some packages have caused more package failures than others, and
                   8244: we'd like to reduce this in the future.
                   8245: 
                   8246: For this reason, pkgsrc-pmc marks some packages with POLICY_UPDATE_LIMITED. The
                   8247: possible values currently are:
                   8248: 
                   8249:   * abi for packages where ABI/API changes often broke the packages depending
                   8250:     on them
                   8251: 
                   8252:   * bootstrap for packages that are used during the pkgsrc bootstrap
                   8253: 
                   8254: pkglint will warn when committing updates to these packages.
                   8255: 
1.266     martin   8256: 24.1.1.  Limited Updates - ABI
1.263     wiz      8257: 
                   8258: Before committing non-micro version updates to packages marked with
                   8259: POLICY_UPDATE_LIMITED=abi, a limited bulk build of meta-pkgs/bulk-test-$
                   8260: {PACKAGE} needs to be run and the result posted to the tech-pkg mailing list,
                   8261: highlighting what packages would stop building (if any).
                   8262: 
                   8263: Depending on the result, pkgsrc-pmc then decides:
                   8264: 
                   8265:   * go ahead with the update
                   8266: 
                   8267:   * wait for packages X, Y, Z to be fixed (upstream or locally) with the
                   8268:     updated version, which is put in wip in the meantime
                   8269: 
                   8270:   * In the second case, all pkgsrc developers are encouraged to work on fixing
                   8271:     this - it is not only the updater's task to fix them.
                   8272: 
                   8273: The decision to wait for packages can be revisited.
                   8274: 
1.266     martin   8275: 24.1.2.  Limited Updates - Bootstrap
1.263     wiz      8276: 
                   8277: When updating packages used in the bootstrap, i.e. marked with
                   8278: POLICY_UPDATE_LIMITED=bootstrap, test the bootstrap process and preferably some
                   8279: basic packages and send the patch to the tech-pkg mailing list so it can be
                   8280: tested on other platforms as well. Give at least two weeks for feedback and
                   8281: testing by others.
                   8282: 
1.266     martin   8283: Chapter  25.  Frequently Asked Questions
1.1       dsieger  8284: 
                   8285: This section contains the answers to questions that may arise when you are
                   8286: writing a package. If you don't find your question answered here, first have a
                   8287: look in the other chapters, and if you still don't have the answer, ask on the
                   8288: pkgsrc-users mailing list.
                   8289: 
1.263     wiz      8290: 25.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
                   8291: 25.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
                   8292: 25.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
                   8293: 25.4. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
                   8294: 25.5. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.271     wiz      8295: the := inside it.
1.263     wiz      8296: 25.6. Which mailing lists are there for package developers?
                   8297: 25.7. Where is the pkgsrc documentation?
                   8298: 25.8. I have a little time to kill. What shall I do?
1.1       dsieger  8299: 
1.263     wiz      8300: 25.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1       dsieger  8301: 
                   8302:       MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
1.223     nia      8303:       (1).
                   8304: 
                   8305:       MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM when
                   8306:       building the package.
                   8307: 
                   8308:       .MAKEFLAGS is an internal variable of bmake and should not be used by
                   8309:       packages.
1.1       dsieger  8310: 
1.263     wiz      8311: 25.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1       dsieger  8312: 
                   8313:       MAKE is the path to the make(1) program that is used in the pkgsrc
1.223     nia      8314:       infrastructure.
                   8315: 
                   8316:       GMAKE is the path to GNU Make, but you need to say USE_TOOLS+=gmake to
                   8317:       use that.
                   8318: 
                   8319:       MAKE_PROGRAM is the path to the Make program that is used for building
                   8320:       the package.
1.1       dsieger  8321: 
1.263     wiz      8322: 25.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1       dsieger  8323: 
                   8324:       CC is the path to the real C compiler, which can be configured by the
1.223     nia      8325:       pkgsrc user.
1.1       dsieger  8326: 
1.223     nia      8327:       PKG_CC is the path to the compiler wrapper.
1.1       dsieger  8328: 
1.223     nia      8329:       PKGSRC_COMPILER is not a path to a compiler, but the type of compiler
                   8330:       that should be used. See mk/compiler.mk for more information about the
                   8331:       latter variable.
1.1       dsieger  8332: 
1.263     wiz      8333: 25.4. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1       dsieger  8334: 
1.266     martin   8335:       For optimization reasons, some variables are only available in the    
                   8336:       wrapper    phase and later. To    simulate    the wrapper phase, append 
1.1       dsieger  8337:       PKG_PHASE=wrapper to the above command.
                   8338: 
1.263     wiz      8339: 25.5. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1       dsieger  8340:       the := inside it.
                   8341: 
1.223     nia      8342:       The := is not an assignment operator, even though it may look like one.
1.108     rillig   8343:       Instead, it is a degenerate form of ${LIST:old_string=new_string}, which
                   8344:       is documented in the make(1) man page and which is commonly used in the
                   8345:       form ${SRCS:.c=.o}. In the case of MASTER_SITE_*, old_string is the empty
                   8346:       string and new_string is package/. That's where the : and the = fall
                   8347:       together.
1.1       dsieger  8348: 
1.263     wiz      8349: 25.6. Which mailing lists are there for package developers?
1.1       dsieger  8350: 
                   8351:       tech-pkg
                   8352: 
                   8353:           This is a list for technical discussions related to pkgsrc
                   8354:           development, e.g. soliciting feedback for changes to pkgsrc
                   8355:           infrastructure, proposed new features, questions related to porting
                   8356:           pkgsrc to a new platform, advice for maintaining a package, patches
                   8357:           that affect many packages, help requests moved from pkgsrc-users when
                   8358:           an infrastructure bug is found, etc.
                   8359: 
                   8360:       pkgsrc-bugs
                   8361: 
                   8362:           All bug reports in category "pkg" sent with send-pr(1) appear here.
                   8363:           Please do not report your bugs here directly; use one of the other
                   8364:           mailing lists.
1.271     wiz      8365: 
1.263     wiz      8366: 25.7. Where is the pkgsrc documentation?
1.1       dsieger  8367: 
                   8368:       There are many places where you can find documentation about pkgsrc:
                   8369: 
                   8370:         * The pkgsrc guide (this document) is a collection of chapters that
                   8371:           explain large parts of pkgsrc, but some chapters tend to be outdated.
                   8372:           Which ones they are is hard to say.
                   8373: 
1.174     leot     8374:         * On the mailing list archives (see https://mail-index.NetBSD.org/),
                   8375:           you can find discussions about certain features, announcements of new
1.1       dsieger  8376:           parts of the pkgsrc infrastructure and sometimes even announcements
                   8377:           that a certain feature has been marked as obsolete. The benefit here
                   8378:           is that each message has a date appended to it.
                   8379: 
                   8380:         * Many of the files in the mk/ directory start with a comment that
                   8381:           describes the purpose of the file and how it can be used by the
                   8382:           pkgsrc user and package authors. An easy way to find this
                   8383:           documentation is to run bmake help.
                   8384: 
                   8385:         * The CVS log messages are a rich source of information, but they tend
                   8386:           to be highly abbreviated, especially for actions that occur often.
                   8387:           Some contain a detailed description of what has changed, but they are
                   8388:           geared towards the other pkgsrc developers, not towards an average
                   8389:           pkgsrc user. They also only document changes, so if you don't know
                   8390:           what has been before, these messages may not be worth too much to
                   8391:           you.
                   8392: 
1.266     martin   8393:         * Some parts of pkgsrc are only    implicitly documented   , that is the
1.1       dsieger  8394:           documentation exists only in the mind of the developer who wrote the
                   8395:           code. To get this information, use the cvs annotate command to see
                   8396:           who has written it and ask on the tech-pkg mailing list, so that
                   8397:           others can find your questions later (see above). To be sure that the
                   8398:           developer in charge reads the mail, you may CC him or her.
                   8399: 
1.263     wiz      8400: 25.8. I have a little time to kill. What shall I do?
1.1       dsieger  8401: 
                   8402:       This is not really an FAQ yet, but here's the answer anyway.
                   8403: 
                   8404:         * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
                   8405:           about newer versions of installed packages that are available, but
                   8406:           not yet updated in pkgsrc.
                   8407: 
1.266     martin   8408:         * Browse pkgsrc/doc/TODO     it contains a list of suggested new packages
                   8409:           and a list of cleanups and enhancements for pkgsrc that would be nice
                   8410:           to have.
1.1       dsieger  8411: 
1.71      wiz      8412:         * Review packages for which review was requested on the tech-pkg
                   8413:           mailing list.
1.1       dsieger  8414: 
1.266     martin   8415: Part  III.  The pkgsrc infrastructure internals
1.1       dsieger  8416: 
                   8417: This part of the guide deals with everything from the infrastructure that is
                   8418: behind the interfaces described in the developer's guide. A casual package
                   8419: maintainer should not need anything from this part.
                   8420: 
                   8421: Table of Contents
                   8422: 
1.263     wiz      8423: 26. Design of the pkgsrc infrastructure
                   8424:     26.1. The meaning of variable definitions
                   8425:     26.2. Avoiding problems before they arise
                   8426:     26.3. Variable evaluation
                   8427:         26.3.1. At load time
                   8428:         26.3.2. At runtime
                   8429:     26.4. How can variables be specified?
                   8430:     26.5. Designing interfaces for Makefile fragments
                   8431:         26.5.1. Procedures with parameters
                   8432:         26.5.2. Actions taken on behalf of parameters
                   8433:     26.6. The order in which files are loaded
                   8434:         26.6.1. The order in bsd.prefs.mk
                   8435:         26.6.2. The order in bsd.pkg.mk
                   8436: 27. Regression tests
                   8437:     27.1. Running the regression tests
                   8438:     27.2. Adding a new regression test
                   8439:         27.2.1. Overridable functions
                   8440:         27.2.2. Helper functions
                   8441: 28. Porting pkgsrc
                   8442:     28.1. Porting pkgsrc to a new operating system
1.1       dsieger  8443: 
1.266     martin   8444: Chapter  26.  Design of the pkgsrc infrastructure
1.1       dsieger  8445: 
                   8446: Table of Contents
                   8447: 
1.263     wiz      8448: 26.1. The meaning of variable definitions
                   8449: 26.2. Avoiding problems before they arise
                   8450: 26.3. Variable evaluation
                   8451:     26.3.1. At load time
                   8452:     26.3.2. At runtime
                   8453: 26.4. How can variables be specified?
                   8454: 26.5. Designing interfaces for Makefile fragments
                   8455:     26.5.1. Procedures with parameters
                   8456:     26.5.2. Actions taken on behalf of parameters
                   8457: 26.6. The order in which files are loaded
                   8458:     26.6.1. The order in bsd.prefs.mk
                   8459:     26.6.2. The order in bsd.pkg.mk
1.1       dsieger  8460: 
                   8461: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
                   8462: fragment needs a properly specified interface. This chapter explains how such
                   8463: an interface looks like.
                   8464: 
1.266     martin   8465: 26.1.  The meaning of variable definitions
1.1       dsieger  8466: 
                   8467: Whenever a variable is defined in the pkgsrc infrastructure, the location and
                   8468: the way of definition provide much information about the intended use of that
                   8469: variable. Additionally, more documentation may be found in a header comment or
                   8470: in this pkgsrc guide.
                   8471: 
                   8472: A special file is mk/defaults/mk.conf, which lists all variables that are
                   8473: intended to be user-defined. They are either defined using the ?= operator or
                   8474: they are left undefined because defining them to anything would effectively
1.266     martin   8475: mean    yes   . All these variables may be overridden by the pkgsrc user in the
1.1       dsieger  8476: MAKECONF file.
                   8477: 
                   8478: Outside this file, the following conventions apply: Variables that are defined
                   8479: using the ?= operator may be overridden by a package.
                   8480: 
                   8481: Variables that are defined using the = operator may be used read-only at
                   8482: run-time.
                   8483: 
                   8484: Variables whose name starts with an underscore must not be accessed outside the
                   8485: pkgsrc infrastructure at all. They may change without further notice.
                   8486: 
                   8487: Note
                   8488: 
                   8489: These conventions are currently not applied consistently to the complete pkgsrc
                   8490: infrastructure.
                   8491: 
1.266     martin   8492: 26.2.  Avoiding problems before they arise
1.1       dsieger  8493: 
                   8494: All variables that contain lists of things should default to being empty. Two
                   8495: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
                   8496: variables cannot simply be modified using the += operator in package Makefiles
                   8497: (or other files included by them), since there is no guarantee whether the
                   8498: variable is already set or not, and what its value is. In the case of
1.266     martin   8499: DISTFILES, the packages    know    the default value and just define it as in the
1.1       dsieger  8500: following example.
                   8501: 
                   8502: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   8503: 
                   8504: Because of the selection of this default value, the same value appears in many
                   8505: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
1.266     martin   8506: value (   c   ) is so short that it doesn't stand out. Nevertheless it is mentioned
1.1       dsieger  8507: in many files.
                   8508: 
1.266     martin   8509: 26.3.  Variable evaluation
1.1       dsieger  8510: 
1.266     martin   8511: 26.3.1.  At load time
1.1       dsieger  8512: 
                   8513: Variable evaluation takes place either at load time or at runtime, depending on
                   8514: the context in which they occur. The contexts where variables are evaluated at
                   8515: load time are:
                   8516: 
                   8517:   * The right hand side of the := and != operators,
                   8518: 
                   8519:   * Make directives like .if or .for,
                   8520: 
                   8521:   * Dependency lines.
                   8522: 
                   8523: A special exception are references to the iteration variables of .for loops,
                   8524: which are expanded inline, no matter in which context they appear.
                   8525: 
                   8526: As the values of variables may change during load time, care must be taken not
                   8527: to evaluate them by accident. Typical examples for variables that should not be
                   8528: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
                   8529: clear, here is an example:
                   8530: 
                   8531: CONFIGURE_ARGS=         # none
                   8532: CFLAGS=                 -O
                   8533: CONFIGURE_ARGS+=        CFLAGS=${CFLAGS:Q}
                   8534: 
                   8535: CONFIGURE_ARGS:=        ${CONFIGURE_ARGS}
                   8536: 
                   8537: CFLAGS+=                -Wall
                   8538: 
                   8539: This code shows how the use of the := operator can quickly lead to unexpected
                   8540: results. The first paragraph is fairly common code. The second paragraph
                   8541: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
                   8542: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
                   8543: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
                   8544: typically occur in completely unrelated files.
                   8545: 
1.266     martin   8546: 26.3.2.  At runtime
1.1       dsieger  8547: 
                   8548: After all the files have been loaded, the values of the variables cannot be
                   8549: changed anymore. Variables that are used in the shell commands are expanded at
                   8550: this point.
                   8551: 
1.266     martin   8552: 26.4.  How can variables be specified?
1.1       dsieger  8553: 
                   8554: There are many ways in which the definition and use of a variable can be
                   8555: restricted in order to detect bugs and violations of the (mostly unwritten)
1.108     rillig   8556: policies. A package can be checked with pkglint -Wall to see whether it meets
                   8557: these rules.
1.1       dsieger  8558: 
1.266     martin   8559: 26.5.  Designing interfaces for Makefile fragments
1.1       dsieger  8560: 
                   8561: Most of the .mk files fall into one of the following classes. Cases where a
                   8562: file falls into more than one class should be avoided as it often leads to
                   8563: subtle bugs.
                   8564: 
1.266     martin   8565: 26.5.1.  Procedures with parameters
1.1       dsieger  8566: 
                   8567: In a traditional imperative programming language some of the .mk files could be
1.266     martin   8568: described as procedures. They take some input parameters and   after
                   8569: inclusion   provide a result in output parameters. Since all variables in
1.23      jakllsch 8570: Makefiles have global scope care must be taken not to use parameter names that
                   8571: have already another meaning. For example, PKGNAME is a bad choice for a
                   8572: parameter name.
1.1       dsieger  8573: 
                   8574: Procedures are completely evaluated at preprocessing time. That is, when
                   8575: calling a procedure all input parameters must be completely resolvable. For
                   8576: example, CONFIGURE_ARGS should never be an input parameter since it is very
                   8577: likely that further text will be added after calling the procedure, which would
                   8578: effectively apply the procedure to only a part of the variable. Also,
1.108     rillig   8579: references to other variables will be modified after calling the procedure.
1.1       dsieger  8580: 
                   8581: A procedure can declare its output parameters either as suitable for use in
                   8582: preprocessing directives or as only available at runtime. The latter
                   8583: alternative is for variables that contain references to other runtime
                   8584: variables.
                   8585: 
                   8586: Procedures shall be written such that it is possible to call the procedure more
                   8587: than once. That is, the file must not contain multiple-inclusion guards.
                   8588: 
                   8589: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
                   8590: To express that the parameters are evaluated at load time, they should be
                   8591: assigned using the := operator, which should be used only for this purpose.
                   8592: 
1.266     martin   8593: 26.5.2.  Actions taken on behalf of parameters
1.1       dsieger  8594: 
                   8595: Action files take some input parameters and may define runtime variables. They
                   8596: shall not define loadtime variables. There are action files that are included
                   8597: implicitly by the pkgsrc infrastructure, while other must be included
                   8598: explicitly.
                   8599: 
                   8600: An example for action files is mk/subst.mk.
                   8601: 
1.266     martin   8602: 26.6.  The order in which files are loaded
1.1       dsieger  8603: 
                   8604: Package Makefiles usually consist of a set of variable definitions, and include
                   8605: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
                   8606: include various other *.mk files if they need to query the availability of
                   8607: certain features like the type of compiler or the X11 implementation. Due to
                   8608: the heavy use of preprocessor directives like .if and .for, the order in which
                   8609: the files are loaded matters.
                   8610: 
                   8611: This section describes at which point the various files are loaded and gives
                   8612: reasons for that order.
                   8613: 
1.266     martin   8614: 26.6.1.  The order in bsd.prefs.mk
1.1       dsieger  8615: 
                   8616: The very first action in bsd.prefs.mk is to define some essential variables
                   8617: like OPSYS, OS_VERSION and MACHINE_ARCH.
                   8618: 
1.4       rillig   8619: Then, the user settings are loaded from the file specified in MAKECONF, which
                   8620: is usually mk.conf. After that, those variables that have not been overridden
                   8621: by the user are loaded from mk/defaults/mk.conf.
1.1       dsieger  8622: 
                   8623: After the user settings, the system settings and platform settings are loaded,
                   8624: which may override the user settings.
                   8625: 
                   8626: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
                   8627: This only happens when building a package, so the proper variables must be used
                   8628: instead of the direct tool names.
                   8629: 
                   8630: As the last steps, some essential variables from the wrapper and the package
                   8631: system flavor are loaded, as well as the variables that have been cached in
                   8632: earlier phases of a package build.
                   8633: 
1.266     martin   8634: 26.6.2.  The order in bsd.pkg.mk
1.1       dsieger  8635: 
                   8636: First, bsd.prefs.mk is loaded.
                   8637: 
                   8638: Then, the various *-vars.mk files are loaded, which fill default values for
                   8639: those variables that have not been defined by the package. These variables may
                   8640: later be used even in unrelated files.
                   8641: 
                   8642: Then, the file bsd.pkg.error.mk provides the target error-check that is added
                   8643: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
                   8644: DELAYED_WARNING_MSG.
                   8645: 
                   8646: Then, the package-specific hacks from hacks.mk are included.
                   8647: 
                   8648: Then, various other files follow. Most of them don't have any dependencies on
                   8649: what they need to have included before or after them, though some do.
                   8650: 
                   8651: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
                   8652: restricts the use of these variables to all the files that have been included
                   8653: before. Appearances in later files will be silently ignored.
                   8654: 
                   8655: Then, the files for the main targets are included, in the order of later
                   8656: execution, though the actual order should not matter.
                   8657: 
                   8658: At last, some more files are included that don't set any interesting variables
                   8659: but rather just define make targets to be executed.
                   8660: 
1.266     martin   8661: Chapter  27.  Regression tests
1.1       dsieger  8662: 
                   8663: Table of Contents
                   8664: 
1.263     wiz      8665: 27.1. Running the regression tests
                   8666: 27.2. Adding a new regression test
                   8667:     27.2.1. Overridable functions
                   8668:     27.2.2. Helper functions
1.1       dsieger  8669: 
                   8670: The pkgsrc infrastructure consists of a large codebase, and there are many
                   8671: corners where every little bit of a file is well thought out, making pkgsrc
                   8672: likely to fail as soon as anything is changed near those parts. To prevent most
                   8673: changes from breaking anything, a suite of regression tests should go along
                   8674: with every important part of the pkgsrc infrastructure. This chapter describes
                   8675: how regression tests work in pkgsrc and how you can add new tests.
                   8676: 
1.266     martin   8677: 27.1.  Running the regression tests
1.1       dsieger  8678: 
1.25      wiz      8679: You first need to install the pkgtools/pkg_regress package, which provides the 
1.1       dsieger  8680: pkg_regress command. Then you can simply run that command, which will run all
1.168     rillig   8681: tests in the regress/ directory.
1.1       dsieger  8682: 
1.266     martin   8683: 27.2.  Adding a new regression test
1.1       dsieger  8684: 
1.168     rillig   8685: Every directory in the regress/ directory that contains a file called spec is
1.1       dsieger  8686: considered a regression test. This file is a shell program that is included by
                   8687: the pkg_regress command. The following functions can be overridden to suit your
                   8688: needs.
                   8689: 
1.266     martin   8690: 27.2.1.  Overridable functions
1.1       dsieger  8691: 
1.266     martin   8692: These functions do not take any parameters. Although they are called in    set -e
                   8693:     mode, they don't stop at the first failing command. See this Stack Overflow
1.108     rillig   8694: question for details.
1.1       dsieger  8695: 
1.108     rillig   8696: do_setup
1.1       dsieger  8697: 
                   8698:     This function prepares the environment for the test. By default it does
                   8699:     nothing.
                   8700: 
1.108     rillig   8701: do_test
1.1       dsieger  8702: 
                   8703:     This function runs the actual test. By default, it calls TEST_MAKE with the
                   8704:     arguments MAKEARGS_TEST and writes its output including error messages into
                   8705:     the file TEST_OUTFILE.
                   8706: 
1.108     rillig   8707:     When defining this function, make sure that all output that needs to be
                   8708:     checked is written to the correct output file. Example:
                   8709: 
                   8710:     do_test() {
                   8711:             echo "Example output"
                   8712:     } 1>$TEST_OUTFILE 2>&1
                   8713: 
                   8714: check_result
1.1       dsieger  8715: 
                   8716:     This function is run after the test and is typically used to compare the
                   8717:     actual output from the one that is expected. It can make use of the various
1.108     rillig   8718:     helper functions from the next section. Example:
                   8719: 
                   8720:     check_result() {
                   8721:             exit_status 0
                   8722:             output_require "Example"
                   8723:             output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
                   8724:             output_prohibit "no such file or directory"
1.169     rillig   8725:             regress_fail "expected $expected but got $actual for input $input"
1.108     rillig   8726:     }
1.1       dsieger  8727: 
1.108     rillig   8728: do_cleanup
1.1       dsieger  8729: 
                   8730:     This function cleans everything up after the test has been run. By default
                   8731:     it does nothing.
                   8732: 
1.266     martin   8733: 27.2.2.  Helper functions
1.1       dsieger  8734: 
1.168     rillig   8735: regress_fail message...
                   8736: 
                   8737:     This function makes the test fail with the given error message.
                   8738: 
1.108     rillig   8739: exit_status expected
1.1       dsieger  8740: 
1.108     rillig   8741:     This function compares the exitcode of the do_test function with its first
                   8742:     parameter. If they differ, the test will fail.
1.1       dsieger  8743: 
1.108     rillig   8744: output_require regex...
1.1       dsieger  8745: 
                   8746:     This function checks for each of its parameters if the output from do_test
1.108     rillig   8747:     matches the extended regular expression. If it does not, the test will
                   8748:     fail. Example:
                   8749: 
                   8750:     output_require "looks fine"
                   8751:     output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
1.1       dsieger  8752: 
1.177     leot     8753: output_prohibit regex...
1.1       dsieger  8754: 
                   8755:     This function checks for each of its parameters if the output from do_test
                   8756:     () does not match the extended regular expression. If any of the regular
                   8757:     expressions matches, the test will fail.
                   8758: 
1.266     martin   8759: Chapter  28.  Porting pkgsrc
1.1       dsieger  8760: 
                   8761: Table of Contents
                   8762: 
1.263     wiz      8763: 28.1. Porting pkgsrc to a new operating system
1.1       dsieger  8764: 
                   8765: The pkgsrc system has already been ported to many operating systems, hardware
                   8766: architectures and compilers. This chapter explains the necessary steps to make
                   8767: pkgsrc even more portable.
                   8768: 
1.266     martin   8769: 28.1.  Porting pkgsrc to a new operating system
1.1       dsieger  8770: 
                   8771: To port pkgsrc to a new operating system (called MyOS in this example), you
                   8772: need to touch the following files:
                   8773: 
                   8774: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
                   8775: 
                   8776:     This file contains some basic definitions, for example the name of the C
                   8777:     compiler.
                   8778: 
                   8779: mk/bsd.prefs.mk
                   8780: 
1.212     wiz      8781:     Insert code that defines the variables OPSYS, OS_VERSION, OPSYS_VERSION,
1.1       dsieger  8782:     LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
                   8783:     that appear in this file.
                   8784: 
                   8785: mk/platform/MyOS.mk
                   8786: 
                   8787:     This file contains the platform-specific definitions that are used by
                   8788:     pkgsrc. Start by copying one of the other files and edit it to your needs.
                   8789: 
                   8790: mk/tools/tools.MyOS.mk
                   8791: 
                   8792:     This file defines the paths to all the tools that are needed by one or the
                   8793:     other package in pkgsrc, as well as by pkgsrc itself. Find out where these
                   8794:     tools are on your platform and add them.
                   8795: 
                   8796: Now, you should be able to build some basic packages, like lang/perl5, shells/
                   8797: bash.
                   8798: 
1.266     martin   8799: Appendix  A.  A simple example package: bison
1.1       dsieger  8800: 
                   8801: Table of Contents
                   8802: 
                   8803: A.1. files
                   8804:     A.1.1. Makefile
                   8805:     A.1.2. DESCR
                   8806:     A.1.3. PLIST
                   8807:     A.1.4. Checking a package with pkglint
                   8808: A.2. Steps for building, installing, packaging
                   8809: 
                   8810: We checked to find a piece of software that wasn't in the packages collection,
1.25      wiz      8811: and picked GNU bison. Quite why someone would want to have bison when Berkeley 
1.1       dsieger  8812: yacc is already present in the tree is beyond us, but it's useful for the
                   8813: purposes of this exercise.
                   8814: 
1.266     martin   8815: A.1.  files
1.1       dsieger  8816: 
1.266     martin   8817: A.1.1.  Makefile
1.1       dsieger  8818: 
1.2       rillig   8819: # $NetBSD$
1.1       dsieger  8820: #
                   8821: 
                   8822: DISTNAME=       bison-1.25
                   8823: CATEGORIES=     devel
1.171     rillig   8824: MASTER_SITES=   ${MASTER_SITE_GNU:=bison/}
1.1       dsieger  8825: 
1.30      dholland 8826: MAINTAINER=     pkgsrc-users@NetBSD.org
1.174     leot     8827: HOMEPAGE=       https://www.gnu.org/software/bison/bison.html
1.1       dsieger  8828: COMMENT=        GNU yacc clone
                   8829: 
                   8830: GNU_CONFIGURE=  yes
1.47      wiz      8831: INFO_FILES=     yes
1.1       dsieger  8832: 
                   8833: .include "../../mk/bsd.pkg.mk"
                   8834: 
1.266     martin   8835: A.1.2.  DESCR
1.1       dsieger  8836: 
                   8837: GNU version of yacc.  Can make re-entrant parsers, and numerous other
                   8838: improvements.  Why you would want this when Berkeley yacc(1) is part
                   8839: of the NetBSD source tree is beyond me.
                   8840: 
1.266     martin   8841: A.1.3.  PLIST
1.1       dsieger  8842: 
1.2       rillig   8843: @comment $NetBSD$
1.1       dsieger  8844: bin/bison
                   8845: man/man1/bison.1.gz
                   8846: share/bison.simple
                   8847: share/bison.hairy
                   8848: 
1.266     martin   8849: A.1.4.  Checking a package with pkglint
1.1       dsieger  8850: 
                   8851: The NetBSD package system comes with pkgtools/pkglint which helps to check the
                   8852: contents of these files. After installation it is quite easy to use, just
1.171     rillig   8853: change to the directory of the package you wish to examine and run pkglint:
1.1       dsieger  8854: 
                   8855: $ pkglint
1.171     rillig   8856: ERROR: Makefile: Each package must define its LICENSE.
                   8857: WARN: Makefile:9: HOMEPAGE should migrate from http to https.
                   8858: NOTE: PLIST:3: The .gz extension is unnecessary for manual pages.
                   8859: WARN: PLIST:5: "share/bison.hairy" should be sorted before "share/bison.simple".
                   8860: 1 error, 2 warnings and 1 note found.
                   8861: (Run "pkglint -e" to show explanations.)
                   8862: (Run "pkglint -fs" to show what can be fixed automatically.)
1.172     rillig   8863: (Run "pkglint -F" to automatically fix some issues.)
1.1       dsieger  8864: 
                   8865: Depending on the supplied command line arguments (see pkglint(1)), more checks
1.170     rillig   8866: will be performed. Use e.g. pkglint -Wall for a very thorough check.
1.1       dsieger  8867: 
1.266     martin   8868: A.2.  Steps for building, installing, packaging
1.1       dsieger  8869: 
                   8870: Create the directory where the package lives, plus any auxiliary directories:
                   8871: 
                   8872: # cd /usr/pkgsrc/lang
                   8873: # mkdir bison
                   8874: # cd bison
                   8875: # mkdir patches
                   8876: 
1.266     martin   8877: Create Makefile, DESCR and PLIST (see Chapter  12, Package components - files,
1.1       dsieger  8878: directories and contents) then continue with fetching the distfile:
                   8879: 
                   8880: # make fetch
                   8881: >> bison-1.25.tar.gz doesn't seem to exist on this system.
                   8882: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
                   8883: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8884: ftp: Error retrieving file: 500 Internal error
                   8885: 
                   8886: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
                   8887: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8888: ftp: Error retrieving file: 500 Internal error
                   8889: 
                   8890: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
                   8891: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8892: Successfully retrieved file.
                   8893: 
                   8894: Generate the checksum of the distfile into distinfo:
                   8895: 
                   8896: # make makedistinfo
                   8897: 
                   8898: Now compile:
                   8899: 
                   8900: # make
                   8901: >> Checksum OK for bison-1.25.tar.gz.
                   8902: ===>  Extracting for bison-1.25
                   8903: ===>  Patching for bison-1.25
                   8904: ===>   Ignoring empty patch directory
                   8905: ===>  Configuring for bison-1.25
                   8906: creating cache ./config.cache
                   8907: checking for gcc... cc
                   8908: checking whether we are using GNU C... yes
                   8909: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
                   8910: checking how to run the C preprocessor... cc -E
                   8911: checking for minix/config.h... no
                   8912: checking for POSIXized ISC... no
                   8913: checking whether cross-compiling... no
                   8914: checking for ANSI C header files... yes
                   8915: checking for string.h... yes
                   8916: checking for stdlib.h... yes
                   8917: checking for memory.h... yes
                   8918: checking for working const... yes
                   8919: checking for working alloca.h... no
                   8920: checking for alloca... yes
                   8921: checking for strerror... yes
                   8922: updating cache ./config.cache
                   8923: creating ./config.status
                   8924: creating Makefile
                   8925: ===>  Building for bison-1.25
                   8926: 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
                   8927: 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
                   8928: 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
                   8929: 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
                   8930: 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
                   8931: 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
                   8932: 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
                   8933: 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
                   8934: 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
                   8935: 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
                   8936: 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
                   8937: 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
                   8938: 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
                   8939: 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
                   8940: 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
                   8941: 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
                   8942: 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
                   8943: 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
                   8944: 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
                   8945: 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
                   8946: 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
                   8947: 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
                   8948: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
                   8949: rm -f bison.s1
                   8950: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
                   8951: 
                   8952: Everything seems OK, so install the files:
                   8953: 
                   8954: # make install
                   8955: >> Checksum OK for bison-1.25.tar.gz.
                   8956: ===>  Installing for bison-1.25
                   8957: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
                   8958: rm -f /usr/pkg/bin/bison
                   8959: cd /usr/pkg/share; rm -f bison.simple bison.hairy
                   8960: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
                   8961: install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
                   8962: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
                   8963: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
                   8964: cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
                   8965: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
                   8966: ===>  Registering installation for bison-1.25
                   8967: 
                   8968: You can now use bison, and also - if you decide so - remove it with pkg_delete
                   8969: bison. Should you decide that you want a binary package, do this now:
                   8970: 
                   8971: # make package
                   8972: >> Checksum OK for bison-1.25.tar.gz.
                   8973: ===>  Building package for bison-1.25
                   8974: Creating package bison-1.25.tgz
                   8975: Registering depends:.
                   8976: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
                   8977: 
                   8978: Now that you don't need the source and object files any more, clean up:
                   8979: 
                   8980: # make clean
                   8981: ===>  Cleaning for bison-1.25
                   8982: 
1.266     martin   8983: Appendix  B.  Security hardening
1.207     leot     8984: 
                   8985: Table of Contents
                   8986: 
                   8987: B.1. Mechanisms
                   8988:     B.1.1. Enabled by default
                   8989:     B.1.2. Not enabled by default
                   8990: B.2. Caveats
                   8991:     B.2.1. Problems with PKGSRC_MKPIE
                   8992:     B.2.2. Problems with PKGSRC_USE_FORTIFY
                   8993:     B.2.3. Problems with PKGSRC_USE_RELRO
                   8994:     B.2.4. Problems with PKGSRC_USE_SSP
                   8995: B.3. Auditing the system
                   8996:     B.3.1. Checking for PIE
                   8997:     B.3.2. Checking for partial RELRO
                   8998:     B.3.3. Checking for full RELRO
                   8999:     B.3.4. Checking for SSP
                   9000: 
                   9001: A number of mechanisms are available in pkgsrc to improve the security of the
                   9002: resulting system. This page describes the mechanisms, and gives hints about
                   9003: detecting and fixing problems.
                   9004: 
                   9005: Mechanisms can be enabled individually in mk.conf, and are individually
                   9006: described below.
                   9007: 
                   9008: Typically, a feature will cause some programs to fail to build or work when
                   9009: first enabled. This can be due to latent problems in the program, and can be
                   9010: due to other reasons. After enough testing to have confidence that user
                   9011: problems will be quite rare, individual mechanisms will be enabled by default.
                   9012: 
                   9013: For each mechanism, see the Caveats section below for an explanation of what
                   9014: might go wrong at compile time and at run time, and how to notice and address
                   9015: these problems.
                   9016: 
1.266     martin   9017: B.1.  Mechanisms
1.207     leot     9018: 
1.266     martin   9019: B.1.1.  Enabled by default
1.207     leot     9020: 
1.266     martin   9021: B.1.1.1.  PKGSRC_USE_FORTIFY
1.207     leot     9022: 
                   9023: This allows substitute wrappers to be used for some commonly used library
                   9024: functions that do not have built-in bounds checking - but could in some cases.
                   9025: 
                   9026: Two mitigation levels are available:
                   9027: 
                   9028:   * "weak" only enables checks at compile-time.
                   9029: 
                   9030:   * "strong" enables checks at compile-time and runtime.
                   9031: 
                   9032: "strong" has been enabled by default since pkgsrc-2017Q3.
                   9033: 
1.266     martin   9034: B.1.1.2.  PKGSRC_USE_SSP
1.207     leot     9035: 
                   9036: This enables a stack-smashing protection mitigation. It is done by adding a
                   9037: guard variable to functions with vulnerable objects. The guards are initialized
                   9038: when a function is entered and then checked when the function exits. The guard
                   9039: check will fail and the program forcibly exited if the variable was modified in
                   9040: the meantime. This can happen in case of buffer overflows or memory corruption,
                   9041: and therefore exposing these bugs.
                   9042: 
                   9043: Different mitigation levels are available:
                   9044: 
                   9045:   * "yes", which will only protect functions considered vulnerable by the
                   9046:     compiler;
                   9047: 
                   9048:   * "all", which will protect every function;
                   9049: 
                   9050:   * "strong", the default, which will apply a better balance between the two
                   9051:     settings above.
                   9052: 
                   9053: This mitigation is supported by both GCC and clang. It may be supported in
                   9054: additional compilers, possibly under a different name. It is particularly
                   9055: useful for unsafe programming languages, such as C/C++.
                   9056: 
                   9057:   * "yes" is enabled by default where known supported since pkgsrc-2017Q3.
                   9058: 
                   9059:   * "strong" is enabled by default where known supported since pkgsrc-2021Q4.
                   9060: 
                   9061: More details can be found here:
                   9062: 
                   9063:   * Buffer overflow protection on Wikipedia
                   9064: 
1.266     martin   9065: B.1.1.3.  PKGSRC_MKPIE
1.207     leot     9066: 
                   9067: This requests the creation of PIE (Position Independent Executables) for all
                   9068: executables. The PIE mechanism is normally used for shared libraries, so that
                   9069: they can be loaded at differing addresses at runtime. PIE itself does not have
                   9070: useful security properties; however, it is necessary to fully leverage some,
                   9071: such as ASLR. Some operating systems support Address Space Layout Randomization
                   9072: (ASLR), which causes different addresses to be used each time a program is run.
                   9073: This makes it more difficult for an attacker to guess addresses and thus makes
                   9074: exploits harder to construct. With PIE, ASLR can really be applied to the
                   9075: entire program, instead of the stack and heap only.
                   9076: 
                   9077: PIE executables will only be built for toolchains that are known to support
                   9078: PIE. Currently, this means NetBSD on x86, ARM, SPARC64, m68k, and MIPS.
                   9079: 
                   9080: PKGSRC_MKPIE was enabled by default after the pkgsrc-2021Q3 branch.
                   9081: 
1.266     martin   9082: B.1.1.4.  PKGSRC_USE_RELRO
1.207     leot     9083: 
                   9084: This also makes the exploitation of some security vulnerabilities more
                   9085: difficult in some cases.
                   9086: 
                   9087: Two different mitigation levels are available:
                   9088: 
1.219     nia      9089:   * partial (the default): the ELF sections are reordered so that internal data
                   9090:     sections precede the program's own data sections, and non-PLT GOT is
                   9091:     read-only;
1.207     leot     9092: 
                   9093:   * full: in addition to partial RELRO, every relocation is performed
1.218     nia      9094:     immediately when starting the program, allowing the entire GOT to be
                   9095:     read-only. This can greatly slow down startup of large programs.
1.207     leot     9096: 
                   9097: This is currently supported by GCC. Many software distributions now enable this
1.220     nia      9098: feature by default, at the "partial" level.
1.207     leot     9099: 
                   9100: More details can be found here:
                   9101: 
                   9102:   * Hardening ELF binaries using Relocation Read-Only (RELRO)
                   9103: 
1.266     martin   9104: B.1.2.  Not enabled by default
1.219     nia      9105: 
1.266     martin   9106: B.1.2.1.  PKGSRC_MKREPRO
1.219     nia      9107: 
                   9108: With this option, pkgsrc will try to build packages reproducibly. This allows
                   9109: packages built from the same tree and with the same options, to produce
                   9110: identical results bit by bit. This option should be combined with ASLR and
                   9111: PKGSRC_MKPIE to avoid predictable address offsets for attackers attempting to
                   9112: exploit security vulnerabilities.
                   9113: 
                   9114: More details can be found here:
                   9115: 
                   9116:   * Reproducible Builds - a set of software development practices that create
                   9117:     an independently-verifiable path from source to binary code
                   9118: 
                   9119: More work likely needs to be done before pkgsrc is fully reproducible.
                   9120: 
1.266     martin   9121: B.1.2.2.  PKGSRC_USE_STACK_CHECK
1.207     leot     9122: 
                   9123: This uses -fstack-check with GCC for another stack protection mitigation.
                   9124: 
                   9125: It asks the compiler to generate code verifying that it does not corrupt the
                   9126: stack. According to GCC's manual page, this is really only useful for
                   9127: multi-threaded programs.
                   9128: 
1.266     martin   9129: B.2.  Caveats
1.207     leot     9130: 
1.266     martin   9131: B.2.1.  Problems with PKGSRC_MKPIE
1.207     leot     9132: 
1.266     martin   9133: B.2.1.1.  Packages failing to build
1.207     leot     9134: 
                   9135: A number of packages may fail to build with this option enabled. The failures
                   9136: are often related to the absence of the -fPIC compilation flag when building
                   9137: libraries or executables (or ideally -fPIE in the latter case). This flag is
                   9138: added to the CFLAGS already, but requires the package to actually support it.
                   9139: 
1.266     martin   9140: B.2.1.1.1.  How to fix
1.207     leot     9141: 
                   9142: These instructions are meant as a reference only; they likely need to be
                   9143: adapted for many packages individually.
                   9144: 
                   9145: For packages using Makefiles:
                   9146: 
                   9147: MAKE_FLAGS+=    CFLAGS=${CFLAGS:Q}
                   9148: MAKE_FLAGS+=    LDFLAGS=${LDFLAGS:Q}
                   9149: 
                   9150: For packages using Imakefiles:
                   9151: 
                   9152: MAKE_FLAGS+=    CCOPTIONS=${CFLAGS:Q}
                   9153: MAKE_FLAGS+=    LOCAL_LDFLAGS=${LDFLAGS:Q}
                   9154: 
1.266     martin   9155: B.2.1.2.  Run-time crashes
1.207     leot     9156: 
                   9157: Some programs may fail to run, or crash at random times once built as PIE. Two
                   9158: scenarios are essentially possible. This is nearly always due to a bug in the
                   9159: program being exposed due to ASLR.
                   9160: 
1.266     martin   9161: B.2.1.3.  Disabling PKGSRC_MKPIE on a per-package basis
1.207     leot     9162: 
                   9163: Ideally, packages should be fixed for compatibility with MKPIE. However, in
                   9164: some cases this is very difficult, due to complex build systems, packages using
                   9165: non-standard toolchains, or programming languages with odd bootstrapping
                   9166: mechanisms.
                   9167: 
                   9168: To disable PKGSRC_MKPIE on a per-package basis, set MKPIE_SUPPORTED= no in the
                   9169: package's Makefile before bsd.prefs.mk is included.
                   9170: 
1.266     martin   9171: B.2.2.  Problems with PKGSRC_USE_FORTIFY
1.207     leot     9172: 
1.266     martin   9173: B.2.2.1.  Packages failing to build
1.207     leot     9174: 
                   9175: This feature makes use of pre-processing directives to look for hardened,
                   9176: alternative implementations of essential library calls. Some programs may fail
                   9177: to build as a result; this usually happens for those trying too hard to be
                   9178: portable, or otherwise abusing definitions in the standard library.
                   9179: 
1.266     martin   9180: B.2.2.2.  Run-time crashes
1.207     leot     9181: 
                   9182: This feature may cause some programs to crash, usually indicating an actual bug
                   9183: in the program. The fix will typically involve patching the original program's
                   9184: source code.
                   9185: 
1.266     martin   9186: B.2.2.3.  Optimization is required
1.207     leot     9187: 
                   9188: At least in the case of GCC, FORTIFY will only be applied if optimization is
                   9189: applied while compiling. This means that the CFLAGS should also contain -O, -O2
                   9190: or another optimization level. This cannot easily be applied globally, as some
                   9191: packages may require specific optimization levels.
                   9192: 
1.266     martin   9193: B.2.2.4.  Disabling FORTIFY on a per-package basis
1.207     leot     9194: 
                   9195: Note
                   9196: 
                   9197: FORTIFY should not be disabled to work around runtime crashes in the program!
                   9198: This is a very bad idea and will expose you to security vulnerabilities.
                   9199: 
                   9200: To disable FORTIFY on a per-package basis, set the following in the package's
                   9201: Makefile before bsd.prefs.mk is included:
                   9202: 
                   9203: FORTIFY_SUPPORTED=      no
                   9204: 
1.266     martin   9205: B.2.3.  Problems with PKGSRC_USE_RELRO
1.207     leot     9206: 
1.266     martin   9207: B.2.3.1.  Performance impact
1.207     leot     9208: 
                   9209: For better protection, full RELRO requires every symbol to be resolved when the
                   9210: program starts, rather than simply when required at run-time. This will have
                   9211: more impact on programs using a lot of symbols, or linked to libraries exposing
                   9212: a lot of symbols. Therefore, daemons or programs otherwise running in
                   9213: background are affected only when started. Programs loading plug-ins at
                   9214: run-time are affected when loading the plug-ins.
                   9215: 
                   9216: The impact is not expected to be noticeable on modern hardware, except in some
                   9217: cases for big programs.
                   9218: 
1.266     martin   9219: B.2.3.2.  Run-time crashes
1.207     leot     9220: 
                   9221: Some programs handle plug-ins and dependencies in a way that conflicts with
                   9222: RELRO: for instance, with an initialization routine listing any other plug-in
                   9223: required. With full RELRO, the missing symbols are resolved before the
                   9224: initialization routine can run, and the dynamic loader will not be able to find
                   9225: them directly and abort as a result. Unfortunately, this is how Xorg loads its
                   9226: drivers. Partial RELRO can be applied instead in this case.
                   9227: 
1.266     martin   9228: B.2.3.3.  Disabling RELRO on a per-package basis
1.207     leot     9229: 
                   9230: To disable RELRO on a per-package basis, set the following in the package's
                   9231: Makefile before bsd.prefs.mk is included:
                   9232: 
                   9233: RELRO_SUPPORTED=        no
                   9234: 
1.209     nia      9235: It is also possible to at most enable partial RELRO, by setting RELRO_SUPPORTED
                   9236: to partial.
                   9237: 
1.266     martin   9238: B.2.4.  Problems with PKGSRC_USE_SSP
1.207     leot     9239: 
1.266     martin   9240: B.2.4.1.  Packages failing to build
1.207     leot     9241: 
                   9242: The stack-smashing protection provided by this option does not work for some
                   9243: programs. The most common situation in which this happens is when the program
                   9244: allocates variables on the stack, with the size determined at run-time.
                   9245: 
1.266     martin   9246: B.2.4.2.  Run-time crashes
1.207     leot     9247: 
                   9248: Again, this feature may cause some programs to crash via a SIGABRT, usually
                   9249: indicating an actual bug in the program.
                   9250: 
                   9251: On NetBSD LOG_CRIT level syslog messages are sent and - by default - appended
                   9252: to /var/log/messages, e.g.:
                   9253: 
                   9254: Jan  6 15:42:51 hostname -: hostname program - - - buffer overflow detected; terminated
                   9255: 
                   9256: (where hostname is the hostname(1) and program is the basename(1) of the
                   9257: program crashed).
                   9258: 
                   9259: Patching the original program is then required.
                   9260: 
                   9261: Rebuilding the package via:
                   9262: 
                   9263: % env CFLAGS=-g INSTALL_UNSTRIPPED=yes make replace
                   9264: 
                   9265: and inspecting the backtrace of the coredump via the debugger should point out
                   9266: the problematic call by inspecting the frame calling the _chk() (SSP) function.
                   9267: 
1.266     martin   9268: B.2.4.3.  Performance impact
1.207     leot     9269: 
                   9270: The compiler emits extra code when using this feature: a check for buffer
                   9271: overflows is performed when entering and exiting functions, requiring an extra
                   9272: variable on the stack. The level of protection can otherwise be adjusted to
                   9273: affect only those functions considered more sensitive by the compiler (with
                   9274: -fstack-protector instead of -fstack-protector-all).
                   9275: 
                   9276: The impact is not expected to be noticeable on modern hardware. However,
                   9277: programs with a hard requirement to run at the fastest possible speed should
                   9278: avoid using this feature, or using libraries built with this feature.
                   9279: 
1.266     martin   9280: B.2.4.4.  Disabling SSP on a per-package basis
1.207     leot     9281: 
                   9282: Note
                   9283: 
                   9284: SSP should not be disabled to work around runtime crashes in the program! This
                   9285: is a very bad idea and will expose you to security vulnerabilities.
                   9286: 
                   9287: To disable SSP on a per-package basis, set the following in the package's
                   9288: Makefile before bsd.prefs.mk is included:
                   9289: 
                   9290: SSP_SUPPORTED=  no
                   9291: 
1.266     martin   9292: B.3.  Auditing the system
1.207     leot     9293: 
                   9294: The illusion of security is worse than having no security at all. This section
                   9295: lists a number of ways to ensure the security features requested are actually
                   9296: effective.
                   9297: 
                   9298: These instructions were obtained and tested on a system derived from NetBSD 7
                   9299: (amd64). YMMV.
                   9300: 
1.266     martin   9301: B.3.1.  Checking for PIE
1.207     leot     9302: 
                   9303: The ELF executable type in use changes for binaries built as PIE; without:
                   9304: 
                   9305: $ file /path/to/bin/ary
                   9306: /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
                   9307: 
                   9308: as opposed to the following binary, built as PIE:
                   9309: 
                   9310: $ file /path/to/pie/bin/ary
                   9311: /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
                   9312: 
                   9313: The latter result is then what is expected.
                   9314: 
1.266     martin   9315: B.3.2.  Checking for partial RELRO
1.207     leot     9316: 
                   9317: The following command should list a section called RELRO:
                   9318: 
                   9319: $ objdump -p /path/to/bin/ary
                   9320: 
                   9321: /path/to/bin/ary:     file format elf64-x86-64
                   9322: 
                   9323: Program Header:
                   9324: [...]
                   9325:    RELRO off    0x0000000000000d78 vaddr 0x0000000000600d78 paddr 0x0000000000600d78 align 2**0
                   9326: 
                   9327: This check is now performed automatically if PKG_DEVELOPER is set and RELRO is
                   9328: enabled.
                   9329: 
1.266     martin   9330: B.3.3.  Checking for full RELRO
1.207     leot     9331: 
                   9332: The dynamic loader will apply RELRO immediately when detecting the presence of
                   9333: the BIND_NOW flag:
                   9334: 
                   9335: $ objdump -x /path/to/bin/ary
                   9336: 
                   9337: /path/to/bin/ary:     file format elf64-x86-64
                   9338: 
                   9339: Dynamic Section:
                   9340: [...]
                   9341:   BIND_NOW             0x0000000000000000
                   9342: 
                   9343: This has to be combined with partial RELRO (see above) to be fully efficient.
                   9344: 
                   9345: This check is now performed automatically (where supported) if PKG_DEVELOPER is
                   9346: set.
                   9347: 
1.266     martin   9348: B.3.4.  Checking for SSP
1.207     leot     9349: 
1.208     nia      9350: Note
                   9351: 
                   9352: Checking for SSP using this method only works where the operating system uses
                   9353: libssp. libssp is not used on recent NetBSD/FreeBSD/Linux versions.
                   9354: 
1.207     leot     9355: Building objects, binaries and libraries with SSP will affect the presence of
                   9356: additional symbols in the resulting file:
                   9357: 
                   9358: $ nm /path/to/bin/ary
                   9359: [...]
                   9360:                  U __stack_chk_fail
                   9361: 0000000000600ea0 B __stack_chk_guard
                   9362: 
                   9363: This is an indicator that the program was indeed built with support for SSP.
                   9364: 
                   9365: This check is now performed automatically (where supported) if PKG_DEVELOPER is
                   9366: set and SSP is enabled.
                   9367: 
1.266     martin   9368: Appendix  C.  Build logs
1.1       dsieger  9369: 
                   9370: Table of Contents
                   9371: 
1.207     leot     9372: C.1. Building figlet
                   9373: C.2. Packaging figlet
1.1       dsieger  9374: 
1.266     martin   9375: C.1.  Building figlet
1.1       dsieger  9376: 
                   9377: # make
                   9378: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   9379: => figlet221.tar.gz doesn't seem to exist on this system.
                   9380: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
                   9381: => [172219 bytes]
                   9382: Connected to ftp.plig.net.
                   9383: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
                   9384: 331 Guest login ok, send your complete e-mail address as password.
                   9385: 230-You are user #5 of 500 simultaneous users allowed.
                   9386: 230-
                   9387: 230-  ___ _             _ _
                   9388: 230- |  _| |_ ___   ___| |_|___   ___ ___ ___
                   9389: 230- |  _|  _| . |_| . | | | . |_| . |  _| . |
                   9390: 230- |_| |_| |  _|_|  _|_|_|_  |_|___|_| |_  |
                   9391: 230-         |_|   |_|     |___|         |___|
                   9392: 230-
                   9393: 230-** Welcome to ftp.plig.org **
                   9394: 230-
                   9395: 230-Please note that all transfers from this FTP site are logged. If you
                   9396: 230-do not like this, please disconnect now.
                   9397: 230-
1.19      snj      9398: 230-This archive is available via
1.1       dsieger  9399: 230-
                   9400: 230-HTTP:  http://ftp.plig.org/
                   9401: 230-FTP:   ftp://ftp.plig.org/     (max 500 connections)
                   9402: 230-RSYNC: rsync://ftp.plig.org/   (max  30 connections)
                   9403: 230-
                   9404: 230-Please email comments, bug reports and requests for packages to be
                   9405: 230-mirrored to ftp-admin@plig.org.
                   9406: 230-
                   9407: 230-
                   9408: 230 Logged in anonymously.
                   9409: Remote system type is UNIX.
                   9410: Using binary mode to transfer files.
                   9411: 200 Type okay.
                   9412: 250 "/pub" is new cwd.
                   9413: 250-"/pub/figlet" is new cwd.
                   9414: 250-
                   9415: 250-Welcome to the figlet archive at ftp.figlet.org
                   9416: 250-
                   9417: 250-    ftp://ftp.figlet.org/pub/figlet/
                   9418: 250-
                   9419: 250-The official FIGlet web page is:
                   9420: 250-    http://www.figlet.org/
                   9421: 250-
                   9422: 250-If you have questions, please mailto:info@figlet.org. If you want to
                   9423: 250-contribute a font or something else, you can email us.
                   9424: 250
                   9425: 250 "/pub/figlet/program" is new cwd.
                   9426: 250 "/pub/figlet/program/unix" is new cwd.
                   9427: local: figlet221.tar.gz remote: figlet221.tar.gz
                   9428: 502 Unimplemented command.
                   9429: 227 Entering Passive Mode (195,40,6,41,246,104)
                   9430: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
                   9431: 38% |**************                       | 65800      64.16 KB/s    00:01 ETA
                   9432: 226 Transfer completed.
                   9433: 172219 bytes received in 00:02 (75.99 KB/s)
                   9434: 221 Goodbye.
                   9435: => Checksum OK for figlet221.tar.gz.
                   9436: ===> Extracting for figlet-2.2.1nb2
                   9437: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
                   9438: ===> Patching for figlet-2.2.1nb2
                   9439: ===> Applying pkgsrc patches for figlet-2.2.1nb2
                   9440: ===> Overriding tools for figlet-2.2.1nb2
                   9441: ===> Creating toolchain wrappers for figlet-2.2.1nb2
                   9442: ===> Configuring for figlet-2.2.1nb2
                   9443: ===> Building for figlet-2.2.1nb2
                   9444: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\"  -DDEFAULTFONTFILE=\"standard.flf\"  figlet.c zipio.c crc.c inflate.c -o figlet
                   9445: chmod a+x figlet
                   9446: gcc -O2 -o chkfont chkfont.c
                   9447: => Unwrapping files-to-be-installed.
                   9448: #
                   9449: # make install
                   9450: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   9451: ===> Installing for figlet-2.2.1nb2
                   9452: install -d -o root -g wheel -m 755 /usr/pkg/bin
                   9453: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
                   9454: mkdir -p /usr/pkg/share/figlet
                   9455: cp figlet /usr/pkg/bin
                   9456: cp chkfont /usr/pkg/bin
                   9457: chmod 555 figlist showfigfonts
                   9458: cp figlist /usr/pkg/bin
                   9459: cp showfigfonts /usr/pkg/bin
                   9460: cp fonts/*.flf /usr/pkg/share/figlet
                   9461: cp fonts/*.flc /usr/pkg/share/figlet
                   9462: cp figlet.6 /usr/pkg/man/man6
                   9463: ===> Registering installation for figlet-2.2.1nb2
                   9464: #
                   9465: 
1.266     martin   9466: C.2.  Packaging figlet
1.1       dsieger  9467: 
                   9468: # make package
                   9469: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   9470: ===> Packaging figlet-2.2.1nb2
                   9471: ===> Building binary package for figlet-2.2.1nb2
                   9472: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
                   9473: Using SrcDir value of /usr/pkg
                   9474: Registering depends:.
                   9475: #
                   9476: 
1.266     martin   9477: Appendix  D.  Directory layout of the pkgsrc FTP server
1.1       dsieger  9478: 
                   9479: Table of Contents
                   9480: 
1.207     leot     9481: D.1. distfiles: The distributed source files
                   9482: D.2. misc: Miscellaneous things
                   9483: D.3. packages: Binary packages
                   9484: D.4. reports: Bulk build reports
                   9485: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  9486: 
                   9487: As in other big projects, the directory layout of pkgsrc is quite complex for
                   9488: newbies. This chapter explains where you find things on the FTP server. The
                   9489: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
                   9490: different, but inside this directory, everything should look the same, no
                   9491: matter on which server you are. This directory contains some subdirectories,
                   9492: which are explained below.
                   9493: 
1.266     martin   9494: D.1.  distfiles: The distributed source files
1.1       dsieger  9495: 
                   9496: The directory distfiles contains lots of archive files from all pkgsrc
                   9497: packages, which are mirrored here. The subdirectories are called after their
                   9498: package names and are used when the distributed files have names that don't
                   9499: explicitly contain a version number or are otherwise too generic (for example
                   9500: release.tar.gz).
                   9501: 
1.266     martin   9502: D.2.  misc: Miscellaneous things
1.1       dsieger  9503: 
                   9504: This directory contains things that individual pkgsrc developers find worth
                   9505: publishing.
                   9506: 
1.266     martin   9507: D.3.  packages: Binary packages
1.1       dsieger  9508: 
1.3       rillig   9509: This directory contains binary packages for the various platforms that are
                   9510: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
                   9511: The meaning of these variables is:
                   9512: 
                   9513:   * OPSYS is the name of the operating system for which the packages have been
1.9       rillig   9514:     built. The name is taken from the output of the uname command, so it may
                   9515:     differ from the one you are used to hear.
1.3       rillig   9516: 
1.8       rillig   9517:   * ARCH is the hardware architecture of the platform for which the packages
1.10      hubertf  9518:     have been built. It also includes the ABI (Application Binary Interface)
                   9519:     for platforms that have several of them.
1.3       rillig   9520: 
1.255     wiz      9521:   * OSVERSION is the version of the operating system. Typically it is the
                   9522:     version defining an ABI, e.g. 9.0.
                   9523: 
                   9524:   * TAG is either 20YYQN for a stable branch, or current for packages built
                   9525:     from the HEAD branch. The latter should only be used when the packages are
                   9526:     updated on a regular basis.
                   9527: 
                   9528: The rationale for this scheme is that users can first search by OPSYS and ARCH,
                   9529: since these are more or less unchangeable. After that, there is a management
                   9530: set of directories with OSVERSION and TAG.
                   9531: 
                   9532: See also README.md in packages for more details, including about symlinks.
1.3       rillig   9533: 
                   9534: In each of these directories, there is a whole binary packages collection for a
                   9535: specific platform. It has a directory called All which contains all binary
1.255     wiz      9536: packages.
1.1       dsieger  9537: 
1.266     martin   9538: D.4.  reports: Bulk build reports
1.8       rillig   9539: 
                   9540: Here are the reports from bulk builds, for those who want to fix packages that
                   9541: didn't build on some of the platforms. The structure of subdirectories should
1.266     martin   9542: look like the one in Section  D.3,    packages: Binary packages   .
1.8       rillig   9543: 
1.266     martin   9544: D.5.  current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  9545: 
1.266     martin   9546: These directories contain the    real    pkgsrc, that is the files that define how
1.1       dsieger  9547: to create binary packages from source archives.
                   9548: 
1.149     leot     9549: Each of the current, stable and pkgsrc-20xxQy directories share the same
                   9550: structure. They each contain a pkgsrc directory and pkgsrc.tar.{bz,gz,xz} file.
                   9551: 
1.1       dsieger  9552: The directory pkgsrc contains a snapshot of the CVS repository, which is
1.149     leot     9553: updated regularly. The file pkgsrc.tar.{bz,gz,xz} contains the same as the
                   9554: directory, ready to be downloaded as a whole.
1.1       dsieger  9555: 
1.149     leot     9556: The current directory contains files related to the HEAD branch of the CVS
                   9557: repository. In this directory there is an additional file called
                   9558: pkgsrc-readmes.tar.{bz,gz,xz} that contains all pkgsrc READMEs with information
                   9559: about categories and packages.
                   9560: 
                   9561: The stable directory is a symlink to the latest pkgsrc-20xxQy.
                   9562: 
                   9563: The pkgsrc-20xxQy. directories contain files related to the -20xxQy stable
                   9564: branch of the CVS repository. In these directories there is an additional file
                   9565: called pkgsrc-20xxQy.tar.{bz,gz,xz}, which contains the state of pkgsrc when it
                   9566: was branched.
1.148     leot     9567: 
1.266     martin   9568: Appendix  E.  Help topics
1.154     rillig   9569: 
                   9570: The following list contains all help topics that are available when running 
                   9571: bmake help topic=:index.
                   9572: 
1.273   ! wiz      9573: #!                                -lintl
        !          9574: 32bit                             64bit
        !          9575: ABI                               ACCEPTABLE_LICENSES
        !          9576: ACROREAD_FONTPATH                 AFAIK
        !          9577: AIX                               ALLOW_NETWORK_ACCESS
        !          9578: ALLOW_NEWER_COMPILER              ALLOW_VULNERABLE_PACKAGES
        !          9579: ALL_ENV                           ALSA_PC
        !          9580: ALTERNATIVES_SRC                  AMANDA_TMP
        !          9581: AMANDA_USER                       AMANDA_VAR
        !          9582: APACHE_GROUP                      APACHE_MODULE_NAME
        !          9583: APACHE_MODULE_SRC                 APACHE_MODULE_SRCDIR
        !          9584: APACHE_PKG_PREFIX                 APACHE_SUEXEC_CONFIGURE_ARGS
        !          9585: APACHE_SUEXEC_DOCROOT             APACHE_USER
        !          9586: ARGMAX_REQ                        ARG_MAX
        !          9587: ARLA_CACHE                        AUDIT_PACKAGES_FLAGS
        !          9588: AUTOCONF_REQD                     AUTOMAKE_OVERRIDE
        !          9589: AUTOMAKE_REQD                     AUTO_MKDIRS
        !          9590: AUX                               BDB185_DEFAULT
        !          9591: BDBBASE                           BDB_ACCEPTED
        !          9592: BDB_DEFAULT                       BDB_LIBS
        !          9593: BDB_TYPE                          BINCIMAP_GROUP
        !          9594: BINCIMAP_LOG_USER                 BINCIMAP_USER
        !          9595: BIND_DIR                          BIND_GROUP
        !          9596: BIND_USER                         BINOWN
        !          9597: BINPKG_SITES                      BIN_INSTALL_FLAGS
        !          9598: BISON_PKGDATADIR                  BLAS
        !          9599: BLAS_ACCEPTED                     BLAS_C_INTERFACE
        !          9600: BLAS_INCLUDES                     BLAS_INDEX64
        !          9601: BLAS_LIBS                         BLAS_PC
        !          9602: BLAS_TYPE                         BOOTSTRAP_DEPENDS
        !          9603: BROKEN                            BROKEN_EXCEPT_ON_PLATFORM
        !          9604: BROKEN_ON_PLATFORM                BSDSRCDIR
        !          9605: BSD_MAKE_ENV                      BUILDLINK_AUTO_DIRS
        !          9606: BUILDLINK_AUTO_VARS               BUILDLINK_CFLAGS
        !          9607: BUILDLINK_CONTENTS_FILTER         BUILDLINK_CPPFLAGS
        !          9608: BUILDLINK_DEPMETHOD               BUILDLINK_FILES
        !          9609: BUILDLINK_FILES_CMD               BUILDLINK_FNAME_TRANSFORM
        !          9610: BUILDLINK_LDFLAGS                 BUILDLINK_LIBS
        !          9611: BUILDLINK_OPSYS_SUPPORT_PTHREAD   BUILDLINK_PKGNAME
        !          9612: BUILDLINK_PREFIX                  BUILDLINK_RPATHDIRS
        !          9613: BUILDLINK_TREE                    BUILD_DEFS
        !          9614: BUILD_DEFS_EFFECTS                BUILD_DEPENDS
        !          9615: BUILD_DIRS                        BUILD_ENV_SHELL
        !          9616: BUILD_MAKE_CMD                    BUILD_MAKE_FLAGS
        !          9617: BUILD_TARGET                      BUILTIN_FIND_FILES
        !          9618: BUILTIN_FIND_FILES_VAR            BUILTIN_FIND_GREP
        !          9619: BUILTIN_FIND_HEADERS              BUILTIN_FIND_HEADERS_VAR
        !          9620: BUILTIN_FIND_PKGCONFIG            BUILTIN_FIND_PKGCONFIG_VAR
        !          9621: BUILTIN_PKG                       BUILTIN_TEST_CURSES_DEFINES
        !          9622: BUILTIN_TEST_CURSES_FUNCS         BUILTIN_VERSION_SCRIPT
        !          9623: BUILTIN_X11_TYPE                  BUILTIN_X11_VERSION
        !          9624: CACTI_GROUP                       CACTI_USER
        !          9625: CANNA_GROUP                       CANNA_USER
        !          9626: CAT                               CBLAS_LIBS
        !          9627: CBLAS_PC                          CCACHE_BASE
        !          9628: CCACHE_DIR                        CCACHE_LOGFILE
        !          9629: CCACHE_RECACHE                    CC_VERSION
        !          9630: CDRECORD_CONF                     CDROM_PKG_URL_DIR
        !          9631: CDROM_PKG_URL_HOST                CHANGES
        !          9632: CHECKOUT_DATE                     CHECK_COMPILER
        !          9633: CHECK_FAKEHOME                    CHECK_FILES
        !          9634: CHECK_FILES_ONLY_PREFIX           CHECK_FILES_SKIP
        !          9635: CHECK_FILES_STRICT                CHECK_HEADERS
        !          9636: CHECK_HEADERS_SKIP                CHECK_INTERPRETER
        !          9637: CHECK_INTERPRETER_SKIP            CHECK_PERMS
        !          9638: CHECK_PERMS_AUTOFIX               CHECK_PERMS_SKIP
        !          9639: CHECK_PIE                         CHECK_PIE_SKIP
        !          9640: CHECK_PIE_SUPPORTED               CHECK_PORTABILITY
        !          9641: CHECK_PORTABILITY_EXPERIMENTAL    CHECK_PORTABILITY_SKIP
        !          9642: CHECK_RELRO                       CHECK_RELRO_SKIP
        !          9643: CHECK_RELRO_SUPPORTED             CHECK_SHLIBS
        !          9644: CHECK_SHLIBS_SKIP                 CHECK_SHLIBS_SUPPORTED
        !          9645: CHECK_SHLIBS_TOXIC                CHECK_SSP
        !          9646: CHECK_SSP_SKIP                    CHECK_SSP_SUPPORTED
        !          9647: CHECK_STRIPPED                    CHECK_STRIPPED_SKIP
        !          9648: CHECK_WRKREF                      CHECK_WRKREF_EXTRA_DIRS
        !          9649: CHECK_WRKREF_SKIP                 CLAMAV_DBDIR
        !          9650: CLAMAV_GROUP                      CLAMAV_USER
        !          9651: CLANGBASE                         CLEANDEPENDS
        !          9652: CLT                               CMAKE_DEPENDENCIES_REWRITE
        !          9653: CMAKE_INSTALL_NAME_DIR            CMAKE_INSTALL_PREFIX
        !          9654: CMAKE_MODULE_PATH_OVERRIDE        CMAKE_PKGSRC_BUILD_FLAGS
        !          9655: CMAKE_PREFIX_PATH                 CMAKE_USE_GNU_INSTALL_DIRS
        !          9656: COMMON_LISP_DOCFILES              COMMON_LISP_EXAMPLES
        !          9657: COMMON_LISP_EXTRAFILES            COMMON_LISP_PACKAGES
        !          9658: COMMON_LISP_SYSTEM                COMPILER_RPATH_FLAG
        !          9659: COMPILER_USE_SYMLINKS             CONFIGURE_ARGS
        !          9660: CONFIGURE_DIRS                    CONFIGURE_ENV
        !          9661: CONFIGURE_ENV_SHELL               CONFIGURE_HAS_INFODIR
        !          9662: CONFIGURE_HAS_MANDIR              CONFIGURE_SCRIPT
        !          9663: CONFIG_SHELL                      CONFIG_SHELL_FLAGS
        !          9664: CONF_FILES                        CONF_FILES_MODE
        !          9665: CONF_FILES_PERMS                  CONSERVER_DEFAULTHOST
        !          9666: CONSERVER_DEFAULTPORT             CP
        !          9667: CPE                               CPE_EDITION
        !          9668: CPE_LANG                          CPE_OTHER
        !          9669: CPE_PART                          CPE_PRODUCT
        !          9670: CPE_SW_EDITION                    CPE_TARGET_HW
        !          9671: CPE_TARGET_SW                     CPE_UPDATE
        !          9672: CPE_URI                           CPE_VENDOR
        !          9673: CPE_VERSION                       CPP
        !          9674: CPP_PRECOMP_FLAGS                 CREATE_WRKDIR_SYMLINK
        !          9675: CROSSBASE                         CTFCONVERT
        !          9676: CTF_FILES_SKIP                    CTF_SUPPORTED
        !          9677: CTYPE                             CUPS_GROUP
        !          9678: CUPS_SYSTEM_GROUPS                CUPS_USER
        !          9679: CURSES_DEFAULT                    CURSES_TYPE
        !          9680: CVS_EXTRACTDIR                    CVS_MODULE
        !          9681: CVS_PROJECT                       CVS_REPOSITORIES
        !          9682: CVS_ROOT                          CVS_ROOT_GNU
        !          9683: CVS_ROOT_NONGNU                   CVS_ROOT_SOURCEFORGE
        !          9684: CVS_TAG                           CYRUS_GROUP
        !          9685: CYRUS_IDLE                        CYRUS_USER
        !          9686: DAEMONTOOLS_GROUP                 DAEMONTOOLS_LOG_USER
        !          9687: DARWIN_NO_SYSTEM_LIBS             DARWIN_REQUIRES_FILTER
        !          9688: DBUS_GROUP                        DBUS_USER
        !          9689: DEFANG_GROUP                      DEFANG_USER
        !          9690: DEFAULT_ACCEPTABLE_LICENSES       DEFAULT_DISTFILES
        !          9691: DEFAULT_IRC_SERVER                DEFAULT_SERIAL_DEVICE
        !          9692: DEF_UMASK                         DEINSTALLDEPENDS
        !          9693: DEINSTALL_SRC                     DEINSTALL_TEMPLATES
        !          9694: DELAYED_ERROR_MSG                 DELAYED_WARNING_MSG
        !          9695: DEPENDS                           DEPENDS_TARGET
        !          9696: DEPENDS_TYPE                      DESTDIR
        !          9697: DESTDIR_VARNAME                   DIALER_GROUP
        !          9698: DIGEST_REQD                       DISTDIR
        !          9699: DISTFILES                         DISTINFO_FILE
        !          9700: DISTNAME                          DIST_PATH
        !          9701: DIST_SUBDIR                       DJBDNS_AXFR_USER
        !          9702: DJBDNS_CACHE_USER                 DJBDNS_DJBDNS_GROUP
        !          9703: DJBDNS_LOG_USER                   DJBDNS_RBL_USER
        !          9704: DJBDNS_TINY_USER                  DLOPEN_REQUIRE_PTHREADS
        !          9705: DL_AUTO_VARS                      DL_CFLAGS
        !          9706: DL_LDFLAGS                        DL_LIBS
        !          9707: DNS                               DOCOWN
        !          9708: DOWNLOADED_DISTFILE               DQCACHE_GROUP
        !          9709: DQCACHE_USER                      DT_LAYOUT
        !          9710: DYNAMIC_SITES_CMD                 DYNAMIC_SITES_SCRIPT
        !          9711: ECHO                              ECHO_N
        !          9712: ELK_GUI                           EMACS_TYPE
        !          9713: EMULDIR                           EMULSUBDIR
        !          9714: EMULSUBDIRSLASH                   EMUL_ARCH
        !          9715: EMUL_DISTRO                       EMUL_EXEC_FMT
        !          9716: EMUL_IS_NATIVE                    EMUL_MODULES
        !          9717: EMUL_OPSYS                        EMUL_PKG_FMT
        !          9718: EMUL_PLATFORM                     EMUL_PLATFORMS
        !          9719: EMUL_PREFER                       EMUL_REQD
        !          9720: EMUL_TYPE                         ERROR_MSG
        !          9721: EXIM_GROUP                        EXIM_USER
        !          9722: EXPORT_SYMBOLS_LDFLAGS            EXTRACTOR
        !          9723: EXTRACT_CMD                       EXTRACT_CMD_DEFAULT
        !          9724: EXTRACT_DIR                       EXTRACT_ELEMENTS
        !          9725: EXTRACT_ENV                       EXTRACT_ONLY
        !          9726: EXTRACT_OPTS                      EXTRACT_SUFX
        !          9727: EXTRACT_USING                     FAIL
        !          9728: FAILOVER_FETCH                    FAIL_MSG
        !          9729: FAKE_NCURSES                      FAM
        !          9730: FAM_ACCEPTED                      FAM_DEFAULT
        !          9731: FAM_SERVER                        FCPATH
        !          9732: FETCH_AFTER_ARGS                  FETCH_BEFORE_ARGS
        !          9733: FETCH_CMD                         FETCH_INSECURE
        !          9734: FETCH_OUTPUT_ARGS                 FETCH_PROXY
        !          9735: FETCH_RESUME_ARGS                 FETCH_TIMEOUT
        !          9736: FETCH_USE_IPV4_ONLY               FETCH_USING
        !          9737: FILES_SUBST                       FILES_SUBST_SED
        !          9738: FIX_SYSTEM_HEADERS                FONTDIR
        !          9739: FONTS_DIRS                        FONTS_VERBOSE
        !          9740: FOO_HACKS_MK                      FORCE_CXX_STD
        !          9741: FORCE_C_STD                       FOSSIL_EXTRACTDIR
        !          9742: FOSSIL_REPO                       FOSSIL_REPOSITORIES
        !          9743: FOSSIL_VERSION                    FOX_USE_XUNICODE
        !          9744: FREEWNN_GROUP                     FREEWNN_USER
        !          9745: FTP_PKG_URL_DIR                   FTP_PKG_URL_HOST
        !          9746: GAMEDATAMODE                      GAMEDATA_PERMS
        !          9747: GAMEDIRMODE                       GAMEDIR_PERMS
        !          9748: GAMEGRP                           GAMEMODE
        !          9749: GAMEOWN                           GAMES_GROUP
        !          9750: GAMES_USER                        GCC
        !          9751: GCCBASE                           GCC_REQD
        !          9752: GCC_VERSION_SUFFIX                GEM_BUILD
        !          9753: GEM_CLEANBUILD                    GEM_CLEANBUILD_EXTENSIONS
        !          9754: GEM_DOCDIR                        GEM_EXTSDIR
        !          9755: GEM_HOME                          GEM_KEEPBUILD
        !          9756: GEM_LIBDIR                        GEM_NAME
        !          9757: GEM_PATH                          GEM_PLUGINSDIR
        !          9758: GEM_SPECFILE                      GENERATE_PLIST
        !          9759: GHC                               GHOSTSCRIPT_REQD
        !          9760: GITHUB_PROJECT                    GITHUB_RELEASE
        !          9761: GITHUB_SUBMODULES                 GITHUB_TAG
        !          9762: GITHUB_TYPE                       GITLAB_PROJECT
        !          9763: GITLAB_RELEASE                    GITLAB_SUBMODULES
        !          9764: GITLAB_TAG                        GITLAB_TYPE
        !          9765: GIT_BRANCH                        GIT_ENV
        !          9766: GIT_EXTRACTDIR                    GIT_REPO
        !          9767: GIT_REPOSITORIES                  GIT_REVISION
        !          9768: GIT_TAG                           GNAT
        !          9769: GNU                               GNU_CONFIGURE
        !          9770: GNU_CONFIGURE_ICONV               GNU_CONFIGURE_INFODIR
        !          9771: GNU_CONFIGURE_MANDIR              GNU_CONFIGURE_QUIET
        !          9772: GNU_CONFIGURE_STRICT              GOFLAGS
        !          9773: GO_BUILD_PATTERN                  GO_DIST_BASE
        !          9774: GO_EXTRA_MOD_DIRS                 GO_MODULE_EXTRACT
        !          9775: GO_MODULE_FILES                   GO_SRCPATH
        !          9776: GROUP_SPECIFIC_PKGS               GRUB_NETWORK_CARDS
        !          9777: GRUB_PRESET_COMMAND               GRUB_SCAN_ARGS
        !          9778: GZIP                              HASKELL_COMPILER
        !          9779: HASKELL_DISABLE_EXECUTABLES       HASKELL_DISABLE_LIBRARIES
        !          9780: HASKELL_ENABLE_DYNAMIC_EXECUTABLE HASKELL_ENABLE_HADDOCK_DOCUMENTATION
        !          9781: HASKELL_ENABLE_LIBRARY_PROFILING  HASKELL_ENABLE_SHARED_LIBRARY
        !          9782: HASKELL_ENABLE_TESTS              HASKELL_OPTIMIZATION_LEVEL
        !          9783: HASKELL_PKG_NAME                  HASKELL_UNRESTRICT_DEPENDENCIES
        !          9784: HEADER_TEMPLATES                  HG_REPO
        !          9785: HG_REPOSITORIES                   HG_TAG
        !          9786: HOMEPAGE                          HOST_PKGTOOLS_ARGS
        !          9787: HOST_SPECIFIC_PKGS                HOWL_GROUP
        !          9788: HOWL_USER                         ICCBASE
        !          9789: ICECAST_CHROOTDIR                 ICON_THEMES
        !          9790: IDOBASE                           IGNORE_CCACHE
        !          9791: IGNORE_INFO_DIRS                  IGNORE_INTERACTIVE_FETCH
        !          9792: IMAKE                             IMAKEOPTS
        !          9793: IMAKE_MAKE                        IMAKE_MANINSTALL
        !          9794: IMAP_UW_CCLIENT_MBOX_FMT          IMDICTDIR
        !          9795: INCOMPAT_CURSES                   INFO_DIR
        !          9796: INFO_FILES                        INFO_MSG
        !          9797: INIT_SYSTEM                       INN_DATA_DIR
        !          9798: INN_GROUP                         INN_USER
        !          9799: INSTALLATION_DIRS                 INSTALLATION_DIRS_FROM_PLIST
        !          9800: INSTALL_ENV                       INSTALL_ENV_SHELL
        !          9801: INSTALL_SH_OVERRIDE               INSTALL_SRC
        !          9802: INSTALL_TEMPLATES                 INSTALL_UNSTRIPPED
        !          9803: IRCD_HYBRID_IRC_GROUP             IRCD_HYBRID_IRC_USER
        !          9804: IRCD_HYBRID_MAXCONN               IRCD_HYBRID_NICLEN
        !          9805: IRCD_HYBRID_SYSLOG_EVENTS         IRCD_HYBRID_SYSLOG_FACILITY
        !          9806: IRCD_HYBRID_TOPICLEN              IRIX
        !          9807: IRRD_USE_PGP                      JABBERD_GROUP
        !          9808: JABBERD_LOGDIR                    JABBERD_PIDDIR
        !          9809: JABBERD_SPOOLDIR                  JABBERD_USER
        !          9810: JAVA_APP_PATH                     JAVA_APP_TARGETS
        !          9811: JAVA_BINPREFIX                    JAVA_CLASSPATH
        !          9812: JAVA_HOME                         JAVA_LD_LIBRARY_PATH
        !          9813: JAVA_NAME                         JAVA_UNLIMIT
        !          9814: JAVA_WRAPPERS                     JPEG_ACCEPTED
        !          9815: JPEG_DEFAULT                      KERBEROS
        !          9816: KERMIT_SUID_UUCP                  KJS_USE_PCRE
        !          9817: KNEWS_DOMAIN_FILE                 KNEWS_DOMAIN_NAME
        !          9818: KRB5_ACCEPTED                     KRB5_DEFAULT
        !          9819: LANGUAGES                         LAPACKE_LIBS
        !          9820: LAPACKE_PC                        LAPACK_LIBS
        !          9821: LAPACK_PC                         LATEX2HTML_ICONPATH
        !          9822: LDCONFIG_ADD_CMD                  LDCONFIG_REMOVE_CMD
        !          9823: LDD                               LEAFNODE_DATA_DIR
        !          9824: LEAFNODE_GROUP                    LEAFNODE_USER
        !          9825: LIBDVDCSS_HOMEPAGE                LIBDVDCSS_MASTER_SITES
        !          9826: LIBIMAGEQUANT_TYPE                LIBRSVG_TYPE
        !          9827: LIBTOOL                           LIBTOOLIZE_PLIST
        !          9828: LIBTOOL_M4_OVERRIDE               LIBUSB_TYPE
        !          9829: LICENSE                           LINKER_RPATH_FLAG
        !          9830: LINK_RPATH_FLAG                   LINUX_BASE_NODEPS
        !          9831: LINUX_BASE_PREFERRED              LINUX_BASE_REQUIRED
        !          9832: LINUX_LOCALES                     LOCALBASE
        !          9833: LOCALBASE_LOCKTYPE                LOCALPATCHES
        !          9834: LOVE_DATA                         LOVE_GAME
        !          9835: LOVE_VERSION                      LOWER_OPSYS
        !          9836: LOWER_OPSYS_VERSUFFIX             LOWER_VARIANT_VERSION
        !          9837: LOWER_VENDOR                      LP32PLATFORMS
        !          9838: LP64PLATFORMS                     LUA_BUSTED_ARGS
        !          9839: LUA_CDIR                          LUA_COMPILER
        !          9840: LUA_DOCDIR                        LUA_EXAMPLESDIR
        !          9841: LUA_INCDIR                        LUA_INTERPRETER
        !          9842: LUA_LDIR                          LUA_LINKER_MAGIC
        !          9843: LUA_PKGPREFIX                     LUA_SELF_CONFLICT
        !          9844: LUA_USE_BUSTED                    LUA_VERSIONS_ACCEPTED
        !          9845: LUA_VERSIONS_INCOMPATIBLE         LUA_VERSION_DEFAULT
        !          9846: LUA_VERSION_REQD                  Lua
        !          9847: MACHINE_PLATFORM                  MAILAGENT_DOMAIN
        !          9848: MAILAGENT_EMAIL                   MAILAGENT_FQDN
        !          9849: MAILAGENT_ORGANIZATION            MAJORDOMO_HOMEDIR
        !          9850: MAJOR_OS_VERSION                  MAKEINFO_ARGS
        !          9851: MAKE_DIRS                         MAKE_DIRS_PERMS
        !          9852: MAKE_ENV                          MAKE_FILE
        !          9853: MAKE_FLAGS                        MAKE_JOBS
        !          9854: MAKE_JOBS_SAFE                    MAKE_PROGRAM
        !          9855: MANCOMPRESSED_IF_MANZ             MANINSTALL
        !          9856: MANZ                              MARIADB_VERSIONS_ALL
        !          9857: MASTER_SITES                      MASTER_SITE_BACKUP
        !          9858: MASTER_SITE_LOCAL                 MASTER_SITE_MOZILLA
        !          9859: MASTER_SITE_OVERRIDE              MASTER_SITE_PERL_CPAN
        !          9860: MASTER_SORT                       MASTER_SORT_RANDOM
        !          9861: MASTER_SORT_REGEX                 MECAB_CHARSET
        !          9862: MEDIATOMB_GROUP                   MEDIATOMB_USER
        !          9863: MIPSPROBASE                       MIREDO_GROUP
        !          9864: MIREDO_USER                       MISSING_FEATURES
        !          9865: MKDIR                             MKPIE_SUPPORTED
        !          9866: MLDONKEY_GROUP                    MLDONKEY_HOME
        !          9867: MLDONKEY_USER                     MONOTONE_GROUP
        !          9868: MONOTONE_USER                     MOTIFBASE
        !          9869: MOTIF_TYPE                        MOTIF_TYPE_DEFAULT
        !          9870: MPI_TYPE                          MSGFMT_STRIP_MSGCTXT
        !          9871: MSGFMT_STRIP_MSGID_PLURAL         MTOOLS_ENABLE_FLOPPYD
        !          9872: MUST                              MV
        !          9873: MYSQL_CHARSET                     MYSQL_DATADIR
        !          9874: MYSQL_EXTRA_CHARSET               MYSQL_GROUP
        !          9875: MYSQL_USER                        MYSQL_VERSION
        !          9876: MYSQL_VERSIONS_ACCEPTED           MYSQL_VERSION_DEFAULT
        !          9877: NAGIOSCMD_GROUP                   NAGIOSDIR
        !          9878: NAGIOS_GROUP                      NAGIOS_USER
        !          9879: NATIVE_EXEC_FMT                   NATIVE_LOWER_OPSYS
        !          9880: NATIVE_LOWER_VENDOR               NATIVE_MACHINE_PLATFORM
        !          9881: NATIVE_OBJECT_FMT                 NATIVE_OPSYS_VERSION
        !          9882: NATIVE_OS_VARIANT                 NATIVE_OS_VERSION
        !          9883: NBPAX_PROGRAM_PREFIX              NETBSD_LOGIN_NAME
        !          9884: NMH_EDITOR                        NMH_MTA
        !          9885: NMH_PAGER                         NODE_VERSIONS_ACCEPTED
        !          9886: NODE_VERSIONS_INCOMPATIBLE        NODE_VERSION_DEFAULT
        !          9887: NODE_VERSION_REQD                 NOLOGIN
        !          9888: NOTE                              NOT_FOR_PLATFORM
        !          9889: NOT_PAX_ASLR_SAFE                 NOT_PAX_MPROTECT_SAFE
        !          9890: NO_BUILD                          NO_CHECKSUM
        !          9891: NO_CONFIGURE                      NO_SKIP
        !          9892: NSD_GROUP                         NSD_LOG_FACILITY
        !          9893: NSD_USER                          NS_PREFERRED
        !          9894: NULLMAILER_GROUP                  NULLMAILER_USER
        !          9895: OBJECT_FMT                        OBJHOSTNAME
        !          9896: OBJMACHINE                        OCAML_FINDLIB_DIRS
        !          9897: OCAML_FINDLIB_REGISTER            OCAML_FINDLIB_REGISTER_VERBOSE
        !          9898: OCAML_SITELIBDIR                  OMF
        !          9899: ONLY_FOR_COMPILER                 ONLY_FOR_PLATFORM
        !          9900: OPENSSH_CHROOT                    OPENSSH_GROUP
        !          9901: OPENSSH_USER                      OPSYS
        !          9902: OPSYS_EMULDIR                     OPSYS_VERSION
        !          9903: OS                                OSS_TYPE
        !          9904: OSX                               OSX_PATH_TO_M4
        !          9905: OSX_PATH_TO_YACC                  OS_HAVE_ALSA
        !          9906: OS_HAVE_RCD                       OS_VARIANT
        !          9907: OS_VERSION                        OTF_FONTS_DIR
        !          9908: OVERRIDE_DIRDEPTH                 OVERRIDE_GEMSPEC
        !          9909: OVERRIDE_GNU_CONFIG_SCRIPTS       OVERRIDE_ROCKSPEC
        !          9910: OWN_DIRS                          OWN_DIRS_PERMS
        !          9911: P4GROUP                           P4PORT
        !          9912: P4ROOT                            P4USER
        !          9913: PACKAGES                          PALMOS_DEFAULT_SDK
        !          9914: PAMBASE                           PAM_DEFAULT
        !          9915: PAPERSIZE                         PASSIVE_FETCH
        !          9916: PATCHDIR                          PATCHFILES
        !          9917: PATCH_ARGS                        PATCH_DEBUG
        !          9918: PATCH_DIST_ARGS                   PATCH_DIST_CAT
        !          9919: PATCH_DIST_STRIP                  PATCH_FUZZ_FACTOR
        !          9920: PATCH_STRIP                       PATH
        !          9921: PCCBASE                           PEAR
        !          9922: PEAR_CHANNEL                      PEAR_CHANNEL_ALIAS
        !          9923: PEAR_CHANNEL_VERSION              PEAR_CMD
        !          9924: PEAR_LIB                          PEAR_PACKAGE_XML
        !          9925: PEP-518                           PERL5
        !          9926: PERL5_CONFIGURE                   PERL5_CONFIGURE_DIRS
        !          9927: PERL5_LDFLAGS                     PERL5_LICENSE
        !          9928: PERL5_MODULE_TYPE                 PERL5_PACKLIST
        !          9929: PERL5_PACKLIST_DIR                PERL5_PERLBASE
        !          9930: PERL5_SITEBASE                    PERL5_USE_PACKLIST
        !          9931: PERL5_VENDORBASE                  PFCTL
        !          9932: PFVAR_H                           PF_VERSION
        !          9933: PGGROUP                           PGHOME
        !          9934: PGPKGSRCDIR                       PGSQL_TYPE
        !          9935: PGSQL_VERSION                     PGSQL_VERSIONS_ACCEPTED
        !          9936: PGSQL_VERSION_DEFAULT             PGUSER
        !          9937: PG_LIB_EXT                        PHP
        !          9938: PHPCOMMON_MK                      PHPPKGSRCDIR
        !          9939: PHP_BASE_VERS                     PHP_EGDIR
        !          9940: PHP_EXTENSION_DIR                 PHP_INCDIR
        !          9941: PHP_LIBDIR                        PHP_MAJOR_VERS
        !          9942: PHP_MINIMUM_TEENY                 PHP_MINOR_VERS
        !          9943: PHP_PKG_PREFIX                    PHP_SHAREDIR
        !          9944: PHP_VER                           PHP_VERSION
        !          9945: PHP_VERSIONS_ACCEPTED             PHP_VERSIONS_INCOMPATIBLE
        !          9946: PHP_VERSION_DEFAULT               PHP_VERSION_REQD
        !          9947: PILRC_USE_GTK                     PKGCONFIG_BASE
        !          9948: PKGCONFIG_FILE                    PKGCONFIG_OVERRIDE
        !          9949: PKGCONFIG_OVERRIDE_STAGE          PKGDIR
        !          9950: PKGGNUDIR                         PKGINFODIR
        !          9951: PKGLOCALEDIR                      PKGMANDIR
        !          9952: PKGNAME                           PKGNAME_REQD
        !          9953: PKGPATH                           PKGREVISION
        !          9954: PKGSRC_BLAS_TYPES                 PKGSRC_CHANGES
        !          9955: PKGSRC_COMPILER                   PKGSRC_KEEP_BIN_PKGS
        !          9956: PKGSRC_LOCKTYPE                   PKGSRC_MAKE_ENV
        !          9957: PKGSRC_MESSAGE_RECIPIENTS         PKGSRC_MKPIE
        !          9958: PKGSRC_MKREPRO                    PKGSRC_OVERRIDE_MKPIE
        !          9959: PKGSRC_RUN_TEST                   PKGSRC_SETENV
        !          9960: PKGSRC_SLEEPSECS                  PKGSRC_TODO
        !          9961: PKGSRC_USE_CTF                    PKGSRC_USE_FORTIFY
        !          9962: PKGSRC_USE_MKTOOLS                PKGSRC_USE_RELRO
        !          9963: PKGSRC_USE_SSP                    PKGSRC_USE_STACK_CHECK
        !          9964: PKGTASKS_DATAFILE                 PKGTOOLS_ARGS
        !          9965: PKGTOOLS_ENV                      PKG_ALTERNATIVES
        !          9966: PKG_APACHE                        PKG_APACHE_ACCEPTED
        !          9967: PKG_APACHE_DEFAULT                PKG_BEST_EXISTS
        !          9968: PKG_BUILD_OPTIONS                 PKG_COMPRESSION
        !          9969: PKG_CONFIG                        PKG_CONFIG_PERMS
        !          9970: PKG_CREATE_USERGROUP              PKG_DBDIR
        !          9971: PKG_DB_TMPDIR                     PKG_DEBUG_LEVEL
        !          9972: PKG_DEFAULT_OPTIONS               PKG_DESTDIR_SUPPORT
        !          9973: PKG_DEVELOPER                     PKG_DISABLED_OPTIONS
        !          9974: PKG_FATAL_ERRORS                  PKG_FC
        !          9975: PKG_FILELIST_CMD                  PKG_GECOS
        !          9976: PKG_GID                           PKG_GROUPS
        !          9977: PKG_GROUPS_VARS                   PKG_HOME
        !          9978: PKG_INIT_SCRIPTS                  PKG_JAVA_HOME
        !          9979: PKG_JVM                           PKG_JVMS_ACCEPTED
        !          9980: PKG_JVM_DEFAULT                   PKG_LEGACY_OPTIONS
        !          9981: PKG_LIBTOOL                       PKG_MKSYMLINKS
        !          9982: PKG_OPTIONS                       PKG_OPTIONS_DEPRECATED_WARNINGS
        !          9983: PKG_OPTIONS_LEGACY_OPTS           PKG_OPTIONS_LEGACY_VARS
        !          9984: PKG_OPTIONS_NONEMPTY_SETS         PKG_OPTIONS_OPTIONAL_GROUPS
        !          9985: PKG_OPTIONS_REQUIRED_GROUPS       PKG_OPTIONS_VAR
        !          9986: PKG_RCD_SCRIPTS                   PKG_REFCOUNT_DBDIR
        !          9987: PKG_REGISTER_SHELLS               PKG_RESUME_TRANSFERS
        !          9988: PKG_SHELL                         PKG_SUGGESTED_OPTIONS
        !          9989: PKG_SUPPORTED_OPTIONS             PKG_SYSCONFBASE
        !          9990: PKG_SYSCONFBASEDIR                PKG_SYSCONFDIR
        !          9991: PKG_SYSCONFDIR_PERMS              PKG_SYSCONFSUBDIR
        !          9992: PKG_SYSCONFVAR                    PKG_TOOLS_BIN
        !          9993: PKG_UID                           PKG_UPDATE_FONTS_DB
        !          9994: PKG_USERS                         PKG_USERS_VARS
        !          9995: PKG_VERBOSE                       PLEASE
        !          9996: PLIST                             PLIST_AWK
        !          9997: PLIST_AWK_ENV                     PLIST_SRC
        !          9998: PLIST_SUBST                       PLIST_TYPE
        !          9999: PLIST_VARS                        POPTOP_USE_MPPE
        !          10000: POSSIBLE_GFORTRAN_VERSION         POST_FETCH_HOOK
        !          10001: PREFER                            PREFER_NATIVE
        !          10002: PREFER_NATIVE_PTHREADS            PREFER_PKGSRC
        !          10003: PREFIX                            PREPEND_PATH
        !          10004: PRE_ROOT_CMD                      PRIVILEGED_STAGES
        !          10005: PS                                PTHREAD_AUTO_VARS
        !          10006: PTHREAD_CFLAGS                    PTHREAD_LDFLAGS
        !          10007: PTHREAD_LIBS                      PTHREAD_OPTS
        !          10008: PTHREAD_TYPE                      PVM_SSH
        !          10009: PYPKGPREFIX                       PYSOABISUFFIX
        !          10010: PYTHON_27_ACCEPTED                PYTHON_FOR_BUILD_ONLY
        !          10011: PYTHON_SELF_CONFLICT              PYTHON_VERSION
        !          10012: PYTHON_VERSIONED_DEPENDENCIES     PYTHON_VERSIONS_ACCEPTED
        !          10013: PYTHON_VERSIONS_INCOMPATIBLE      PYTHON_VERSION_DEFAULT
        !          10014: PYTHON_VERSION_REQD               PYVERSSUFFIX
        !          10015: QMAILDIR                          QMAIL_ALIAS_USER
        !          10016: QMAIL_DAEMON_USER                 QMAIL_LOG_USER
        !          10017: QMAIL_NOFILES_GROUP               QMAIL_PASSWD_USER
        !          10018: QMAIL_QMAIL_GROUP                 QMAIL_QUEUE_DIR
        !          10019: QMAIL_QUEUE_EXTRA                 QMAIL_QUEUE_USER
        !          10020: QMAIL_REMOTE_USER                 QMAIL_ROOT_USER
        !          10021: QMAIL_SEND_USER                   QORE_LATEST_MODULE_API
        !          10022: QORE_MODULE_API                   QORE_MODULE_DIR
        !          10023: QORE_USER_MODULE_DIR              QORE_VERSION
        !          10024: QPOPPER_FAC                       QPOPPER_SPOOL_DIR
        !          10025: QPOPPER_USER                      RAKE_NAME
        !          10026: RASMOL_DEPTH                      RCD_DIR
        !          10027: RCD_ORDER                         RCD_SCRIPTS
        !          10028: RCD_SCRIPTS_DIR                   RCD_SCRIPTS_EXAMPLEDIR
        !          10029: RCD_SCRIPTS_MODE                  RCD_SCRIPTS_SHELL
        !          10030: RCD_SCRIPT_SRC                    RCD_SUBR
        !          10031: RDOC                              READLINE_DEFAULT
        !          10032: READLINE_TYPE                     REAL_ROOT_GROUP
        !          10033: REAL_ROOT_USER                    RECURSIVE_MAKE
        !          10034: RELAY_CTRL_DIR                    RELRO_SUPPORTED
        !          10035: REPLACE_AWK                       REPLACE_BASH
        !          10036: REPLACE_CSH                       REPLACE_KSH
        !          10037: REPLACE_LUA                       REPLACE_NODEJS
        !          10038: REPLACE_OCTAVE                    REPLACE_PERL
        !          10039: REPLACE_PERL6                     REPLACE_PHP
        !          10040: REPLACE_PYTHON                    REPLACE_QORE
        !          10041: REPLACE_R                         REPLACE_RUBY
        !          10042: REPLACE_RUBY_DIRS                 REPLACE_RUBY_PAT
        !          10043: REPLACE_SH                        REPLACE_TEXLUA
        !          10044: REPLACE_TOOL_PYTHON               REPLACE_WISH
        !          10045: REQD_DIRS                         REQD_DIRS_PERMS
        !          10046: REQD_FILES                        REQD_FILES_MODE
        !          10047: REQD_FILES_PERMS                  RESOLV_AUTO_VARS
        !          10048: RESOLV_LDFLAGS                    RESOLV_LIBS
        !          10049: RM                                ROCKSPEC_NAME
        !          10050: ROCKSPEC_SPECFILE                 ROOT_CMD
        !          10051: ROOT_GROUP                        ROOT_USER
        !          10052: RPCGEN                            RPM
        !          10053: RPM2PKG_PLIST                     RPM2PKG_PREFIX
        !          10054: RPM2PKG_STAGE                     RPM2PKG_STRIP
        !          10055: RPM2PKG_SUBPREFIX                 RPMFILES
        !          10056: RPMIGNOREPATH                     RPM_DB_PREFIX
        !          10057: RSSH_CVS_PATH                     RSSH_RDIST_PATH
        !          10058: RSSH_RSYNC_PATH                   RSSH_SCP_PATH
        !          10059: RSSH_SFTP_SERVER_PATH             RUBY
        !          10060: RUBYGEM                           RUBYGEM_MANPAGES
        !          10061: RUBYGEM_NAME                      RUBYGEM_OPTIONS
        !          10062: RUBYGEM_USE_MANPAGES              RUBYGEM_VERBOSE
        !          10063: RUBY_ABI_VERSION                  RUBY_ALLOW_HAS_RDOC
        !          10064: RUBY_ARCH                         RUBY_ARCHINC
        !          10065: RUBY_ARCHLIB                      RUBY_BASE
        !          10066: RUBY_BASERIDIR                    RUBY_BUILD_DOCUMENT
        !          10067: RUBY_DLEXT                        RUBY_DOC
        !          10068: RUBY_DYNAMIC_DIRS                 RUBY_EG
        !          10069: RUBY_EXTCONF                      RUBY_EXTCONF_CHECK
        !          10070: RUBY_EXTCONF_DEBUG                RUBY_EXTCONF_MAKEFILE
        !          10071: RUBY_GEM_ARCH                     RUBY_GEM_BASE
        !          10072: RUBY_INC                          RUBY_LIB
        !          10073: RUBY_LIB_BASE                     RUBY_NAME
        !          10074: RUBY_NOVERSION                    RUBY_PKGPREFIX
        !          10075: RUBY_RAILS                        RUBY_RAILS61_VERSION
        !          10076: RUBY_RAILS70_VERSION              RUBY_RAILS71_VERSION
        !          10077: RUBY_RAILS72_VERSION              RUBY_RAILS80_VERSION
        !          10078: RUBY_RAILS_ACCEPTED               RUBY_RAILS_DEFAULT
        !          10079: RUBY_RAILS_REQD                   RUBY_RAILS_STRICT_DEP
        !          10080: RUBY_RIDIR                        RUBY_SETUP
        !          10081: RUBY_SHLIB                        RUBY_SHLIBALIAS
        !          10082: RUBY_SHLIBVER                     RUBY_SIMPLE_INSTALL
        !          10083: RUBY_SITEARCHLIB                  RUBY_SITELIB
        !          10084: RUBY_SITELIB_BASE                 RUBY_SITERIDIR
        !          10085: RUBY_SLEXT                        RUBY_SRCDIR
        !          10086: RUBY_STATICLIB                    RUBY_SUFFIX
        !          10087: RUBY_SYSRIDIR                     RUBY_USE_PTHREAD
        !          10088: RUBY_VENDORARCHLIB                RUBY_VENDORLIB
        !          10089: RUBY_VENDORLIB_BASE               RUBY_VER
        !          10090: RUBY_VERSION                      RUBY_VERSIONS_ACCEPTED
        !          10091: RUBY_VERSIONS_INCOMPATIBLE        RUBY_VERSION_DEFAULT
        !          10092: RUBY_VERSION_REQD                 RUBY_VER_DIR
        !          10093: RUN                               RUN_LDCONFIG
        !          10094: RUST_TYPE                         SCO
        !          10095: SCREWS_GROUP                      SCREWS_USER
        !          10096: SCRIPTS_ENV                       SCROLLKEEPER_DATADIR
        !          10097: SCROLLKEEPER_REBUILDDB            SCROLLKEEPER_UPDATEDB
        !          10098: SDIST_PAWD                        SDL12_TYPE
        !          10099: SERIAL_DEVICES                    SETGIDGAME
        !          10100: SETGID_GAMES_PERMS                SETUID_ROOT_PERMS
        !          10101: SH                                SHAIRPORT_GROUP
        !          10102: SHAIRPORT_USER                    SHLIB_EXT
        !          10103: SHORTNAME                         SIGN_PACKAGES
        !          10104: SILC_CLIENT_WITH_PERL             SITE_SPECIFIC_PKGS
        !          10105: SKIP_DEPENDS                      SMF_INSTANCES
        !          10106: SMF_MANIFEST                      SMF_METHODS
        !          10107: SMF_METHOD_SHELL                  SMF_METHOD_SRC
        !          10108: SMF_NAME                          SMF_PREFIX
        !          10109: SMF_SRCDIR                        SNIPROXY_GROUP
        !          10110: SNIPROXY_USER                     SOURCE_BUFFSIZE
        !          10111: SPECIAL_PERMS                     SPECIFIC_PKGS
        !          10112: SSH_SUID                          SSLCERTBUNDLE
        !          10113: SSLCERTS                          SSLDIR
        !          10114: SSLKEYS                           SSP_SUPPORTED
        !          10115: SSYNC_PAWD                        STEP_MSG
        !          10116: STRIP                             STRIP_DBG
        !          10117: STRIP_DEBUG                       STRIP_DEBUG_SUPPORTED
        !          10118: STRIP_FILES_SKIP                  SU
        !          10119: SUBDIR                            SUBST
        !          10120: SUBST_CLASSES                     SUBST_FILES
        !          10121: SUBST_FILTER_CMD                  SUBST_MESSAGE
        !          10122: SUBST_NOOP_OK                     SUBST_SED
        !          10123: SUBST_SHOW_DIFF                   SUBST_SKIP_TEXT_CHECK
        !          10124: SUBST_STAGE                       SUBST_VARS
        !          10125: SUNWSPROBASE                      SUSE_PREFER
        !          10126: SU_CMD                            SVN_EXTRACTDIR
        !          10127: SVN_REPO                          SVN_REPOSITORIES
        !          10128: SVN_REVISION                      SYSCONFBASE
        !          10129: TARGET_MACHINE_ARCH               TBL
        !          10130: TERMCAP_TYPE                      TERMINFO_DEFAULT
        !          10131: TERMINFO_TYPE                     TEST
        !          10132: TEST_DEPENDS                      TEST_DIRS
        !          10133: TEST_ENV                          TEST_ENV_SHELL
        !          10134: TEST_MAKE_CMD                     TEST_MAKE_FLAGS
        !          10135: TEST_TARGET                       TEXLIVE_IGNORE_PATTERNS
        !          10136: TEXLIVE_REV                       TEXLIVE_UNVERSIONED
        !          10137: TEXMFSITE                         TEX_FORMATS
        !          10138: TEX_HYPHEN_DAT                    TEX_HYPHEN_DEF
        !          10139: TEX_TEXMF_DIRS                    THTTPD_LOG_FACILITY
        !          10140: TINYDYN_USER                      TLS
        !          10141: TLSWRAPPER_CHROOT                 TO
        !          10142: TOOLDIR                           TOOLS_ALIASES
        !          10143: TOOLS_ALWAYS_WRAP                 TOOLS_ARGS
        !          10144: TOOLS_BROKEN                      TOOLS_CMD
        !          10145: TOOLS_CMDLINE_SED                 TOOLS_CREATE
        !          10146: TOOLS_CROSS_DESTDIR               TOOLS_DIR
        !          10147: TOOLS_FAIL                        TOOLS_GNU_MISSING
        !          10148: TOOLS_LDCONFIG                    TOOLS_NOOP
        !          10149: TOOLS_PATH                        TOOLS_SCRIPT
        !          10150: TOOLS_USE_CROSS_COMPILE           TOOL_DEPENDS
        !          10151: TTF_FONTDIR                       TTF_FONTS_DIR
        !          10152: TYPE                              UAC_REQD_EXECS
        !          10153: UCSPI_SSL_GROUP                   UCSPI_SSL_USER
        !          10154: UNBOUND_GROUP                     UNBOUND_LOG_FACILITY
        !          10155: UNBOUND_USER                      UNLIMIT_RESOURCES
        !          10156: UNPRIVILEGED                      UNPRIVILEGED_GROUP
        !          10157: UNPRIVILEGED_GROUPS               UNPRIVILEGED_USER
        !          10158: UNWRAP_FILES                      UNWRAP_PATTERNS
        !          10159: UPDATE_GEMSPEC                    UPDATE_TARGET
        !          10160: URI                               USERGROUP_PHASE
        !          10161: USERPPP_GROUP                     USER_SPECIFIC_PKGS
        !          10162: USE_ABI_DEPENDS                   USE_ADA_FEATURES
        !          10163: USE_APR                           USE_BSD_MAKEFILE
        !          10164: USE_BUILTIN                       USE_CC_FEATURES
        !          10165: USE_CROSS_COMPILE                 USE_CURSES
        !          10166: USE_CWRAPPERS                     USE_CXX_FEATURES
        !          10167: USE_DB185                         USE_FEATURES
        !          10168: USE_GAMESGROUP                    USE_GCC_RUNTIME
        !          10169: USE_IMAKE                         USE_INDIRECT_DEPENDS
        !          10170: USE_JAVA                          USE_JAVA2
        !          10171: USE_LANGUAGES                     USE_LIBTOOL
        !          10172: USE_NATIVE_GCC                    USE_NETBSD_REPO
        !          10173: USE_PKGSRC_GCC                    USE_PKGSRC_GCC_RUNTIME
        !          10174: USE_PKGTASKS                      USE_PKG_ADMIN_DIGEST
        !          10175: USE_RUBY_EXTCONF                  USE_RUBY_INSTALL
        !          10176: USE_RUBY_SETUP                    USE_RUBY_SETUP_PKG
        !          10177: USE_TMPFILES                      USE_TOOLS
        !          10178: UUCP_GROUP                        UUCP_USER
        !          10179: VARBASE                           VARNAME
        !          10180: VIM_EXTRA_OPTS                    WARNING_MSG
        !          10181: WCALC_CGIDIR                      WCALC_CGIPATH
        !          10182: WCALC_HTMLDIR                     WCALC_HTMLPATH
        !          10183: WDM_MANAGERS                      WRAPPER_CC
        !          10184: WRAPPER_REORDER_CMDS              WRKDIR
        !          10185: WRKDIR_BASENAME                   WRKDIR_LOCKTYPE
        !          10186: WRKLOG                            WRKOBJDIR
        !          10187: WRKSRC                            X10_PORT
        !          10188: X11                               X11BASE
        !          10189: X11_PKGSRCDIR                     X11_TYPE
        !          10190: X509_CERTIFICATE                  X509_KEY
        !          10191: XAW_TYPE                          XLOCK_DEFAULT_MODE
        !          10192: XMKMF                             XMKMF_FLAGS
        !          10193: XXX                               XXXX
        !          10194: YES                               ZSH_STATIC
        !          10195: __stdc__                          _vargroups
        !          10196: accept                            acquire-localbase-lock
        !          10197: acquire-lock                      add
        !          10198: added                             administrator
        !          10199: alloca                            alternatives
        !          10200: aslr                              asprintf
        !          10201: atlas                             autoconf
        !          10202: automake                          autoreconf
        !          10203: awk                               barrier
        !          10204: bash                              big-endian
        !          10205: bin-install                       bind
        !          10206: binpkg-list                       blas
        !          10207: bootstrap-depends                 broken
        !          10208: broken_on_platform                bsd
        !          10209: bsd.prog.mk                       build
        !          10210: build-env                         buildlink-directories
        !          10211: buildlink-oss-soundcard-h         built-in
        !          10212: builtin                           c
        !          10213: c++                               ccache
        !          10214: cce                               cdefs
        !          10215: ceil                              changes
        !          10216: changes-entry                     changes-entry-noupdate
        !          10217: check                             check-clean
        !          10218: check-files                       check-files-clean
        !          10219: check-hackage                     check-vulnerable
        !          10220: checksum                          checksum-phase
        !          10221: clean                             clean-depends
        !          10222: cleandir                          commit
        !          10223: commit-changes-entry              compact
        !          10224: compiler                          conf
        !          10225: config.guess                      config.sub
        !          10226: configuration                     configure
        !          10227: configure-env                     configure-help
        !          10228: configure_args                    connect
        !          10229: cos                               cpe
        !          10230: cputime                           create-usergroup
        !          10231: csh                               ctf
        !          10232: cvs                               debug
        !          10233: debug-barrier                     declaration
        !          10234: declare                           defined
        !          10235: depend                            dependencies
        !          10236: depends                           depends-checksum
        !          10237: depends-fetch                     describe
        !          10238: destdir                           disable
        !          10239: distclean                         distfiles
        !          10240: distinfo                          dl
        !          10241: dlopen                            do-buildlink
        !          10242: do-clean                          do-configure
        !          10243: do-configure-post-hook            do-extract
        !          10244: do-fetch                          do-install
        !          10245: download                          emul
        !          10246: emul-distinfo                     emul-fetch
        !          10247: emulation                         emulator
        !          10248: enable                            endian
        !          10249: endif                             enomem
        !          10250: ensurepip                         err
        !          10251: errx                              etc
        !          10252: exp                               extract-rpm
        !          10253: fabs                              feature
        !          10254: features                          fetch
        !          10255: fetch-list                        follows
        !          10256: forbids                           form
        !          10257: format                            fortify
        !          10258: fortify_source                    fossil
        !          10259: friend                            fts
        !          10260: fts_close                         fts_open
        !          10261: fts_read                          fts_set
        !          10262: gcc                               gethostbyaddr
        !          10263: gethostbyname                     gethostbyname2
        !          10264: getopt_long                       getprogname
        !          10265: getservbyname                     getservbyport
        !          10266: getservent                        gettext
        !          10267: git                               github
        !          10268: gitlab                            glob
        !          10269: gnu                               gnu_configure_strict
        !          10270: go                                golang
        !          10271: guess-license                     hashbang
        !          10272: heimdal                           help
        !          10273: hg                                imake
        !          10274: in-tree                           increment
        !          10275: indirect                          inet_aton
        !          10276: install                           install-env
        !          10277: interp                            interpreter
        !          10278: intl                              ip4
        !          10279: ip6                               ipv4
        !          10280: ipv6                              iso
        !          10281: kerberos                          krb
        !          10282: krb5                              ksh
        !          10283: lapack                            latex
        !          10284: libiconv                          libintl_bindtextdomain
        !          10285: libintl_gettext                   libintl_textdomain
        !          10286: libnbcompat                       libs
        !          10287: libtool                           licence
        !          10288: license                           lintl
        !          10289: little-endian                     lock
        !          10290: locking                           lua
        !          10291: lvalue                            machine_endian
        !          10292: make                              makedistinfo
        !          10293: makepatchsum                      makesum
        !          10294: mdi                               memory
        !          10295: mercurial                         meta
        !          10296: meta-package                      meta_package
        !          10297: mit-krb5                          mk.conf
        !          10298: mkl                               mount
        !          10299: move                              moved
        !          10300: mprotect                          mps
        !          10301: mremap                            native
        !          10302: nb                                nbcompat
        !          10303: netlib                            network
        !          10304: node                              node.js
        !          10305: nodejs                            obstack
        !          10306: obstack_ptr_grow                  occurs
        !          10307: only                              openblas
        !          10308: options                           options.mk
        !          10309: order                             override
        !          10310: override-intltool                 override-message-intltool
        !          10311: package                           parallel
        !          10312: path                              pax
        !          10313: paxctl                            pbulk-index
        !          10314: pc                                perl
        !          10315: perl5                             perms
        !          10316: php                               pkg-build-options
        !          10317: pkg-config                        pkg_build_options
        !          10318: pkgsrc                            platform
        !          10319: plist                             post-extract
        !          10320: post-fetch                        post-wrapper
        !          10321: pre-build-checks-hook             pre-configure-checks-hook
        !          10322: pre-extract                       pre-fetch
        !          10323: print-plist                       print-summary-data
        !          10324: privileged-install-hook           pypi
        !          10325: python                            r
        !          10326: readme-all                        recursive
        !          10327: recv                              recvfrom
        !          10328: regcomp                           release-localbase-lock
        !          10329: release-lock                      relro
        !          10330: remove                            removed
        !          10331: rename                            renamed
        !          10332: reorder                           replace
        !          10333: replace_interpreter               reproducible
        !          10334: resolv                            root
        !          10335: ruby                              send
        !          10336: sendfile                          sendto
        !          10337: setenv                            setgid
        !          10338: setprogname                       setuid
        !          10339: sh                                shebang
        !          10340: show                              show-all
        !          10341: show-build-defs                   show-depends
        !          10342: show-depends-dirs                 show-depends-pkgpaths
        !          10343: show-depends-recursive            show-deps
        !          10344: show-distfiles                    show-downlevel
        !          10345: show-subdir-var                   show-tools
        !          10346: show-var                          show-vars
        !          10347: snprintf                          socket
        !          10348: ssp                               st_mode
        !          10349: stage-install                     strcasestr
        !          10350: strict                            strip
        !          10351: strndup                           strnlen
        !          10352: strsep                            subst
        !          10353: substitutions                     subversion
        !          10354: sun                               sunpro
        !          10355: sunwspro                          svn
        !          10356: symlink                           test
        !          10357: test-env                          tex
        !          10358: texlive                           tmp
        !          10359: todo                              tool
        !          10360: tools                             tools-libtool-m4-override
        !          10361: transitive                        type
        !          10362: ulimit                            undefined
        !          10363: undo-replace                      unlimit
        !          10364: unprivileged                      unprivileged-install-hook
        !          10365: unstripped                        update
        !          10366: updated                           upload
        !          10367: upload-distfiles                  use_tools
        !          10368: user                              utimes
        !          10369: vasprintf                         verbose
        !          10370: vsnprintf                         warn
        !          10371: warning                           warnings
        !          10372: warnx                             wattr_off
        !          10373: wattr_on                          work
        !          10374: wrapper                           wrkdir
1.154     rillig   10375: 
1.266     martin   10376: Appendix  F.  Editing guidelines for the pkgsrc guide
1.1       dsieger  10377: 
                   10378: Table of Contents
                   10379: 
1.207     leot     10380: F.1. Make targets
                   10381: F.2. Procedure
1.1       dsieger  10382: 
                   10383: This section contains information on editing the pkgsrc guide itself.
                   10384: 
1.266     martin   10385: F.1.  Make targets
1.1       dsieger  10386: 
                   10387: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
                   10388: files are created from it:
                   10389: 
                   10390:   * pkgsrc/doc/pkgsrc.txt
                   10391: 
                   10392:   * pkgsrc/doc/pkgsrc.html
                   10393: 
1.174     leot     10394:   * https://www.NetBSD.org/docs/pkgsrc/
1.1       dsieger  10395: 
1.174     leot     10396:   * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the
                   10397:     pkgsrc guide.
1.1       dsieger  10398: 
1.174     leot     10399:   * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
1.2       rillig   10400:     pkgsrc guide.
1.1       dsieger  10401: 
1.266     martin   10402: F.2.  Procedure
1.1       dsieger  10403: 
                   10404: The procedure to edit the pkgsrc guide is:
                   10405: 
1.190     bacon    10406:  1. Make sure you have checked out the htdocs repository into a sibling
                   10407:     directory of your pkgsrc directory. You will need the ability to commit
                   10408:     from both pkgsrc and htdocs.
                   10409: 
                   10410:  2. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46      obache   10411:     other XML-based NetBSD documentation) installed. These are automatically
                   10412:     installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1       dsieger  10413: 
1.190     bacon    10414:  3. Run cd doc/guide to get to the right directory. All further steps will take
1.1       dsieger  10415:     place here.
                   10416: 
1.190     bacon    10417:  4. Edit the XML file(s) in files/.
1.1       dsieger  10418: 
1.190     bacon    10419:  5. Run bmake to check the pkgsrc guide for valid XML and to build the final
1.1       dsieger  10420:     output files. If you get any errors at this stage, you can just edit the
                   10421:     files, as there are only symbolic links in the working directory, pointing
                   10422:     to the files in files/.
                   10423: 
1.190     bacon    10424:  6. (cd files && cvs commit)
1.1       dsieger  10425: 
1.190     bacon    10426:  7. Run bmake clean && bmake to regenerate the output files with the proper RCS
1.1       dsieger  10427:     Ids.
                   10428: 
1.190     bacon    10429:  8. Run bmake regen to install and commit the files in both pkgsrc/doc and
1.1       dsieger  10430:     htdocs.
                   10431: 
                   10432:     Note
                   10433: 
                   10434:     If you have added, removed or renamed some chapters, you need to
                   10435:     synchronize them using cvs add or cvs delete in the htdocs directory.
                   10436: 

CVSweb <webmaster@jp.NetBSD.org>