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

1.1       dsieger     1: The pkgsrc guide
                      2: 
                      3: Documentation on the NetBSD packages system
                      4: 
                      5: Alistair Crooks
                      6: 
                      7: <agc@NetBSD.org>
                      8: 
                      9: Hubert Feyrer
                     10: 
                     11: <hubertf@NetBSD.org>
                     12: 
                     13: The pkgsrc Developers
                     14: 
1.252     jnemeth    15: Copyright   1994-2024 The NetBSD Foundation, Inc
1.1       dsieger    16: 
1.252     jnemeth    17: $NetBSD: pkgsrc.xml,v 1.43 2024/01/02 07:26:32 jnemeth Exp $
1.1       dsieger    18: 
                     19: Abstract
                     20: 
                     21: pkgsrc is a centralized package management system for Unix-like operating
                     22: systems. This guide provides information for users and developers of pkgsrc. It
                     23: covers installation of binary and source packages, creation of binary and
                     24: source packages and a high-level overview about the infrastructure.
                     25: 
                     26: -------------------------------------------------------------------------------
                     27: 
                     28: Table of Contents
                     29: 
                     30: 1. What is pkgsrc?
                     31:     1.1. Introduction
                     32:         1.1.1. Why pkgsrc?
                     33:         1.1.2. Supported platforms
                     34:     1.2. Overview
                     35:     1.3. Terminology
                     36:         1.3.1. Roles involved in pkgsrc
                     37:     1.4. Typography
                     38: I. The pkgsrc user's guide
1.154     rillig     39:     2. Getting help
                     40:     3. Where to get pkgsrc and how to keep it up-to-date
                     41:         3.1. Getting pkgsrc for the first time
                     42:             3.1.1. As tar archive
                     43:             3.1.2. Via anonymous CVS
                     44:         3.2. Keeping pkgsrc up-to-date
                     45:             3.2.1. Via tar files
                     46:             3.2.2. Via CVS
                     47:     4. Using pkgsrc on systems other than NetBSD
                     48:         4.1. Binary distribution
                     49:         4.2. Bootstrapping pkgsrc
                     50:     5. Using pkgsrc
                     51:         5.1. Using binary packages
                     52:             5.1.1. Finding binary packages
                     53:             5.1.2. Installing binary packages
1.202     nia        54:             5.1.3. Updating packages
                     55:             5.1.4. Deinstalling packages
                     56:             5.1.5. Getting information about installed packages
                     57:             5.1.6. Checking for security vulnerabilities in installed packages
                     58:             5.1.7. Finding if newer versions of your installed packages are in
1.232     gutterid   59:             pkgsrc
1.202     nia        60:             5.1.8. Other administrative functions
1.154     rillig     61:         5.2. Building packages from source
                     62:             5.2.1. Requirements
                     63:             5.2.2. Fetching distfiles
                     64:             5.2.3. How to build and install
                     65:     6. Configuring pkgsrc
                     66:         6.1. General configuration
                     67:         6.2. Variables affecting the build process
1.241     rillig     68:         6.3. Preferences for native or pkgsrc software
                     69:         6.4. Variables affecting the installation process
                     70:         6.5. Selecting and configuring the compiler
                     71:             6.5.1. Selecting the compiler
                     72:             6.5.2. Additional flags to the compiler (CFLAGS)
                     73:             6.5.3. Additional flags to the linker (LDFLAGS)
                     74:         6.6. Developer/advanced settings
                     75:         6.7. Selecting Build Options
1.154     rillig     76:     7. Creating binary packages
                     77:         7.1. Building a single binary package
                     78:         7.2. Settings for creation of binary packages
                     79:     8. Creating binary packages for everything in pkgsrc (bulk builds)
                     80:         8.1. Preparations
1.180     rillig     81:         8.2. Running a bulk build
1.154     rillig     82:             8.2.1. Configuration
                     83:         8.3. Requirements of a full bulk build
1.178     rillig     84:         8.4. Bulk build variants
1.179     rillig     85:             8.4.1. Detect unknown configure options
                     86:             8.4.2. Detect classes of bugs by forcing compiler warnings
1.181     rillig     87:             8.4.3. Force compiler options only in the build phase
                     88:             8.4.4. Use custom directories
                     89:             8.4.5. Turn warnings into errors
                     90:             8.4.6. Reject packages for which pkglint reports errors
                     91:             8.4.7. Reject packages that contain forbidden strings
                     92:             8.4.8. Reject packages whose self-test fails
                     93:             8.4.9. Reject packages that use undefined shell variables
                     94:             8.4.10. Turn off verbose logging
1.178     rillig     95:         8.5. Creating a multiple CD-ROM packages collection
                     96:             8.5.1. Example of cdpack
1.154     rillig     97:     9. Directory layout of the installed files
                     98:         9.1. File system layout in ${LOCALBASE}
                     99:         9.2. File system layout in ${VARBASE}
                    100:     10. Frequently Asked Questions
                    101:         10.1. Are there any mailing lists for pkg-related discussion?
                    102:         10.2. Utilities for package management (pkgtools)
                    103:         10.3. How to use pkgsrc as non-root
                    104:         10.4. How to resume transfers when fetching distfiles?
                    105:         10.5. How can I install/use modular X.org from pkgsrc?
                    106:         10.6. How to fetch files from behind a firewall
                    107:         10.7. How to fetch files from HTTPS sites
                    108:         10.8. How do I tell make fetch to do passive FTP?
                    109:         10.9. How to fetch all distfiles at once
                    110:         10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc"
1.232     gutterid  111:         mean?
1.154     rillig    112:         10.11. What does "Could not find bsd.own.mk" mean?
1.221     nia       113:         10.12. Using 'sudo' or `priv` with pkgsrc
1.154     rillig    114:         10.13. How do I change the location of configuration files?
                    115:         10.14. Automated security checks
                    116:         10.15. Why do some packages ignore my CFLAGS?
                    117:         10.16. A package does not build. What shall I do?
                    118:         10.17. What does "Makefile appears to contain unresolved cvs/rcs/???
1.232     gutterid  119:         merge conflicts" mean?
1.1       dsieger   120: II. The pkgsrc developer's guide
1.154     rillig    121:     11. Getting help
1.184     rillig    122:     12. Package components - files, directories and contents
                    123:         12.1. Makefile
                    124:         12.2. distinfo
                    125:         12.3. patches/*
                    126:             12.3.1. Structure of a single patch file
                    127:             12.3.2. Creating patch files
                    128:             12.3.3. Sources where the patch files come from
                    129:             12.3.4. Patching guidelines
                    130:             12.3.5. Feedback to the author
                    131:         12.4. Other mandatory files
                    132:         12.5. Optional files
                    133:             12.5.1. Files affecting the binary package
                    134:             12.5.2. Files affecting the build process
                    135:             12.5.3. Files affecting nothing at all
                    136:         12.6. work*
                    137:         12.7. files/*
                    138:     13. The build process
                    139:         13.1. Introduction
                    140:         13.2. Program location
                    141:         13.3. Directories used during the build process
                    142:         13.4. Running a phase
                    143:         13.5. The fetch phase
                    144:             13.5.1. What to fetch and where to get it from
                    145:             13.5.2. How are the files fetched?
                    146:         13.6. The checksum phase
                    147:         13.7. The extract phase
                    148:         13.8. The patch phase
                    149:         13.9. The tools phase
                    150:         13.10. The wrapper phase
                    151:         13.11. The configure phase
                    152:         13.12. The build phase
                    153:         13.13. The test phase
                    154:         13.14. The install phase
                    155:         13.15. The package phase
                    156:         13.16. Cleaning up
                    157:         13.17. Other helpful targets
                    158:     14. Creating a new pkgsrc package from scratch
                    159:         14.1. Common types of packages
1.219     nia       160:             14.1.1. Python modules and programs
                    161:             14.1.2. R packages
                    162:             14.1.3. TeXlive packages
1.184     rillig    163:         14.2. Examples
                    164:             14.2.1. How the www/nvu package came into pkgsrc
                    165:     15. Programming in Makefiles
                    166:         15.1. Caveats
                    167:         15.2. Makefile variables
                    168:             15.2.1. Naming conventions
                    169:         15.3. Code snippets
                    170:             15.3.1. Adding things to a list
                    171:             15.3.2. Echoing a string exactly as-is
                    172:             15.3.3. Passing CFLAGS to GNU configure scripts
                    173:             15.3.4. Handling possibly empty variables
1.229     gutterid  174:             15.3.5. Testing yes/no variables in conditions
1.184     rillig    175:     16. Options handling
                    176:         16.1. Global default options
                    177:         16.2. Converting packages to use bsd.options.mk
                    178:         16.3. Option Names
                    179:         16.4. Determining the options of dependencies
                    180:     17. Tools needed for building or running
                    181:         17.1. Tools for pkgsrc builds
                    182:         17.2. Tools needed by packages
                    183:         17.3. Tools provided by platforms
                    184:     18. Buildlink methodology
                    185:         18.1. Converting packages to use buildlink3
                    186:         18.2. Writing buildlink3.mk files
                    187:             18.2.1. Anatomy of a buildlink3.mk file
                    188:             18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
1.232     gutterid  189:             BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
1.184     rillig    190:         18.3. Writing builtin.mk files
                    191:             18.3.1. Anatomy of a builtin.mk file
                    192:     19. PLIST issues
                    193:         19.1. RCS ID
                    194:         19.2. Semi-automatic PLIST generation
                    195:         19.3. Tweaking output of make print-PLIST
                    196:         19.4. Variable substitution in PLIST
                    197:         19.5. Man page compression
                    198:         19.6. Changing PLIST source with PLIST_SRC
                    199:         19.7. Platform-specific and differing PLISTs
                    200:         19.8. Build-specific PLISTs
                    201:         19.9. Sharing directories between packages
                    202:     20. The pkginstall framework
                    203:         20.1. Files and directories outside the installation prefix
                    204:             20.1.1. Directory manipulation
                    205:             20.1.2. File manipulation
                    206:         20.2. Configuration files
                    207:             20.2.1. How PKG_SYSCONFDIR is set
                    208:             20.2.2. Telling the software where configuration files are
1.239     dholland  209:             20.2.3. Patching installation
                    210:             20.2.4. Declaring configuration files
                    211:             20.2.5. Disabling handling of configuration files
1.184     rillig    212:         20.3. System startup scripts
                    213:             20.3.1. Disabling handling of system startup scripts
                    214:         20.4. System users and groups
                    215:         20.5. System shells
                    216:             20.5.1. Disabling shell registration
                    217:         20.6. Fonts
                    218:             20.6.1. Disabling automatic update of the fonts databases
1.154     rillig    219:     21. Making your package work
                    220:         21.1. General operation
                    221:             21.1.1. How to pull in user-settable variables from mk.conf
                    222:             21.1.2. User interaction
                    223:             21.1.3. Handling licenses
                    224:             21.1.4. Restricted packages
                    225:             21.1.5. Handling dependencies
                    226:             21.1.6. Handling conflicts with other packages
                    227:             21.1.7. Packages that cannot or should not be built
                    228:             21.1.8. Packages which should not be deleted, once installed
                    229:             21.1.9. Handling packages with security problems
                    230:             21.1.10. How to handle incrementing versions when fixing an
1.232     gutterid  231:             existing package
1.154     rillig    232:             21.1.11. Substituting variable text in the package files (the SUBST
1.232     gutterid  233:             framework)
1.154     rillig    234:         21.2. The fetch phase
                    235:             21.2.1. Packages whose distfiles aren't available for plain
1.232     gutterid  236:             downloading
1.154     rillig    237:             21.2.2. How to handle modified distfiles with the 'old' name
                    238:             21.2.3. Packages hosted on github.com
                    239:         21.3. The configure phase
                    240:             21.3.1. Shared libraries - libtool
                    241:             21.3.2. Using libtool on GNU packages that already support libtool
                    242:             21.3.3. GNU Autoconf/Automake
1.223     nia       243:             21.3.4. Meson / ninja
1.154     rillig    244:         21.4. Programming languages
                    245:             21.4.1. C, C++, and Fortran
                    246:             21.4.2. Java
1.205     wiz       247:             21.4.3. Go
1.223     nia       248:             21.4.4. Rust
                    249:             21.4.5. Packages containing Perl scripts
                    250:             21.4.6. Packages containing shell scripts
                    251:             21.4.7. Other programming languages
1.154     rillig    252:         21.5. The build phase
                    253:             21.5.1. Compiling C and C++ code conditionally
                    254:             21.5.2. How to handle compiler bugs
1.172     rillig    255:             21.5.3. No such file or directory
                    256:             21.5.4. Undefined reference to "..."
                    257:             21.5.5. Running out of memory
1.154     rillig    258:         21.6. The install phase
                    259:             21.6.1. Creating needed directories
                    260:             21.6.2. Where to install documentation
                    261:             21.6.3. Installing highscore files
                    262:             21.6.4. Adding DESTDIR support to packages
                    263:             21.6.5. Packages with hardcoded paths to other interpreters
1.203     nia       264:             21.6.6. Packages installing Perl modules
1.154     rillig    265:             21.6.7. Packages installing info files
                    266:             21.6.8. Packages installing man pages
1.203     nia       267:             21.6.9. Packages installing X11 fonts
                    268:             21.6.10. Packages installing SGML or XML data
                    269:             21.6.11. Packages installing extensions to the MIME database
                    270:             21.6.12. Packages using intltool
                    271:             21.6.13. Packages installing startup scripts
                    272:             21.6.14. Packages installing TeX modules
                    273:             21.6.15. Packages supporting running binaries in emulation
                    274:             21.6.16. Packages installing hicolor icons
                    275:             21.6.17. Packages installing desktop files
1.154     rillig    276:         21.7. Marking packages as having problems
1.184     rillig    277:     22. GNOME packaging and porting
                    278:         22.1. Meta packages
                    279:         22.2. Packaging a GNOME application
                    280:         22.3. Updating GNOME to a newer version
                    281:         22.4. Patching guidelines
1.154     rillig    282:     23. Submitting and Committing
                    283:         23.1. Submitting binary packages
                    284:         23.2. Submitting source packages (for non-NetBSD-developers)
                    285:         23.3. General notes when adding, updating, or removing packages
                    286:         23.4. Commit Messages
                    287:         23.5. Committing: Adding a package to CVS
                    288:         23.6. Updating a package to a newer version
                    289:         23.7. Renaming a package in pkgsrc
                    290:         23.8. Moving a package in pkgsrc
                    291:     24. Frequently Asked Questions
1.1       dsieger   292: III. The pkgsrc infrastructure internals
1.184     rillig    293:     25. Design of the pkgsrc infrastructure
                    294:         25.1. The meaning of variable definitions
                    295:         25.2. Avoiding problems before they arise
                    296:         25.3. Variable evaluation
                    297:             25.3.1. At load time
                    298:             25.3.2. At runtime
                    299:         25.4. How can variables be specified?
                    300:         25.5. Designing interfaces for Makefile fragments
                    301:             25.5.1. Procedures with parameters
                    302:             25.5.2. Actions taken on behalf of parameters
                    303:         25.6. The order in which files are loaded
                    304:             25.6.1. The order in bsd.prefs.mk
                    305:             25.6.2. The order in bsd.pkg.mk
                    306:     26. Regression tests
                    307:         26.1. Running the regression tests
                    308:         26.2. Adding a new regression test
                    309:             26.2.1. Overridable functions
                    310:             26.2.2. Helper functions
                    311:     27. Porting pkgsrc
                    312:         27.1. Porting pkgsrc to a new operating system
1.1       dsieger   313: A. A simple example package: bison
                    314:     A.1. files
                    315:         A.1.1. Makefile
                    316:         A.1.2. DESCR
                    317:         A.1.3. PLIST
                    318:         A.1.4. Checking a package with pkglint
                    319:     A.2. Steps for building, installing, packaging
1.207     leot      320: B. Security hardening
                    321:     B.1. Mechanisms
                    322:         B.1.1. Enabled by default
                    323:         B.1.2. Not enabled by default
                    324:     B.2. Caveats
                    325:         B.2.1. Problems with PKGSRC_MKPIE
                    326:         B.2.2. Problems with PKGSRC_USE_FORTIFY
                    327:         B.2.3. Problems with PKGSRC_USE_RELRO
                    328:         B.2.4. Problems with PKGSRC_USE_SSP
                    329:     B.3. Auditing the system
                    330:         B.3.1. Checking for PIE
                    331:         B.3.2. Checking for partial RELRO
                    332:         B.3.3. Checking for full RELRO
                    333:         B.3.4. Checking for SSP
                    334: C. Build logs
                    335:     C.1. Building figlet
                    336:     C.2. Packaging figlet
                    337: D. Directory layout of the pkgsrc FTP server
                    338:     D.1. distfiles: The distributed source files
                    339:     D.2. misc: Miscellaneous things
                    340:     D.3. packages: Binary packages
                    341:     D.4. reports: Bulk build reports
                    342:     D.5. current, stable, pkgsrc-20xxQy: source packages
                    343: E. Help topics
                    344: F. Editing guidelines for the pkgsrc guide
                    345:     F.1. Make targets
                    346:     F.2. Procedure
1.1       dsieger   347: 
                    348: List of Tables
                    349: 
                    350: 1.1. Platforms supported by pkgsrc
1.184     rillig    351: 12.1. Patching examples
                    352: 22.1. PLIST handling for GNOME packages
1.1       dsieger   353: 
                    354: Chapter 1. What is pkgsrc?
                    355: 
                    356: Table of Contents
                    357: 
                    358: 1.1. Introduction
                    359:     1.1.1. Why pkgsrc?
                    360:     1.1.2. Supported platforms
                    361: 1.2. Overview
                    362: 1.3. Terminology
                    363:     1.3.1. Roles involved in pkgsrc
                    364: 1.4. Typography
                    365: 
                    366: 1.1. Introduction
                    367: 
                    368: There is a lot of software freely available for Unix-based systems, which is
                    369: usually available in form of the source code. Before such software can be used,
                    370: it needs to be configured to the local system, compiled and installed, and this
                    371: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
                    372: some basic commands to handle binary packages, so that not every user has to
                    373: build the packages for himself, which is a time-costly task.
                    374: 
                    375: pkgsrc currently contains several thousand packages, including:
                    376: 
1.104     sevan     377:   * www/apache24 - The Apache web server
1.1       dsieger   378: 
                    379:   * www/firefox - The Firefox web browser
                    380: 
                    381:   * meta-pkgs/gnome - The GNOME Desktop Environment
                    382: 
1.102     ryoon     383:   * meta-pkgs/kde4 - The K Desktop Environment
1.1       dsieger   384: 
1.108     rillig    385: ? just to name a few.
1.1       dsieger   386: 
                    387: pkgsrc has built-in support for handling varying dependencies, such as pthreads
                    388: and X11, and extended features such as IPv6 support on a range of platforms.
                    389: 
                    390: 1.1.1. Why pkgsrc?
                    391: 
                    392: pkgsrc provides the following key features:
                    393: 
                    394:   * Easy building of software from source as well as the creation and
                    395:     installation of binary packages. The source and latest patches are
                    396:     retrieved from a master or mirror download site, checksum verified, then
                    397:     built on your system. Support for binary-only distributions is available
                    398:     for both native platforms and NetBSD emulated platforms.
                    399: 
                    400:   * All packages are installed in a consistent directory tree, including
                    401:     binaries, libraries, man pages and other documentation.
                    402: 
1.104     sevan     403:   * Tracking of package dependencies automatically, including when performing
                    404:     updates, to ensure required packages are installed. The configuration files
                    405:     of various packages are handled automatically during updates, so local
                    406:     changes are preserved.
1.1       dsieger   407: 
                    408:   * Like NetBSD, pkgsrc is designed with portability in mind and consists of
                    409:     highly portable code. This allows the greatest speed of development when
1.26      spz       410:     porting to a new platform. This portability also ensures that pkgsrc is 
1.1       dsieger   411:     consistent across all platforms.
                    412: 
                    413:   * The installation prefix, acceptable software licenses, international
                    414:     encryption requirements and build-time options for a large number of
                    415:     packages are all set in a simple, central configuration file.
                    416: 
                    417:   * The entire source (not including the distribution files) is freely
                    418:     available under a BSD license, so you may extend and adapt pkgsrc to your
                    419:     needs. Support for local packages and patches is available right out of the
                    420:     box, so you can configure it specifically for your environment.
                    421: 
                    422: The following principles are basic to pkgsrc:
                    423: 
1.198     leot      424:   * "It should only work if it's right." -- That means, if a package contains
1.1       dsieger   425:     bugs, it's better to find them and to complain about them rather than to
                    426:     just install the package and hope that it works. There are numerous checks
1.175     gutterid  427:     in pkgsrc that try to find such bugs: static analysis tools (pkgtools/
1.1       dsieger   428:     pkglint), build-time checks (portability of shell scripts), and
                    429:     post-installation checks (installed files, references to shared libraries,
                    430:     script interpreters).
                    431: 
1.198     leot      432:   * "If it works, it should work everywhere" -- Like NetBSD has been ported to
1.1       dsieger   433:     many hardware architectures, pkgsrc has been ported to many operating
                    434:     systems. Care is taken that packages behave the same on all platforms.
                    435: 
                    436: 1.1.2. Supported platforms
                    437: 
                    438: pkgsrc consists of both a source distribution and a binary distribution for
                    439: these operating systems. After retrieving the required source or binaries, you
                    440: can be up and running with pkgsrc in just minutes!
                    441: 
                    442: pkgsrc was derived from FreeBSD's ports system, and initially developed for
                    443: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
                    444: platforms:
                    445: 
                    446: Table 1.1. Platforms supported by pkgsrc
                    447: 
1.92      sevan     448: +-----------------------------------------------------------------------------+
1.229     gutterid  449: |              Platform               | Date Support  |         Notes         |
                    450: |                                     |     Added     |                       |
                    451: |-------------------------------------+---------------+-----------------------|
                    452: |NetBSD                               |   Aug 1997    |                       |
                    453: |-------------------------------------+---------------+-----------------------|
                    454: |Solaris                              |   Mar 1999    |README.Solaris         |
                    455: |-------------------------------------+---------------+-----------------------|
                    456: |Linux                                |   Jun 1999    |README.Linux           |
                    457: |-------------------------------------+---------------+-----------------------|
                    458: |Darwin / Mac OS X / OS X / macOS     |   Oct 2001    |README.macOS           |
                    459: |-------------------------------------+---------------+-----------------------|
                    460: |FreeBSD                              |   Nov 2002    |README.FreeBSD         |
                    461: |-------------------------------------+---------------+-----------------------|
                    462: |OpenBSD                              |   Nov 2002    |README.OpenBSD         |
                    463: |-------------------------------------+---------------+-----------------------|
                    464: |IRIX                                 |   Dec 2002    |README.IRIX            |
                    465: |-------------------------------------+---------------+-----------------------|
                    466: |BSD/OS                               |   Dec 2003    |                       |
                    467: |-------------------------------------+---------------+-----------------------|
                    468: |AIX                                  |   Dec 2003    |README.AIX             |
                    469: |-------------------------------------+---------------+-----------------------|
                    470: |Interix (Microsoft Windows Services  |   Mar 2004    |README.Interix         |
                    471: |for Unix)                            |               |                       |
                    472: |-------------------------------------+---------------+-----------------------|
                    473: |DragonFlyBSD                         |   Oct 2004    |                       |
                    474: |-------------------------------------+---------------+-----------------------|
                    475: |OSF/1                                |   Nov 2004    |README.OSF1            |
                    476: |-------------------------------------+---------------+-----------------------|
                    477: |HP-UX                                |   Apr 2007    |README.HPUX            |
                    478: |-------------------------------------+---------------+-----------------------|
                    479: |Haiku                                |   Sep 2010    |README.Haiku           |
                    480: |-------------------------------------+---------------+-----------------------|
                    481: |MirBSD                               |   Jan 2011    |                       |
                    482: |-------------------------------------+---------------+-----------------------|
                    483: |Minix3                               |   Nov 2011    |README.Minix3          |
                    484: |-------------------------------------+---------------+-----------------------|
                    485: |Cygwin                               |   Mar 2013    |README.Cygwin          |
                    486: |-------------------------------------+---------------+-----------------------|
                    487: |GNU/kFreeBSD                         |   Jul 2013    |README.GNUkFreeBSD     |
                    488: |-------------------------------------+---------------+-----------------------|
                    489: |Bitrig                               |   Jun 2014    |Removed from pkgsrc Sep|
                    490: |                                     |               |2022                   |
1.92      sevan     491: +-----------------------------------------------------------------------------+
1.1       dsieger   492: 
                    493: 
                    494: 1.2. Overview
                    495: 
                    496: This document is divided into three parts. The first, The pkgsrc user's guide,
                    497: describes how one can use one of the packages in the Package Collection, either
                    498: by installing a precompiled binary package, or by building one's own copy using
                    499: the NetBSD package system. The second part, The pkgsrc developer's guide,
                    500: explains how to prepare a package so it can be easily built by other NetBSD
                    501: users without knowing about the package's building details. The third part, The
                    502: pkgsrc infrastructure internals is intended for those who want to understand
                    503: how pkgsrc is implemented.
                    504: 
                    505: This document is available in various formats: HTML, PDF, PS, TXT.
                    506: 
                    507: 1.3. Terminology
                    508: 
                    509: There has been a lot of talk about "ports", "packages", etc. so far. Here is a
                    510: description of all the terminology used within this document.
                    511: 
                    512: Package
                    513: 
                    514:     A set of files and building instructions that describe what's necessary to
                    515:     build a certain piece of software using pkgsrc. Packages are traditionally
1.123     wiz       516:     stored under /usr/pkgsrc, but may be stored in any location, referred to as
                    517:     PKGSRCDIR.
1.1       dsieger   518: 
                    519: The NetBSD package system
                    520: 
                    521:     This is the former name of "pkgsrc". It is part of the NetBSD operating
                    522:     system and can be bootstrapped to run on non-NetBSD operating systems as
                    523:     well. It handles building (compiling), installing, and removing of
                    524:     packages.
                    525: 
                    526: Distfile
                    527: 
                    528:     This term describes the file or files that are provided by the author of
                    529:     the piece of software to distribute his work. All the changes necessary to
                    530:     build on NetBSD are reflected in the corresponding package. Usually the
                    531:     distfile is in the form of a compressed tar-archive, but other types are
                    532:     possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
                    533: 
                    534: Port
                    535: 
                    536:     This is the term used by FreeBSD and OpenBSD people for what we call a
                    537:     package. In NetBSD terminology, "port" refers to a different architecture.
                    538: 
                    539: Precompiled/binary package
                    540: 
                    541:     A set of binaries built with pkgsrc from a distfile and stuffed together in
                    542:     a single .tgz file so it can be installed on machines of the same machine
                    543:     architecture without the need to recompile. Packages are usually generated
                    544:     in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
                    545: 
                    546:     Sometimes, this is referred to by the term "package" too, especially in the
                    547:     context of precompiled packages.
                    548: 
                    549: Program
                    550: 
                    551:     The piece of software to be installed which will be constructed from all
                    552:     the files in the distfile by the actions defined in the corresponding
                    553:     package.
                    554: 
                    555: 1.3.1. Roles involved in pkgsrc
                    556: 
                    557: pkgsrc users
                    558: 
                    559:     The pkgsrc users are people who use the packages provided by pkgsrc.
                    560:     Typically they are system administrators. The people using the software
                    561:     that is inside the packages (maybe called "end users") are not covered by
                    562:     the pkgsrc guide.
                    563: 
                    564:     There are two kinds of pkgsrc users: Some only want to install pre-built
                    565:     binary packages. Others build the pkgsrc packages from source, either for
                    566:     installing them directly or for building binary packages themselves. For
                    567:     pkgsrc users Part I, "The pkgsrc user's guide" should provide all necessary
                    568:     documentation.
                    569: 
                    570: package maintainers
                    571: 
                    572:     A package maintainer creates packages as described in Part II, "The pkgsrc
                    573:     developer's guide".
                    574: 
                    575: infrastructure developers
                    576: 
                    577:     These people are involved in all those files that live in the mk/ directory
                    578:     and below. Only these people should need to read through Part III, "The
                    579:     pkgsrc infrastructure internals", though others might be curious, too.
                    580: 
                    581: 1.4. Typography
                    582: 
                    583: When giving examples for commands, shell prompts are used to show if the
                    584: command should/can be issued as root, or if "normal" user privileges are
1.115     sevan     585: sufficient. We use a # for root's shell prompt, a % for users' shell prompt,
1.229     gutterid  586: assuming they use the C-shell or tcsh and a $ for Bourne shell and derivatives.
1.1       dsieger   587: 
                    588: Part I. The pkgsrc user's guide
                    589: 
                    590: Table of Contents
                    591: 
1.154     rillig    592: 2. Getting help
                    593: 3. Where to get pkgsrc and how to keep it up-to-date
                    594:     3.1. Getting pkgsrc for the first time
                    595:         3.1.1. As tar archive
                    596:         3.1.2. Via anonymous CVS
                    597:     3.2. Keeping pkgsrc up-to-date
                    598:         3.2.1. Via tar files
                    599:         3.2.2. Via CVS
                    600: 4. Using pkgsrc on systems other than NetBSD
                    601:     4.1. Binary distribution
                    602:     4.2. Bootstrapping pkgsrc
                    603: 5. Using pkgsrc
                    604:     5.1. Using binary packages
                    605:         5.1.1. Finding binary packages
                    606:         5.1.2. Installing binary packages
1.202     nia       607:         5.1.3. Updating packages
                    608:         5.1.4. Deinstalling packages
                    609:         5.1.5. Getting information about installed packages
                    610:         5.1.6. Checking for security vulnerabilities in installed packages
                    611:         5.1.7. Finding if newer versions of your installed packages are in
1.232     gutterid  612:         pkgsrc
1.202     nia       613:         5.1.8. Other administrative functions
1.154     rillig    614:     5.2. Building packages from source
                    615:         5.2.1. Requirements
                    616:         5.2.2. Fetching distfiles
                    617:         5.2.3. How to build and install
                    618: 6. Configuring pkgsrc
                    619:     6.1. General configuration
                    620:     6.2. Variables affecting the build process
1.241     rillig    621:     6.3. Preferences for native or pkgsrc software
                    622:     6.4. Variables affecting the installation process
                    623:     6.5. Selecting and configuring the compiler
                    624:         6.5.1. Selecting the compiler
                    625:         6.5.2. Additional flags to the compiler (CFLAGS)
                    626:         6.5.3. Additional flags to the linker (LDFLAGS)
                    627:     6.6. Developer/advanced settings
                    628:     6.7. Selecting Build Options
1.154     rillig    629: 7. Creating binary packages
                    630:     7.1. Building a single binary package
                    631:     7.2. Settings for creation of binary packages
                    632: 8. Creating binary packages for everything in pkgsrc (bulk builds)
                    633:     8.1. Preparations
1.180     rillig    634:     8.2. Running a bulk build
1.154     rillig    635:         8.2.1. Configuration
                    636:     8.3. Requirements of a full bulk build
1.178     rillig    637:     8.4. Bulk build variants
1.179     rillig    638:         8.4.1. Detect unknown configure options
                    639:         8.4.2. Detect classes of bugs by forcing compiler warnings
1.181     rillig    640:         8.4.3. Force compiler options only in the build phase
                    641:         8.4.4. Use custom directories
                    642:         8.4.5. Turn warnings into errors
                    643:         8.4.6. Reject packages for which pkglint reports errors
                    644:         8.4.7. Reject packages that contain forbidden strings
                    645:         8.4.8. Reject packages whose self-test fails
                    646:         8.4.9. Reject packages that use undefined shell variables
                    647:         8.4.10. Turn off verbose logging
1.178     rillig    648:     8.5. Creating a multiple CD-ROM packages collection
                    649:         8.5.1. Example of cdpack
1.154     rillig    650: 9. Directory layout of the installed files
                    651:     9.1. File system layout in ${LOCALBASE}
                    652:     9.2. File system layout in ${VARBASE}
                    653: 10. Frequently Asked Questions
                    654:     10.1. Are there any mailing lists for pkg-related discussion?
                    655:     10.2. Utilities for package management (pkgtools)
                    656:     10.3. How to use pkgsrc as non-root
                    657:     10.4. How to resume transfers when fetching distfiles?
                    658:     10.5. How can I install/use modular X.org from pkgsrc?
                    659:     10.6. How to fetch files from behind a firewall
                    660:     10.7. How to fetch files from HTTPS sites
                    661:     10.8. How do I tell make fetch to do passive FTP?
                    662:     10.9. How to fetch all distfiles at once
                    663:     10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
                    664:     10.11. What does "Could not find bsd.own.mk" mean?
1.221     nia       665:     10.12. Using 'sudo' or `priv` with pkgsrc
1.154     rillig    666:     10.13. How do I change the location of configuration files?
                    667:     10.14. Automated security checks
                    668:     10.15. Why do some packages ignore my CFLAGS?
                    669:     10.16. A package does not build. What shall I do?
                    670:     10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.232     gutterid  671:     conflicts" mean?
1.1       dsieger   672: 
1.154     rillig    673: Chapter 2. Getting help
                    674: 
                    675: To get help when using pkgsrc, the definitive source is this document, the
                    676: pkgsrc guide. If you don't find anything here, there are alternatives:
                    677: 
                    678:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
                    679:     Run bmake help topic=? to get help for any topic, such as a variable name
                    680:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                    681:     like strcasecmp or any other topic.
                    682: 
1.207     leot      683:     The available help topics are listed in Appendix E, Help topics.
1.154     rillig    684: 
1.163     rillig    685:   * To see the value of a single variable, run bmake show-var VARNAME=X.
                    686: 
                    687:   * To see the values of the most common variables, run bmake show-all. These
                    688:     variables are grouped by topic. To see the variables for a single topic,
                    689:     run bmake show-all-topic, for example bmake show-all-fetch.
                    690: 
1.154     rillig    691:   * The pkgsrc-users mailing list, to which you can subscribe and then ask your
                    692:     questions.
                    693: 
                    694:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                    695:     a specialized chat program such as XChat. Pick any user name and join the
                    696:     channel #pkgsrc.
                    697: 
                    698: Chapter 3. Where to get pkgsrc and how to keep it up-to-date
1.1       dsieger   699: 
                    700: Table of Contents
                    701: 
1.154     rillig    702: 3.1. Getting pkgsrc for the first time
                    703:     3.1.1. As tar archive
                    704:     3.1.2. Via anonymous CVS
                    705: 3.2. Keeping pkgsrc up-to-date
                    706:     3.2.1. Via tar files
                    707:     3.2.2. Via CVS
1.1       dsieger   708: 
                    709: Before you download and extract the files, you need to decide where you want to
                    710: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
                    711: usr/pkgsrc. You are though free to install the sources and binary packages
                    712: wherever you want in your filesystem, provided that the pathname does not
                    713: contain white-space or other characters that are interpreted specially by the
                    714: shell and some other programs. A safe bet is to use only letters, digits,
                    715: underscores and dashes.
                    716: 
1.154     rillig    717: 3.1. Getting pkgsrc for the first time
1.1       dsieger   718: 
1.25      wiz       719: Before you download any pkgsrc files, you should decide whether you want the 
1.1       dsieger   720: current branch or the stable branch. The latter is forked on a quarterly basis
                    721: from the current branch and only gets modified for security updates. The names
                    722: of the stable branches are built from the year and the quarter, for example
1.246     leot      723: 2023Q3.
1.1       dsieger   724: 
                    725: The second step is to decide how you want to download pkgsrc. You can get it as
1.24      wiz       726: a tar file or via CVS. Both ways are described here.
1.1       dsieger   727: 
1.52      asau      728: Note that tar archive contains CVS working copy. Thus you can switch to using
                    729: CVS at any later time.
1.1       dsieger   730: 
1.154     rillig    731: 3.1.1. As tar archive
1.52      asau      732: 
1.151     sevan     733: The primary download location for all pkgsrc files is https://cdn.NetBSD.org/
                    734: pub/pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same
                    735: location). There are a number of subdirectories for different purposes, which
1.207     leot      736: are described in detail in Appendix D, Directory layout of the pkgsrc FTP
1.151     sevan     737: server.
1.1       dsieger   738: 
1.52      asau      739: The tar archive for the current branch is in the directory current and is
1.118     sevan     740: called pkgsrc.tar.gz. It is autogenerated weekly.
1.52      asau      741: 
                    742: To save download time we provide bzip2- and xz-compressed archives which are
                    743: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
                    744: 
                    745: You can fetch the same files using FTP.
1.1       dsieger   746: 
1.246     leot      747: The tar file for the stable branch 2023Q3 is in the directory pkgsrc-2023Q3 and
1.59      jnemeth   748: is also called pkgsrc.tar.gz.
1.1       dsieger   749: 
1.136     leot      750: To download the latest pkgsrc stable tarball, run:
1.12      weinem    751: 
1.246     leot      752: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2023Q3/pkgsrc.tar.gz
1.12      weinem    753: 
1.78      snj       754: If you prefer, you can also fetch it using "wget", "curl", or your web browser.
1.52      asau      755: 
1.12      weinem    756: Then, extract it with:
                    757: 
1.78      snj       758: $ tar -xzf pkgsrc.tar.gz -C /usr
1.12      weinem    759: 
                    760: This will create the directory pkgsrc/ in /usr/ and all the package source will
                    761: be stored under /usr/pkgsrc/.
                    762: 
                    763: To download pkgsrc-current, run:
                    764: 
                    765: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1       dsieger   766: 
1.154     rillig    767: 3.1.2. Via anonymous CVS
1.1       dsieger   768: 
1.24      wiz       769: To fetch a specific pkgsrc stable branch, run:
1.1       dsieger   770: 
1.246     leot      771: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2023Q3 -P pkgsrc
1.13      weinem    772: 
1.24      wiz       773: This will create the directory pkgsrc/ in your /usr/ directory and all the
                    774: package source will be stored under /usr/pkgsrc/.
                    775: 
                    776: To fetch the pkgsrc current branch, run:
1.1       dsieger   777: 
1.40      wiz       778: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   779: 
1.30      dholland  780: Refer to the list of available mirrors to choose a faster CVS mirror, if
                    781: needed.
1.1       dsieger   782: 
1.24      wiz       783: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1       dsieger   784: 
1.40      wiz       785: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   786: 
1.24      wiz       787: Refer to documentation on your command shell how to set CVS_RSH=ssh
                    788: permanently. For Bourne shells, you can set it in your .profile or better
                    789: globally in /etc/profile:
                    790: 
                    791: # set CVS remote shell command
                    792: CVS_RSH=ssh
                    793: export CVS_RSH
1.12      weinem    794: 
1.13      weinem    795: By default, CVS doesn't do things like most people would expect it to do. But
                    796: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12      weinem    797: directory and saving the following lines to it. This file will save you lots of
                    798: headache and some bug reports, so we strongly recommend it. You can find an
                    799: explanation of this file in the CVS documentation.
1.2       rillig    800: 
                    801: # recommended CVS configuration file from the pkgsrc guide
1.155     sevan     802: cvs -q
1.2       rillig    803: checkout -P
1.4       rillig    804: update -dP
                    805: diff -upN
1.2       rillig    806: rdiff -u
1.24      wiz       807: release -d
1.1       dsieger   808: 
1.154     rillig    809: 3.2. Keeping pkgsrc up-to-date
1.1       dsieger   810: 
                    811: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
                    812: have first installed it via a tar file). It saves bandwidth and hard disk
                    813: activity, compared to downloading the tar file again.
                    814: 
1.154     rillig    815: 3.2.1. Via tar files
1.1       dsieger   816: 
                    817: Warning
                    818: 
                    819: When updating from a tar file, you first need to completely remove the old
                    820: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
                    821: the mean time will not be removed on your local disk, resulting in
                    822: inconsistencies. When removing the old files, any changes that you have done to
                    823: the pkgsrc files will be lost after updating. Therefore updating via CVS is
                    824: strongly recommended.
                    825: 
                    826: Note that by default the distfiles and the binary packages are saved in the
                    827: pkgsrc tree, so don't forget to rescue them before updating. You can also
1.78      snj       828: configure pkgsrc to store distfiles and packages in directories outside the
1.154     rillig    829: pkgsrc tree by setting the DISTDIR and PACKAGES variables. See Chapter 6, 
1.78      snj       830: Configuring pkgsrc for the details.
1.1       dsieger   831: 
                    832: To update pkgsrc from a tar file, download the tar file as explained above.
                    833: Then, make sure that you have not made any changes to the files in the pkgsrc
                    834: directory. Remove the pkgsrc directory and extract the new tar file. Done.
                    835: 
1.154     rillig    836: 3.2.2. Via CVS
1.1       dsieger   837: 
1.26      spz       838: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12      weinem    839: 
1.26      spz       840: $ cd /usr/pkgsrc && cvs update -dP
                    841: 
                    842: If you get error messages from rsh, you need to set CVS_RSH variable as
                    843: described above. E.g.:
                    844: 
                    845: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1       dsieger   846: 
1.154     rillig    847: 3.2.2.1. Switching between different pkgsrc branches
1.1       dsieger   848: 
                    849: When updating pkgsrc, the CVS program keeps track of the branch you selected.
                    850: But if you, for whatever reason, want to switch from the stable branch to the
                    851: current one, you can do it by adding the option "-A" after the "update"
1.25      wiz       852: keyword. To switch from the current branch back to the stable branch, add the "
1.246     leot      853: -rpkgsrc-2023Q3" option.
1.1       dsieger   854: 
1.154     rillig    855: 3.2.2.2. What happens to my changes when updating?
1.1       dsieger   856: 
                    857: When you update pkgsrc, the CVS program will only touch those files that are
                    858: registered in the CVS repository. That means that any packages that you created
                    859: on your own will stay unmodified. If you change files that are managed by CVS,
                    860: later updates will try to merge your changes with those that have been done by
                    861: others. See the CVS manual, chapter "update" for details.
                    862: 
1.154     rillig    863: Chapter 4. Using pkgsrc on systems other than NetBSD
1.1       dsieger   864: 
                    865: Table of Contents
                    866: 
1.154     rillig    867: 4.1. Binary distribution
                    868: 4.2. Bootstrapping pkgsrc
1.1       dsieger   869: 
1.154     rillig    870: 4.1. Binary distribution
1.1       dsieger   871: 
1.154     rillig    872: See Section 5.1, "Using binary packages".
1.1       dsieger   873: 
1.154     rillig    874: 4.2. Bootstrapping pkgsrc
1.1       dsieger   875: 
1.44      asau      876: pkgsrc can be bootstrapped for use in two different modes: privileged and
                    877: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45      asau      878: programs are installed under one particular user and cannot utilise privileged
1.44      asau      879: operations (packages don't create special users and all special file
                    880: permissions like setuid are ignored).
                    881: 
1.1       dsieger   882: Installing the bootstrap kit from source should be as simple as:
                    883: 
1.60      asau      884: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   885: # cd pkgsrc/bootstrap
                    886: # ./bootstrap
                    887: 
                    888: 
1.44      asau      889: To bootstrap in unprivileged mode pass "--unprivileged" flag to bootstrap
                    890: 
                    891: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
1.118     sevan     892: will be installed in, and /usr/pkg/pkgdb for the package database directory
                    893: where pkgsrc will do its internal bookkeeping, /var is used as varbase, where
1.44      asau      894: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
1.118     sevan     895: for prefix, ~/pkg/pkgdb for the package database, and ~/pkg/var for varbase.
1.44      asau      896: 
                    897: You can change default layout using command-line arguments. Run "./bootstrap
                    898: --help" to get details.
1.1       dsieger   899: 
                    900: Note
                    901: 
                    902: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
                    903: For examples in this guide, use bmake instead of "make".
                    904: 
1.44      asau      905: Note
                    906: 
                    907: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
                    908: directories. Use bmake corresponding to the installation you're working with to
                    909: build and install packages.
                    910: 
1.154     rillig    911: Chapter 5. Using pkgsrc
1.1       dsieger   912: 
                    913: Table of Contents
                    914: 
1.154     rillig    915: 5.1. Using binary packages
                    916:     5.1.1. Finding binary packages
                    917:     5.1.2. Installing binary packages
1.202     nia       918:     5.1.3. Updating packages
                    919:     5.1.4. Deinstalling packages
                    920:     5.1.5. Getting information about installed packages
                    921:     5.1.6. Checking for security vulnerabilities in installed packages
                    922:     5.1.7. Finding if newer versions of your installed packages are in pkgsrc
                    923:     5.1.8. Other administrative functions
1.154     rillig    924: 5.2. Building packages from source
                    925:     5.2.1. Requirements
                    926:     5.2.2. Fetching distfiles
                    927:     5.2.3. How to build and install
1.1       dsieger   928: 
                    929: Basically, there are two ways of using pkgsrc. The first is to only install the
                    930: package tools and to use binary packages that someone else has prepared. This
                    931: is the "pkg" in pkgsrc. The second way is to install the "src" of pkgsrc, too.
                    932: Then you are able to build your own packages, and you can still use binary
                    933: packages from someone else.
                    934: 
1.154     rillig    935: 5.1. Using binary packages
1.1       dsieger   936: 
1.151     sevan     937: On the cdn.NetBSD.org site and mirrors, there are collections of binary
1.9       rillig    938: packages, ready to be installed. These binary packages have been built using
                    939: the default settings for the directories, that is:
                    940: 
                    941:   * /usr/pkg for LOCALBASE, where most of the files are installed,
                    942: 
                    943:   * /usr/pkg/etc for configuration files,
                    944: 
                    945:   * /var for VARBASE, where those files are installed that may change after
                    946:     installation.
                    947: 
                    948: If you cannot use these directories for whatever reasons (maybe because you're
                    949: not root), you cannot use these binary packages, but have to build the packages
1.154     rillig    950: yourself, which is explained in Section 4.2, "Bootstrapping pkgsrc".
1.1       dsieger   951: 
1.154     rillig    952: 5.1.1. Finding binary packages
1.1       dsieger   953: 
1.5       weinem    954: To install binary packages, you first need to know from where to get them. The
1.202     nia       955: first place where you should look is on the main pkgsrc CDN in the directory /
                    956: pub/pkgsrc/packages.
1.5       weinem    957: 
                    958: This directory contains binary packages for multiple platforms. First, select
1.226     gutterid  959: your operating system. Then, select your hardware architecture, and in the
                    960: third step, the OS version and the "version" of pkgsrc.
1.9       rillig    961: 
1.226     gutterid  962: In this directory, you may find a file called bootstrap.tar.gz which contains
1.9       rillig    963: the package management tools. If the file is missing, it is likely that your
                    964: operating system already provides those tools. Download the file and extract it
                    965: in the / directory. It will create the directories /usr/pkg (containing the
1.118     sevan     966: tools for managing binary packages and the database of installed packages).
1.1       dsieger   967: 
1.154     rillig    968: 5.1.2. Installing binary packages
1.1       dsieger   969: 
1.85      wiz       970: In the directory from the last section, there is a subdirectory called All/,
1.9       rillig    971: which contains all the binary packages that are available for the platform,
1.202     nia       972: excluding those that may not be distributed via HTTP or FTP.
1.9       rillig    973: 
                    974: To install packages directly from an FTP or HTTP server, run the following
                    975: commands in a Bourne-compatible shell (be sure to su to root first):
                    976: 
1.202     nia       977: # PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
                    978: # PKG_PATH="https://cdn.NetBSD.org/pub/pkgsrc/packages"
1.169     rillig    979: # PKG_PATH="$PKG_PATH/OPSYS/ARCH/VERSIONS/All/"
1.9       rillig    980: # export PATH PKG_PATH
1.202     nia       981: # pkg_add pkgin
1.9       rillig    982: 
                    983: Instead of URLs, you can also use local paths, for example if you are
                    984: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
                    985: to install packages from multiple sources, you can separate them by a semicolon
                    986: in PKG_PATH.
                    987: 
                    988: After these preparations, installing a package is very easy:
                    989: 
1.202     nia       990: # pkgin search nginx
                    991: nginx-1.19.6         Lightweight HTTP server and mail proxy server
                    992: nginx-1.18.0nb8      Lightweight HTTP server and mail proxy server
                    993: # pkgin install zsh nginx-1.19.6 vim
1.1       dsieger   994: 
1.202     nia       995: Note that pkgin is a user-friendly frontend to the pkg_* tools.
1.1       dsieger   996: 
1.202     nia       997: Any prerequisite packages needed to run the package in question will be
                    998: installed, too, assuming they are present in the repository.
1.1       dsieger   999: 
                   1000: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
                   1001: in your PATH so you can actually start the just installed program.
                   1002: 
1.202     nia      1003: 5.1.3. Updating packages
1.1       dsieger  1004: 
1.202     nia      1005: To update binary packages, it is recommended that you use pkgin upgrade. This
                   1006: will compare the remote package repository to your locally installed packages
                   1007: and safely replace any older packages.
1.1       dsieger  1008: 
1.202     nia      1009: Note that pkgsrc is released as quarterly branches. If you are updating to a
                   1010: newer quarterly branch of pkgsrc, you may need to adjust the repository in /usr
                   1011: /pkg/etc/pkgin/repositories.conf.
1.1       dsieger  1012: 
1.202     nia      1013: 5.1.4. Deinstalling packages
1.1       dsieger  1014: 
1.202     nia      1015: To deinstall a package, it does not matter whether it was installed from source
                   1016: code or from a binary package. Neither the pkgin or the pkg_delete command need
                   1017: to know.
1.1       dsieger  1018: 
1.202     nia      1019: To delete a package, you can just run pkgin remove package-name. The package
                   1020: name can be given with or without version number.
1.1       dsieger  1021: 
1.202     nia      1022: 5.1.5. Getting information about installed packages
1.1       dsieger  1023: 
                   1024: The pkg_info shows information about installed packages or binary package
1.202     nia      1025: files. As with other management tools, it works with packages installed from
                   1026: source or binaries.
1.1       dsieger  1027: 
1.202     nia      1028: 5.1.6. Checking for security vulnerabilities in installed packages
1.1       dsieger  1029: 
1.202     nia      1030: The pkgsrc Security Team and Packages Groups maintain a list of known
1.164     leot     1031: vulnerabilities to packages which are (or have been) included in pkgsrc. The
1.202     nia      1032: list is available from the NetBSD CDN at https://cdn.NetBSD.org/pub/NetBSD/
1.179     rillig   1033: packages/vulns/pkg-vulnerabilities.
1.1       dsieger  1034: 
1.202     nia      1035: Please note that not every "vulnerability" with a CVE assignment is exploitable
                   1036: in every configuration. Some bugs are marked as active simply because an fix
                   1037: was not marked as such. Operating system specific hardening and mitigation
                   1038: features may also reduce the impact of bugs.
                   1039: 
1.23      jakllsch 1040: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
                   1041: automatically, and a security audit of all packages installed on a system can
                   1042: take place.
                   1043: 
                   1044: There are two components to auditing. The first step, pkg_admin
                   1045: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
                   1046: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
                   1047: your installed packages are vulnerable. If a package is vulnerable, you will
                   1048: see output similar to the following:
1.1       dsieger  1049: 
                   1050: Package samba-2.0.9 has a local-root-shell vulnerability, see
1.174     leot     1051:     https://www.samba.org/samba/whatsnew/macroexploit.html
1.1       dsieger  1052: 
1.23      jakllsch 1053: You may wish to have the vulnerabilities file downloaded daily so that it
                   1054: remains current. This may be done by adding an appropriate entry to the root
                   1055: users crontab(5) entry. For example the entry
                   1056: 
1.121     sevan    1057: # Download vulnerabilities file
1.118     sevan    1058: 0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1.121     sevan    1059: # Audit the installed packages and email results to root
                   1060: 9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
                   1061:             root >/dev/null 2>&1
1.118     sevan    1062: 
                   1063: 
                   1064: will update the vulnerability list every day at 3AM, followed by an audit at
                   1065: 3:09AM. The result of the audit are then emailed to root. On NetBSD this may be
                   1066: accomplished instead by adding the following line to /etc/daily.conf:
                   1067: 
                   1068: fetch_pkg_vulnerabilities=YES
                   1069: 
1.23      jakllsch 1070: 
1.118     sevan    1071: to fetch the vulnerability list from the daily security script. The system is
                   1072: set to audit the packages by default but can be set explicitly, if desired (not
1.123     wiz      1073: required), by adding the following line to /etc/security.conf:
1.23      jakllsch 1074: 
1.118     sevan    1075: check_pkg_vulnerabilities=YES
1.23      jakllsch 1076: 
                   1077: 
1.118     sevan    1078: see daily.conf(5) and security.conf(5) for more details.
1.1       dsieger  1079: 
1.202     nia      1080: 5.1.7. Finding if newer versions of your installed packages are in pkgsrc
1.1       dsieger  1081: 
1.12      weinem   1082: Install pkgtools/lintpkgsrc and run lintpkgsrc with the "-i" argument to check
1.202     nia      1083: if any packages are stale, e.g.
1.1       dsieger  1084: 
                   1085: % lintpkgsrc -i
                   1086: ...
                   1087: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
                   1088: 
                   1089: 
1.202     nia      1090: 5.1.8. Other administrative functions
1.1       dsieger  1091: 
                   1092: The pkg_admin executes various administrative functions on the package system.
                   1093: 
1.154     rillig   1094: 5.2. Building packages from source
1.1       dsieger  1095: 
                   1096: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25      wiz      1097: organized into categories. You can browse the online index of packages, or run 
1.1       dsieger  1098: make readme from the pkgsrc directory to build local README.html files for all
                   1099: packages, viewable with any web browser such as www/lynx or www/firefox.
                   1100: 
                   1101: The default prefix for installed packages is /usr/pkg. If you wish to change
                   1102: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
                   1103: use multiple different LOCALBASE definitions on the same system (inside a
                   1104: chroot is an exception).
                   1105: 
                   1106: The rest of this chapter assumes that the package is already in pkgsrc. If it
                   1107: is not, see Part II, "The pkgsrc developer's guide" for instructions how to
                   1108: create your own packages.
                   1109: 
1.154     rillig   1110: 5.2.1. Requirements
1.1       dsieger  1111: 
                   1112: To build packages from source, you need a working C compiler. On NetBSD, you
                   1113: need to install the "comp" and the "text" distribution sets. If you want to
                   1114: build X11-related packages, the "xbase" and "xcomp" distribution sets are
                   1115: required, too.
                   1116: 
1.154     rillig   1117: 5.2.2. Fetching distfiles
1.1       dsieger  1118: 
                   1119: The first step for building a package is downloading the distfiles (i.e. the
                   1120: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
                   1121: them automatically.
                   1122: 
                   1123: If you have all files that you need in the distfiles directory, you don't need
                   1124: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
                   1125: and add:
                   1126: 
                   1127: DISTDIR=/cdrom/pkgsrc/distfiles
                   1128: 
                   1129: to your mk.conf.
                   1130: 
                   1131: By default a list of distribution sites will be randomly intermixed to prevent
                   1132: huge load on servers which holding popular packages (for example,
                   1133: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
                   1134: distfile all the mirrors will be tried in new (random) order. You can turn this
                   1135: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
                   1136: disabled).
                   1137: 
                   1138: You can overwrite some of the major distribution sites to fit to sites that are
                   1139: close to your own. By setting one or two variables you can modify the order in
                   1140: which the master sites are accessed. MASTER_SORT contains a whitespace
                   1141: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
                   1142: contains a whitespace delimited list of regular expressions. It has higher
                   1143: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
                   1144: some examples. This may save some of your bandwidth and time.
                   1145: 
                   1146: You can change these settings either in your shell's environment, or, if you
1.4       rillig   1147: want to keep the settings, by editing the mk.conf file, and adding the
1.1       dsieger  1148: definitions there.
                   1149: 
1.132     wiz      1150: If a package depends on many other packages (such as meta-pkgs/kde4), the build
1.1       dsieger  1151: process may alternate between periods of downloading source, and compiling. To
                   1152: ensure you have all the source downloaded initially you can run the command:
                   1153: 
                   1154: % make fetch-list | sh
                   1155: 
                   1156: which will output and run a set of shell commands to fetch the necessary files
                   1157: into the distfiles directory. You can also choose to download the files
                   1158: manually.
                   1159: 
1.154     rillig   1160: 5.2.3. How to build and install
1.1       dsieger  1161: 
                   1162: Once the software has downloaded, any patches will be applied, then it will be
                   1163: compiled for you. This may take some time depending on your computer, and how
                   1164: many other packages the software depends on and their compile time.
                   1165: 
                   1166: Note
                   1167: 
                   1168: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
                   1169: command instead of "make" in the examples in this guide.
                   1170: 
                   1171: For example, type
                   1172: 
                   1173: % cd misc/figlet
                   1174: % make
                   1175: 
                   1176: 
                   1177: at the shell prompt to build the various components of the package.
                   1178: 
                   1179: The next stage is to actually install the newly compiled program onto your
                   1180: system. Do this by entering:
                   1181: 
                   1182: % make install
                   1183: 
                   1184: 
                   1185: while you are still in the directory for whatever package you are installing.
                   1186: 
                   1187: Installing the package on your system may require you to be root. However,
                   1188: pkgsrc has a just-in-time-su feature, which allows you to only become root for
                   1189: the actual installation step.
                   1190: 
                   1191: That's it, the software should now be installed and setup for use. You can now
                   1192: enter:
                   1193: 
                   1194: % make clean
                   1195: 
                   1196: 
                   1197: to remove the compiled files in the work directory, as you shouldn't need them
                   1198: any more. If other packages were also added to your system (dependencies) to
                   1199: allow your program to compile, you can tidy these up also with the command:
                   1200: 
                   1201: % make clean-depends
                   1202: 
                   1203: 
                   1204: Taking the figlet utility as an example, we can install it on our system by
1.207     leot     1205: building as shown in Appendix C, Build logs.
1.1       dsieger  1206: 
                   1207: The program is installed under the default root of the packages tree - /usr/
                   1208: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
                   1209: environment, and it will use that value as the root of your packages tree. So,
                   1210: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
                   1211: that you should use a directory which is dedicated to packages and not shared
                   1212: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
                   1213: not try to add any of your own files or directories (such as src/, obj/, or
                   1214: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
                   1215: between programs and other files installed by the package system and whatever
                   1216: else may have been installed there.
                   1217: 
1.4       rillig   1218: Some packages look in mk.conf to alter some configuration options at build
1.1       dsieger  1219: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
                   1220: be set there by default. Environment variables such as LOCALBASE can be set in
1.4       rillig   1221: mk.conf to save having to remember to set them each time you want to use
1.1       dsieger  1222: pkgsrc.
                   1223: 
                   1224: Occasionally, people want to "look under the covers" to see what is going on
                   1225: when a package is building or being installed. This may be for debugging
                   1226: purposes, or out of simple curiosity. A number of utility values have been
                   1227: added to help with this.
                   1228: 
                   1229:  1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
                   1230:     amount of information will be displayed. For example,
                   1231: 
                   1232:     make patch PKG_DEBUG_LEVEL=2
                   1233: 
1.25      wiz      1234:     will show all the commands that are invoked, up to and including the "patch
                   1235:     " stage.
1.1       dsieger  1236: 
                   1237:  2. If you want to know the value of a certain make(1) definition, then the
                   1238:     VARNAME definition should be used, in conjunction with the show-var target.
                   1239:     e.g. to show the expansion of the make(1) variable LOCALBASE:
                   1240: 
                   1241:     % make show-var VARNAME=LOCALBASE
                   1242:     /usr/pkg
                   1243:     %
                   1244: 
                   1245: 
                   1246: If you want to install a binary package that you've either created yourself
                   1247: (see next section), that you put into pkgsrc/packages manually or that is
                   1248: located on a remote FTP server, you can use the "bin-install" target. This
                   1249: target will install a binary package - if available - via pkg_add(1), else do a
                   1250: make package. The list of remote FTP sites searched is kept in the variable
                   1251: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
                   1252: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
                   1253: for more details.
                   1254: 
                   1255: A final word of warning: If you set up a system that has a non-standard setting
                   1256: for LOCALBASE, be sure to set that before any packages are installed, as you
                   1257: cannot use several directories for the same purpose. Doing so will result in
                   1258: pkgsrc not being able to properly detect your installed packages, and fail
                   1259: miserably. Note also that precompiled binary packages are usually built with
                   1260: the default LOCALBASE of /usr/pkg, and that you should not install any if you
                   1261: use a non-standard LOCALBASE.
                   1262: 
1.154     rillig   1263: Chapter 6. Configuring pkgsrc
1.1       dsieger  1264: 
                   1265: Table of Contents
                   1266: 
1.154     rillig   1267: 6.1. General configuration
                   1268: 6.2. Variables affecting the build process
1.241     rillig   1269: 6.3. Preferences for native or pkgsrc software
                   1270: 6.4. Variables affecting the installation process
                   1271: 6.5. Selecting and configuring the compiler
                   1272:     6.5.1. Selecting the compiler
                   1273:     6.5.2. Additional flags to the compiler (CFLAGS)
                   1274:     6.5.3. Additional flags to the linker (LDFLAGS)
                   1275: 6.6. Developer/advanced settings
                   1276: 6.7. Selecting Build Options
1.1       dsieger  1277: 
                   1278: The whole pkgsrc system is configured in a single file, usually called mk.conf.
                   1279: In which directory pkgsrc looks for that file depends on the installation. On
                   1280: NetBSD, when you use make(1) from the base system, it is in the directory /etc
                   1281: /. In all other cases the default location is ${PREFIX}/etc/, depending on
                   1282: where you told the bootstrap program to install the binary packages.
                   1283: 
                   1284: The format of the configuration file is that of the usual BSD-style Makefiles.
                   1285: The whole pkgsrc configuration is done by setting variables in this file. Note
                   1286: that you can define all kinds of variables, and no special error checking (for
1.112     rillig   1287: example for spelling mistakes) takes place.
1.1       dsieger  1288: 
1.154     rillig   1289: 6.1. General configuration
1.1       dsieger  1290: 
1.112     rillig   1291: The following variables apply to all pkgsrc packages. A complete list of the
                   1292: variables that can be configured by the user is available in mk/defaults/
                   1293: mk.conf, together with some comments that describe each variable's intent.
1.1       dsieger  1294: 
                   1295:   * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
                   1296:     not mix binary packages with different LOCALBASEs!
                   1297: 
                   1298:   * CROSSBASE: Where "cross" category packages will be installed. The default
                   1299:     is ${LOCALBASE}/cross.
                   1300: 
1.84      wiz      1301:   * X11BASE: Where X11 is installed on the system. The default is /usr/X11R7.
1.1       dsieger  1302: 
                   1303:   * DISTDIR: Where to store the downloaded copies of the original source
                   1304:     distributions used for building pkgsrc packages. The default is $
                   1305:     {PKGSRCDIR}/distfiles.
                   1306: 
                   1307:   * PKG_DBDIR: Where the database about installed packages is stored. The
1.118     sevan    1308:     default is /usr/pkg/pkgdb.
1.1       dsieger  1309: 
                   1310:   * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
                   1311:     value.
                   1312: 
                   1313:   * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
                   1314:     files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.118     sevan    1315:     respectively. The defaults is ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1.1       dsieger  1316:     {DIST_SUBDIR}/.
                   1317: 
                   1318:   * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
                   1319:     with OS release ("2.0", etc.) and architecture ("mipsel", etc.).
                   1320: 
1.23      jakllsch 1321:   * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
                   1322:     case-sensitive. Whenever you try to build a package whose license is not in
                   1323:     this list, you will get an error message. If the license condition is
                   1324:     simple enough, the error message will include specific instructions on how
                   1325:     to change this variable.
1.1       dsieger  1326: 
1.154     rillig   1327: 6.2. Variables affecting the build process
1.1       dsieger  1328: 
                   1329:   * PACKAGES: The top level directory for the binary packages. The default is $
                   1330:     {PKGSRCDIR}/packages.
                   1331: 
                   1332:   * WRKOBJDIR: The top level directory where, if defined, the separate working
                   1333:     directories will get created, and symbolically linked to from ${WRKDIR}
                   1334:     (see below). This is useful for building packages on several architectures,
                   1335:     then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
                   1336:     architecture. (It should be noted that PKGSRCDIR should not be set by the
1.198     leot     1337:     user -- it is an internal definition which refers to the root of the pkgsrc
1.1       dsieger  1338:     tree. It is possible to have many pkgsrc tree instances.)
                   1339: 
                   1340:   * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.184     rillig   1341:     Section 12.3, "patches/*" for more information.
1.1       dsieger  1342: 
                   1343:   * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
                   1344:     Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
                   1345:     up settings used by builds in /usr/src.
                   1346: 
1.241     rillig   1347: 6.3. Preferences for native or pkgsrc software
                   1348: 
                   1349: Whenever a package depends on a package that has a builtin.mk file, the
                   1350: dependent package can either use the built-in (native) version from the base
                   1351: system or the pkgsrc-provided version. This only affects dependencies, so it is
                   1352: still possible to build the pkgsrc package devel/pcre++ even when other
                   1353: packages depend on the native pcre++ version instead.
                   1354: 
                   1355: To force using the pkgsrc-provided version for a particular package, define "
                   1356: PREFER_PKGSRC = package-ID" in mk.conf. To force using the native package,
                   1357: define "PREFER_NATIVE = package-ID". In both cases, the package-ID is the one
                   1358: from the buildlink3.mk of the package. In most cases, this ID is the same as
                   1359: the directory name of the package, but for example, devel/pcre++ has the
                   1360: package ID "pcrexx".
                   1361: 
                   1362: For the packages that are not listed by their package ID, pkgsrc uses the
                   1363: pkgsrc-provided version if PREFER_PKGSRC contains the word "yes". Otherwise, if
                   1364: PREFER_NATIVE contains the word "yes", pkgsrc uses the native version. For
                   1365: example, to require using the pkgsrc-provided versions for all but the most
                   1366: basic bits on a NetBSD system, you can set:
                   1367: 
                   1368: PREFER_PKGSRC=  yes
                   1369: PREFER_NATIVE=  getopt skey tcp_wrappers
                   1370: 
                   1371: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
                   1372: it is simply ignored in that list.
                   1373: 
                   1374: PREFER_PKGSRC and PREFER_NATIVE should be set during bootstrap to ensure that
                   1375: the bootstrap process does not use inapropriate native tools as dependencies
                   1376: for core packages.
                   1377: 
                   1378: # ./bootstrap --prefer-pkgsrc yes --prefer-native openssl
                   1379: 
                   1380: Switching between settings globally at a later date can introduce complications
                   1381: with dependency resolution. This is caused by packages built with the opposite
                   1382: preference being installed alongside each other. Hence, when changing any of
                   1383: these variables after bootstrap, you need to rebuild all packages depending on
                   1384: those whose preference has been changed. This is not trivial and should be
                   1385: avoided.
                   1386: 
                   1387: When using pkgsrc on Linux systems, there is high risk of "leakage", where
                   1388: programs installed by pkgsrc may inadvertently use a command or library not
                   1389: installed by pkgsrc, e.g. those installed by yum or apt. Such foreign
                   1390: dependencies may be installed, removed, or upgraded to a version incompatible
                   1391: with the pkgsrc package at any time, causing pkgsrc packages to subsequently
                   1392: malfunction. Pkgsrc cannot prevent this, as it has no control over other
                   1393: package managers. Another potential problem is that under Redhat Enterprise and
                   1394: related Linux systems, yum packages are only patched and never upgraded, so
                   1395: eventually they may become too outdated for use by pkgsrc. Even intentionally
                   1396: using foreign dependencies, not considered leakage, can lead to these problems,
                   1397: so it is generally discouraged. In order to minimize such problems,
                   1398: PREFER_PKGSRC defaults to "yes" on Linux systems. This ensures that pkgsrc is
                   1399: aware of any changes to dependency packages and can rebuild or upgrade the
                   1400: entire dependency tree as needed. This default can be overridden by setting
                   1401: --prefer-pkgsrc to a list of packages and --prefer-native to "yes".
                   1402: 
                   1403: 6.4. Variables affecting the installation process
1.1       dsieger  1404: 
1.198     leot     1405:   * PKGSRC_KEEP_BIN_PKGS: By default, binary packages of built packages are
1.150     leot     1406:     preserved in ${PACKAGES}/All. Setting this variable to "no" prevents this.
1.1       dsieger  1407: 
1.107     jnemeth  1408: Packages have to support installation into a subdirectory of WRKDIR. This
                   1409: allows a package to be built, before the actual filesystem is touched. DESTDIR
                   1410: support exists in two variations:
1.4       rillig   1411: 
                   1412:   * Basic DESTDIR support means that the package installation and packaging is
                   1413:     still run as root.
                   1414: 
                   1415:   * Full DESTDIR support can run the complete build, installation and packaging
                   1416:     as normal user. Root privileges are only needed to add packages.
                   1417: 
                   1418: With basic DESTDIR support, make clean needs to be run as root.
                   1419: 
1.17      imil     1420: Considering the foo/bar package, DESTDIR full support can be tested using the
                   1421: following commands
                   1422: 
                   1423: $ id
                   1424: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
                   1425: $ mkdir $HOME/packages
                   1426: $ cd $PKGSRCDIR/foo/bar
                   1427: 
                   1428: Verify DESTDIR full support, no root privileges should be needed
                   1429: 
1.66      asau     1430: $ make stage-install
1.17      imil     1431: 
                   1432: Create a package without root privileges
                   1433: 
1.66      asau     1434: $ make PACKAGES=$HOME/packages package
1.17      imil     1435: 
                   1436: For the following command, you must be able to gain root privileges using su(1)
                   1437: 
1.66      asau     1438: $ make PACKAGES=$HOME/packages install
1.17      imil     1439: 
                   1440: Then, as a simple user
                   1441: 
                   1442: $ make clean
                   1443: 
1.241     rillig   1444: 6.5. Selecting and configuring the compiler
1.4       rillig   1445: 
1.241     rillig   1446: 6.5.1. Selecting the compiler
1.1       dsieger  1447: 
                   1448: By default, pkgsrc will use GCC to build packages. This may be overridden by
                   1449: setting the following variables in /etc/mk.conf:
                   1450: 
                   1451: PKGSRC_COMPILER:
                   1452: 
                   1453:     This is a list of values specifying the chain of compilers to invoke when
                   1454:     building packages. Valid values are:
                   1455: 
1.232     gutterid 1456:       o ccc: Compaq C Compilers (Tru64)
1.66      asau     1457: 
1.232     gutterid 1458:       o ccache: compiler cache (chainable)
1.66      asau     1459: 
1.232     gutterid 1460:       o clang: Clang C and Objective-C compiler
1.66      asau     1461: 
1.232     gutterid 1462:       o distcc: distributed C/C++ (chainable)
1.1       dsieger  1463: 
1.232     gutterid 1464:       o f2c: Fortran 77 to C compiler (chainable)
1.66      asau     1465: 
1.232     gutterid 1466:       o icc: Intel C++ Compiler (Linux)
1.66      asau     1467: 
1.232     gutterid 1468:       o ido: SGI IRIS Development Option cc (IRIX 5)
1.1       dsieger  1469: 
1.232     gutterid 1470:       o gcc: GNU C/C++ Compiler
1.1       dsieger  1471: 
1.232     gutterid 1472:       o hp: HP-UX C/aC++ compilers
1.66      asau     1473: 
1.232     gutterid 1474:       o mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1       dsieger  1475: 
1.232     gutterid 1476:       o mipspro-ucode: Silicon Graphics, Inc. MIPSpro (o32)
1.1       dsieger  1477: 
1.232     gutterid 1478:       o sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1       dsieger  1479: 
1.232     gutterid 1480:       o xlc: IBM's XL C/C++ compiler suite
1.66      asau     1481: 
1.1       dsieger  1482:     The default is "gcc". You can use ccache and/or distcc with an appropriate
                   1483:     PKGSRC_COMPILER setting, e.g. "ccache gcc". This variable should always be
                   1484:     terminated with a value for a real compiler. Note that only one real
                   1485:     compiler should be listed (e.g. "sunpro gcc" is not allowed).
                   1486: 
                   1487: GCC_REQD:
                   1488: 
                   1489:     This specifies the minimum version of GCC to use when building packages. If
                   1490:     the system GCC doesn't satisfy this requirement, then pkgsrc will build and
                   1491:     install one of the GCC packages to use instead.
                   1492: 
1.153     leot     1493: PYTHON_VERSION_DEFAULT:
1.114     maya     1494: 
                   1495:     Specifies which version of python to use when several options are
                   1496:     available.
                   1497: 
                   1498: PKGSRC_FORTRAN:
                   1499: 
1.176     gutterid 1500:     Specifies the Fortran compiler to use. The default is gfortran.
1.114     maya     1501: 
                   1502: GFORTRAN_VERSION:
                   1503: 
                   1504:     If PKGSRC_FORTRAN= gfortran is used, this option specifies which version to
                   1505:     use.
                   1506: 
1.241     rillig   1507: 6.5.2. Additional flags to the compiler (CFLAGS)
1.1       dsieger  1508: 
                   1509: If you wish to set the CFLAGS variable, please make sure to use the += operator
                   1510: instead of the = operator:
                   1511: 
                   1512: CFLAGS+=        -your -flags
                   1513: 
                   1514: Using CFLAGS= (i.e. without the "+") may lead to problems with packages that
1.16      jnemeth  1515: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24      wiz      1516: package if you're interested in optimization specifically for the current CPU.
1.1       dsieger  1517: 
1.241     rillig   1518: 6.5.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger  1519: 
                   1520: If you want to pass flags to the linker, both in the configure step and the
                   1521: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
                   1522: difference between the two is that LIBS will be appended to the command line,
                   1523: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
                   1524: machines depending on the setting of USE_IMAKE or the inclusion of mk/
                   1525: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
                   1526: settings, use the += operator:
                   1527: 
                   1528: LDFLAGS+=        -your -linkerflags
                   1529: 
1.241     rillig   1530: 6.6. Developer/advanced settings
1.1       dsieger  1531: 
                   1532:   * PKG_DEVELOPER: Run some sanity checks that package developers want:
                   1533: 
1.42      asau     1534:       + make sure patches apply with zero fuzz
1.1       dsieger  1535: 
1.42      asau     1536:       + run check-shlibs to see that all binaries will find their shared libs.
1.1       dsieger  1537: 
1.232     gutterid 1538:   * CHECK_FILES_STRICT: Also check VARBASE and PKG_SYSCONFDIR values in PLIST
                   1539:     entries.
                   1540: 
1.1       dsieger  1541:   * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
                   1542:     making and installing the package. The default value for this is 0, which
                   1543:     will not display the commands as they are executed (normal, default, quiet
                   1544:     operation); the value 1 will display all shell commands before their
                   1545:     invocation, and the value 2 will display both the shell commands before
1.112     rillig   1546:     their invocation, as well as their actual execution progress with set -x.
1.1       dsieger  1547: 
1.241     rillig   1548: 6.7. Selecting Build Options
1.1       dsieger  1549: 
                   1550: Some packages have build time options, usually to select between different
                   1551: dependencies, enable optional support for big dependencies or enable
                   1552: experimental features.
                   1553: 
                   1554: To see which options, if any, a package supports, and which options are
                   1555: mutually exclusive, run make show-options, for example:
                   1556: 
                   1557:     The following options are supported by this package:
                   1558:         ssl      Enable SSL support.
                   1559:     Exactly one of the following gecko options is required:
                   1560:         firefox  Use firefox as gecko rendering engine.
                   1561:         mozilla  Use mozilla as gecko rendering engine.
                   1562:     At most one of the following database options may be selected:
                   1563:         mysql    Enable support for MySQL database.
                   1564:         pgsql    Enable support for PostgreSQL database.
                   1565: 
                   1566:     These options are enabled by default: firefox
                   1567:     These options are currently enabled: mozilla ssl
                   1568: 
1.4       rillig   1569: The following variables can be defined in mk.conf to select which options to
                   1570: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1       dsieger  1571: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
                   1572: which can be used to select or disable options specifically for package pkgbase
                   1573: . Options listed in these variables are selected, options preceded by "-" are
                   1574: disabled. A few examples:
                   1575: 
1.4       rillig   1576: $ grep "PKG.*OPTION" mk.conf
1.1       dsieger  1577: PKG_DEFAULT_OPTIONS=    -arts -dvdread -esound
                   1578: PKG_OPTIONS.kdebase=    debug -sasl
                   1579: PKG_OPTIONS.apache=     suexec
                   1580: 
1.11      rillig   1581: It is important to note that options that were specifically suggested by the
1.19      snj      1582: package maintainer must be explicitly removed if you do not wish to include the
                   1583: option. If you are unsure you can view the current state with make show-options
                   1584: .
1.11      rillig   1585: 
1.1       dsieger  1586: The following settings are consulted in the order given, and the last setting
                   1587: that selects or disables an option is used:
                   1588: 
                   1589:  1. the default options as suggested by the package maintainer
                   1590: 
                   1591:  2. the options implied by the settings of legacy variables (see below)
                   1592: 
                   1593:  3. PKG_DEFAULT_OPTIONS
                   1594: 
                   1595:  4. PKG_OPTIONS.pkgbase
                   1596: 
                   1597: For groups of mutually exclusive options, the last option selected is used, all
                   1598: others are automatically disabled. If an option of the group is explicitly
                   1599: disabled, the previously selected option, if any, is used. It is an error if no
                   1600: option from a required group of options is selected, and building the package
                   1601: will fail.
                   1602: 
                   1603: Before the options framework was introduced, build options were selected by
1.4       rillig   1604: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
                   1605: transition to the options framework for the user, these legacy variables are
                   1606: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
                   1607: automatically. A warning is issued to prompt the user to update mk.conf to use
                   1608: the options framework directly. Support for the legacy variables will be
1.1       dsieger  1609: removed eventually.
                   1610: 
1.154     rillig   1611: Chapter 7. Creating binary packages
1.1       dsieger  1612: 
                   1613: Table of Contents
                   1614: 
1.154     rillig   1615: 7.1. Building a single binary package
                   1616: 7.2. Settings for creation of binary packages
1.1       dsieger  1617: 
1.154     rillig   1618: 7.1. Building a single binary package
1.1       dsieger  1619: 
                   1620: Once you have built and installed a package, you can create a binary package
                   1621: which can be installed on another system with pkg_add(1). This saves having to
                   1622: build the same package on a group of hosts and wasting CPU time. It also
                   1623: provides a simple means for others to install your package, should you
                   1624: distribute it.
                   1625: 
                   1626: To create a binary package, change into the appropriate directory in pkgsrc,
                   1627: and run make package:
                   1628: 
1.112     rillig   1629: $ cd misc/figlet
                   1630: $ make package
1.1       dsieger  1631: 
1.242     gutterid 1632: This will build your package (if not already done) and package it into a binary
                   1633: package. You can then use the pkg_* tools to manipulate it. Binary packages are
                   1634: created in PACKAGES, which defaults to /usr/pkgsrc/packages, in the form of a
                   1635: compressed tar file. See Section C.2, "Packaging figlet" for a continuation of
                   1636: the above misc/figlet example.
1.1       dsieger  1637: 
1.154     rillig   1638: See Chapter 23, Submitting and Committing for information on how to submit such
1.1       dsieger  1639: a binary package.
                   1640: 
1.154     rillig   1641: 7.2. Settings for creation of binary packages
1.1       dsieger  1642: 
1.184     rillig   1643: See Section 13.17, "Other helpful targets".
1.6       rillig   1644: 
1.154     rillig   1645: Chapter 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig   1646: 
                   1647: Table of Contents
                   1648: 
1.154     rillig   1649: 8.1. Preparations
1.180     rillig   1650: 8.2. Running a bulk build
1.154     rillig   1651:     8.2.1. Configuration
                   1652: 8.3. Requirements of a full bulk build
1.178     rillig   1653: 8.4. Bulk build variants
1.179     rillig   1654:     8.4.1. Detect unknown configure options
                   1655:     8.4.2. Detect classes of bugs by forcing compiler warnings
1.181     rillig   1656:     8.4.3. Force compiler options only in the build phase
                   1657:     8.4.4. Use custom directories
                   1658:     8.4.5. Turn warnings into errors
                   1659:     8.4.6. Reject packages for which pkglint reports errors
                   1660:     8.4.7. Reject packages that contain forbidden strings
                   1661:     8.4.8. Reject packages whose self-test fails
                   1662:     8.4.9. Reject packages that use undefined shell variables
                   1663:     8.4.10. Turn off verbose logging
1.178     rillig   1664: 8.5. Creating a multiple CD-ROM packages collection
                   1665:     8.5.1. Example of cdpack
1.6       rillig   1666: 
1.175     gutterid 1667: For a number of reasons, you may want to build binary packages for a large
                   1668: selected set of packages in pkgsrc, or even for all pkgsrc packages. For
1.71      wiz      1669: instance, when you have multiple machines that should run the same software, it
                   1670: is wasted time if they all build their packages themselves from source. Or you
                   1671: may want to build a list of packages you want and check them before deploying
1.175     gutterid 1672: onto production systems. There is a way of getting a set of binary packages:
                   1673: the bulk build system, or pbulk ("p" stands for "parallel"). This chapter
                   1674: describes how to set it up.
1.71      wiz      1675: 
1.154     rillig   1676: 8.1. Preparations
1.71      wiz      1677: 
                   1678: First of all, you have to decide whether you build all packages or a limited
                   1679: set of them. Full bulk builds usually consume a lot more resources, both space
1.175     gutterid 1680: and time, than builds for some practical sets of packages. A number of
                   1681: particularly heavy packages exist that are not actually interesting to a wide
                   1682: audience. (The approximate resource consumption for a full bulk build is given
                   1683: in section Section 8.3, "Requirements of a full bulk build".) For limited bulk
                   1684: builds you need to make a list of packages you want to build. Note that all
                   1685: their dependencies will be built, so you don't need to track them manually.
1.71      wiz      1686: 
                   1687: During bulk builds various packages are installed and deinstalled in /usr/pkg
                   1688: (or whatever LOCALBASE is), so make sure that you don't need any package during
1.112     rillig   1689: the builds. Essentially, you should provide a fresh system, either a chroot
1.71      wiz      1690: environment or something even more restrictive, depending on what the operating
                   1691: system provides, or dedicate the whole physical machine. As a useful side
                   1692: effect this makes sure that bulk builds cannot break anything in your system.
                   1693: There have been numerous cases where certain packages tried to install files
                   1694: outside the LOCALBASE or wanted to edit some files in /etc.
1.6       rillig   1695: 
1.180     rillig   1696: 8.2. Running a bulk build
1.6       rillig   1697: 
1.180     rillig   1698: Running a bulk build works roughly as follows:
1.15      rillig   1699: 
                   1700:   * First, build the pbulk infrastructure in a fresh pkgsrc location.
                   1701: 
                   1702:   * Then, build each of the packages from a clean installation directory using
                   1703:     the infrastructure.
                   1704: 
1.154     rillig   1705: 8.2.1. Configuration
1.6       rillig   1706: 
1.112     rillig   1707: To simplify configuration, we provide the helper script mk/pbulk/pbulk.sh.
1.6       rillig   1708: 
1.68      asau     1709: In order to use it, prepare a clear system (real one, chroot environment, jail,
                   1710: zone, virtual machine). Configure network access to fetch distribution files.
1.112     rillig   1711: Create a user with name "pbulk".
1.68      asau     1712: 
                   1713: Fetch and extract pkgsrc. Use a command like one of these:
                   1714: 
1.151     sevan    1715: # (cd /usr && ftp -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
                   1716: # (cd /usr && fetch -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1.72      wiz      1717: # (cd /usr && cvs -Q -z3 -d anoncvs@anoncvs.NetBSD.org:/cvsroot get -P pkgsrc)
1.68      asau     1718: 
                   1719: Or any other way that fits (e.g., curl, wget).
                   1720: 
                   1721: Deploy and configure pbulk tools, e.g.:
                   1722: 
1.118     sevan    1723: # sh pbulk.sh -n # use native make, no bootstrap kit needed (for use on NetBSD)
1.68      asau     1724: # sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment
                   1725: # sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build
                   1726: 
                   1727: Note
                   1728: 
                   1729: mk.conf.frag is a fragment of mk.conf that contains settings you want to apply
                   1730: to packages you build. For instance,
                   1731: 
1.112     rillig   1732: PKG_DEVELOPER=          yes     # perform more checks
                   1733: X11_TYPE=               modular # use pkgsrc X11
                   1734: SKIP_LICENSE_CHECK=     yes     # accept all licences (useful
                   1735:                                 # when building all packages)
1.68      asau     1736: 
                   1737: If configured for limited list, replace the list in /usr/pbulk/etc/pbulk.list
1.112     rillig   1738: with your list of packages, one per line without empty lines or comments. E.g.:
1.68      asau     1739: 
                   1740: www/firefox
                   1741: mail/thunderbird
                   1742: misc/libreoffice4
                   1743: 
1.69      asau     1744: At this point you can also review configuration in /usr/pbulk/etc and make
                   1745: final amendments, if wanted.
                   1746: 
1.68      asau     1747: Start it:
                   1748: 
                   1749: # /usr/pbulk/bin/bulkbuild
                   1750: 
                   1751: After it finishes, you'll have /mnt filled with distribution files, binary
                   1752: packages, and reports, plain text summary in /mnt/bulklog/meta/report.txt
                   1753: 
                   1754: Note
                   1755: 
                   1756: The pbulk.sh script does not cover all possible use cases. While being ready to
                   1757: run, it serves as a good starting point to understand and build more complex
                   1758: setups. The script is kept small enough for better understanding.
                   1759: 
                   1760: Note
                   1761: 
                   1762: The pbulk.sh script supports running unprivileged bulk build and helps
1.205     wiz      1763: configuring distributed bulk builds. Distributed bulk builds support either
                   1764: building in worker chroots (each node is a path to a different chroot) that
                   1765: replicate the target system, including the pbulk prefix, or remote machines
                   1766: (each node is an IP address that must be accessible over SSH without a
                   1767: password).
1.15      rillig   1768: 
1.154     rillig   1769: 8.3. Requirements of a full bulk build
1.71      wiz      1770: 
                   1771: A complete bulk build requires lots of disk space. Some of the disk space can
                   1772: be read-only, some other must be writable. Some can be on remote filesystems
                   1773: (such as NFS) and some should be local. Some can be temporary filesystems,
                   1774: others must survive a sudden reboot.
                   1775: 
1.205     wiz      1776:   * 70 GB for the distfiles (read-write, remote, temporary)
1.71      wiz      1777: 
1.205     wiz      1778:   * 60 GB for the binary packages (read-write, remote, permanent)
1.71      wiz      1779: 
                   1780:   * 1 GB for the pkgsrc tree (read-only, remote, permanent)
                   1781: 
                   1782:   * 5 GB for LOCALBASE (read-write, local, temporary)
                   1783: 
                   1784:   * 10 GB for the log files (read-write, remote, permanent)
                   1785: 
                   1786:   * 5 GB for temporary files (read-write, local, temporary)
                   1787: 
1.178     rillig   1788: 8.4. Bulk build variants
                   1789: 
                   1790: To ensure that pkgsrc packages work in different configurations, it makes sense
                   1791: to run non-default bulk builds from time to time. This section lists some ideas
                   1792: for bulk builds that intentionally let packages fail if they don't follow the
                   1793: pkgsrc style.
                   1794: 
1.179     rillig   1795: 8.4.1. Detect unknown configure options
1.178     rillig   1796: 
                   1797: Add the following line to mk.conf.
                   1798: 
                   1799: GNU_CONFIGURE_STRICT=   yes
                   1800: 
                   1801: When a package fails this additional check, the most common cause is that the
                   1802: configure option was valid for an older version of the package but does not
                   1803: apply anymore. In that case, just remove it.
                   1804: 
1.179     rillig   1805: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.178     rillig   1806: 
                   1807: The job of a compiler is not restricted to producing executable code, most
1.179     rillig   1808: compilers also detect typical programming mistakes. The pkgsrc compiler
                   1809: wrappers make it easy to force compiler options when the package is built. This
                   1810: can be used to find typical bugs across all packages that are in pkgsrc. By
                   1811: reporting these bugs upstream, the packages will be more reliable with the next
                   1812: updates.
1.178     rillig   1813: 
1.179     rillig   1814: Add some of the following lines to mk.conf:
1.178     rillig   1815: 
                   1816: CFLAGS+=        -Werror=char-subscripts
1.179     rillig   1817: CFLAGS+=        -Werror=implicit-function-declaration
1.178     rillig   1818: 
1.179     rillig   1819: When a package fails to build using these stricter compiler options, document
                   1820: the circumstances in which the compiler produced the error message. This
                   1821: includes:
1.178     rillig   1822: 
                   1823:   * The platform (MACHINE_PLATFORM)
                   1824: 
                   1825:   * The source file
                   1826: 
                   1827:   * An excerpt of the code. GCC and Clang already do this as part of the
                   1828:     diagnostic.
                   1829: 
1.179     rillig   1830:   * The exact error message from the compiler.
1.178     rillig   1831: 
1.179     rillig   1832: If a package produces these error messages, but the package is fine, record
                   1833: this in your local mk.conf, like this, to skip this check in the next builds:
1.178     rillig   1834: 
1.179     rillig   1835: .if ${PKGPATH} == category/package
1.178     rillig   1836: # Version ${VERSION} failed on ${MACHINE_PLATFORM}:
                   1837: # error message
                   1838: # code
1.179     rillig   1839: # Reason why the code does not need to be fixed.
1.178     rillig   1840: BUILDLINK_TRANSFORM+=   rm:-Werror=char-subscripts
1.179     rillig   1841: .endif
1.178     rillig   1842: 
                   1843: If the error messages from the compiler are valid and the code needs to be
1.179     rillig   1844: fixed, prepare a local patch (see LOCALPATCHES) and report the bug to the
                   1845: upstream authors of the package, providing them with the information you
                   1846: collected above.
1.178     rillig   1847: 
1.179     rillig   1848: Patches that are not essential for the package to work should only be reported
                   1849: upstream but not committed to pkgsrc, to make future updates easier.
                   1850: 
1.181     rillig   1851: 8.4.3. Force compiler options only in the build phase
                   1852: 
                   1853: When adding custom compiler flags via CFLAGS, these apply to all phases of the
                   1854: package build process. Especially in the configure phase, adding -Werror leads
                   1855: to wrong decisions. The GNU configure scripts feed many small test programs to
                   1856: the C compiler to see whether certain headers are available, functions are
                   1857: defined in a library and programs can be run. In many cases these programs
                   1858: would not survive a strict compiler run with -Wall -Wextra -Werror.
                   1859: 
                   1860: The pkgsrc infrastructure is flexible enough to support compiler options being
                   1861: added between the configure and build phases. It's a little more complicated
                   1862: than the other examples in this section but still easy enough.
                   1863: 
                   1864: The basic idea is to use the pkgsrc compiler wrapper to inject the desired
                   1865: compiler options. The compiler wrapper's original task is to hide unwanted
                   1866: directories of include files and to normalize compiler options. It does this by
                   1867: wrapping the compiler command and rewriting the command line. To see this in
                   1868: action, run bmake patch in a package directory and examine the work/.cwrappers/
                   1869: config directory. It contains individual configurations for the C compiler and
                   1870: the related tools. The plan is to find a hook between the configure and build
                   1871: phases, and to modify these configuration files at that point.
                   1872: 
                   1873: To find this hook, have a look at mk/build/build.mk, which contains among
                   1874: others the pre-build-checks-hook. The word checks doesn't quite fit, but the
                   1875: pre-build-hook sounds good enough.
                   1876: 
                   1877: The code to be included in mk.conf is:
                   1878: 
                   1879: # Just a few example options.
                   1880: BUILD_ONLY_CFLAGS=      -Wall -Werror -O2 -DTEMPDIR='"/tmp"'
                   1881: 
                   1882: .if ${BUILD_ONLY_CFLAGS:U:M*}
                   1883: pre-build-checks-hook: add-build-only-cflags
                   1884: 
                   1885: add-build-only-cflags: .PHONY
                   1886:         ${RUN} cd ${CWRAPPERS_CONFIG_DIR};      \
                   1887:         ${TEST} ! -f ${.TARGET} || exit 0;      \
                   1888:         for flag in ${BUILD_ONLY_CFLAGS}; do    \
                   1889:                 ${ECHO} "append=$$flag" >> cc;  \
                   1890:         done;                                   \
                   1891:         > ${.TARGET}
                   1892: .endif
                   1893: 
                   1894: (When editing the mk.conf, make sure that the commands of the
                   1895: add-build-only-cflags target are indented with a tab, not with spaces.)
                   1896: 
                   1897: The condition in the .if statement contains the :U modifier to prevent parse
                   1898: errors if the variable should be undefined, possibly because it is only defined
                   1899: for a subset of the packages. The :M* modifier ensures that there is at least
                   1900: one compiler option, to prevent a syntax error in the shell parser.
                   1901: 
                   1902: The code around the ${.TARGET} variable ensures that the additional compiler
                   1903: options are only appended once, even if bmake build is run multiple times. To
                   1904: do this, it creates a marker file.
                   1905: 
                   1906: To verify that this setup works, run bmake configure in a package directory. Up
                   1907: to now, everything works as usual. Examine the directory work/.cwrappers/config
                   1908: to see that the compiler options from BUILD_ONLY_CFLAGS are not yet added to
                   1909: the file cc. Examine the tail of the work/.work.log file to see that the normal
                   1910: compiler options are used.
                   1911: 
                   1912: Now run bmake build. This will append the options to the file cc and will
                   1913: create the marker file in the same directory. After that, the build starts as
                   1914: usual, but with the added compiler options. Examine the tail of the file work
                   1915: /.work.log to see that the lines starting with [*] don't contain the compiler
                   1916: options, but the corresponding lines starting with <.> do end with these
                   1917: options.
                   1918: 
                   1919: Building packages using this setup variant and fixing the resulting bugs is the
                   1920: same as in Section 8.4.2, "Detect classes of bugs by forcing compiler warnings"
                   1921: .
                   1922: 
                   1923: 8.4.4. Use custom directories
1.178     rillig   1924: 
                   1925: Some directories like PREFIX, VARBASE, PKG_SYSCONFDIR, PKGMANDIR, PKG_INFODIR
                   1926: can be configured in pkgsrc. Set these to arbitrary paths during bootstrap or
                   1927: afterwards in mk.conf.
                   1928: 
                   1929: PREFIX=         /a-random-uuid
                   1930: PKG_SYSCONFDIR= /a-random-uuid
                   1931: VARBASE=        /a-random-uuid
                   1932: PKGMANDIR=      a-random-uuid
                   1933: PKG_INFODIR=    a-random-uuid
                   1934: 
1.181     rillig   1935: 8.4.5. Turn warnings into errors
1.178     rillig   1936: 
                   1937: When building a package, warnings are typically ignored since they just flow by
                   1938: and do not cause the build to fail immediately. To find these warnings,
                   1939: redefine them to errors in mk.conf.
                   1940: 
                   1941: DELAYED_WARNING_MSG=    ${DELAYED_ERROR_MSG} "(was warning)"
                   1942: WARNING_MSG=            ${FAIL_MSG} "(was warning)"
                   1943: 
                   1944: (There are many more classes of warnings in pkgsrc, and most of them can be
                   1945: redefined with a simple definition like above.
                   1946: 
1.179     rillig   1947: If a package suggests to add USE_TOOLS+=perl to the package Makefile, research
1.178     rillig   1948: whether the package actually needs Perl. If it does, add USE_TOOLS+=perl to the
                   1949: package Makefile, and if it doesn't, add TOOLS_BROKEN+=perl.
                   1950: 
1.181     rillig   1951: 8.4.6. Reject packages for which pkglint reports errors
1.178     rillig   1952: 
                   1953: Using pkglint as part of the regular build process is mostly a waste of time.
                   1954: If you want to fix some of the warnings, just run pkglint recursively on the
                   1955: whole pkgsrc tree. This will take a few minutes (up to 10), which is much
                   1956: faster than a complete bulk build.
                   1957: 
1.181     rillig   1958: 8.4.7. Reject packages that contain forbidden strings
1.178     rillig   1959: 
                   1960: To ensure that the binary packages don't contain references to the build
                   1961: directory, there is already CHECK_WRKREF. If that variable includes the item
                   1962: extra, it is possible to define additional patterns that must not appear in any
                   1963: installed file. This is specified in mk.conf.
                   1964: 
                   1965: CHECK_WRKREF=                   extra
                   1966: CHECK_WRKREF_EXTRA_DIRS+=       /usr/local
                   1967: CHECK_WRKREF_EXTRA_DIRS+=       /usr/pkg
                   1968: CHECK_WRKREF_EXTRA_DIRS+=       @[A-Z][A-Z]*@
                   1969: 
                   1970: The above patterns will probably generate many false positives, therefore the
                   1971: results need to be taken with a grain of salt.
                   1972: 
1.181     rillig   1973: 8.4.8. Reject packages whose self-test fails
1.178     rillig   1974: 
                   1975: To run the test suites that come with each package, add this line to mk.conf.
                   1976: 
                   1977: PKGSRC_RUN_TEST=        yes
                   1978: 
                   1979: Be prepared that even the most basic packages fail this test. When doing a bulk
                   1980: build with this, it will often abort in the early phase where the packages are
                   1981: scanned for their dependencies since there are cyclic dependencies. There is
                   1982: still a lot to do in this area.
                   1983: 
1.181     rillig   1984: 8.4.9. Reject packages that use undefined shell variables
1.178     rillig   1985: 
                   1986: To catch typos in the shell snippets from the Makefile fragments, add the -u
                   1987: flag to most of the commands by adding this line to mk.conf.
                   1988: 
                   1989: RUN=    @set -eu;
                   1990: 
1.181     rillig   1991: After that, ensure that none of the bulk build log files (even those for
                   1992: successfully built packages) contains the string parameter not set or whatever
                   1993: error message the command sh -ceu '$undefined' outputs.
                   1994: 
1.178     rillig   1995: See mk/misc/common.mk for the existing definition.
                   1996: 
1.181     rillig   1997: 8.4.10. Turn off verbose logging
1.178     rillig   1998: 
                   1999: The build logs of a package are often quite long. This allows error messages or
                   2000: other interesting details to hide between the noise. To make the actual error
                   2001: message stand out more, add these lines to mk.conf.
                   2002: 
                   2003: GNU_CONFIGURE_QUIET=    yes
                   2004: MAKE_FLAGS+=            -s
                   2005: 
                   2006: The -s option works for both GNU Make and BSD Make. On exotic platforms with
                   2007: their own make, it may be a little different.
                   2008: 
                   2009: 8.5. Creating a multiple CD-ROM packages collection
1.1       dsieger  2010: 
                   2011: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
                   2012: of the resulting binary packages to assist in installing packages on other
                   2013: machines. The pkgtools/cdpack package provides a simple tool for creating the
                   2014: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
                   2015: keeps all the dependencies for a given package on the same CD as that package.
                   2016: 
1.178     rillig   2017: 8.5.1. Example of cdpack
1.1       dsieger  2018: 
                   2019: Complete documentation for cdpack is found in the cdpack(1) man page. The
                   2020: following short example assumes that the binary packages are left in /usr/
                   2021: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
                   2022: ISO 9660 images.
                   2023: 
                   2024: # mkdir /u2/images
                   2025: # pkg_add /usr/pkgsrc/packages/All/cdpack
                   2026: # cdpack /usr/pkgsrc/packages/All /u2/images
                   2027: 
                   2028: 
                   2029: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
                   2030: CD in the collection, then you need to create a directory which contains these
1.175     gutterid 2031: files, e.g.:
1.1       dsieger  2032: 
                   2033: # mkdir /tmp/common
                   2034: # echo "This is a README" > /tmp/common/README
                   2035: # echo "Another file" > /tmp/common/COPYING
                   2036: # mkdir /tmp/common/bin
                   2037: # echo "#!/bin/sh" > /tmp/common/bin/myscript
                   2038: # echo "echo Hello world" >> /tmp/common/bin/myscript
                   2039: # chmod 755 /tmp/common/bin/myscript
                   2040: 
                   2041: 
                   2042: Now create the images:
                   2043: 
                   2044: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
                   2045: 
                   2046: Each image will contain README, COPYING, and bin/myscript in their root
                   2047: directories.
                   2048: 
1.154     rillig   2049: Chapter 9. Directory layout of the installed files
1.1       dsieger  2050: 
                   2051: Table of Contents
                   2052: 
1.154     rillig   2053: 9.1. File system layout in ${LOCALBASE}
                   2054: 9.2. File system layout in ${VARBASE}
1.1       dsieger  2055: 
                   2056: The files that are installed by pkgsrc are organized in a way that is similar
                   2057: to what you find in the /usr directory of the base system. But some details are
                   2058: different. This is because pkgsrc initially came from FreeBSD and had adopted
                   2059: its file system hierarchy. Later it was largely influenced by NetBSD. But no
                   2060: matter which operating system you are using pkgsrc with, you can expect the
                   2061: same layout for pkgsrc.
                   2062: 
                   2063: There are mainly four root directories for pkgsrc, which are all configurable
                   2064: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
                   2065: default locations are:
                   2066: 
                   2067: LOCALBASE=              /usr/pkg
                   2068: PKG_SYSCONFBASE=        /usr/pkg/etc
                   2069: VARBASE=                /var
1.119     sevan    2070: PKG_DBDIR=              /usr/pkg/pkgdb
1.1       dsieger  2071: 
                   2072: In unprivileged mode (when pkgsrc has been installed as any other user), the
                   2073: default locations are:
                   2074: 
                   2075: LOCALBASE=              ${HOME}/pkg
                   2076: PKG_SYSCONFBASE=        ${HOME}/pkg/etc
                   2077: VARBASE=                ${HOME}/pkg/var
1.119     sevan    2078: PKG_DBDIR=              ${HOME}/pkg/pkgdb
1.1       dsieger  2079: 
                   2080: What these four directories are for, and what they look like is explained
                   2081: below.
                   2082: 
1.25      wiz      2083:   * LOCALBASE corresponds to the /usr directory in the base system. It is the "
                   2084:     main" directory where the files are installed and contains the well-known
1.1       dsieger  2085:     subdirectories like bin, include, lib, share and sbin.
                   2086: 
                   2087:   * VARBASE corresponds to /var in the base system. Some programs (especially
                   2088:     games, network daemons) need write access to it during normal operation.
                   2089: 
                   2090:   * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
                   2091:     configuration files of the packages, as well as pkgsrc's mk.conf itself.
                   2092: 
1.154     rillig   2093: 9.1. File system layout in ${LOCALBASE}
1.1       dsieger  2094: 
                   2095: The following directories exist in a typical pkgsrc installation in $
                   2096: {LOCALBASE}.
                   2097: 
                   2098: bin
                   2099: 
                   2100:     Contains executable programs that are intended to be directly used by the
                   2101:     end user.
                   2102: 
                   2103: emul
                   2104: 
                   2105:     Contains files for the emulation layers of various other operating systems,
                   2106:     especially for NetBSD.
                   2107: 
                   2108: etc (the usual location of ${PKG_SYSCONFDIR})
                   2109: 
                   2110:     Contains the configuration files.
                   2111: 
                   2112: include
                   2113: 
                   2114:     Contains headers for the C and C++ programming languages.
                   2115: 
                   2116: info
                   2117: 
                   2118:     Contains GNU info files of various packages.
                   2119: 
                   2120: lib
                   2121: 
                   2122:     Contains shared and static libraries.
                   2123: 
                   2124: libdata
                   2125: 
                   2126:     Contains data files that don't change after installation. Other data files
                   2127:     belong into ${VARBASE}.
                   2128: 
                   2129: libexec
                   2130: 
                   2131:     Contains programs that are not intended to be used by end users, such as
                   2132:     helper programs or network daemons.
                   2133: 
                   2134: libexec/cgi-bin
                   2135: 
                   2136:     Contains programs that are intended to be executed as CGI scripts by a web
                   2137:     server.
                   2138: 
                   2139: man (the usual value of ${PKGMANDIR})
                   2140: 
                   2141:     Contains brief documentation in form of manual pages.
                   2142: 
                   2143: sbin
                   2144: 
                   2145:     Contains programs that are intended to be used only by the super-user.
                   2146: 
                   2147: share
                   2148: 
                   2149:     Contains platform-independent data files that don't change after
                   2150:     installation.
                   2151: 
                   2152: share/doc
                   2153: 
                   2154:     Contains documentation files provided by the packages.
                   2155: 
                   2156: share/examples
                   2157: 
                   2158:     Contains example files provided by the packages. Among others, the original
                   2159:     configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
                   2160:     installation.
                   2161: 
                   2162: share/examples/rc.d
                   2163: 
                   2164:     Contains the original files for rc.d scripts.
                   2165: 
                   2166: var (the usual location of ${VARBASE})
                   2167: 
                   2168:     Contains files that may be modified after installation.
                   2169: 
1.154     rillig   2170: 9.2. File system layout in ${VARBASE}
1.1       dsieger  2171: 
                   2172: db/pkg (the usual location of ${PKG_DBDIR})
                   2173: 
                   2174:     Contains information about the currently installed packages.
                   2175: 
                   2176: games
                   2177: 
                   2178:     Contains highscore files.
                   2179: 
                   2180: log
                   2181: 
                   2182:     Contains log files.
                   2183: 
                   2184: run
                   2185: 
                   2186:     Contains informational files about daemons that are currently running.
                   2187: 
1.154     rillig   2188: Chapter 10. Frequently Asked Questions
1.1       dsieger  2189: 
                   2190: Table of Contents
                   2191: 
1.154     rillig   2192: 10.1. Are there any mailing lists for pkg-related discussion?
                   2193: 10.2. Utilities for package management (pkgtools)
                   2194: 10.3. How to use pkgsrc as non-root
                   2195: 10.4. How to resume transfers when fetching distfiles?
                   2196: 10.5. How can I install/use modular X.org from pkgsrc?
                   2197: 10.6. How to fetch files from behind a firewall
                   2198: 10.7. How to fetch files from HTTPS sites
                   2199: 10.8. How do I tell make fetch to do passive FTP?
                   2200: 10.9. How to fetch all distfiles at once
                   2201: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
                   2202: 10.11. What does "Could not find bsd.own.mk" mean?
1.221     nia      2203: 10.12. Using 'sudo' or `priv` with pkgsrc
1.154     rillig   2204: 10.13. How do I change the location of configuration files?
                   2205: 10.14. Automated security checks
                   2206: 10.15. Why do some packages ignore my CFLAGS?
                   2207: 10.16. A package does not build. What shall I do?
                   2208: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.232     gutterid 2209: conflicts" mean?
1.1       dsieger  2210: 
                   2211: This section contains hints, tips & tricks on special things in pkgsrc that we
                   2212: didn't find a better place for in the previous chapters, and it contains items
                   2213: for both pkgsrc users and developers.
                   2214: 
1.154     rillig   2215: 10.1. Are there any mailing lists for pkg-related discussion?
1.1       dsieger  2216: 
                   2217: The following mailing lists may be of interest to pkgsrc users:
                   2218: 
                   2219:   * pkgsrc-users: This is a general purpose list for most issues regarding
                   2220:     pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
                   2221:     configuration, unexpected build failures, using particular packages,
                   2222:     upgrading pkgsrc installations, questions regarding the pkgsrc release
                   2223:     branches, etc. General announcements or proposals for changes that impact
                   2224:     the pkgsrc user community, e.g. major infrastructure changes, new features,
                   2225:     package removals, etc., may also be posted.
                   2226: 
                   2227:   * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
                   2228:     discussed.
                   2229: 
                   2230:   * pkgsrc-changes: This list is for those who are interested in getting a
                   2231:     commit message for every change committed to pkgsrc. It is also available
                   2232:     in digest form, meaning one daily message containing all commit messages
                   2233:     for changes to the package source tree in that 24 hour period.
                   2234: 
                   2235: To subscribe, do:
                   2236: 
                   2237: % echo subscribe listname | mail majordomo@NetBSD.org
                   2238: 
1.174     leot     2239: Archives for all these mailing lists are available from https://
1.1       dsieger  2240: mail-index.NetBSD.org/.
                   2241: 
1.154     rillig   2242: 10.2. Utilities for package management (pkgtools)
1.1       dsieger  2243: 
                   2244: The directory pkgsrc/pkgtools contains a number of useful utilities for both
                   2245: users and developers of pkgsrc. This section attempts only to make the reader
1.121     sevan    2246: aware of some of the utilities and when they might be useful, and not to
                   2247: duplicate the documentation that comes with each package.
1.1       dsieger  2248: 
                   2249: Utilities used by pkgsrc (automatically installed when needed):
                   2250: 
                   2251:   * pkgtools/x11-links: Symlinks for use by buildlink.
                   2252: 
                   2253: OS tool augmentation (automatically installed when needed):
                   2254: 
1.121     sevan    2255:   * pkgtools/digest: Calculates various kinds of checksums (including SHA3).
1.1       dsieger  2256: 
                   2257:   * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
                   2258: 
                   2259:   * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
                   2260: 
                   2261:   * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
                   2262:     for use on operating systems where pkg_install is not present.
                   2263: 
                   2264: Utilities used by pkgsrc (not automatically installed):
                   2265: 
                   2266:   * pkgtools/pkg_tarup: Create a binary package from an already-installed
                   2267:     package. Used by make replace to save the old package.
                   2268: 
                   2269:   * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
                   2270:     distfiles from multiple locations. It currently supports the following
                   2271:     methods: multiple CD-ROMs and network FTP/HTTP connections.
                   2272: 
                   2273:   * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24      wiz      2274:     current CPU and compiler.
1.1       dsieger  2275: 
                   2276: Utilities for keeping track of installed packages, being up to date, etc:
                   2277: 
1.65      wiz      2278:   * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
                   2279:     and upgrade binary packages easily.
                   2280: 
1.1       dsieger  2281:   * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
                   2282:     the latest pkgsrc entries.
                   2283: 
                   2284:   * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
                   2285:     strategy for updating.
                   2286: 
                   2287:   * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
                   2288:     graphviz).
                   2289: 
1.12      weinem   2290:   * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
                   2291: 
                   2292:   * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
                   2293:     complete pkgsrc system.
1.1       dsieger  2294: 
                   2295:   * pkgtools/pkgsurvey: Report what packages you have installed.
                   2296: 
                   2297: Utilities for people maintaining or creating individual packages:
                   2298: 
                   2299:   * pkgtools/pkgdiff: Automate making and maintaining patches for a package
                   2300:     (includes pkgdiff, pkgvi, mkpatches, etc.).
                   2301: 
1.65      wiz      2302:   * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1       dsieger  2303: 
                   2304: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
                   2305: 
                   2306:   * pkgtools/pkg_comp: Build packages in a chrooted area.
                   2307: 
                   2308:   * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
                   2309: 
1.154     rillig   2310: 10.3. How to use pkgsrc as non-root
1.1       dsieger  2311: 
1.108     rillig   2312: To install packages from source as a non-root user, download pkgsrc as
1.154     rillig   2313: described in Chapter 3, Where to get pkgsrc and how to keep it up-to-date, cd
1.108     rillig   2314: into that directory and run the command ./bootstrap/bootstrap --unprivileged.
                   2315: 
                   2316: This will install the binary part of pkgsrc to ~/pkg and put the pkgsrc
                   2317: configuration mk.conf into ~/pkg/etc.
                   2318: 
                   2319: For more details, see mk/unprivileged.mk.
1.1       dsieger  2320: 
1.154     rillig   2321: 10.4. How to resume transfers when fetching distfiles?
1.1       dsieger  2322: 
                   2323: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4       rillig   2324: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
                   2325: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1       dsieger  2326: 
1.61      wiz      2327: You can also use a different program than the platform default program by
                   2328: changing the FETCH_USING variable. You can specify the program by using of ftp,
                   2329: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
                   2330: manual. A value of custom disables the system defaults and dependency tracking
                   2331: for the fetch program. In that case you have to provide FETCH_CMD,
                   2332: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1       dsieger  2333: 
1.16      jnemeth  2334: For example, if you want to use wget to download, you'll have to use something
                   2335: like:
1.1       dsieger  2336: 
1.16      jnemeth  2337: FETCH_USING=    wget
1.1       dsieger  2338: 
1.154     rillig   2339: 10.5. How can I install/use modular X.org from pkgsrc?
1.1       dsieger  2340: 
1.4       rillig   2341: If you want to use modular X.org from pkgsrc instead of your system's own X11
                   2342: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1       dsieger  2343: mk.conf:
                   2344: 
1.4       rillig   2345: X11_TYPE=modular
1.1       dsieger  2346: 
1.154     rillig   2347: 10.6. How to fetch files from behind a firewall
1.1       dsieger  2348: 
                   2349: If you are sitting behind a firewall which does not allow direct connections to
                   2350: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
                   2351: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
                   2352: machine "orpheus.amdahl.com" is one of the firewalls, and it uses port 80 as
                   2353: the proxy port number. So the proxy environment variables are:
                   2354: 
                   2355: ftp_proxy=ftp://orpheus.amdahl.com:80/
                   2356: http_proxy=http://orpheus.amdahl.com:80/
                   2357: 
1.154     rillig   2358: 10.7. How to fetch files from HTTPS sites
1.65      wiz      2359: 
                   2360: Some fetch tools are not prepared to support HTTPS by default (for example, the
                   2361: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
                   2362: openssl dependency that low in the dependency graph).
                   2363: 
                   2364: Usually you won't notice, because distribution files are mirrored weekly to "
                   2365: ftp.NetBSD.org", but that might not be often enough if you are following
                   2366: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to "curl" or
                   2367: "wget", which are both compiled with HTTPS support by default. Of course, these
                   2368: tools need to be installed before you can use them this way.
                   2369: 
1.154     rillig   2370: 10.8. How do I tell make fetch to do passive FTP?
1.1       dsieger  2371: 
                   2372: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
                   2373: FETCH_CMD is assigned the first available command from the following list:
                   2374: 
                   2375:   * ${LOCALBASE}/bin/ftp
                   2376: 
                   2377:   * /usr/bin/ftp
                   2378: 
                   2379: On a default NetBSD installation, this will be /usr/bin/ftp, which
                   2380: automatically tries passive connections first, and falls back to active
                   2381: connections if the server refuses to do passive. For the other tools, add the
1.4       rillig   2382: following to your mk.conf file: PASSIVE_FETCH=1.
1.1       dsieger  2383: 
                   2384: Having that option present will prevent /usr/bin/ftp from falling back to
                   2385: active transfers.
                   2386: 
1.154     rillig   2387: 10.9. How to fetch all distfiles at once
1.1       dsieger  2388: 
                   2389: You would like to download all the distfiles in a single batch from work or
                   2390: university, where you can't run a make fetch. There is an archive of distfiles
                   2391: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
                   2392: 
                   2393: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
                   2394: subdirectories, carry the resulting list to your machine at work/school and use
                   2395: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
                   2396: don't forget to set FETCH_CMD to something that fetches a URL:
                   2397: 
                   2398: At home:
                   2399: 
                   2400: % cd /usr/pkgsrc
                   2401: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
                   2402: % scp /tmp/fetch.sh work:/tmp
                   2403: 
                   2404: At work:
                   2405: 
                   2406: % sh /tmp/fetch.sh
                   2407: 
                   2408: then tar up /tmp/distfiles and take it home.
                   2409: 
                   2410: If you have a machine running NetBSD, and you want to get all distfiles (even
                   2411: ones that aren't for your machine architecture), you can do so by using the
                   2412: above-mentioned make fetch-list approach, or fetch the distfiles directly by
                   2413: running:
                   2414: 
                   2415: % make mirror-distfiles
                   2416: 
                   2417: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
                   2418: everything by running:
                   2419: 
                   2420: % make fetch NO_SKIP=yes
                   2421: 
1.154     rillig   2422: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
1.1       dsieger  2423: 
                   2424: When compiling the pkgtools/pkg_install package, you get the error from make
                   2425: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
                   2426: that you don't have installed the "text" set (nroff, ...) from the NetBSD base
                   2427: distribution on your machine. It is recommended to do that to format man pages.
                   2428: 
                   2429: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4       rillig   2430: NOMAN=YES either in the environment or in mk.conf.
1.1       dsieger  2431: 
1.154     rillig   2432: 10.11. What does "Could not find bsd.own.mk" mean?
1.1       dsieger  2433: 
                   2434: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
                   2435: machine. Please get and install it, by extracting it in /:
                   2436: 
                   2437: # cd /
                   2438: # tar --unlink -zxvpf .../comp.tgz
                   2439: 
                   2440: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
                   2441: release (determine via uname -r).
                   2442: 
1.221     nia      2443: 10.12. Using 'sudo' or `priv` with pkgsrc
1.1       dsieger  2444: 
                   2445: When installing packages as non-root user and using the just-in-time su(1)
                   2446: feature of pkgsrc, it can become annoying to type in the root password for each
                   2447: required package installed. To avoid this, the sudo package can be used, which
1.221     nia      2448: does password caching over a limited time. To use it, install sudo or priv
                   2449: (either as binary package, from security/priv, or security/sudo) and then put
                   2450: the following into your mk.conf, somewhere after the definition of the
                   2451: LOCALBASE variable:
1.1       dsieger  2452: 
                   2453: .if exists(${LOCALBASE}/bin/sudo)
                   2454: SU_CMD=        ${LOCALBASE}/bin/sudo /bin/sh -c
                   2455: .endif
                   2456: 
1.154     rillig   2457: 10.13. How do I change the location of configuration files?
1.1       dsieger  2458: 
                   2459: As the system administrator, you can choose where configuration files are
                   2460: installed. The default settings make all these files go into ${PREFIX}/etc or
                   2461: some of its subdirectories; this may be suboptimal depending on your
                   2462: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
                   2463: configuration of the provided packages).
                   2464: 
                   2465: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4       rillig   2466: (in mk.conf) to point to your preferred configuration directory; some common
                   2467: examples include /etc or /etc/pkg.
1.1       dsieger  2468: 
                   2469: Furthermore, you can change this value on a per-package basis by setting the
                   2470: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
                   2471: matches the name of the package you would like to modify, that is, the contents
                   2472: of PKGBASE.
                   2473: 
                   2474: Note that after changing these settings, you must rebuild and reinstall any
                   2475: affected packages.
                   2476: 
1.154     rillig   2477: 10.14. Automated security checks
1.1       dsieger  2478: 
                   2479: Please be aware that there can often be bugs in third-party software, and some
                   2480: of these bugs can leave a machine vulnerable to exploitation by attackers. In
                   2481: an effort to lessen the exposure, the NetBSD packages team maintains a database
                   2482: of known-exploits to packages which have at one time been included in pkgsrc.
                   2483: The database can be downloaded automatically, and a security audit of all
1.14      jmcneill 2484: packages installed on a system can take place. To do this, refer to the
                   2485: following two tools (installed as part of the pkgtools/pkg_install package):
1.1       dsieger  2486: 
1.21      snj      2487:  1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
                   2488:     security vulnerabilities information. This list is kept up to date by the
1.26      spz      2489:     pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1       dsieger  2490: 
1.177     leot     2491:     https://ftp.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities
1.1       dsieger  2492: 
1.21      snj      2493:  2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24      wiz      2494:     known vulnerability. If a vulnerable package is installed, it will be shown
                   2495:     by output to stdout, including a description of the type of vulnerability,
                   2496:     and a URL containing more information.
1.1       dsieger  2497: 
1.202     nia      2498: Use of these tools is strongly recommended! See Section 5.1.6, "Checking for
1.121     sevan    2499: security vulnerabilities in installed packages" for instructions on how to
                   2500: automate checking and reporting.
                   2501: 
                   2502: If this database is installed, pkgsrc builds will use it to perform a security
                   2503: check before building any package.
1.1       dsieger  2504: 
1.154     rillig   2505: 10.15. Why do some packages ignore my CFLAGS?
1.1       dsieger  2506: 
                   2507: When you add your own preferences to the CFLAGS variable in your mk.conf, these
                   2508: flags are passed in environment variables to the ./configure scripts and to
                   2509: make(1). Some package authors ignore the CFLAGS from the environment variable
                   2510: by overriding them in the Makefiles of their package.
                   2511: 
                   2512: Currently there is no solution to this problem. If you really need the package
                   2513: to use your CFLAGS you should run make patch in the package directory and then
                   2514: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
                   2515: Usually you can remove these lines. But be aware that some "smart" programmers
                   2516: write so bad code that it only works for the specific combination of CFLAGS
                   2517: they have chosen.
                   2518: 
1.172     rillig   2519: To find out where the CFLAGS are ignored, add the following lines to mk.conf:
                   2520: 
                   2521: CPPFLAGS+=              -Dpkgsrc___CPPFLAGS
                   2522: CFLAGS+=                -Dpkgsrc___CFLAGS
                   2523: CXXFLAGS+=              -Dpkgsrc___CXXFLAGS
                   2524: 
                   2525: Then run bmake show-all-configure show-all-build to see whether the above flags
                   2526: are passed to the actual build commands in general.
                   2527: 
                   2528: To find out whether the flags are passed to individual compiler commands, have
                   2529: a look at the file work/.work.log. In most cases, the flags from the original
                   2530: command lines (the lines starting with [*]) are passed unmodified to the actual
                   2531: compiler (the lines starting with <.>). If the flag is missing from the actual
                   2532: compiler command, it must have been removed by the pkgsrc compiler wrappers.
                   2533: 
1.154     rillig   2534: 10.16. A package does not build. What shall I do?
1.1       dsieger  2535: 
                   2536:  1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
                   2537:     is that people only update pkgsrc in parts, because of performance reasons.
                   2538:     Since pkgsrc is one large system, not a collection of many small systems,
                   2539:     there are sometimes changes that only work when the whole pkgsrc tree is
                   2540:     updated.
                   2541: 
1.25      wiz      2542:  2. Make sure that you don't have any CVS conflicts. Search for "<<<<<<" or "
                   2543:     >>>>>>" in all your pkgsrc files.
1.1       dsieger  2544: 
1.25      wiz      2545:  3. Make sure that you don't have old copies of the packages extracted. Run 
1.1       dsieger  2546:     make clean clean-depends to verify this.
                   2547: 
1.108     rillig   2548:  4. If you are a package developer who wants to invest some work, have a look
1.154     rillig   2549:     at Chapter 21, Making your package work.
1.108     rillig   2550: 
                   2551:  5. If the problem still exists, write a mail to the pkgsrc-users mailing list.
1.1       dsieger  2552: 
1.154     rillig   2553: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.1       dsieger  2554: conflicts" mean?
                   2555: 
                   2556: You have modified a file from pkgsrc, and someone else has modified that same
                   2557: file afterwards in the CVS repository. Both changes are in the same region of
                   2558: the file, so when you updated pkgsrc, the cvs command marked the conflicting
                   2559: changes in the file. Because of these markers, the file is no longer a valid
                   2560: Makefile.
                   2561: 
                   2562: Have a look at that file, and if you don't need your local changes anymore, you
                   2563: can remove that file and run cvs -q update -dP in that directory to download
                   2564: the current version.
                   2565: 
                   2566: Part II. The pkgsrc developer's guide
                   2567: 
                   2568: This part of the book deals with creating and modifying packages. It starts
                   2569: with a "HOWTO"-like guide on creating a new package. The remaining chapters are
                   2570: more like a reference manual for pkgsrc.
                   2571: 
                   2572: Table of Contents
                   2573: 
1.154     rillig   2574: 11. Getting help
1.184     rillig   2575: 12. Package components - files, directories and contents
                   2576:     12.1. Makefile
                   2577:     12.2. distinfo
                   2578:     12.3. patches/*
                   2579:         12.3.1. Structure of a single patch file
                   2580:         12.3.2. Creating patch files
                   2581:         12.3.3. Sources where the patch files come from
                   2582:         12.3.4. Patching guidelines
                   2583:         12.3.5. Feedback to the author
                   2584:     12.4. Other mandatory files
                   2585:     12.5. Optional files
                   2586:         12.5.1. Files affecting the binary package
                   2587:         12.5.2. Files affecting the build process
                   2588:         12.5.3. Files affecting nothing at all
                   2589:     12.6. work*
                   2590:     12.7. files/*
                   2591: 13. The build process
                   2592:     13.1. Introduction
                   2593:     13.2. Program location
                   2594:     13.3. Directories used during the build process
                   2595:     13.4. Running a phase
                   2596:     13.5. The fetch phase
                   2597:         13.5.1. What to fetch and where to get it from
                   2598:         13.5.2. How are the files fetched?
                   2599:     13.6. The checksum phase
                   2600:     13.7. The extract phase
                   2601:     13.8. The patch phase
                   2602:     13.9. The tools phase
                   2603:     13.10. The wrapper phase
                   2604:     13.11. The configure phase
                   2605:     13.12. The build phase
                   2606:     13.13. The test phase
                   2607:     13.14. The install phase
                   2608:     13.15. The package phase
                   2609:     13.16. Cleaning up
                   2610:     13.17. Other helpful targets
                   2611: 14. Creating a new pkgsrc package from scratch
                   2612:     14.1. Common types of packages
1.219     nia      2613:         14.1.1. Python modules and programs
                   2614:         14.1.2. R packages
                   2615:         14.1.3. TeXlive packages
1.184     rillig   2616:     14.2. Examples
                   2617:         14.2.1. How the www/nvu package came into pkgsrc
                   2618: 15. Programming in Makefiles
                   2619:     15.1. Caveats
                   2620:     15.2. Makefile variables
                   2621:         15.2.1. Naming conventions
                   2622:     15.3. Code snippets
                   2623:         15.3.1. Adding things to a list
                   2624:         15.3.2. Echoing a string exactly as-is
                   2625:         15.3.3. Passing CFLAGS to GNU configure scripts
                   2626:         15.3.4. Handling possibly empty variables
1.229     gutterid 2627:         15.3.5. Testing yes/no variables in conditions
1.184     rillig   2628: 16. Options handling
                   2629:     16.1. Global default options
                   2630:     16.2. Converting packages to use bsd.options.mk
                   2631:     16.3. Option Names
                   2632:     16.4. Determining the options of dependencies
                   2633: 17. Tools needed for building or running
                   2634:     17.1. Tools for pkgsrc builds
                   2635:     17.2. Tools needed by packages
                   2636:     17.3. Tools provided by platforms
                   2637: 18. Buildlink methodology
                   2638:     18.1. Converting packages to use buildlink3
                   2639:     18.2. Writing buildlink3.mk files
                   2640:         18.2.1. Anatomy of a buildlink3.mk file
                   2641:         18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
1.232     gutterid 2642:         pkg in buildlink3.mk files
1.184     rillig   2643:     18.3. Writing builtin.mk files
                   2644:         18.3.1. Anatomy of a builtin.mk file
                   2645: 19. PLIST issues
                   2646:     19.1. RCS ID
                   2647:     19.2. Semi-automatic PLIST generation
                   2648:     19.3. Tweaking output of make print-PLIST
                   2649:     19.4. Variable substitution in PLIST
                   2650:     19.5. Man page compression
                   2651:     19.6. Changing PLIST source with PLIST_SRC
                   2652:     19.7. Platform-specific and differing PLISTs
                   2653:     19.8. Build-specific PLISTs
                   2654:     19.9. Sharing directories between packages
                   2655: 20. The pkginstall framework
                   2656:     20.1. Files and directories outside the installation prefix
                   2657:         20.1.1. Directory manipulation
                   2658:         20.1.2. File manipulation
                   2659:     20.2. Configuration files
                   2660:         20.2.1. How PKG_SYSCONFDIR is set
                   2661:         20.2.2. Telling the software where configuration files are
1.239     dholland 2662:         20.2.3. Patching installation
                   2663:         20.2.4. Declaring configuration files
                   2664:         20.2.5. Disabling handling of configuration files
1.184     rillig   2665:     20.3. System startup scripts
                   2666:         20.3.1. Disabling handling of system startup scripts
                   2667:     20.4. System users and groups
                   2668:     20.5. System shells
                   2669:         20.5.1. Disabling shell registration
                   2670:     20.6. Fonts
                   2671:         20.6.1. Disabling automatic update of the fonts databases
1.154     rillig   2672: 21. Making your package work
                   2673:     21.1. General operation
                   2674:         21.1.1. How to pull in user-settable variables from mk.conf
                   2675:         21.1.2. User interaction
                   2676:         21.1.3. Handling licenses
                   2677:         21.1.4. Restricted packages
                   2678:         21.1.5. Handling dependencies
                   2679:         21.1.6. Handling conflicts with other packages
                   2680:         21.1.7. Packages that cannot or should not be built
                   2681:         21.1.8. Packages which should not be deleted, once installed
                   2682:         21.1.9. Handling packages with security problems
                   2683:         21.1.10. How to handle incrementing versions when fixing an existing
1.232     gutterid 2684:         package
1.154     rillig   2685:         21.1.11. Substituting variable text in the package files (the SUBST
1.232     gutterid 2686:         framework)
1.154     rillig   2687:     21.2. The fetch phase
                   2688:         21.2.1. Packages whose distfiles aren't available for plain downloading
                   2689:         21.2.2. How to handle modified distfiles with the 'old' name
                   2690:         21.2.3. Packages hosted on github.com
                   2691:     21.3. The configure phase
                   2692:         21.3.1. Shared libraries - libtool
                   2693:         21.3.2. Using libtool on GNU packages that already support libtool
                   2694:         21.3.3. GNU Autoconf/Automake
1.223     nia      2695:         21.3.4. Meson / ninja
1.154     rillig   2696:     21.4. Programming languages
                   2697:         21.4.1. C, C++, and Fortran
                   2698:         21.4.2. Java
1.205     wiz      2699:         21.4.3. Go
1.223     nia      2700:         21.4.4. Rust
                   2701:         21.4.5. Packages containing Perl scripts
                   2702:         21.4.6. Packages containing shell scripts
                   2703:         21.4.7. Other programming languages
1.154     rillig   2704:     21.5. The build phase
                   2705:         21.5.1. Compiling C and C++ code conditionally
                   2706:         21.5.2. How to handle compiler bugs
1.172     rillig   2707:         21.5.3. No such file or directory
                   2708:         21.5.4. Undefined reference to "..."
                   2709:         21.5.5. Running out of memory
1.154     rillig   2710:     21.6. The install phase
                   2711:         21.6.1. Creating needed directories
                   2712:         21.6.2. Where to install documentation
                   2713:         21.6.3. Installing highscore files
                   2714:         21.6.4. Adding DESTDIR support to packages
                   2715:         21.6.5. Packages with hardcoded paths to other interpreters
1.203     nia      2716:         21.6.6. Packages installing Perl modules
1.154     rillig   2717:         21.6.7. Packages installing info files
                   2718:         21.6.8. Packages installing man pages
1.203     nia      2719:         21.6.9. Packages installing X11 fonts
                   2720:         21.6.10. Packages installing SGML or XML data
                   2721:         21.6.11. Packages installing extensions to the MIME database
                   2722:         21.6.12. Packages using intltool
                   2723:         21.6.13. Packages installing startup scripts
                   2724:         21.6.14. Packages installing TeX modules
                   2725:         21.6.15. Packages supporting running binaries in emulation
                   2726:         21.6.16. Packages installing hicolor icons
                   2727:         21.6.17. Packages installing desktop files
1.154     rillig   2728:     21.7. Marking packages as having problems
1.184     rillig   2729: 22. GNOME packaging and porting
                   2730:     22.1. Meta packages
                   2731:     22.2. Packaging a GNOME application
                   2732:     22.3. Updating GNOME to a newer version
                   2733:     22.4. Patching guidelines
1.154     rillig   2734: 23. Submitting and Committing
                   2735:     23.1. Submitting binary packages
                   2736:     23.2. Submitting source packages (for non-NetBSD-developers)
                   2737:     23.3. General notes when adding, updating, or removing packages
                   2738:     23.4. Commit Messages
                   2739:     23.5. Committing: Adding a package to CVS
                   2740:     23.6. Updating a package to a newer version
                   2741:     23.7. Renaming a package in pkgsrc
                   2742:     23.8. Moving a package in pkgsrc
                   2743: 24. Frequently Asked Questions
                   2744: 
                   2745: Chapter 11. Getting help
                   2746: 
                   2747: To get help when developing pkgsrc, the definitive source is this document, the
                   2748: pkgsrc guide. If you don't find anything here, there are alternatives:
                   2749: 
                   2750:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
                   2751:     Run bmake help topic=? to get help for any topic, such as a variable name
                   2752:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                   2753:     like strcasecmp or any other topic.
                   2754: 
1.207     leot     2755:     The available help topics are listed in Appendix E, Help topics.
1.154     rillig   2756: 
1.163     rillig   2757:   * To see the value of a single variable, run bmake show-var VARNAME=X.
                   2758: 
                   2759:   * To see the values of the most common variables, run bmake show-all. These
                   2760:     variables are grouped by topic. To see the variables for a single topic,
                   2761:     run bmake show-all-topic, for example bmake show-all-fetch.
                   2762: 
1.154     rillig   2763:   * The tech-pkg mailing list, to which you can subscribe and then ask your
                   2764:     questions.
                   2765: 
                   2766:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                   2767:     a specialized chat program such as XChat. Pick any user name and join the
                   2768:     channel #pkgsrc.
1.1       dsieger  2769: 
1.184     rillig   2770: Chapter 12. Package components - files, directories and contents
1.1       dsieger  2771: 
                   2772: Table of Contents
                   2773: 
1.184     rillig   2774: 12.1. Makefile
                   2775: 12.2. distinfo
                   2776: 12.3. patches/*
                   2777:     12.3.1. Structure of a single patch file
                   2778:     12.3.2. Creating patch files
                   2779:     12.3.3. Sources where the patch files come from
                   2780:     12.3.4. Patching guidelines
                   2781:     12.3.5. Feedback to the author
                   2782: 12.4. Other mandatory files
                   2783: 12.5. Optional files
                   2784:     12.5.1. Files affecting the binary package
                   2785:     12.5.2. Files affecting the build process
                   2786:     12.5.3. Files affecting nothing at all
                   2787: 12.6. work*
                   2788: 12.7. files/*
1.1       dsieger  2789: 
1.184     rillig   2790: Whenever you're preparing a package, there are a number of files involved which
                   2791: are described in the following sections.
1.1       dsieger  2792: 
1.184     rillig   2793: 12.1. Makefile
1.1       dsieger  2794: 
1.184     rillig   2795: Building, installation and creation of a binary package are all controlled by
                   2796: the package's Makefile. The Makefile describes various things about a package,
                   2797: for example from where to get it, how to configure, build, and install it.
1.1       dsieger  2798: 
1.184     rillig   2799: A package Makefile contains several sections that describe the package.
1.1       dsieger  2800: 
1.184     rillig   2801: In the first section there are the following variables, which should appear
                   2802: exactly in the order given here. The order and grouping of the variables is
                   2803: mostly historical and has no further meaning.
1.1       dsieger  2804: 
1.184     rillig   2805:   * DISTNAME is the basename of the distribution file to be downloaded from the
                   2806:     package's website.
1.1       dsieger  2807: 
1.184     rillig   2808:   * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
                   2809:     it if DISTNAME (which is the default) is not a good name for the package in
                   2810:     pkgsrc or DISTNAME is not provided (no distribution file is required).
                   2811:     Usually it is the pkgsrc directory name together with the version number.
                   2812:     It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
                   2813:     is, it starts with a letter or digit, and contains only letters, digits,
1.204     nia      2814:     dashes, underscores, dots and plus signs. New packages should have entirely
                   2815:     lower-case names, with the exception of some that must follow pre-existing
                   2816:     conventions (e.g. R packages begin with R-). You can use the :tl variable
                   2817:     modifier to lower-case the package name.
1.26      spz      2818: 
1.184     rillig   2819:   * CATEGORIES is a list of categories which the package fits in. You can
                   2820:     choose any of the top-level directories of pkgsrc for it.
1.1       dsieger  2821: 
1.184     rillig   2822:     Currently the following values are available for CATEGORIES. If more than
                   2823:     one is used, they need to be separated by spaces:
1.1       dsieger  2824: 
1.184     rillig   2825:     archivers     cross         geography     meta-pkgs     security
                   2826:     audio         databases     graphics      misc          shells
                   2827:     benchmarks    devel         ham           multimedia    sysutils
                   2828:     biology       editors       inputmethod   net           textproc
                   2829:     cad           emulators     lang          news          time
                   2830:     chat          finance       mail          parallel      wm
                   2831:     comms         fonts         math          pkgtools      www
                   2832:     converters    games         mbone         print         x11
1.1       dsieger  2833: 
1.184     rillig   2834:   * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
                   2835:     are discussed in detail in Section 13.5, "The fetch phase".
1.1       dsieger  2836: 
1.184     rillig   2837: The second section contains information about separately downloaded patches, if
                   2838: any.
1.1       dsieger  2839: 
1.184     rillig   2840:   * PATCHFILES: Name(s) of additional files that contain distribution patches.
                   2841:     There is no default. pkgsrc will look for them at PATCH_SITES. They will
                   2842:     automatically be uncompressed before patching if the names end with .gz or
                   2843:     .Z.
1.1       dsieger  2844: 
1.184     rillig   2845:   * PATCH_SITES: Primary location(s) for distribution patch files (see
                   2846:     PATCHFILES above) if not found locally.
1.1       dsieger  2847: 
1.184     rillig   2848:   * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
                   2849:     count to help find the correct files to patch. It defaults to -p0.
1.1       dsieger  2850: 
1.184     rillig   2851: The third section contains the following variables.
1.1       dsieger  2852: 
1.253   ! gutterid 2853:   * MAINTAINER is the email address of the person who is currently responsible
        !          2854:     for this package. In theory, the maintainer will be aware of upstream
        !          2855:     release, keep it updated, and generally resolve problems. Others
        !          2856:     contemplating significant changes should ask the maintainer for advice or
        !          2857:     review of a proposed change. This is not necessary for micro updates, bug
        !          2858:     fixes, pkgsrc-wide changes affecting many packages, and other things
        !          2859:     expected to be uncontroversial. It goes with this "should ask" that the
        !          2860:     maintainer should respond to inquiries reasonably promptly (most of the
        !          2861:     time), and either approve changes or provide reasons why not. Typically,
        !          2862:     when packaging a new program, set MAINTAINER to yourself. If you don't
        !          2863:     intend to maintain the package (especially if you feel you have no special
        !          2864:     insight), set it to <pkgsrc-users@NetBSD.org>. This special value is a code
        !          2865:     point indicating that there is no maintainer, but the variable is
        !          2866:     mandatory, absent OWNER.
        !          2867: 
        !          2868:   * OWNER can be used instead of MAINTAINER in relatively rare circumstances
        !          2869:     when the package is such that modifying it is riskier than normal. This is
        !          2870:     a stronger form of being the maintainer, with an expectation that others
        !          2871:     will ask for almost all changes, except revbumps and accommodating
        !          2872:     structural changes. Someone who becomes OWNER has a strong obligation to
        !          2873:     keep the package very well maintained, to answer queries promptly and to be
        !          2874:     a steward of the package on behalf of users. In this case, MAINTAINER
        !          2875:     should be omitted.
        !          2876: 
        !          2877:     Because of the friction that OWNER adds, PMC may downgrade it to MAINTAINER
        !          2878:     at any time.
1.1       dsieger  2879: 
1.184     rillig   2880:   * HOMEPAGE is a URL where users can find more information about the package.
1.1       dsieger  2881: 
1.184     rillig   2882:   * COMMENT is a one-line description of the package (should not include the
                   2883:     package name).
1.1       dsieger  2884: 
1.184     rillig   2885:   * LICENSE indicates the license(s) applicable for the package. See
                   2886:     Section 21.1.3, "Handling licenses" for further details.
1.1       dsieger  2887: 
1.184     rillig   2888: Other variables that affect the build:
1.1       dsieger  2889: 
1.184     rillig   2890:   * WRKSRC: The directory where the interesting distribution files of the
                   2891:     package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
                   2892:     most packages.
1.1       dsieger  2893: 
1.184     rillig   2894:     If a package doesn't create a subdirectory for itself (most GNU software
                   2895:     does, for instance), but extracts itself in the current directory, you
                   2896:     should set WRKSRC=${WRKDIR}.
1.1       dsieger  2897: 
1.184     rillig   2898:     If a package doesn't create a subdirectory with the name of DISTNAME but
                   2899:     some different name, set WRKSRC to point to the proper name in ${WRKDIR},
                   2900:     for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
                   2901:     other examples.
1.17      imil     2902: 
1.184     rillig   2903:     The name of the working directory created by pkgsrc is taken from the
                   2904:     WRKDIR_BASENAME variable. By default, its value is work. If you want to use
                   2905:     the same pkgsrc tree for building different kinds of binary packages, you
                   2906:     can change the variable according to your needs. Two other variables handle
                   2907:     common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
                   2908:     defined in mk.conf, the first component of the host's name is attached to
                   2909:     the directory name. If OBJMACHINE is defined, the platform name is
                   2910:     attached, which might look like work.i386 or work.sparc.
1.17      imil     2911: 
1.184     rillig   2912: Please pay attention to the following gotchas:
1.17      imil     2913: 
1.184     rillig   2914:   * Add MANCOMPRESSED if man pages are installed in compressed form by the
                   2915:     package. For packages using BSD-style makefiles which honor MANZ, there is
                   2916:     MANCOMPRESSED_IF_MANZ.
1.17      imil     2917: 
1.184     rillig   2918:   * Replace /usr/local with "${PREFIX}" in all files (see patches, below).
1.103     wiz      2919: 
1.184     rillig   2920:   * If the package installs any info files, see Section 21.6.7, "Packages
                   2921:     installing info files".
1.103     wiz      2922: 
1.184     rillig   2923: 12.2. distinfo
1.17      imil     2924: 
1.184     rillig   2925: The distinfo file contains the message digest, or checksum, of each distfile
                   2926: needed for the package. This ensures that the distfiles retrieved from the
                   2927: Internet have not been corrupted during transfer or altered by a malign force
                   2928: to introduce a security hole. To provide maximum security, all distfiles are
1.243     gutterid 2929: protected using two different message digest algorithms (BLAKE2s and SHA512),
                   2930: as well as the file size.
1.17      imil     2931: 
1.184     rillig   2932: The distinfo file also contains the checksums for all the patches found in the
                   2933: patches directory (see Section 12.3, "patches/*"). These checksums ensure that
                   2934: patches are only applied intentionally and that they don't accidentally change,
                   2935: e.g. when merging different changes together. They also make sure that new
                   2936: patches are actually added to CVS and old ones are removed. Too see whether the
                   2937: patches and the distinfo file match, run pkglint after changing the patches.
1.17      imil     2938: 
1.184     rillig   2939: To regenerate the distinfo file, use the make distinfo command.
1.17      imil     2940: 
1.184     rillig   2941: Some packages have different sets of distfiles depending on the platform, for
                   2942: example lang/openjdk8. These are kept in the same distinfo file and care should
                   2943: be taken when upgrading such a package to ensure distfile information is not
                   2944: lost.
1.17      imil     2945: 
1.184     rillig   2946: 12.3. patches/*
1.63      wiz      2947: 
1.184     rillig   2948: Some packages don't work out-of-the box on the various platforms that are
                   2949: supported by pkgsrc. These packages need to be patched to make them work. The
                   2950: patch files can be found in the patches/ directory.
1.17      imil     2951: 
1.184     rillig   2952: In the patch phase, these patches are applied to the files in WRKSRC directory
                   2953: after extracting them, in alphabetic order.
1.160     brook    2954: 
1.184     rillig   2955: 12.3.1. Structure of a single patch file
1.160     brook    2956: 
1.184     rillig   2957: The patch-* files should be in diff -bu format, and apply without a fuzz to
                   2958: avoid problems. (To force patches to apply with fuzz you can set
                   2959: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
                   2960: a single file, and no file should be patched by more than one patch file. This
                   2961: helps to keep future modifications simple.
1.160     brook    2962: 
1.184     rillig   2963: Each patch file is structured as follows: In the first line, there is the RCS
                   2964: Id of the patch itself. The second line should be empty for aesthetic reasons.
                   2965: After that, there should be a comment for each change that the patch does.
                   2966: There are a number of standard cases:
1.160     brook    2967: 
1.184     rillig   2968:   * Patches for commonly known vulnerabilities should mention the vulnerability
                   2969:     ID (CAN, CVE).
1.160     brook    2970: 
1.184     rillig   2971:   * Patches that change source code should mention the platform and other
                   2972:     environment (for example, the compiler) that the patch is needed for.
1.160     brook    2973: 
1.184     rillig   2974: The patch should be commented so that any developer who knows the code of the
                   2975: application can make some use of the patch. Special care should be taken for
                   2976: the upstream developers, since we generally want that they accept our patches,
                   2977: so we have less work in the future.
1.160     brook    2978: 
1.184     rillig   2979: 12.3.2. Creating patch files
1.160     brook    2980: 
1.184     rillig   2981: One important thing to mention is to pay attention that no RCS IDs get stored
                   2982: in the patch files, as these will cause problems when later checked into the
                   2983: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
                   2984: avoid these problems.
1.160     brook    2985: 
1.184     rillig   2986: For even more automation, we recommend using mkpatches from the same package to
1.222     gutterid 2987: make a whole set of patches. You just have to back up files before you edit
                   2988: them to filename.orig, e.g., with cp -p filename filename.orig or, easier, by
                   2989: using pkgvi again from the same package. If you upgrade a package this way, you
                   2990: can easily compare the new set of patches with the previously existing one with
1.184     rillig   2991: patchdiff. The files in patches are replaced by new files, so carefully check
                   2992: if you want to take all the changes.
1.160     brook    2993: 
1.184     rillig   2994: When you have finished a package, remember to generate the checksums for the
                   2995: patch files by using the make makepatchsum command, see Section 12.2,
                   2996: "distinfo".
1.1       dsieger  2997: 
1.184     rillig   2998: When adding a patch that corrects a problem in the distfile (rather than e.g.
                   2999: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
                   3000: report to the maintainer. This benefits non-pkgsrc users of the package, and
                   3001: usually makes it possible to remove the patch in future version.
1.1       dsieger  3002: 
1.184     rillig   3003: The file names of the patch files are usually of the form patch-
                   3004: path_to_file__with__underscores.c. Many packages still use the previous
                   3005: convention patch-[a-z][a-z], but new patches should be of the form containing
                   3006: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
                   3007: automatically.
1.1       dsieger  3008: 
1.222     gutterid 3009: When updating pre-existing patch files, if a file uses the old patch-[a-z][a-z]
                   3010: convention, it's best not to change it to the new form, as that will just cause
                   3011: churn that makes it harder to track changes to patching over time. Similarly,
                   3012: if a patch now applies at different line offsets, but still applies cleanly
                   3013: as-is, there's no need to update it, as that also unnecessarily complicates the
                   3014: patch history.
                   3015: 
1.184     rillig   3016: 12.3.3. Sources where the patch files come from
1.1       dsieger  3017: 
1.184     rillig   3018: If you want to share patches between multiple packages in pkgsrc, e.g. because
                   3019: they use the same distfiles, set PATCHDIR to the path where the patch files can
                   3020: be found, e.g.:
1.1       dsieger  3021: 
1.184     rillig   3022: PATCHDIR=       ../../editors/xemacs/patches
1.1       dsieger  3023: 
1.184     rillig   3024: Patch files that are distributed by the author or other maintainers can be
                   3025: listed in PATCHFILES.
1.1       dsieger  3026: 
1.184     rillig   3027: If it is desired to store any patches that should not be committed into pkgsrc,
                   3028: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
                   3029: directory tree there is expected to have the same "category/package" structure
                   3030: as pkgsrc, and patches are expected to be stored inside these dirs (also known
                   3031: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
                   3032: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
                   3033: files in the named directory are expected to be patch files, and they are
                   3034: applied after pkgsrc patches are applied.
1.1       dsieger  3035: 
1.184     rillig   3036: 12.3.4. Patching guidelines
1.1       dsieger  3037: 
1.184     rillig   3038: When fixing a portability issue in the code do not use preprocessor magic to
                   3039: check for the current operating system nor platform. Doing so hurts portability
                   3040: to other platforms because the OS-specific details are not abstracted
                   3041: appropriately.
1.1       dsieger  3042: 
1.184     rillig   3043: The general rule to follow is: instead of checking for the operating system the
                   3044: application is being built on, check for the specific features you need. For
                   3045: example, instead of assuming that kqueue is available under NetBSD and using
                   3046: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
1.198     leot     3047: kqueue itself -- yes, this generally involves patching the configure script.
1.184     rillig   3048: There is absolutely nothing that prevents some OSes from adopting interfaces
                   3049: from other OSes (e.g. Linux implementing kqueue), something that the above
                   3050: checks cannot take into account.
1.1       dsieger  3051: 
1.184     rillig   3052: Of course, checking for features generally involves more work on the
                   3053: developer's side, but the resulting changes are cleaner and there are chances
                   3054: they will work on many other platforms. Not to mention that there are higher
                   3055: chances of being later integrated into the mainstream sources. Remember: It
                   3056: doesn't work unless it is right!
1.1       dsieger  3057: 
1.184     rillig   3058: Some typical examples:
1.121     sevan    3059: 
1.184     rillig   3060: Table 12.1. Patching examples
1.1       dsieger  3061: 
1.184     rillig   3062: +-------------------------------------------------------------------------------------------+
                   3063: |  Where  |        Incorrect         |                       Correct                        |
                   3064: |---------+--------------------------+------------------------------------------------------|
                   3065: |         |case ${target_os} in      |                                                      |
                   3066: |configure|netbsd*) have_kvm=yes ;;  |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
                   3067: |script   |*)       have_kvm=no  ;;  |                                                      |
                   3068: |         |esac                      |                                                      |
                   3069: |---------+--------------------------+------------------------------------------------------|
                   3070: |C source |#if defined(__NetBSD__)   |#if defined(HAVE_SYS_EVENT_H)                         |
                   3071: |file     |#  include <sys/event.h>  |#  include <sys/event.h>                              |
                   3072: |         |#endif                    |#endif                                                |
                   3073: |---------+--------------------------+------------------------------------------------------|
                   3074: |         |int                       |int                                                   |
                   3075: |         |monitor_file(...)         |monitor_file(...)                                     |
                   3076: |         |{                         |{                                                     |
                   3077: |         |#if defined(__NetBSD__)   |#if defined(HAVE_KQUEUE)                              |
                   3078: |C source |        int fd = kqueue();|        int fd = kqueue();                            |
                   3079: |file     |        ...               |        ...                                           |
                   3080: |         |#else                     |#else                                                 |
                   3081: |         |        ...               |        ...                                           |
                   3082: |         |#endif                    |#endif                                                |
                   3083: |         |}                         |}                                                     |
                   3084: +-------------------------------------------------------------------------------------------+
1.1       dsieger  3085: 
                   3086: 
1.184     rillig   3087: 12.3.5. Feedback to the author
1.1       dsieger  3088: 
1.184     rillig   3089: Always, always, always feed back any portability fixes or improvements you do
                   3090: to a package to the mainstream developers. This is the only way to get their
                   3091: attention on portability issues and to ensure that future versions can be built
                   3092: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
                   3093: get the fixes straight from the packaged code.
1.1       dsieger  3094: 
1.184     rillig   3095: This generally involves cleaning up the patches (because sometimes the patches
                   3096: that are added to pkgsrc are quick hacks), filing bug reports in the
                   3097: appropriate trackers for the projects and working with the mainstream authors
                   3098: to accept your changes. It is extremely important that you do it so that the
                   3099: packages in pkgsrc are kept simple and thus further changes can be done without
                   3100: much hassle.
1.1       dsieger  3101: 
1.184     rillig   3102: When you have done this, please add a URL to the upstream bug report to the
                   3103: patch comment.
1.1       dsieger  3104: 
1.184     rillig   3105: Support the idea of free software!
1.1       dsieger  3106: 
1.184     rillig   3107: 12.4. Other mandatory files
1.1       dsieger  3108: 
1.184     rillig   3109: DESCR
1.1       dsieger  3110: 
1.184     rillig   3111:     A multi-line description of the piece of software. This should include any
                   3112:     credits where they are due. Please bear in mind that others do not share
                   3113:     your sense of humour (or spelling idiosyncrasies), and that others will
                   3114:     read everything that you write here.
1.1       dsieger  3115: 
1.184     rillig   3116: PLIST
1.1       dsieger  3117: 
1.184     rillig   3118:     This file governs the files that are installed on your system: all the
                   3119:     binaries, manual pages, etc. There are other directives which may be
                   3120:     entered in this file, to control the creation and deletion of directories,
                   3121:     and the location of inserted files. See Chapter 19, PLIST issues for more
                   3122:     information.
1.1       dsieger  3123: 
1.184     rillig   3124: 12.5. Optional files
1.1       dsieger  3125: 
1.184     rillig   3126: 12.5.1. Files affecting the binary package
1.1       dsieger  3127: 
1.184     rillig   3128: INSTALL
1.1       dsieger  3129: 
1.184     rillig   3130:     This shell script is invoked twice by pkg_add(1). First time after package
                   3131:     extraction and before files are moved in place, the second time after the
                   3132:     files to install are moved in place. This can be used to do any custom
                   3133:     procedures not possible with @exec commands in PLIST. See pkg_add(1) and
                   3134:     pkg_create(1) for more information. See also Section 20.1, "Files and
                   3135:     directories outside the installation prefix". Please note that you can
                   3136:     modify variables in it easily by using FILES_SUBST in the package's
                   3137:     Makefile:
1.1       dsieger  3138: 
1.184     rillig   3139:     FILES_SUBST+=  SOMEVAR="somevalue"
1.1       dsieger  3140: 
1.184     rillig   3141:     replaces "@SOMEVAR@" with "somevalue" in the INSTALL. By default,
                   3142:     substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
                   3143:     few others, type make help topic=FILES_SUBST for a complete list.
1.1       dsieger  3144: 
1.184     rillig   3145: DEINSTALL
1.1       dsieger  3146: 
1.184     rillig   3147:     This script is executed before and after any files are removed. It is this
                   3148:     script's responsibility to clean up any additional messy details around the
                   3149:     package's installation, since all pkg_delete knows is how to delete the
                   3150:     files created in the original distribution. See pkg_delete(1) and
                   3151:     pkg_create(1) for more information. The same methods to replace variables
                   3152:     can be used as for the INSTALL file.
1.1       dsieger  3153: 
1.184     rillig   3154: MESSAGE
1.1       dsieger  3155: 
1.198     leot     3156:     This file is displayed after installation of the package. While this was
                   3157:     used often in the past, it has two problems: the display will be missed if
                   3158:     many packages are intalled at once, and the person installing the package
                   3159:     and the one using or configuring it may be different. It should therefore
                   3160:     be used only in exceptional circumstances where lasting negative
                   3161:     consequences would result from someone not reading it.
                   3162: 
                   3163:     MESSAGE should not be used for:
                   3164: 
1.232     gutterid 3165:       o exhortations to read the documentation
1.198     leot     3166: 
1.232     gutterid 3167:       o reminders to install rc.d files and set variables
1.198     leot     3168: 
1.232     gutterid 3169:       o anything that should be explained in the installation/configuration
1.198     leot     3170:         documentation that should come with the package
                   3171: 
                   3172:     If the documentation provided by upstream needs enhancing, create e.g.
                   3173:     files/README.pkgsrc and install it in the package's documentation
                   3174:     directory.
                   3175: 
                   3176:     Note that MESSAGE is shown for all operating systems and all init systems.
                   3177:     If a MESSAGE is necessary, it should be narrowed to only those operating
                   3178:     systems and init systems to which it applies.
                   3179: 
                   3180:     Note that you can modify variables in it easily by using MESSAGE_SUBST in
                   3181:     the package's Makefile:
1.1       dsieger  3182: 
1.184     rillig   3183:     MESSAGE_SUBST+=  SOMEVAR="somevalue"
1.1       dsieger  3184: 
1.184     rillig   3185:     replaces "${SOMEVAR}" with "somevalue" in MESSAGE. By default, substitution
                   3186:     is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11BASE,
                   3187:     PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1       dsieger  3188: 
1.184     rillig   3189:     You can display a different or additional files by setting the MESSAGE_SRC
                   3190:     variable. Its default is MESSAGE, if the file exists.
1.1       dsieger  3191: 
1.184     rillig   3192: ALTERNATIVES
1.1       dsieger  3193: 
1.184     rillig   3194:     This file is used by the alternatives framework. It creates, configures,
                   3195:     and destroys generic wrappers used to run programs with similar interfaces.
                   3196:     See pkg_alternatives(8) from pkgtools/pkg_alternatives for more
                   3197:     information.
1.1       dsieger  3198: 
1.184     rillig   3199:     Each line of the file contains two filenames, first the wrapper and then
                   3200:     the alternative provided by the package. Both paths are relative to PREFIX.
1.1       dsieger  3201: 
1.184     rillig   3202: 12.5.2. Files affecting the build process
1.1       dsieger  3203: 
1.184     rillig   3204: Makefile.common
1.1       dsieger  3205: 
1.184     rillig   3206:     This file contains arbitrary things that could also go into a Makefile, but
                   3207:     its purpose is to be used by more than one package. This file should only
                   3208:     be used when the packages that will use the file are known in advance. For
                   3209:     other purposes it is often better to write a *.mk file and give it a good
                   3210:     name that describes what it does.
1.1       dsieger  3211: 
1.184     rillig   3212: buildlink3.mk
1.1       dsieger  3213: 
1.184     rillig   3214:     This file contains the dependency information for the buildlink3 framework
                   3215:     (see Chapter 18, Buildlink methodology).
1.1       dsieger  3216: 
1.184     rillig   3217: hacks.mk
1.1       dsieger  3218: 
1.184     rillig   3219:     This file contains workarounds for compiler bugs and similar things. It is
                   3220:     included automatically by the pkgsrc infrastructure, so you don't need an
                   3221:     extra .include line for it.
1.1       dsieger  3222: 
1.184     rillig   3223: options.mk
1.1       dsieger  3224: 
1.184     rillig   3225:     This file contains the code for the package-specific options (see
                   3226:     Chapter 16, Options handling) that can be selected by the user. If a
                   3227:     package has only one or two options, it is equally acceptable to put the
                   3228:     code directly into the Makefile.
1.1       dsieger  3229: 
1.184     rillig   3230: 12.5.3. Files affecting nothing at all
1.1       dsieger  3231: 
1.184     rillig   3232: README*
1.1       dsieger  3233: 
1.184     rillig   3234:     These files do not take place in the creation of a package and thus are
                   3235:     purely informative to the package developer.
1.1       dsieger  3236: 
1.184     rillig   3237: TODO
1.1       dsieger  3238: 
1.184     rillig   3239:     This file contains things that need to be done to make the package even
                   3240:     better.
1.1       dsieger  3241: 
1.184     rillig   3242: 12.6. work*
1.1       dsieger  3243: 
1.184     rillig   3244: When you type make, the distribution files are unpacked into the directory
                   3245: denoted by WRKDIR. It can be removed by running make clean. Besides the
                   3246: sources, this directory is also used to keep various timestamp files. The
                   3247: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
                   3248: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
1.1       dsieger  3249: 
1.184     rillig   3250: 12.7. files/*
1.80      wiz      3251: 
1.184     rillig   3252: If you have any files that you wish to be placed in the package prior to
                   3253: configuration or building, you can place these files here and use a ${CP}
                   3254: command in the "post-extract" target to achieve this.
1.1       dsieger  3255: 
1.184     rillig   3256: If you want to share files in this way with other packages, set the FILESDIR
                   3257: variable to point to the other package's files directory, e.g.:
1.1       dsieger  3258: 
1.184     rillig   3259: FILESDIR=       ../../editors/xemacs/files
1.14      jmcneill 3260: 
1.184     rillig   3261: Chapter 13. The build process
1.1       dsieger  3262: 
1.184     rillig   3263: Table of Contents
1.1       dsieger  3264: 
1.184     rillig   3265: 13.1. Introduction
                   3266: 13.2. Program location
                   3267: 13.3. Directories used during the build process
                   3268: 13.4. Running a phase
                   3269: 13.5. The fetch phase
                   3270:     13.5.1. What to fetch and where to get it from
                   3271:     13.5.2. How are the files fetched?
                   3272: 13.6. The checksum phase
                   3273: 13.7. The extract phase
                   3274: 13.8. The patch phase
                   3275: 13.9. The tools phase
                   3276: 13.10. The wrapper phase
                   3277: 13.11. The configure phase
                   3278: 13.12. The build phase
                   3279: 13.13. The test phase
                   3280: 13.14. The install phase
                   3281: 13.15. The package phase
                   3282: 13.16. Cleaning up
                   3283: 13.17. Other helpful targets
1.1       dsieger  3284: 
1.184     rillig   3285: 13.1. Introduction
1.122     leot     3286: 
1.184     rillig   3287: This chapter gives a detailed description on how a package is built. Building a
                   3288: package is separated into different phases (for example fetch, build, install),
                   3289: all of which are described in the following sections. Each phase is split into
                   3290: so-called stages, which take the name of the containing phase, prefixed by one
                   3291: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
                   3292: actual work is done in the do-* stages.
1.1       dsieger  3293: 
1.184     rillig   3294: Never override the regular targets (like fetch), if you have to, override the
                   3295: do-* ones instead.
1.1       dsieger  3296: 
1.184     rillig   3297: The basic steps for building a program are always the same. First the program's
                   3298: source (distfile) must be brought to the local system and then extracted. After
                   3299: any pkgsrc-specific patches to compile properly are applied, the software can
                   3300: be configured, then built (usually by compiling), and finally the generated
                   3301: binaries, etc. can be put into place on the system.
1.1       dsieger  3302: 
1.184     rillig   3303: To get more details about what is happening at each step, you can set the
                   3304: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
                   3305: more details about the patch step.
1.1       dsieger  3306: 
1.184     rillig   3307: 13.2. Program location
1.1       dsieger  3308: 
1.184     rillig   3309: Before outlining the process performed by the NetBSD package system in the next
                   3310: section, here's a brief discussion on where programs are installed, and which
                   3311: variables influence this.
1.1       dsieger  3312: 
1.184     rillig   3313: The automatic variable PREFIX indicates where all files of the final program
                   3314: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
                   3315: pkgs in the cross category. The value of PREFIX needs to be put into the
                   3316: various places in the program's source where paths to these files are encoded.
                   3317: See Section 12.3, "patches/*" and Section 21.3.1, "Shared libraries - libtool"
                   3318: for more details.
1.1       dsieger  3319: 
1.184     rillig   3320: When choosing which of these variables to use, follow the following rules:
1.1       dsieger  3321: 
1.184     rillig   3322:   * PREFIX always points to the location where the current pkg will be
                   3323:     installed. When referring to a pkg's own installation path, use "${PREFIX}"
                   3324:     .
1.1       dsieger  3325: 
1.223     nia      3326:   * LOCALBASE is where all pkgs are installed. If you need to construct a -I or
                   3327:     -L argument to the compiler to find includes and libraries installed by
                   3328:     another pkg, use "${LOCALBASE}". The name LOCALBASE stems from FreeBSD,
                   3329:     which installed all packages in /usr/local. As pkgsrc leaves /usr/local for
                   3330:     the system administrator, this variable is a misnomer.
1.1       dsieger  3331: 
1.184     rillig   3332:   * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
                   3333:     installed. When looking for standard X11 includes (not those installed by a
                   3334:     package), use "${X11BASE}".
1.1       dsieger  3335: 
1.184     rillig   3336:   * X11-based packages using imake must set USE_IMAKE to be installed correctly
                   3337:     under LOCALBASE.
1.1       dsieger  3338: 
1.184     rillig   3339:   * Within ${PREFIX}, packages should install files according to hier(7), with
                   3340:     the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
                   3341:     man.
1.1       dsieger  3342: 
1.184     rillig   3343: 13.3. Directories used during the build process
1.2       rillig   3344: 
1.184     rillig   3345: When building a package, various directories are used to store source files,
                   3346: temporary files, pkgsrc-internal files, and so on. These directories are
                   3347: explained here.
1.1       dsieger  3348: 
1.184     rillig   3349: Some of the directory variables contain relative pathnames. There are two
                   3350: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
                   3351: used for directories that are pkgsrc-specific. WRKSRC is used for directories
                   3352: inside the package itself.
1.1       dsieger  3353: 
1.184     rillig   3354: PKGSRCDIR
1.1       dsieger  3355: 
1.184     rillig   3356:     This is an absolute pathname that points to the pkgsrc root directory.
                   3357:     Generally, you don't need it.
1.1       dsieger  3358: 
1.184     rillig   3359: PKGDIR
1.1       dsieger  3360: 
1.184     rillig   3361:     This is an absolute pathname that points to the current package.
1.1       dsieger  3362: 
1.184     rillig   3363: PKGPATH
1.1       dsieger  3364: 
1.184     rillig   3365:     This is a pathname relative to PKGSRCDIR that points to the current
1.228     gutterid 3366:     package. It is defined after including bsd.prefs.mk and can be used in
                   3367:     makefile fragments that are used by several packages to distinguish between
                   3368:     these packages. Other variables that would serve the same purpose are
                   3369:     PKGBASE and PKGNAME, but these are only defined after including bsd.pkg.mk,
                   3370:     which is too late.
                   3371: 
                   3372:     In mk.conf, the pkgsrc user can use PKGPATH to tweak variables like
                   3373:     MAKE_JOBS and CFLAGS.
1.1       dsieger  3374: 
1.184     rillig   3375: WRKDIR
1.1       dsieger  3376: 
1.184     rillig   3377:     This is an absolute pathname pointing to the directory where all work takes
                   3378:     place. The distfiles are extracted to this directory. It also contains
                   3379:     temporary directories and log files used by the various pkgsrc frameworks,
                   3380:     like buildlink or the wrappers.
1.1       dsieger  3381: 
1.184     rillig   3382: WRKSRC
1.1       dsieger  3383: 
1.184     rillig   3384:     This is an absolute pathname pointing to the directory where the distfiles
                   3385:     are extracted. It is usually a direct subdirectory of WRKDIR, and often
                   3386:     it's the only directory entry that isn't hidden. This variable may be
                   3387:     changed by a package Makefile.
1.1       dsieger  3388: 
1.184     rillig   3389: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
                   3390: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
                   3391: created in the pkgsrc entry's directory. If users would like to have their
                   3392: pkgsrc trees behave in a read-only manner, then the value of
                   3393: CREATE_WRKDIR_SYMLINK should be set to no.
1.1       dsieger  3394: 
1.184     rillig   3395: 13.4. Running a phase
1.1       dsieger  3396: 
1.184     rillig   3397: You can run a particular phase by typing make phase, where phase is the name of
                   3398: the phase. This will automatically run all phases that are required for this
                   3399: phase. The default phase is build, that is, when you run make without
                   3400: parameters in a package directory, the package will be built, but not
                   3401: installed.
1.1       dsieger  3402: 
1.184     rillig   3403: 13.5. The fetch phase
1.1       dsieger  3404: 
1.184     rillig   3405: The first step in building a package is to fetch the distribution files
                   3406: (distfiles) from the sites that are providing them. This is the task of the 
                   3407: fetch phase.
1.25      wiz      3408: 
1.184     rillig   3409: 13.5.1. What to fetch and where to get it from
1.1       dsieger  3410: 
1.184     rillig   3411: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
                   3412: name is derived from the DISTNAME variable, is fetched. The more complicated
                   3413: cases are described below.
1.1       dsieger  3414: 
1.184     rillig   3415: The variable DISTFILES specifies the list of distfiles that have to be fetched.
                   3416: Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
                   3417: {EXTRACT_SUFX}, so that most packages don't need to define it at all.
                   3418: EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
                   3419: your package requires additional distfiles to the default one, you cannot just
                   3420: append the additional filenames using the += operator, but you have write for
                   3421: example:
1.1       dsieger  3422: 
1.184     rillig   3423: DISTFILES=      ${DEFAULT_DISTFILES} additional-files.tar.gz
1.1       dsieger  3424: 
1.184     rillig   3425: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
                   3426: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
                   3427: can set SITES.distfile to the list of URLs where the file distfile (including
                   3428: the suffix) can be found.
1.1       dsieger  3429: 
1.184     rillig   3430: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
                   3431: DISTFILES+=     foo-file.tar.gz
                   3432: SITES.foo-file.tar.gz= \
                   3433: https://www.somewhere.com/somehow/ \
                   3434: https://www.somewhereelse.com/mirror/somehow/
1.1       dsieger  3435: 
1.184     rillig   3436: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
                   3437: gets the name of each distfile appended to it, without an intermediate slash.
                   3438: Therefore, all site values have to end with a slash or other separator
                   3439: character. This allows for example to set MASTER_SITES to a URL of a CGI script
                   3440: that gets the name of the distfile as a parameter. In this case, the definition
                   3441: would look like:
1.1       dsieger  3442: 
1.184     rillig   3443: MASTER_SITES=   https://www.example.com/download.cgi?file=
1.1       dsieger  3444: 
1.184     rillig   3445: The exception to this rule are URLs starting with a dash. In that case the URL
                   3446: is taken as is, fetched and the result stored under the name of the distfile.
                   3447: You can use this style for the case when the download URL style does not match
                   3448: the above common case. For example, if permanent download URL is a redirector
                   3449: to the real download URL, or the download file name is offered by an HTTP
                   3450: Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
                   3451: created instead of the default v1.0.0.tar.gz.
1.1       dsieger  3452: 
1.184     rillig   3453: DISTNAME=       foo-1.0.0
                   3454: MASTER_SITES=   -https://www.example.com/archive/v1.0.0.tar.gz
1.29      wiz      3455: 
1.184     rillig   3456: There are some predefined values for MASTER_SITES, which can be used in
                   3457: packages. The names of the variables should speak for themselves.
1.29      wiz      3458: 
1.225     gutterid 3459: MASTER_SITE_APACHE        MASTER_SITE_BACKUP
                   3460: MASTER_SITE_CRATESIO      MASTER_SITE_CYGWIN
                   3461: MASTER_SITE_DEBIAN        MASTER_SITE_FREEBSD
                   3462: MASTER_SITE_FREEBSD_LOCAL MASTER_SITE_GENTOO
                   3463: MASTER_SITE_GITHUB        MASTER_SITE_GITLAB
                   3464: MASTER_SITE_GNOME         MASTER_SITE_GNU
                   3465: MASTER_SITE_GNUSTEP       MASTER_SITE_HASKELL_HACKAGE
                   3466: MASTER_SITE_IFARCHIVE     MASTER_SITE_KDE
                   3467: MASTER_SITE_MOZILLA       MASTER_SITE_MOZILLA_ALL
                   3468: MASTER_SITE_MYSQL         MASTER_SITE_NETLIB
                   3469: MASTER_SITE_OPENBSD       MASTER_SITE_OPENOFFICE
                   3470: MASTER_SITE_OSDN          MASTER_SITE_PERL_CPAN
                   3471: MASTER_SITE_PGSQL         MASTER_SITE_PYPI
                   3472: MASTER_SITE_RUBYGEMS      MASTER_SITE_R_CRAN
                   3473: MASTER_SITE_SOURCEFORGE   MASTER_SITE_SUNSITE
                   3474: MASTER_SITE_SUSE          MASTER_SITE_TEX_CTAN
                   3475: MASTER_SITE_XCONTRIB      MASTER_SITE_XEMACS
                   3476: MASTER_SITE_XORG           
1.1       dsieger  3477: 
1.184     rillig   3478: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
                   3479: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
                   3480: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
                   3481: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
                   3482: distfiles/LOCAL_PORTS/.
1.1       dsieger  3483: 
1.184     rillig   3484: If you choose one of these predefined sites, you may want to specify a
                   3485: subdirectory of that site. Since these macros may expand to more than one
                   3486: actual site, you must use the following construct to specify a subdirectory:
1.1       dsieger  3487: 
1.184     rillig   3488: MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
                   3489: MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
1.1       dsieger  3490: 
1.184     rillig   3491: Note the trailing slash after the subdirectory name.
1.1       dsieger  3492: 
1.184     rillig   3493: 13.5.2. How are the files fetched?
1.1       dsieger  3494: 
1.184     rillig   3495: The fetch phase makes sure that all the distfiles exist in a local directory
                   3496: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
                   3497: are fetched using commands of the form
1.1       dsieger  3498: 
1.184     rillig   3499: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
1.1       dsieger  3500: 
1.184     rillig   3501: where ${site} varies through several possibilities in turn: first,
                   3502: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
                   3503: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
                   3504: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
                   3505: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
                   3506: MASTER_SORT_AWK or MASTER_SORT_REGEX.
1.1       dsieger  3507: 
1.184     rillig   3508: The specific command and arguments used depend on the FETCH_USING parameter.
                   3509: The example above is for FETCH_USING=custom.
1.66      asau     3510: 
1.184     rillig   3511: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
                   3512: target to mirror the distfiles, if they are freely distributable. Packages
                   3513: setting NO_SRC_ON_FTP (usually to "${RESTRICTED}") will not have their
                   3514: distfiles mirrored.
1.1       dsieger  3515: 
1.184     rillig   3516: 13.6. The checksum phase
1.1       dsieger  3517: 
1.184     rillig   3518: After the distfile(s) are fetched, their checksum is generated and compared
                   3519: with the checksums stored in the distinfo file. If the checksums don't match,
                   3520: the build is aborted. This is to ensure the same distfile is used for building,
                   3521: and that the distfile wasn't changed, e.g. by some malign force, deliberately
                   3522: changed distfiles on the master distribution site or network lossage.
1.1       dsieger  3523: 
1.184     rillig   3524: 13.7. The extract phase
1.1       dsieger  3525: 
1.184     rillig   3526: When the distfiles are present on the local system, they need to be extracted,
                   3527: as they usually come in the form of some compressed archive format.
1.1       dsieger  3528: 
1.184     rillig   3529: By default, all DISTFILES are extracted. If you only need some of them, you can
                   3530: set the EXTRACT_ONLY variable to the list of those files.
1.1       dsieger  3531: 
1.184     rillig   3532: Extracting the files is usually done by a little program, mk/extract/extract,
                   3533: which already knows how to extract various archive formats, so most likely you
                   3534: will not need to change anything here. But if you need, the following variables
                   3535: may help you:
1.1       dsieger  3536: 
1.184     rillig   3537: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
1.1       dsieger  3538: 
1.184     rillig   3539:     Use these variables to override the default options for an extract command,
                   3540:     which are defined in mk/extract/extract.
1.1       dsieger  3541: 
1.184     rillig   3542: EXTRACT_USING
1.1       dsieger  3543: 
1.184     rillig   3544:     This variable can be set to bsdtar, gtar, nbtar (which is the default
                   3545:     value), pax, or an absolute pathname pointing to the command with which tar
                   3546:     archives should be extracted. It is preferred to choose bsdtar over gtar if
                   3547:     NetBSD's pax-as-tar is not good enough.
1.1       dsieger  3548: 
1.184     rillig   3549: If the extract program doesn't serve your needs, you can also override the
                   3550: EXTRACT_CMD variable, which holds the command used for extracting the files.
                   3551: This command is executed in the ${WRKSRC} directory. During execution of this
                   3552: command, the shell variable extract_file holds the absolute pathname of the
                   3553: file that is going to be extracted.
1.1       dsieger  3554: 
1.184     rillig   3555: And if that still does not suffice, you can override the do-extract target in
                   3556: the package Makefile.
1.1       dsieger  3557: 
1.184     rillig   3558: 13.8. The patch phase
1.1       dsieger  3559: 
1.184     rillig   3560: After extraction, all the patches named by the PATCHFILES, those present in the
                   3561: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
                   3562: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
                   3563: are uncompressed before they are applied, files ending in .orig or .rej are
                   3564: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
                   3565: Section 12.3, "patches/*" for more details.
1.1       dsieger  3566: 
1.184     rillig   3567: By default patch(1) is given special arguments to make it fail if the expected
                   3568: text from the patch context is not found in the patched file. If that happens,
                   3569: fix the patch file by comparing it with the actual text in the file to be
                   3570: patched.
1.1       dsieger  3571: 
1.184     rillig   3572: 13.9. The tools phase
1.1       dsieger  3573: 
1.184     rillig   3574: This is covered in Chapter 17, Tools needed for building or running.
1.1       dsieger  3575: 
1.184     rillig   3576: 13.10. The wrapper phase
1.1       dsieger  3577: 
1.184     rillig   3578: This phase creates wrapper programs for the compilers and linkers. The
                   3579: following variables can be used to tweak the wrappers.
1.1       dsieger  3580: 
1.184     rillig   3581: ECHO_WRAPPER_MSG
1.1       dsieger  3582: 
1.184     rillig   3583:     The command used to print progress messages. Does nothing by default. Set
                   3584:     to ${ECHO} to see the progress messages.
1.1       dsieger  3585: 
1.184     rillig   3586: WRAPPER_DEBUG
1.1       dsieger  3587: 
1.184     rillig   3588:     This variable can be set to yes (default) or no, depending on whether you
                   3589:     want additional information in the wrapper log file.
1.1       dsieger  3590: 
1.184     rillig   3591: WRAPPER_UPDATE_CACHE
1.1       dsieger  3592: 
1.184     rillig   3593:     This variable can be set to yes or no, depending on whether the wrapper
                   3594:     should use its cache, which will improve the speed. The default value is
                   3595:     yes, but is forced to no if the platform does not support it.
1.1       dsieger  3596: 
1.184     rillig   3597: WRAPPER_REORDER_CMDS
1.1       dsieger  3598: 
1.184     rillig   3599:     A list of reordering commands. A reordering command has the form reorder:l:
                   3600:     lib1:lib2. It ensures that that -llib1 occurs before -llib2.
1.1       dsieger  3601: 
1.184     rillig   3602: 13.11. The configure phase
1.1       dsieger  3603: 
1.184     rillig   3604: Most pieces of software need information on the header files, system calls, and
                   3605: library routines which are available on the platform they run on. The process
                   3606: of determining this information is known as configuration, and is usually
                   3607: automated. In most cases, a script is supplied with the distfiles, and its
                   3608: invocation results in generation of header files, Makefiles, etc.
1.1       dsieger  3609: 
1.184     rillig   3610: If the package contains a configure script, this can be invoked by setting
                   3611: HAS_CONFIGURE to "yes". If the configure script is a GNU autoconf script, you
1.187     rillig   3612: should set GNU_CONFIGURE to "yes" instead.
1.1       dsieger  3613: 
1.187     rillig   3614: In the do-configure stage, a rough equivalent of the following command is run.
                   3615: See mk/configure/configure.mk, target do-configure-script for the exact
                   3616: definition.
                   3617: 
                   3618: .for dir in ${CONFIGURE_DIRS}
                   3619:         cd ${WRKSRC} && cd ${dir} \
                   3620:         && env ${CONFIGURE_ENV} \
                   3621:             ${CONFIG_SHELL} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
1.184     rillig   3622: .endfor
1.1       dsieger  3623: 
1.184     rillig   3624: CONFIGURE_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In
                   3625: each of these directories, the configure script is run with the environment
                   3626: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
                   3627: CONFIGURE_SCRIPT (default: "./configure") and CONFIGURE_ARGS may all be changed
                   3628: by the package.
1.1       dsieger  3629: 
1.184     rillig   3630: If the program uses the Perl way of configuration (mainly Perl modules, but not
                   3631: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
                   3632: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
                   3633: (e.g., MAKE_PARAMS+=foo=bar
1.1       dsieger  3634: 
1.184     rillig   3635: If the program uses an Imakefile for configuration, the appropriate steps can
                   3636: be invoked by setting USE_IMAKE to "yes". If you only need xmkmf, add it to
                   3637: USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
                   3638: SCRIPTS_ENV variable.
1.1       dsieger  3639: 
1.184     rillig   3640: If the program uses cmake for configuration, the appropriate steps can be
1.233     wiz      3641: invoked by including ../../devel/cmake/build.mk. You can add variables to
                   3642: cmake's environment by adding them to the CONFIGURE_ENV variable and arguments
                   3643: to cmake by adding them to the CMAKE_ARGS variable. If you want to add
                   3644: arguments only for particular stages, you can use the CMAKE_CONFIGURE_ARGS,
                   3645: CMAKE_BUILD_ARGS, and CMAKE_INSTALL_ARGS variables. You can set the
                   3646: CONFIGURE_DIRS variable to the directories in which CMake should be run,
                   3647: relative to WRKSRC. This defaults to to ".".
1.1       dsieger  3648: 
1.184     rillig   3649: If there is no configure step at all, set NO_CONFIGURE to "yes".
1.1       dsieger  3650: 
1.184     rillig   3651: 13.12. The build phase
1.1       dsieger  3652: 
1.187     rillig   3653: For building a package, a rough equivalent of the following code is executed;
                   3654: see mk/build/build.mk, target do-build for the exact definition.
1.154     rillig   3655: 
1.187     rillig   3656: .for dir in ${BUILD_DIRS}
                   3657:         cd ${WRKSRC} && cd ${dir} \
1.184     rillig   3658:         && env ${MAKE_ENV} \
1.187     rillig   3659:             ${MAKE_PROGRAM} ${MAKE_FLAGS} ${BUILD_MAKE_FLAGS} \
1.184     rillig   3660:                 -f ${MAKE_FILE} \
                   3661:                 ${BUILD_TARGET}
                   3662: .endfor
1.1       dsieger  3663: 
1.184     rillig   3664: BUILD_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In each of
                   3665: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
                   3666: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
                   3667: and BUILD_TARGET may all be changed by the package.
1.1       dsieger  3668: 
1.184     rillig   3669: The default value of MAKE_PROGRAM is "gmake" if USE_TOOLS contains "gmake", "
                   3670: make" otherwise. The default value of MAKE_FILE is "Makefile", and BUILD_TARGET
                   3671: defaults to "all".
1.1       dsieger  3672: 
1.184     rillig   3673: If there is no build step at all, set NO_BUILD to "yes".
1.1       dsieger  3674: 
1.184     rillig   3675: 13.13. The test phase
1.1       dsieger  3676: 
1.184     rillig   3677: [TODO]
1.1       dsieger  3678: 
1.184     rillig   3679: 13.14. The install phase
1.1       dsieger  3680: 
1.184     rillig   3681: Once the build stage has completed, the final step is to install the software
                   3682: in public directories, so users can access the programs and files.
1.1       dsieger  3683: 
1.187     rillig   3684: In the install phase, a rough equivalent of the following code is executed; see
                   3685: mk/install/install.mk, target do-install for the exact definition.
                   3686: Additionally, before and after this code, several consistency checks are run
                   3687: against the files-to-be-installed, see mk/check/*.mk for details.
                   3688: 
                   3689: .for dir in ${INSTALL_DIRS}
                   3690:         cd ${WRKSRC} && cd ${dir} \
                   3691:         && env ${INSTALL_ENV} ${MAKE_ENV} \
                   3692:             ${MAKE_PROGRAM} ${MAKE_FLAGS} ${INSTALL_MAKE_FLAGS} \
                   3693:                 -f ${MAKE_FILE} ${INSTALL_TARGET}
1.184     rillig   3694: .endfor
1.1       dsieger  3695: 
1.184     rillig   3696: The variable's meanings are analogous to the ones in the build phase.
                   3697: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is "install" by default,
                   3698: plus "install.man" if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
                   3699: defined.
1.1       dsieger  3700: 
1.184     rillig   3701: In the install phase, the following variables are useful. They are all
                   3702: variations of the install(1) command that have the owner, group and permissions
                   3703: preset. INSTALL is the plain install command. The specialized variants,
                   3704: together with their intended use, are:
1.1       dsieger  3705: 
1.184     rillig   3706: INSTALL_PROGRAM_DIR
1.1       dsieger  3707: 
1.184     rillig   3708:     directories that contain binaries
1.1       dsieger  3709: 
1.184     rillig   3710: INSTALL_SCRIPT_DIR
1.1       dsieger  3711: 
1.184     rillig   3712:     directories that contain scripts
1.1       dsieger  3713: 
1.184     rillig   3714: INSTALL_LIB_DIR
1.1       dsieger  3715: 
1.184     rillig   3716:     directories that contain shared and static libraries
1.1       dsieger  3717: 
1.184     rillig   3718: INSTALL_DATA_DIR
1.108     rillig   3719: 
1.184     rillig   3720:     directories that contain data files
1.108     rillig   3721: 
1.184     rillig   3722: INSTALL_MAN_DIR
1.108     rillig   3723: 
1.184     rillig   3724:     directories that contain man pages
1.108     rillig   3725: 
1.184     rillig   3726: INSTALL_GAME_DIR
1.108     rillig   3727: 
1.184     rillig   3728:     directories that contain data files for games
1.108     rillig   3729: 
1.184     rillig   3730: INSTALL_PROGRAM
1.108     rillig   3731: 
1.184     rillig   3732:     binaries that can be stripped from debugging symbols
1.108     rillig   3733: 
1.184     rillig   3734: INSTALL_SCRIPT
1.108     rillig   3735: 
1.184     rillig   3736:     binaries that cannot be stripped
1.108     rillig   3737: 
1.184     rillig   3738: INSTALL_GAME
1.108     rillig   3739: 
1.184     rillig   3740:     game binaries
1.108     rillig   3741: 
1.184     rillig   3742: INSTALL_LIB
1.108     rillig   3743: 
1.184     rillig   3744:     shared and static libraries
1.108     rillig   3745: 
1.184     rillig   3746: INSTALL_DATA
1.108     rillig   3747: 
1.184     rillig   3748:     data files
1.1       dsieger  3749: 
1.184     rillig   3750: INSTALL_GAME_DATA
1.1       dsieger  3751: 
1.184     rillig   3752:     data files for games
1.108     rillig   3753: 
1.184     rillig   3754: INSTALL_MAN
1.108     rillig   3755: 
1.184     rillig   3756:     man pages
1.1       dsieger  3757: 
1.184     rillig   3758: Some other variables are:
1.1       dsieger  3759: 
1.184     rillig   3760: INSTALL_UNSTRIPPED
1.1       dsieger  3761: 
1.184     rillig   3762:     If set to yes, do not run strip(1) when installing binaries. Any debugging
                   3763:     sections and symbols present in binaries will be preserved.
1.1       dsieger  3764: 
1.184     rillig   3765: INSTALLATION_DIRS
1.1       dsieger  3766: 
1.184     rillig   3767:     A list of directories relative to PREFIX that are created by pkgsrc at the
                   3768:     beginning of the install phase. The package is supposed to create all
                   3769:     needed directories itself before installing files to it and list all other
                   3770:     directories here.
1.1       dsieger  3771: 
1.184     rillig   3772: In the rare cases that a package shouldn't install anything, set NO_INSTALL to 
                   3773: "yes". This is mostly relevant for packages in the regress category.
1.1       dsieger  3774: 
1.184     rillig   3775: 13.15. The package phase
1.121     sevan    3776: 
1.184     rillig   3777: Once the install stage has completed, a binary package of the installed files
                   3778: can be built. These binary packages can be used for quick installation without
                   3779: previous compilation, e.g. by the make bin-install or by using pkg_add.
1.1       dsieger  3780: 
1.184     rillig   3781: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
                   3782: created in ${PACKAGES}/category, one for each category in the CATEGORIES
                   3783: variable. PACKAGES defaults to pkgsrc/packages.
1.1       dsieger  3784: 
1.184     rillig   3785: 13.16. Cleaning up
1.1       dsieger  3786: 
1.184     rillig   3787: Once you're finished with a package, you can clean the work directory by
                   3788: running make clean. If you want to clean the work directories of all
                   3789: dependencies too, use make clean-depends.
1.1       dsieger  3790: 
1.184     rillig   3791: 13.17. Other helpful targets
1.1       dsieger  3792: 
1.184     rillig   3793: pre/post-*
1.1       dsieger  3794: 
1.184     rillig   3795:     For any of the main targets described in the previous section (configure,
                   3796:     build, install, etc.), two auxiliary targets exist with "pre-" and "post-"
                   3797:     used as a prefix for the main target's name. These targets are invoked
                   3798:     before and after the main target is called, allowing extra configuration or
                   3799:     installation steps be performed from a package's Makefile, for example,
                   3800:     which a program's configure script or install target omitted.
                   3801: 
                   3802:     About 5% of the pkgsrc packages define their custom post-extract target,
                   3803:     another 5% define pre-configure, and 10% define post-install. The other pre
                   3804:     /post-* targets are defined even less often.
1.1       dsieger  3805: 
1.184     rillig   3806: do-*
1.182     leot     3807: 
1.184     rillig   3808:     Should one of the main targets do the wrong thing, and should there be no
                   3809:     variable to fix this, you can redefine it with the do-* target. (Note that
                   3810:     redefining the target itself instead of the do-* target is a bad idea, as
                   3811:     the pre-* and post-* targets won't be called anymore, etc.)
1.1       dsieger  3812: 
1.184     rillig   3813:     About 15% of the pkgsrc packages override the default do-install, the other
                   3814:     do-* targets are overridden even less often.
1.1       dsieger  3815: 
1.184     rillig   3816: reinstall
1.1       dsieger  3817: 
1.184     rillig   3818:     If you did a make install and you noticed some file was not installed
                   3819:     properly, you can repeat the installation with this target, which will
                   3820:     ignore the "already installed" flag.
1.1       dsieger  3821: 
1.184     rillig   3822:     This is the default value of DEPENDS_TARGET except in the case of make
                   3823:     update and make package, where the defaults are "package" and "update",
                   3824:     respectively.
1.1       dsieger  3825: 
1.184     rillig   3826: deinstall
1.1       dsieger  3827: 
1.184     rillig   3828:     This target does a pkg_delete(1) in the current directory, effectively
                   3829:     de-installing the package. The following variables can be used to tune the
                   3830:     behaviour:
1.1       dsieger  3831: 
1.184     rillig   3832:     PKG_VERBOSE
1.1       dsieger  3833: 
1.184     rillig   3834:         Add a "-v" to the pkg_delete(1) command.
1.1       dsieger  3835: 
1.184     rillig   3836:     DEINSTALLDEPENDS
1.1       dsieger  3837: 
1.184     rillig   3838:         Remove all packages that require (depend on) the given package. This
                   3839:         can be used to remove any packages that may have been pulled in by a
                   3840:         given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
                   3841:         pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding "-R
                   3842:         " to the pkg_delete(1) command line.
1.1       dsieger  3843: 
1.184     rillig   3844: bin-install
1.1       dsieger  3845: 
1.184     rillig   3846:     Install a binary package from local disk and via FTP from a list of sites
                   3847:     (see the BINPKG_SITES variable), and do a make package if no binary package
                   3848:     is available anywhere. The arguments given to pkg_add can be set via
                   3849:     BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
1.1       dsieger  3850: 
1.184     rillig   3851: install-clean
1.1       dsieger  3852: 
1.184     rillig   3853:     This target removes the state files for the "install" and later phases so
                   3854:     that the "install" target may be re-invoked. This can be used after editing
                   3855:     the PLIST to install the package without rebuilding it.
1.1       dsieger  3856: 
1.184     rillig   3857: build-clean
1.18      mishka   3858: 
1.184     rillig   3859:     This target removes the state files for the "build" and later phases so
                   3860:     that the "build" target may be re-invoked.
1.18      mishka   3861: 
1.184     rillig   3862: update
1.18      mishka   3863: 
1.184     rillig   3864:     This target causes the current package to be updated to the latest version.
                   3865:     The package and all depending packages first get de-installed, then current
                   3866:     versions of the corresponding packages get compiled and installed. This is
                   3867:     similar to manually noting which packages are currently installed, then
                   3868:     performing a series of make deinstall and make install (or whatever
                   3869:     UPDATE_TARGET is set to) for these packages.
1.18      mishka   3870: 
1.184     rillig   3871:     You can use the "update" target to resume package updating in case a
                   3872:     previous make update was interrupted for some reason. However, in this
                   3873:     case, make sure you don't call make clean or otherwise remove the list of
                   3874:     dependent packages in WRKDIR. Otherwise, you lose the ability to
                   3875:     automatically update the current package along with the dependent packages
                   3876:     you have installed.
1.121     sevan    3877: 
1.184     rillig   3878:     Resuming an interrupted make update will only work as long as the package
                   3879:     tree remains unchanged. If the source code for one of the packages to be
                   3880:     updated has been changed, resuming make update will most certainly fail!
1.1       dsieger  3881: 
1.184     rillig   3882:     The following variables can be used either on the command line or in
                   3883:     mk.conf to alter the behaviour of make update:
1.1       dsieger  3884: 
1.184     rillig   3885:     UPDATE_TARGET
1.1       dsieger  3886: 
1.184     rillig   3887:         Install target to recursively use for the updated package and the
                   3888:         dependent packages. Defaults to DEPENDS_TARGET if set, "install"
                   3889:         otherwise for make update. Other good targets are "package" or "
                   3890:         bin-install". Do not set this to "update" or you will get stuck in an
                   3891:         endless loop!
1.1       dsieger  3892: 
1.184     rillig   3893:     NOCLEAN
1.1       dsieger  3894: 
1.184     rillig   3895:         Don't clean up after updating. Useful if you want to leave the work
                   3896:         sources of the updated packages around for inspection or other
                   3897:         purposes. Be sure you eventually clean up the source tree (see the "
                   3898:         clean-update" target below) or you may run into troubles with old
                   3899:         source code still lying around on your next make or make update.
1.1       dsieger  3900: 
1.184     rillig   3901:     REINSTALL
1.1       dsieger  3902: 
1.184     rillig   3903:         Deinstall each package before installing (making DEPENDS_TARGET). This
                   3904:         may be necessary if the "clean-update" target (see below) was called
                   3905:         after interrupting a running make update.
1.1       dsieger  3906: 
1.184     rillig   3907:     DEPENDS_TARGET
1.1       dsieger  3908: 
1.184     rillig   3909:         Allows you to disable recursion and hardcode the target for packages.
                   3910:         The default is "update" for the update target, facilitating a recursive
                   3911:         update of prerequisite packages. Only set DEPENDS_TARGET if you want to
                   3912:         disable recursive updates. Use UPDATE_TARGET instead to just set a
                   3913:         specific target for each package to be installed during make update
                   3914:         (see above).
1.1       dsieger  3915: 
1.184     rillig   3916: clean-update
1.1       dsieger  3917: 
1.184     rillig   3918:     Clean the source tree for all packages that would get updated if make
                   3919:     update was called from the current directory. This target should not be
                   3920:     used if the current package (or any of its depending packages) have already
                   3921:     been de-installed (e.g., after calling make update) or you may lose some
                   3922:     packages you intended to update. As a rule of thumb: only use this target 
                   3923:     before the first time you run make update and only if you have a dirty
                   3924:     package tree (e.g., if you used NOCLEAN).
1.86      wiz      3925: 
1.184     rillig   3926:     If you are unsure about whether your tree is clean, you can either perform
                   3927:     a make clean at the top of the tree, or use the following sequence of
                   3928:     commands from the directory of the package you want to update (before
                   3929:     running make update for the first time, otherwise you lose all the packages
                   3930:     you wanted to update!):
1.86      wiz      3931: 
1.184     rillig   3932:     # make clean-update
                   3933:     # make clean CLEANDEPENDS=YES
                   3934:     # make update
1.86      wiz      3935: 
                   3936: 
1.184     rillig   3937:     The following variables can be used either on the command line or in
                   3938:     mk.conf to alter the behaviour of make clean-update:
1.86      wiz      3939: 
1.184     rillig   3940:     CLEAR_DIRLIST
1.86      wiz      3941: 
1.184     rillig   3942:         After make clean, do not reconstruct the list of directories to update
                   3943:         for this package. Only use this if make update successfully installed
                   3944:         all packages you wanted to update. Normally, this is done automatically
                   3945:         on make update, but may have been suppressed by the NOCLEAN variable
                   3946:         (see above).
1.1       dsieger  3947: 
1.184     rillig   3948: replace
1.1       dsieger  3949: 
1.184     rillig   3950:     Update the installation of the current package. This differs from update in
                   3951:     that it does not replace dependent packages. You will need to install
                   3952:     pkgtools/pkg_tarup for this target to work.
1.1       dsieger  3953: 
1.184     rillig   3954:     Be careful when using this target! There are no guarantees that dependent
                   3955:     packages will still work, in particular they will most certainly break if
                   3956:     you make replace a library package whose shared library major version
                   3957:     changed between your installed version and the new one. For this reason,
                   3958:     this target is not officially supported and only recommended for advanced
                   3959:     users.
1.1       dsieger  3960: 
1.184     rillig   3961: info
1.1       dsieger  3962: 
1.184     rillig   3963:     This target invokes pkg_info(1) for the current package. You can use this
                   3964:     to check which version of a package is installed.
1.86      wiz      3965: 
1.184     rillig   3966: index
1.1       dsieger  3967: 
1.184     rillig   3968:     This is a top-level command, i.e. it should be used in the pkgsrc
                   3969:     directory. It creates a database of all packages in the local pkgsrc tree,
                   3970:     including dependencies, comment, maintainer, and some other useful
                   3971:     information. Individual entries are created by running make describe in the
                   3972:     packages' directories. This index file is saved as pkgsrc/INDEX. It can be
                   3973:     displayed in verbose format by running make print-index. You can search in
                   3974:     it with make search key=something. You can extract a list of all packages
                   3975:     that depend on a particular one by running make show-deps PKG=somepackage.
1.1       dsieger  3976: 
1.184     rillig   3977:     Running this command takes a very long time, some hours even on fast
                   3978:     machines!
1.1       dsieger  3979: 
1.184     rillig   3980: readme
1.1       dsieger  3981: 
1.199     nia      3982:     This target generates a index.html file, which can be viewed using a
1.184     rillig   3983:     browser such as www/firefox or www/links. The generated files contain
                   3984:     references to any packages which are in the PACKAGES directory on the local
                   3985:     host. The generated files can be made to refer to URLs based on
                   3986:     FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
1.199     nia      3987:     index.html files which pointed to binary packages on the local machine, in
1.184     rillig   3988:     the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
                   3989:     FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
                   3990:     subdirectories will be searched for all the binary packages.
1.1       dsieger  3991: 
1.184     rillig   3992:     The target can be run at the toplevel or in category directories, in which
                   3993:     case it descends recursively.
1.1       dsieger  3994: 
1.184     rillig   3995: readme-all
1.1       dsieger  3996: 
1.184     rillig   3997:     This is a top-level command, run it in pkgsrc. Use this target to create a
                   3998:     file README-all.html which contains a list of all packages currently
                   3999:     available in the NetBSD Packages Collection, together with the category
                   4000:     they belong to and a short description. This file is compiled from the
1.199     nia      4001:     pkgsrc/*/index.html files, so be sure to run this after a make readme.
1.1       dsieger  4002: 
1.184     rillig   4003: cdrom-readme
1.1       dsieger  4004: 
1.184     rillig   4005:     This is very much the same as the "readme" target (see above), but is to be
                   4006:     used when generating a pkgsrc tree to be written to a CD-ROM. This target
1.199     nia      4007:     also produces index.html files, and can be made to refer to URLs based on
1.184     rillig   4008:     CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
1.1       dsieger  4009: 
1.184     rillig   4010: show-distfiles
1.1       dsieger  4011: 
1.184     rillig   4012:     This target shows which distfiles and patchfiles are needed to build the
                   4013:     package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
                   4014:     patches/*).
1.1       dsieger  4015: 
1.184     rillig   4016: show-downlevel
1.1       dsieger  4017: 
1.184     rillig   4018:     This target shows nothing if the package is not installed. If a version of
                   4019:     this package is installed, but is not the version provided in this version
                   4020:     of pkgsrc, then a warning message is displayed. This target can be used to
                   4021:     show which of your installed packages are downlevel, and so the old
                   4022:     versions can be deleted, and the current ones added.
1.1       dsieger  4023: 
1.184     rillig   4024: show-pkgsrc-dir
1.1       dsieger  4025: 
1.184     rillig   4026:     This target shows the directory in the pkgsrc hierarchy from which the
                   4027:     package can be built and installed. This may not be the same directory as
                   4028:     the one from which the package was installed. This target is intended to be
                   4029:     used by people who may wish to upgrade many packages on a single host, and
                   4030:     can be invoked from the top-level pkgsrc Makefile by using the "
                   4031:     show-host-specific-pkgs" target.
1.1       dsieger  4032: 
1.184     rillig   4033: show-installed-depends
1.1       dsieger  4034: 
1.184     rillig   4035:     This target shows which installed packages match the current package's
                   4036:     DEPENDS. Useful if out of date dependencies are causing build problems.
1.1       dsieger  4037: 
1.184     rillig   4038: print-build-depends-list
1.1       dsieger  4039: 
1.184     rillig   4040:     This target shows the list of packages that the current package depends on
                   4041:     for building.
1.1       dsieger  4042: 
1.184     rillig   4043: print-run-depends-list
1.1       dsieger  4044: 
1.184     rillig   4045:     This target shows the list of packages that the current package depends on
                   4046:     for running.
1.1       dsieger  4047: 
1.184     rillig   4048: check-shlibs
1.1       dsieger  4049: 
1.184     rillig   4050:     After a package is installed, check all its binaries and (on ELF platforms)
                   4051:     shared libraries to see if they find the shared libs they need. Run by
                   4052:     default if PKG_DEVELOPER is set in mk.conf.
1.1       dsieger  4053: 
1.184     rillig   4054: print-PLIST
1.1       dsieger  4055: 
1.184     rillig   4056:     After a "make install" from a new or upgraded pkg, this prints out an
                   4057:     attempt to generate a new PLIST from a find -newer work/.extract_done. An
                   4058:     attempt is made to care for shared libs etc., but it is strongly
                   4059:     recommended to review the result before putting it into PLIST. On upgrades,
                   4060:     it's useful to diff the output of this command against an already existing
                   4061:     PLIST file.
1.1       dsieger  4062: 
1.184     rillig   4063:     If the package installs files via tar(1) or other methods that don't update
                   4064:     file access times, be sure to add these files manually to your PLIST, as
                   4065:     the "find -newer" command used by this target won't catch them!
1.56      ryoon    4066: 
1.184     rillig   4067:     See Section 19.3, "Tweaking output of make print-PLIST" for more
                   4068:     information on this target.
1.1       dsieger  4069: 
1.184     rillig   4070: Chapter 14. Creating a new pkgsrc package from scratch
1.1       dsieger  4071: 
1.184     rillig   4072: Table of Contents
1.1       dsieger  4073: 
1.184     rillig   4074: 14.1. Common types of packages
1.219     nia      4075:     14.1.1. Python modules and programs
                   4076:     14.1.2. R packages
                   4077:     14.1.3. TeXlive packages
1.184     rillig   4078: 14.2. Examples
                   4079:     14.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  4080: 
1.184     rillig   4081: When you find a package that is not yet in pkgsrc, you most likely have a URL
                   4082: from where you can download the source code. Starting with this URL, creating a
                   4083: package involves only a few steps.
1.1       dsieger  4084: 
1.184     rillig   4085:  1. In your mk.conf, set PKG_DEVELOPER=yes to enable the basic quality checks.
1.1       dsieger  4086: 
1.184     rillig   4087:  2. Install the package meta-pkgs/pkg_developer, which among others will
                   4088:     install the utilities url2pkg, pkglint, pkgvi and mkpatches:
1.1       dsieger  4089: 
1.184     rillig   4090:     $ cd /usr/pkgsrc
                   4091:     $ (cd meta-pkgs/pkg_developer && bmake update)
1.1       dsieger  4092: 
1.184     rillig   4093:  3. Choose one of the top-level directories as the category in which you want
                   4094:     to place your package. You can also create a directory of your own (maybe
1.219     nia      4095:     called local). Change into that category directory:
1.1       dsieger  4096: 
1.219     nia      4097:     $ cd category
1.1       dsieger  4098: 
1.219     nia      4099:  4. Run the program url2pkg, passing as argument the URL of the distribution
                   4100:     file (in most cases a .tar.gz file). This will download the distribution
                   4101:     file and create the necessary files of the package, based on what's in the
                   4102:     distribution file:
1.1       dsieger  4103: 
1.184     rillig   4104:     $ url2pkg https://www.example.org/packages/package-1.0.tar.gz
1.1       dsieger  4105: 
1.184     rillig   4106:  5. Examine the extracted files to determine the dependencies of your package.
                   4107:     Ideally, this is mentioned in some README file, but things may differ. For
                   4108:     each of these dependencies, look where it exists in pkgsrc, and if there is
                   4109:     a file called buildlink3.mk in that directory, add a line to your package
                   4110:     Makefile which includes that file just before the last line. If the
                   4111:     buildlink3.mk file does not exist, it must be created first. The
                   4112:     buildlink3.mk file makes sure that the package's include files and
                   4113:     libraries are provided.
1.1       dsieger  4114: 
1.219     nia      4115:     If you just need binaries from a dependent package, add a DEPENDS line to
                   4116:     the Makefile, which specifies the version of the dependency and where it
                   4117:     can be found in pkgsrc. This line should be placed in the third paragraph.
                   4118:     If the dependency is only needed for building the package, but not when
                   4119:     using it, use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The
                   4120:     difference between TOOL_DEPENDS and BUILD_DEPENDS occurs when
                   4121:     cross-compiling: TOOL_DEPENDS are native packages, i.e. packages for the
                   4122:     platform where the package is built; BUILD_DEPENDS are target packages,
                   4123:     i.e. packages for the platform for which the package is built. There is
                   4124:     also TEST_DEPENDS, which specifies a dependency used only for testing the
                   4125:     resulting package built, using the upstream project's included test suite,
                   4126:     on the native platform. Your package may then look like this:
1.1       dsieger  4127: 
1.184     rillig   4128:     [...]
1.1       dsieger  4129: 
1.184     rillig   4130:     TOOL_DEPENDS+=  libxslt-[0-9]*:../../textproc/libxslt
                   4131:     DEPENDS+=       screen-[0-9]*:../../misc/screen
                   4132:     DEPENDS+=       screen>=4.0:../../misc/screen
1.1       dsieger  4133: 
1.184     rillig   4134:     [...]
1.1       dsieger  4135: 
1.184     rillig   4136:     .include "../../category/package/buildlink3.mk"
                   4137:     .include "../../devel/glib2/buildlink3.mk"
                   4138:     .include "../../mk/bsd.pkg.mk"
1.1       dsieger  4139: 
1.184     rillig   4140:  6. Run pkglint to see what things still need to be done to make your package a
                   4141:     "good" one. If you don't know what pkglint's warnings want to tell you, try
                   4142:     pkglint --explain or pkglint -e, which outputs additional explanations.
1.1       dsieger  4143: 
1.184     rillig   4144:  7. In many cases the package is not yet ready to build. You can find
                   4145:     instructions for the most common cases in the next section, Section 14.1,
                   4146:     "Common types of packages". After you have followed the instructions over
                   4147:     there, you can hopefully continue here.
1.1       dsieger  4148: 
1.184     rillig   4149:  8. Run bmake clean to clean the working directory from the extracted files.
1.219     nia      4150:     Besides these files, a lot of cache files and other system information have
                   4151:     been saved in the working directory, which may have become outdated after
                   4152:     you edited the Makefile.
1.1       dsieger  4153: 
1.184     rillig   4154:  9. Now, run bmake to build the package. For the various things that can go
                   4155:     wrong in this phase, consult Chapter 21, Making your package work.
1.1       dsieger  4156: 
1.184     rillig   4157:     If the extracted files from the package need to be fixed, run multiple
                   4158:     rounds of these commands:
1.1       dsieger  4159: 
1.219     nia      4160:     $ bmake
1.184     rillig   4161:     $ pkgvi ${WRKSRC}/some/file/that/does/not/compile
                   4162:     $ mkpatches
1.219     nia      4163:     $ bmake mps
                   4164:     $ bmake clean
1.1       dsieger  4165: 
1.184     rillig   4166: 10. When the package builds fine, the next step is to install the package. Run 
                   4167:     bmake install and hope that everything works.
1.1       dsieger  4168: 
1.184     rillig   4169: 11. Up to now, the file PLIST, which contains a list of the files that are
                   4170:     installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
                   4171:     generate a probably correct list. Check the file using your preferred text
                   4172:     editor to see if the list of files looks plausible.
1.1       dsieger  4173: 
1.184     rillig   4174: 12. Run pkglint again to see if the generated PLIST contains garbage or not.
1.1       dsieger  4175: 
1.184     rillig   4176: 13. When you ran bmake install, the package had been registered in the database
                   4177:     of installed files, but with an empty list of files. To fix this, run bmake
                   4178:     deinstall and bmake install again. Now the package is registered with the
                   4179:     list of files from PLIST.
1.48      wiz      4180: 
1.219     nia      4181: 14. Run bmake clean update to run everything from above again in a single step,
1.184     rillig   4182:     making sure that the PLIST is correct and the whole package is created as
                   4183:     intended.
1.48      wiz      4184: 
1.219     nia      4185: 15. Run pkglint to see if there's anything left to do.
1.48      wiz      4186: 
1.219     nia      4187: 16. Commit the package to pkgsrc-wip or main pkgsrc; see Chapter 23, Submitting
1.184     rillig   4188:     and Committing.
1.50      wiz      4189: 
1.184     rillig   4190: 14.1. Common types of packages
1.1       dsieger  4191: 
1.219     nia      4192: 14.1.1. Python modules and programs
1.1       dsieger  4193: 
1.184     rillig   4194: Python modules and programs packages are easily created using a set of
                   4195: predefined variables.
1.1       dsieger  4196: 
1.184     rillig   4197: If some Python versions are not supported by the software, set the
                   4198: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
                   4199: supported, e.g.
1.1       dsieger  4200: 
1.184     rillig   4201: PYTHON_VERSIONS_INCOMPATIBLE=       27
1.1       dsieger  4202: 
1.249     gutterid 4203: If the packaged software is a Python module, include ../../lang/python/
1.253   ! gutterid 4204: wheel.mk. Note per PEP-518, the minimum and default requirements to create .whl
        !          4205: files are py-setuptools plus py-wheel; however, there are various other
        !          4206: possible tools that projects can use. Thus inclusion of wheel.mk does not imply
        !          4207: these defaults are defined as TOOL_DEPENDS. Whatever the project specifically
        !          4208: requires as packaging tools must be defined in the package Makefile.
1.1       dsieger  4209: 
1.248     wiz      4210: The package directory should be called "py-software" and PKGNAME should be set
                   4211: to "${PYPKGPREFIX}-${DISTNAME}", e.g.
1.1       dsieger  4212: 
1.184     rillig   4213: DISTNAME=   foopymodule-1.2.10
                   4214: PKGNAME=    ${PYPKGPREFIX}-${DISTNAME}
1.1       dsieger  4215: 
1.226     gutterid 4216: For software in PyPi, the name should match what PyPi specifies for "pip
                   4217: install software".
                   4218: 
1.184     rillig   4219: If it is an application, include "../../lang/python/application.mk". In order
                   4220: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
                   4221: variable and set it to the list of files (paths relative to WRKSRC) that must
                   4222: be corrected. For example:
1.1       dsieger  4223: 
1.184     rillig   4224: REPLACE_PYTHON=   *.py
1.1       dsieger  4225: 
1.184     rillig   4226: Some Python modules have separate distributions for Python-2.x and Python-3.x
                   4227: support. In pkgsrc this is handled by the versioned_dependencies.mk file. Set
                   4228: PYTHON_VERSIONED_DEPENDENCIES to the list of packages that should be depended
                   4229: upon and include "../../lang/python/versioned_dependencies.mk", then the pkgsrc
                   4230: infrastructure will depend on the appropriate package version. For example:
1.1       dsieger  4231: 
1.184     rillig   4232: PYTHON_VERSIONED_DEPENDENCIES=dialog
1.1       dsieger  4233: 
1.184     rillig   4234: Look inside versioned_dependencies.mk for a list of supported packages.
1.1       dsieger  4235: 
1.219     nia      4236: 14.1.2. R packages
1.1       dsieger  4237: 
1.184     rillig   4238: Simple R packages from CRAN are handled automatically by R2pkg, which is
                   4239: available in pkgtools/R2pkg. Individual packages (and optionally their
                   4240: dependencies) may be created and updated. R packages generally follow the same
                   4241: form, and most of the relevant information needed is contained in a DESCRIPTION
                   4242: file as part of each R package on CRAN. Consequently, R2pkg downloads that
                   4243: information and creates or updates a package in the canonical form. The
                   4244: resulting package should be reviewed for correctness.
1.1       dsieger  4245: 
1.219     nia      4246: 14.1.3. TeXlive packages
1.1       dsieger  4247: 
1.184     rillig   4248: TeXlive packages from CTAN are handled automatically by texlive2pkg, which is
                   4249: available in pkgtools/texlive2pkg.
1.1       dsieger  4250: 
1.184     rillig   4251: If the TeXlive package name is not known, it may be useful to search CTAN. A "
                   4252: Contained in" field on the package page typically identifies the basename of
                   4253: the package file in the TeXlive archive.
1.1       dsieger  4254: 
1.184     rillig   4255: If the TeXlive package name is known, download the files from the TeXlive
                   4256: archive. For package foo, you will need to download foo.tar.xz. Most TeXlive
                   4257: packages also have associated documentation packages, so download
                   4258: foo.doc.tar.xz at the same time. These files should be placed in the
                   4259: appropriate category directory, which is often but not always print. Then run
                   4260: the following command in the category directory.
1.1       dsieger  4261: 
1.184     rillig   4262: texlive2pkg foo.tar.xz foo.doc.tar.xz
1.1       dsieger  4263: 
1.184     rillig   4264: This will create two packages, tex-foo and tex-foo-doc. Be sure to check that
                   4265: both packages are correct.
1.1       dsieger  4266: 
1.184     rillig   4267: Finally, CTAN currently does not include version information in package
                   4268: filenames and changes their contents periodically when updates occur.
                   4269: Consequently, pkgsrc avoids downloading distfiles directly from CTAN and
                   4270: instead relies on the pkgsrc archives. For each new or updated TeXlive package,
                   4271: e.g., the main one and the corresponding documentation, upload the distfiles
                   4272: with the following command in each package directory.
1.1       dsieger  4273: 
1.184     rillig   4274: make upload-distfiles
1.117     sevan    4275: 
1.184     rillig   4276: 14.2. Examples
1.117     sevan    4277: 
1.184     rillig   4278: 14.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  4279: 
1.184     rillig   4280: 14.2.1.1. The initial package
1.1       dsieger  4281: 
1.184     rillig   4282: Looking at the file pkgsrc/doc/TODO, I saw that the "nvu" package has not yet
                   4283: been imported into pkgsrc. As the description says it has to do with the web,
                   4284: the obvious choice for the category is "www".
1.1       dsieger  4285: 
1.184     rillig   4286: $ mkdir www/nvu
                   4287: $ cd www/nvu
1.1       dsieger  4288: 
1.184     rillig   4289: The web site says that the sources are available as a tar file, so I fed that
                   4290: URL to the url2pkg program:
1.1       dsieger  4291: 
1.184     rillig   4292: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
1.1       dsieger  4293: 
1.184     rillig   4294: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
                   4295: package name should not have the word "sources" in it. I also filled in the
                   4296: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
                   4297: that:
1.1       dsieger  4298: 
1.184     rillig   4299: # $NetBSD $
                   4300: #
1.1       dsieger  4301: 
1.184     rillig   4302: DISTNAME=       nvu-1.0-sources
                   4303: PKGNAME=        nvu-1.0
                   4304: CATEGORIES=     www
                   4305: MASTER_SITES=   http://cvs.nvu.com/download/
                   4306: EXTRACT_SUFX=   .tar.bz2
1.1       dsieger  4307: 
1.184     rillig   4308: MAINTAINER=     rillig@NetBSD.org
                   4309: HOMEPAGE=       http://cvs.nvu.com/
                   4310: COMMENT=        Web Authoring System
1.1       dsieger  4311: 
1.184     rillig   4312: # url2pkg-marker (please do not remove this line.)
                   4313: .include "../../mk/bsd.pkg.mk"
1.1       dsieger  4314: 
1.184     rillig   4315: On the first line of output above, an artificial space has been added between
                   4316: NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
                   4317: the guide.
1.1       dsieger  4318: 
1.184     rillig   4319: Then, I quit the editor and watched pkgsrc downloading a large source archive:
1.1       dsieger  4320: 
1.184     rillig   4321: url2pkg> Running "make makesum" ...
                   4322: => Required installed package digest>=20010302: digest-20060826 found
                   4323: => Fetching nvu-1.0-sources.tar.bz2
                   4324: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
                   4325: 100% |*************************************| 28992 KB  150.77 KB/s00:00 ETA
                   4326: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
                   4327: url2pkg> Running "make extract" ...
                   4328: => Required installed package digest>=20010302: digest-20060826 found
                   4329: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   4330: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   4331: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
                   4332: ===> Installing dependencies for nvu-1.0
                   4333: ===> Overriding tools for nvu-1.0
                   4334: ===> Extracting for nvu-1.0
                   4335: url2pkg> Adjusting the Makefile.
1.1       dsieger  4336: 
1.184     rillig   4337: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
1.1       dsieger  4338: 
1.184     rillig   4339: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
1.1       dsieger  4340: 
1.184     rillig   4341: 14.2.1.2. Fixing all kinds of problems to make the package work
1.1       dsieger  4342: 
1.184     rillig   4343: Now that the package has been extracted, let's see what's inside it. The
                   4344: package has a README.txt, but that only says something about mozilla, so it's
                   4345: probably useless for seeing what dependencies this package has. But since there
                   4346: is a GNU configure script in the package, let's hope that it will complain
                   4347: about everything it needs.
1.1       dsieger  4348: 
1.184     rillig   4349: $ bmake
                   4350: => Required installed package digest>=20010302: digest-20060826 found
                   4351: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   4352: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   4353: ===> Patching for nvu-1.0
                   4354: ===> Creating toolchain wrappers for nvu-1.0
                   4355: ===> Configuring for nvu-1.0
                   4356: [...]
                   4357: configure: error: Perl 5.004 or higher is required.
                   4358: [...]
                   4359: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
                   4360: [...]
1.1       dsieger  4361: 
1.184     rillig   4362: That worked quite well. So I opened the package Makefile in my editor, and
                   4363: since it already has a USE_TOOLS line, I just appended "perl" to it. Since the
                   4364: dependencies of the package have changed now, and since a perl wrapper is
                   4365: automatically installed in the "tools" phase, I need to build the package from
                   4366: scratch.
1.1       dsieger  4367: 
1.184     rillig   4368: $ bmake clean
                   4369: ===> Cleaning for nvu-1.0
                   4370: $ bmake
                   4371: [...]
                   4372: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
                   4373: GNU Make.  You will not be able to build Mozilla without GNU Make.
                   4374: [...]
1.1       dsieger  4375: 
1.184     rillig   4376: So I added "gmake" to the USE_TOOLS line and tried again (from scratch).
1.1       dsieger  4377: 
1.184     rillig   4378: [...]
                   4379: checking for GTK - version >= 1.2.0... no
                   4380: *** Could not run GTK test program, checking why...
                   4381: [...]
1.1       dsieger  4382: 
1.184     rillig   4383: Now to the other dependencies. The first question is: Where is the GTK package
                   4384: hidden in pkgsrc?
1.1       dsieger  4385: 
1.184     rillig   4386: $ echo ../../*/gtk*
                   4387: [many packages ...]
                   4388: $ echo ../../*/gtk
                   4389: ../../x11/gtk
                   4390: $ echo ../../*/gtk2
                   4391: ../../x11/gtk2
                   4392: $ echo ../../*/gtk2/bui*
                   4393: ../../x11/gtk2/buildlink3.mk
1.1       dsieger  4394: 
1.184     rillig   4395: The first try was definitely too broad. The second one had exactly one result,
                   4396: which is very good. But there is one pitfall with GNOME packages. Before GNOME
                   4397: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
                   4398: able to continue to use these packages, the GNOME 2 packages were imported as
                   4399: separate packages, and their names usually have a "2" appended. So I checked
                   4400: whether this was the case here, and indeed it was.
1.1       dsieger  4401: 
1.184     rillig   4402: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
                   4403: easy. I just inserted an .include line before the last line of the package
                   4404: Makefile, so that it now looks like this:
1.1       dsieger  4405: 
1.184     rillig   4406: [...]
                   4407: .include "../../x11/gtk2/buildlink3.mk"
                   4408: .include "../../mk/bsd.pkg.mk
1.1       dsieger  4409: 
1.184     rillig   4410: After another bmake clean && bmake, the answer was:
1.108     rillig   4411: 
1.184     rillig   4412: [...]
                   4413: checking for gtk-config... /home/roland/pkg/bin/gtk-config
                   4414: checking for GTK - version >= 1.2.0... no
                   4415: *** Could not run GTK test program, checking why...
                   4416: *** The test program failed to compile or link. See the file config.log for the
                   4417: *** exact error that occured. This usually means GTK was incorrectly installed
                   4418: *** or that you have moved GTK since it was installed. In the latter case, you
                   4419: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
                   4420: configure: error: Test for GTK failed.
                   4421: [...]
1.1       dsieger  4422: 
1.184     rillig   4423: In this particular case, the assumption that "every package prefers GNOME 2"
                   4424: had been wrong. The first of the lines above told me that this package really
                   4425: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
                   4426: it would have looked for pkg-config instead of gtk-config. So I changed the x11
                   4427: /gtk2 to x11/gtk in the package Makefile, and tried again.
1.1       dsieger  4428: 
1.184     rillig   4429: [...]
                   4430: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\"  [...]
                   4431: In file included from xpidl.c:42:
                   4432: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
                   4433: In file included from xpidl.c:42:
                   4434: xpidl.h:132: error: parse error before "IDL_ns"
                   4435: [...]
1.1       dsieger  4436: 
1.184     rillig   4437: The package still does not find all of its dependencies. Now the question is:
                   4438: Which package provides the libIDL/IDL.h header file?
1.1       dsieger  4439: 
1.184     rillig   4440: $ echo ../../*/*idl*
                   4441: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
                   4442: $ echo ../../*/*IDL*
                   4443: ../../net/libIDL
1.1       dsieger  4444: 
1.184     rillig   4445: Let's take the one from the second try. So I included the ../../net/libIDL/
                   4446: buildlink3.mk file and tried again. But the error didn't change. After digging
                   4447: through some of the code, I concluded that the build process of the package was
                   4448: broken and couldn't have ever worked, but since the Mozilla source tree is
                   4449: quite large, I didn't want to fix it. So I added the following to the package
                   4450: Makefile and tried again:
1.1       dsieger  4451: 
1.184     rillig   4452: CPPFLAGS+=              -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
                   4453: BUILDLINK_TRANSFORM+=   l:IDL:IDL-2
1.1       dsieger  4454: 
1.184     rillig   4455: The latter line is needed because the package expects the library libIDL.so,
                   4456: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
                   4457: that on the fly.
1.1       dsieger  4458: 
1.184     rillig   4459: The next problem was related to a recent change of the FreeType interface. I
                   4460: looked up in www/seamonkey which patch files were relevant for this issue and
                   4461: copied them to the patches directory. Then I retried, fixed the patches so that
                   4462: they applied cleanly and retried again. This time, everything worked.
1.1       dsieger  4463: 
1.184     rillig   4464: 14.2.1.3. Installing the package
1.1       dsieger  4465: 
1.184     rillig   4466: $ bmake CHECK_FILES=no install
                   4467: [...]
                   4468: $ bmake print-PLIST >PLIST
                   4469: $ bmake deinstall
                   4470: $ bmake install
1.1       dsieger  4471: 
1.184     rillig   4472: Chapter 15. Programming in Makefiles
1.1       dsieger  4473: 
1.184     rillig   4474: Table of Contents
1.1       dsieger  4475: 
1.184     rillig   4476: 15.1. Caveats
                   4477: 15.2. Makefile variables
                   4478:     15.2.1. Naming conventions
                   4479: 15.3. Code snippets
                   4480:     15.3.1. Adding things to a list
                   4481:     15.3.2. Echoing a string exactly as-is
                   4482:     15.3.3. Passing CFLAGS to GNU configure scripts
                   4483:     15.3.4. Handling possibly empty variables
1.229     gutterid 4484:     15.3.5. Testing yes/no variables in conditions
1.1       dsieger  4485: 
1.184     rillig   4486: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
                   4487: part of the pkgsrc system. Using the make(1) system as a programming language
                   4488: for a big system like pkgsrc requires some discipline to keep the code correct
                   4489: and understandable.
1.1       dsieger  4490: 
1.184     rillig   4491: The basic ingredients for Makefile programming are variables and shell
                   4492: commands. Among these shell commands may even be more complex ones like awk(1)
                   4493: programs. To make sure that every shell command runs as intended it is
                   4494: necessary to quote all variables correctly when they are used.
1.1       dsieger  4495: 
1.184     rillig   4496: This chapter describes some patterns that appear quite often in Makefiles,
                   4497: including the pitfalls that come along with them.
1.1       dsieger  4498: 
1.184     rillig   4499: 15.1. Caveats
1.1       dsieger  4500: 
1.184     rillig   4501:   * When you are creating a file as a target of a rule, always write the data
                   4502:     to a temporary file first and finally rename that file. Otherwise there
                   4503:     might occur an error in the middle of generating the file, and when the
                   4504:     user runs make(1) for the second time, the file exists and will not be
                   4505:     regenerated properly. Example:
1.1       dsieger  4506: 
1.184     rillig   4507:     wrong:
                   4508:             @echo "line 1" > ${.TARGET}
                   4509:             @echo "line 2" >> ${.TARGET}
                   4510:             @false
1.1       dsieger  4511: 
1.184     rillig   4512:     correct:
                   4513:             @echo "line 1" > ${.TARGET}.tmp
                   4514:             @echo "line 2" >> ${.TARGET}.tmp
                   4515:             @false
                   4516:             @mv ${.TARGET}.tmp ${.TARGET}
1.1       dsieger  4517: 
1.184     rillig   4518:     When you run make wrong twice, the file wrong will exist, although there
                   4519:     was an error message in the first run. On the other hand, running make
                   4520:     correct gives an error message twice, as expected.
1.1       dsieger  4521: 
1.184     rillig   4522:     You might remember that make(1) sometimes removes ${.TARGET} in case of
                   4523:     error, but this only happens when it is interrupted, for example by
                   4524:     pressing Ctrl+C. This does not happen when one of the commands fails (like
                   4525:     false(1) above).
1.1       dsieger  4526: 
1.184     rillig   4527: 15.2. Makefile variables
1.1       dsieger  4528: 
1.184     rillig   4529: Makefile variables contain strings that can be processed using the five
                   4530: operators =, +=, ?=, := and !=, which are described in the make(1) man page.
1.1       dsieger  4531: 
1.184     rillig   4532: When a variable's value is parsed from a Makefile, the hash character # and the
                   4533: backslash character \ are handled specially. If a backslash is the last
                   4534: character in a line, that backslash is removed from the line and the line
                   4535: continues with the next line of the file.
1.1       dsieger  4536: 
1.184     rillig   4537: The # character starts a comment that reaches until the end of the line. To get
                   4538: an actual # character, such as in a URL, write \# instead.
1.1       dsieger  4539: 
1.184     rillig   4540: The evaluation of variables either happens immediately or lazy. It happens
                   4541: immediately when the variable occurs on the right-hand side of the := or the !=
                   4542: operator, in a .if condition or a .for loop. In the other cases, it is
                   4543: evaluated lazily.
1.1       dsieger  4544: 
1.184     rillig   4545: Some of the modifiers split the string into words and then operate on the
                   4546: words, others operate on the string as a whole. When a string is split into
                   4547: words, double quotes and single quotes are interpreted as delimiters, just like
                   4548: in sh(1).
1.1       dsieger  4549: 
1.184     rillig   4550: 15.2.1. Naming conventions
1.1       dsieger  4551: 
1.184     rillig   4552:   * All variable names starting with an underscore are reserved for use by the
                   4553:     pkgsrc infrastructure. They shall not be used by packages.
1.1       dsieger  4554: 
1.184     rillig   4555:   * In .for loops you should use lowercase variable names for the iteration
                   4556:     variables.
1.1       dsieger  4557: 
1.184     rillig   4558:   * All list variables should have a plural name, such as PKG_OPTIONS or
                   4559:     DISTFILES.
1.1       dsieger  4560: 
1.184     rillig   4561: 15.3. Code snippets
1.1       dsieger  4562: 
1.184     rillig   4563: 15.3.1. Adding things to a list
1.1       dsieger  4564: 
1.184     rillig   4565: When adding a string that possibly contains whitespace or quotes to a list
                   4566: (example 1), it must be quoted using the :Q modifier.
1.1       dsieger  4567: 
1.184     rillig   4568: When adding another list to a list (example 2), it must not be quoted, since
                   4569: its elements are already quoted.
1.1       dsieger  4570: 
1.184     rillig   4571: STRING=         foo * bar `date`
                   4572: LIST=           # empty
                   4573: ANOTHER_LIST=   a=b c=d
1.1       dsieger  4574: 
1.184     rillig   4575: LIST+=          ${STRING:Q}       # 1
                   4576: LIST+=          ${ANOTHER_LIST}   # 2
1.1       dsieger  4577: 
1.184     rillig   4578: 15.3.2. Echoing a string exactly as-is
1.1       dsieger  4579: 
1.184     rillig   4580: Echoing a string containing special characters needs special work.
1.1       dsieger  4581: 
1.184     rillig   4582: STRING=         foo bar <    > * `date` $$HOME ' "
                   4583: EXAMPLE_ENV=    string=${STRING:Q} x=multiple\ quoted\ words
1.1       dsieger  4584: 
1.184     rillig   4585: all:
                   4586:         echo ${STRING}                  # 1
                   4587:         echo ${STRING:Q}                # 2
                   4588:         printf '%s\n' ${STRING:Q}''     # 3
                   4589:         env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"'   # 4
1.1       dsieger  4590: 
1.184     rillig   4591: Example 1 leads to a syntax error in the shell, as the characters are just
                   4592: copied.
1.1       dsieger  4593: 
1.184     rillig   4594: Example 2 quotes the string so that the shell interprets it correctly. But the
                   4595: echo command may additionally interpret strings with a leading dash or those
                   4596: containing backslashes.
1.1       dsieger  4597: 
1.184     rillig   4598: Example 3 can handle arbitrary strings, since printf(1) only interprets the
                   4599: format string, but not the next argument. The trailing single quotes handle the
                   4600: case when the string is empty. In that case, the :Q modifier would result in an
                   4601: empty string too, which would then be skipped by the shell. For printf(1) this
                   4602: doesn't make a difference, but other programs may care.
1.1       dsieger  4603: 
1.184     rillig   4604: In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
                   4605: has already been done when adding elements to the list.
1.1       dsieger  4606: 
1.184     rillig   4607: 15.3.3. Passing CFLAGS to GNU configure scripts
1.1       dsieger  4608: 
1.184     rillig   4609: When passing CFLAGS or similar variables to a GNU-style configure script
                   4610: (especially those that call other configure scripts), it must not have leading
                   4611: or trailing whitespace, since otherwise the configure script gets confused. To
                   4612: trim leading and trailing whitespace, use the :M modifier, as in the following
                   4613: example:
1.1       dsieger  4614: 
1.184     rillig   4615: CPPFLAGS=               # empty
                   4616: CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX}\"
                   4617: CPPFLAGS+=              ${MY_CPPFLAGS}
1.1       dsieger  4618: 
1.184     rillig   4619: CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
1.1       dsieger  4620: 
1.184     rillig   4621: all:
                   4622:         echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
                   4623:         echo x${CONFIGURE_ARGS:Q}x      # properly trimmed
1.1       dsieger  4624: 
1.184     rillig   4625: In this example, CPPFLAGS has both leading and trailing whitespace because the
                   4626: += operator always adds a space.
1.1       dsieger  4627: 
1.184     rillig   4628: 15.3.4. Handling possibly empty variables
1.1       dsieger  4629: 
1.184     rillig   4630: When a possibly empty variable is used in a shell program, it may lead to a
                   4631: syntax error.
1.1       dsieger  4632: 
1.184     rillig   4633: EGFILES=        # empty
1.1       dsieger  4634: 
1.184     rillig   4635: install-examples:   # produces a syntax error in the shell
                   4636:         for egfile in ${EGFILES}; do            \
                   4637:                 echo "Installing $$egfile";     \
                   4638:         done
1.1       dsieger  4639: 
1.184     rillig   4640: The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
                   4641: with an empty string by make(1). To fix this syntax error, use one of the
                   4642: snippets below.
1.1       dsieger  4643: 
1.229     gutterid 4644: EGFILES=        # empty
1.1       dsieger  4645: 
1.184     rillig   4646: install-examples:
                   4647:         for egfile in ${EGFILES} ""; do         \
                   4648:                 [ -n "$$egfile" ] || continue;  \
                   4649:                 echo "Installing $$egfile";     \
                   4650:         done
1.1       dsieger  4651: 
1.184     rillig   4652: In this case, an empty string is appended to the iteration list (to prevent the
                   4653: syntax error) and filtered out later.
1.1       dsieger  4654: 
1.184     rillig   4655: EGFILES=        # empty
1.1       dsieger  4656: 
1.184     rillig   4657: install-examples:
                   4658: .for egfile in ${EGFILES}
                   4659:         echo "Installing ${egfile}"
                   4660: .endfor
1.1       dsieger  4661: 
1.184     rillig   4662: If one of the filenames contains special characters, it should be enclosed in
                   4663: single or double quotes.
1.1       dsieger  4664: 
1.184     rillig   4665: To have a shell command test whether a make variable is empty, use the
                   4666: following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
1.1       dsieger  4667: 
1.229     gutterid 4668: 15.3.5. Testing yes/no variables in conditions
                   4669: 
                   4670: When a variable can have the values yes or no, use the following pattern to
                   4671: test the variable:
                   4672: 
                   4673: .if ${VAR:U:tl} == "yes"
                   4674: # do something
                   4675: .endif
                   4676: 
                   4677: The :U modifier is only necessary if the variable can be undefined. If the
                   4678: variable is guaranteed to be defined, the :U can be omitted.
                   4679: 
                   4680: The :tl modifier converts the variable value to lowercase, allowing for the
                   4681: values yes, Yes, YES.
                   4682: 
1.184     rillig   4683: Chapter 16. Options handling
1.1       dsieger  4684: 
                   4685: Table of Contents
                   4686: 
1.184     rillig   4687: 16.1. Global default options
                   4688: 16.2. Converting packages to use bsd.options.mk
                   4689: 16.3. Option Names
                   4690: 16.4. Determining the options of dependencies
1.1       dsieger  4691: 
                   4692: Many packages have the ability to be built to support different sets of
                   4693: features. bsd.options.mk is a framework in pkgsrc that provides generic
                   4694: handling of those options that determine different ways in which the packages
                   4695: can be built. It's possible for the user to specify exactly which sets of
                   4696: options will be built into a package or to allow a set of global default
                   4697: options apply.
                   4698: 
1.7       rillig   4699: There are two broad classes of behaviors that one might want to control via
                   4700: options. One is whether some particular feature is enabled in a program that
                   4701: will be built anyway, often by including or not including a dependency on some
                   4702: other package. The other is whether or not an additional program will be built
                   4703: as part of the package. Generally, it is better to make a split package for
                   4704: such additional programs instead of using options, because it enables binary
                   4705: packages to be built which can then be added separately. For example, the foo
                   4706: package might have minimal dependencies (those packages without which foo
                   4707: doesn't make sense), and then the foo-gfoo package might include the GTK
                   4708: frontend program gfoo. This is better than including a gtk option to foo that
                   4709: adds gfoo, because either that option is default, in which case binary users
                   4710: can't get foo without gfoo, or not default, in which case they can't get gfoo.
                   4711: With split packages, they can install foo without having GTK, and later decide
                   4712: to install gfoo (pulling in GTK at that time). This is an advantage to source
                   4713: users too, avoiding the need for rebuilds.
                   4714: 
                   4715: Plugins with widely varying dependencies should usually be split instead of
                   4716: options.
                   4717: 
                   4718: It is often more work to maintain split packages, especially if the upstream
                   4719: package does not support this. The decision of split vs. option should be made
                   4720: based on the likelihood that users will want or object to the various pieces,
                   4721: the size of the dependencies that are included, and the amount of work.
                   4722: 
                   4723: A further consideration is licensing. Non-free parts, or parts that depend on
                   4724: non-free dependencies (especially plugins) should almost always be split if
                   4725: feasible.
                   4726: 
1.184     rillig   4727: 16.1. Global default options
1.1       dsieger  4728: 
                   4729: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
                   4730: the options that should be built into every package if that option is
1.4       rillig   4731: supported. This variable should be set in mk.conf.
1.1       dsieger  4732: 
1.184     rillig   4733: 16.2. Converting packages to use bsd.options.mk
1.1       dsieger  4734: 
                   4735: The following example shows how bsd.options.mk should be used by the
                   4736: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
                   4737: e.g. options.mk, that is included by the main package Makefile.
                   4738: 
                   4739: PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
                   4740: PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
                   4741: PKG_OPTIONS_OPTIONAL_GROUPS=    database
                   4742: PKG_OPTIONS_GROUP.database=     mysql pgsql
                   4743: PKG_SUGGESTED_OPTIONS=          wibble-foo
                   4744: PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
                   4745: PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
                   4746: 
                   4747: .include "../../mk/bsd.prefs.mk"
                   4748: 
                   4749: # this package was previously named wibble2
                   4750: .if defined(PKG_OPTIONS.wibble2)
                   4751: PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
                   4752: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
                   4753:         "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
                   4754: .endif
                   4755: 
                   4756: .include "../../mk/bsd.options.mk"
                   4757: 
                   4758: # Package-specific option-handling
                   4759: 
                   4760: ###
                   4761: ### FOO support
                   4762: ###
                   4763: .if !empty(PKG_OPTIONS:Mwibble-foo)
                   4764: CONFIGURE_ARGS+=    --enable-foo
                   4765: .endif
                   4766: 
                   4767: ###
                   4768: ### LDAP support
                   4769: ###
                   4770: .if !empty(PKG_OPTIONS:Mldap)
                   4771: .  include "../../databases/openldap-client/buildlink3.mk"
                   4772: CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
                   4773: .endif
                   4774: 
                   4775: ###
                   4776: ### database support
                   4777: ###
                   4778: .if !empty(PKG_OPTIONS:Mmysql)
                   4779: .  include "../../mk/mysql.buildlink3.mk"
                   4780: .endif
                   4781: .if !empty(PKG_OPTIONS:Mpgsql)
                   4782: .  include "../../mk/pgsql.buildlink3.mk"
                   4783: .endif
                   4784: 
                   4785: The first section contains the information about which build options are
                   4786: supported by the package, and any default options settings if needed.
                   4787: 
                   4788:  1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
                   4789:     to override the default options. It should be set to PKG_OPTIONS.pkgbase.
                   4790:     Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
                   4791:     the point where the options are processed.
                   4792: 
                   4793:  2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
                   4794: 
                   4795:  3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
                   4796:     exclusive options. The options in each group are listed in
                   4797:     PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
                   4798:     the group takes precedence over all other options in the group. Options
                   4799:     from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
                   4800: 
                   4801:  4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
                   4802:     building the packages will fail if no option from the group is selected.
                   4803: 
                   4804:  5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
                   4805:     one option from each set must be selected. The options in each set are
                   4806:     listed in PKG_OPTIONS_SET.setname. Options from the sets will be
                   4807:     automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
                   4808:     fail if no option from the set is selected.
                   4809: 
                   4810:  6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
                   4811:     default.
                   4812: 
                   4813:  7. PKG_OPTIONS_LEGACY_VARS is a list of "USE_VARIABLE:option" pairs that map
1.4       rillig   4814:     legacy mk.conf variables to their option counterparts. Pairs should be
1.1       dsieger  4815:     added with "+=" to keep the listing of global legacy variables. A warning
                   4816:     will be issued if the user uses a legacy variable.
                   4817: 
                   4818:  8. PKG_OPTIONS_LEGACY_OPTS is a list of "old-option:new-option" pairs that map
                   4819:     options that have been renamed to their new counterparts. Pairs should be
                   4820:     added with "+=" to keep the listing of global legacy options. A warning
                   4821:     will be issued if the user uses a legacy option.
                   4822: 
                   4823:  9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
                   4824:     used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
                   4825:     PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
                   4826: 
                   4827: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
                   4828:     variables or options used, and what to use instead.
                   4829: 
                   4830: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
                   4831: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
                   4832: options, use PKG_SUGGESTED_OPTIONS.
                   4833: 
                   4834: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
                   4835: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
                   4836: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
                   4837: options if none of them is supported on the current platform), PKG_OPTIONS is
                   4838: set to the empty list and the package is otherwise treated as not using the
                   4839: options framework.
                   4840: 
                   4841: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
                   4842: list of selected build options, properly filtered to remove unsupported and
                   4843: duplicate options.
                   4844: 
                   4845: The remaining sections contain the logic that is specific to each option. The
                   4846: correct way to check for an option is to check whether it is listed in
                   4847: PKG_OPTIONS:
                   4848: 
                   4849: .if !empty(PKG_OPTIONS:Moption)
                   4850: 
1.184     rillig   4851: 16.3. Option Names
1.1       dsieger  4852: 
                   4853: Options that enable similar features in different packages (like optional
                   4854: support for a library) should use a common name in all packages that support it
                   4855: (like the name of the library). If another package already has an option with
                   4856: the same meaning, use the same name.
                   4857: 
                   4858: Options that enable features specific to one package, where it's unlikely that
                   4859: another (unrelated) package has the same (or a similar) optional feature,
                   4860: should use a name prefixed with pkgname-.
                   4861: 
                   4862: If a group of related packages share an optional feature specific to that
                   4863: group, prefix it with the name of the "main" package (e. g.
                   4864: djbware-errno-hack).
                   4865: 
                   4866: For new options, add a line to mk/defaults/options.description. Lines have two
                   4867: fields, separated by tab. The first field is the option name, the second its
                   4868: description. The description should be a whole sentence (starting with an
                   4869: uppercase letter and ending with a period) that describes what enabling the
                   4870: option does. E. g. "Enable ispell support." The file is sorted by option names.
                   4871: 
1.184     rillig   4872: 16.4. Determining the options of dependencies
1.7       rillig   4873: 
                   4874: When writing buildlink3.mk files, it is often necessary to list different
                   4875: dependencies based on the options with which the package was built. For
                   4876: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
                   4877: A typical example looks like this:
                   4878: 
                   4879: pkgbase := libpurple
                   4880: .include "../../mk/pkg-build-options.mk"
                   4881: 
                   4882: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
                   4883: ...
                   4884: .endif
                   4885: 
                   4886: Including pkg-build-options.mk here will set the variable
                   4887: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
                   4888: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
                   4889: pkg-build-options.mk for more details.
                   4890: 
1.184     rillig   4891: Chapter 17. Tools needed for building or running
                   4892: 
                   4893: Table of Contents
                   4894: 
                   4895: 17.1. Tools for pkgsrc builds
                   4896: 17.2. Tools needed by packages
                   4897: 17.3. Tools provided by platforms
                   4898: 
                   4899: The USE_TOOLS definition is used both internally by pkgsrc and also for
                   4900: individual packages to define what commands are needed for building a package
                   4901: (like TOOL_DEPENDS) or for later run-time of an installed packaged (such as
                   4902: DEPENDS). If the native system provides an adequate tool, then in many cases, a
                   4903: pkgsrc package will not be used.
                   4904: 
                   4905: When building a package, the replacement tools are made available in a
                   4906: directory (as symlinks or wrapper scripts) that is early in the executable
                   4907: search path. Just like the buildlink system, this helps with consistent builds.
                   4908: 
                   4909: A tool may be needed to help build a specific package. For example, perl, GNU
                   4910: make (gmake) or yacc may be needed.
                   4911: 
                   4912: Also a tool may be needed, for example, because the native system's supplied
                   4913: tool may be inefficient for building a package with pkgsrc. For example, a
                   4914: package may need GNU awk, bison (instead of yacc) or a better sed.
                   4915: 
                   4916: The tools used by a package can be listed by running make show-tools.
                   4917: 
                   4918: 17.1. Tools for pkgsrc builds
                   4919: 
                   4920: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
                   4921: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
                   4922: seen by running: make show-var VARNAME=USE_TOOLS.
                   4923: 
                   4924: If a package needs a specific program to build then the USE_TOOLS variable can
                   4925: be used to define the tools needed.
                   4926: 
                   4927: 17.2. Tools needed by packages
                   4928: 
                   4929: In the following examples, the :run means that it is needed at run-time (and
                   4930: becomes a DEPENDS). The default is a build dependency which can be set with
                   4931: :build. (So in this example, it is the same as gmake:build and
                   4932: pkg-config:build.)
                   4933: 
                   4934: USE_TOOLS+=     gmake perl:run pkg-config
                   4935: 
                   4936: When using the tools framework, a TOOLS_PATH.foo variable is defined which
                   4937: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
                   4938: could be "/bin/bash" on Linux systems.
                   4939: 
                   4940: If you always need a pkgsrc version of the tool at run-time, then just use
                   4941: DEPENDS instead.
                   4942: 
                   4943: 17.3. Tools provided by platforms
                   4944: 
                   4945: When improving or porting pkgsrc to a new platform, have a look at (or create)
                   4946: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
                   4947: tools.${OPSYS}.mk which defines the name of the common tools. For example:
                   4948: 
                   4949: .if exists(/usr/bin/bzcat)
                   4950: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
                   4951: .elif exists(/usr/bin/bzip2)
                   4952: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
                   4953: .endif
                   4954: 
                   4955: TOOLS_PLATFORM.true?=           true                    # shell builtin
                   4956: 
                   4957: Chapter 18. Buildlink methodology
1.1       dsieger  4958: 
                   4959: Table of Contents
                   4960: 
1.184     rillig   4961: 18.1. Converting packages to use buildlink3
                   4962: 18.2. Writing buildlink3.mk files
                   4963:     18.2.1. Anatomy of a buildlink3.mk file
                   4964:     18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.232     gutterid 4965:     buildlink3.mk files
1.184     rillig   4966: 18.3. Writing builtin.mk files
                   4967:     18.3.1. Anatomy of a builtin.mk file
                   4968: 
                   4969: Buildlink is a framework in pkgsrc that controls what headers and libraries are
                   4970: seen by a package's configure and build processes. This is implemented in a two
                   4971: step process:
                   4972: 
                   4973:  1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
                   4974:     default is a subdirectory of WRKDIR.
                   4975: 
                   4976:  2. Create wrapper scripts that are used in place of the normal compiler tools
                   4977:     that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
                   4978:     references to BUILDLINK_DIR. The wrapper scripts also make native compiler
                   4979:     on some operating systems look like GCC, so that packages that expect GCC
                   4980:     won't require modifications to build with those native compilers.
                   4981: 
                   4982: This normalizes the environment in which a package is built so that the package
                   4983: may be built consistently despite what other software may be installed. Please
                   4984: note that the normal system header and library paths, e.g. /usr/include, /usr/
                   4985: lib, etc., are always searched -- buildlink3 is designed to insulate the
                   4986: package build from non-system-supplied software.
                   4987: 
                   4988: 18.1. Converting packages to use buildlink3
1.1       dsieger  4989: 
1.184     rillig   4990: The process of converting packages to use the buildlink3 framework ("bl3ifying"
                   4991: ) is fairly straightforward. The things to keep in mind are:
1.1       dsieger  4992: 
1.184     rillig   4993:  1. Ensure that the build always calls the wrapper scripts instead of the
                   4994:     actual toolchain. Some packages are tricky, and the only way to know for
                   4995:     sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
                   4996:     invoked.
1.1       dsieger  4997: 
1.184     rillig   4998:  2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
                   4999:     standalone shells, etc., because the code to symlink files into $
                   5000:     {BUILDLINK_DIR} looks for files relative to "pkg_info -qp pkgname".
1.1       dsieger  5001: 
1.184     rillig   5002:  3. Remember that only the buildlink3.mk files that you list in a package's
                   5003:     Makefile are added as dependencies for that package.
1.1       dsieger  5004: 
1.184     rillig   5005: If a dependency on a particular package is required for its libraries and
                   5006: headers, then we replace:
1.1       dsieger  5007: 
1.184     rillig   5008: DEPENDS+=       foo>=1.1.0:../../category/foo
1.1       dsieger  5009: 
1.184     rillig   5010: with
1.1       dsieger  5011: 
1.184     rillig   5012: .include "../../category/foo/buildlink3.mk"
1.1       dsieger  5013: 
1.184     rillig   5014: The buildlink3.mk files usually define the required dependencies. If you need a
                   5015: newer version of the dependency when using buildlink3.mk files, then you can
                   5016: define it in your Makefile; for example:
1.1       dsieger  5017: 
1.184     rillig   5018: BUILDLINK_API_DEPENDS.foo+=   foo>=1.1.0
                   5019: .include "../../category/foo/buildlink3.mk"
1.1       dsieger  5020: 
1.184     rillig   5021: There are several buildlink3.mk files in pkgsrc/mk that handle special package
                   5022: issues:
1.1       dsieger  5023: 
1.184     rillig   5024:   * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
                   5025:     implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
1.1       dsieger  5026: 
1.184     rillig   5027:   * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
                   5028:     this will take care to install the devel/ncurses package.
1.1       dsieger  5029: 
1.184     rillig   5030:   * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
                   5031:     a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
                   5032:     implementation.
1.1       dsieger  5033: 
1.184     rillig   5034:   * motif.buildlink3.mk checks for a system-provided Motif installation or adds
                   5035:     a dependency on x11/lesstif or x11/motif. The user can set MOTIF_TYPE to "
                   5036:     dt", "lesstif" or "motif" to choose which Motif version will be used.
1.1       dsieger  5037: 
1.184     rillig   5038:   * readline.buildlink3.mk checks for a system-provided GNU readline or
                   5039:     editline (libedit) installation, or adds a dependency on devel/readline,
                   5040:     devel/editline. The user can set READLINE_DEFAULT to choose readline
                   5041:     implementation. If your package really needs GNU readline library, its
                   5042:     Makefile should include devel/readline/buildlink3.mk instead of
                   5043:     readline.buildlink3.mk.
1.1       dsieger  5044: 
1.184     rillig   5045:   * oss.buildlink3.mk defines several variables that may be used by packages
                   5046:     that use the Open Sound System (OSS) API.
1.1       dsieger  5047: 
1.184     rillig   5048:   * pgsql.buildlink3.mk will accept any of the Postgres versions in the
                   5049:     variable PGSQL_VERSIONS_ACCEPTED and default to the version
                   5050:     PGSQL_VERSION_DEFAULT. See the file for more information.
1.1       dsieger  5051: 
1.184     rillig   5052:   * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
                   5053:     pthreads or adds a dependency on devel/pth as needed.
1.1       dsieger  5054: 
1.184     rillig   5055:   * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
                   5056:     widgets library.
1.1       dsieger  5057: 
1.184     rillig   5058: The comments in those buildlink3.mk files provide a more complete description
                   5059: of how to use them properly.
1.1       dsieger  5060: 
1.184     rillig   5061: 18.2. Writing buildlink3.mk files
1.1       dsieger  5062: 
1.184     rillig   5063: A package's buildlink3.mk file is included by Makefiles to indicate the need to
                   5064: compile and link against header files and libraries provided by the package. A
                   5065: buildlink3.mk file should always provide enough information to add the correct
                   5066: type of dependency relationship and include any other buildlink3.mk files that
                   5067: it needs to find headers and libraries that it needs in turn.
1.1       dsieger  5068: 
1.184     rillig   5069: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
                   5070: pkgtools/createbuildlink package is highly recommended. For most packages, the
                   5071: following command will generate a good starting point for buildlink3.mk files:
1.1       dsieger  5072: 
1.184     rillig   5073: % cd pkgsrc/category/pkgdir
                   5074: % createbuildlink >buildlink3.mk
1.1       dsieger  5075: 
                   5076: 
1.184     rillig   5077: 18.2.1. Anatomy of a buildlink3.mk file
1.1       dsieger  5078: 
1.184     rillig   5079: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
                   5080: tiff:
1.14      jmcneill 5081: 
1.184     rillig   5082: BUILDLINK_TREE+=        tiff
1.1       dsieger  5083: 
1.184     rillig   5084: .if !defined(TIFF_BUILDLINK3_MK)
                   5085: TIFF_BUILDLINK3_MK:=
1.1       dsieger  5086: 
1.184     rillig   5087: BUILDLINK_API_DEPENDS.tiff+=    tiff>=3.6.1
                   5088: BUILDLINK_ABI_DEPENDS.tiff+=    tiff>=3.7.2nb1
                   5089: BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
1.1       dsieger  5090: 
1.184     rillig   5091: .include "../../devel/zlib/buildlink3.mk"
                   5092: .include "../../graphics/jpeg/buildlink3.mk"
                   5093: .endif # TIFF_BUILDLINK3_MK
1.1       dsieger  5094: 
1.184     rillig   5095: BUILDLINK_TREE+=        -tiff
1.1       dsieger  5096: 
1.184     rillig   5097: The header and footer manipulate BUILDLINK_TREE, which is common across all
                   5098: buildlink3.mk files and is used to track the dependency tree.
1.1       dsieger  5099: 
1.184     rillig   5100: The main section is protected from multiple inclusion and controls how the
                   5101: dependency on pkg is added. Several important variables are set in the section:
1.1       dsieger  5102: 
1.185     wiz      5103:   * BUILDLINK_API_DEPENDS.pkg is the dependency version recorded in the
1.184     rillig   5104:     installed package; this should always be set using += to ensure that we're
                   5105:     appending to any pre-existing list of values. This variable should be set
1.185     wiz      5106:     to the last version of the package that had an backwards-incompatible API
1.184     rillig   5107:     change.
1.1       dsieger  5108: 
1.184     rillig   5109:   * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
1.1       dsieger  5110: 
1.184     rillig   5111:   * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
1.236     gutterid 5112:     BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
                   5113:     is selected by setting BUILDLINK_DEPMETHOD.pkg to "build". By default, the
                   5114:     full dependency is used.
1.1       dsieger  5115: 
1.184     rillig   5116:   * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
                   5117:     of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
                   5118:     library search paths. These default to "include" and "lib" respectively.
1.1       dsieger  5119: 
1.184     rillig   5120:   * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
                   5121:     to add to CPPFLAGS, which are passed on to the configure and build phases.
                   5122:     The "-I" option should be avoided and instead be handled using
                   5123:     BUILDLINK_INCDIRS.pkg as above.
1.66      asau     5124: 
1.184     rillig   5125: The following variables are all optionally defined within this second section
                   5126: (protected against multiple inclusion) and control which package files are
                   5127: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
                   5128: symlinking:
1.23      jakllsch 5129: 
1.184     rillig   5130:   * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
                   5131:     {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
                   5132:     *.h.
1.1       dsieger  5133: 
1.184     rillig   5134:   * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
                   5135:     to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
                   5136:     resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
                   5137:     takes the +CONTENTS of a pkg and filters it through $
                   5138:     {BUILDLINK_CONTENTS_FILTER.pkg}.
1.1       dsieger  5139: 
1.184     rillig   5140:   * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
                   5141:     filters +CONTENTS input into a list of files relative to $
                   5142:     {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
                   5143:     outputs the contents of the include and lib directories in the package
                   5144:     +CONTENTS.
1.1       dsieger  5145: 
1.184     rillig   5146:   * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
                   5147:     used to transform the name of the source filename into a destination
                   5148:     filename, e.g. -e "s|/curses.h|/ncurses.h|g".
1.1       dsieger  5149: 
1.184     rillig   5150: This section can additionally include any buildlink3.mk needed for pkg's
                   5151: library dependencies. Including these buildlink3.mk files means that the
                   5152: headers and libraries for these dependencies are also symlinked into $
                   5153: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
                   5154: are only added for directly include buildlink3.mk files.
1.1       dsieger  5155: 
1.184     rillig   5156: When providing a buildlink3.mk and including other buildlink3.mk files in it,
                   5157: please only add necessary ones, i.e., those whose libraries or header files are
                   5158: automatically exposed when the package is use.
1.1       dsieger  5159: 
1.184     rillig   5160: In particular, if only an executable (bin/foo) is linked against a library,
                   5161: that library does not need to be propagated in the buildlink3.mk file.
1.1       dsieger  5162: 
1.184     rillig   5163: The following steps should help you decide if a buildlink3.mk file needs to be
                   5164: included:
1.1       dsieger  5165: 
1.184     rillig   5166:   * Look at the installed header files: What headers do they include? The
                   5167:     packages providing these files must be buildlinked.
1.1       dsieger  5168: 
1.184     rillig   5169:   * Run ldd on all installed libraries and look against what other libraries
                   5170:     they link. Some of the packages providing these probably need to be
                   5171:     buildlinked; however, it's not automatic, since e.g. GTK on some systems
                   5172:     pulls in the X libraries, so they will show up in the ldd output, while on
                   5173:     others (like OS X) it won't. ldd output can thus only be used as a hint.
1.1       dsieger  5174: 
1.184     rillig   5175: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
                   5176: buildlink3.mk files
1.16      jnemeth  5177: 
1.185     wiz      5178: Both variables set lower bounds for a version of this package. The two
                   5179: variables differ in that one describes source compatibility (API) and the other
                   5180: binary compatibility (ABI). The difference is that a change in the API breaks
                   5181: compilation of programs while changes in the ABI stop compiled programs from
                   5182: running.
                   5183: 
                   5184: The BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk should be changed
                   5185: very rarely. (One possible scenario: If all packages using this package need a
                   5186: higher version than defined in the buildlink3.mk, BUILDLINK_API_DEPENDS.pkg
                   5187: could be updated to that higher version.)
                   5188: 
                   5189: On the other hand, changes to BUILDLINK_ABI_DEPENDS.pkg are more common. The
                   5190: variable will need to be updated every time the major version of one of its
                   5191: shared libraries is changed, or any other change where a binary built against
                   5192: the previous version of the package will not run against the new version any
                   5193: longer.
                   5194: 
                   5195: In such a case, the package's BUILDLINK_ABI_DEPENDS.pkg must be increased to
                   5196: require the new package version. Then the PKGREVISION of all packages foo that
                   5197: depend on this package need to be increased, and if they have buildlink3.mk
                   5198: files, BUILDLINK_ABI_DEPENDS.foo in their buildlink3.mk files must be increased
                   5199: to the new version as well. This is required so that a package will pull in the
                   5200: versions of the packages that use the new ABI and that the packages'
                   5201: PKGREVISIONs uniquely identify the packages built against the new ABI. The
                   5202: pkgtools/revbump package can help with these updates.
1.1       dsieger  5203: 
1.184     rillig   5204: See Section 21.1.5, "Handling dependencies" for more information about
1.185     wiz      5205: dependencies on other packages, including the BUILDLINK_API_DEPENDS
                   5206: definitions.
1.1       dsieger  5207: 
1.184     rillig   5208: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
1.185     wiz      5209: BUILDLINK_ABI_DEPENDS.pkg in a buildlink3.mk file as we don't want to cause
                   5210: unneeded package deletions and rebuilds. In many cases, new versions of
                   5211: packages work just fine with older dependencies.
1.1       dsieger  5212: 
1.211     gutterid 5213: Also, it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
1.184     rillig   5214: BUILDLINK_API_DEPENDS.pkg.
1.1       dsieger  5215: 
1.211     gutterid 5216: Note there is also the distinction that users are able to disable enforcement
                   5217: of ABI dependencies using the USE_ABI_DEPENDS variable, but there is no
                   5218: equivalent option for API dependencies.
                   5219: 
1.184     rillig   5220: 18.3. Writing builtin.mk files
1.1       dsieger  5221: 
1.184     rillig   5222: Some packages in pkgsrc install headers and libraries that coincide with
                   5223: headers and libraries present in the base system. Aside from a buildlink3.mk
                   5224: file, these packages should also include a builtin.mk file that includes the
                   5225: necessary checks to decide whether using the built-in software or the pkgsrc
                   5226: software is appropriate.
1.1       dsieger  5227: 
1.184     rillig   5228: The only requirements of a builtin.mk file for pkg are:
1.1       dsieger  5229: 
1.184     rillig   5230:  1. It should set USE_BUILTIN.pkg to either "yes" or "no" after it is included.
1.1       dsieger  5231: 
1.184     rillig   5232:  2. It should not override any USE_BUILTIN.pkg which is already set before the
                   5233:     builtin.mk file is included.
1.1       dsieger  5234: 
1.184     rillig   5235:  3. It should be written to allow multiple inclusion. This is very important
                   5236:     and takes careful attention to Makefile coding.
1.1       dsieger  5237: 
1.184     rillig   5238: 18.3.1. Anatomy of a builtin.mk file
1.1       dsieger  5239: 
1.184     rillig   5240: The following is the recommended template for builtin.mk files:
1.1       dsieger  5241: 
1.184     rillig   5242: .if !defined(IS_BUILTIN.foo)
                   5243: #
                   5244: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
                   5245: # genuinely exists in the system or not.
                   5246: #
                   5247: IS_BUILTIN.foo?=        no
1.1       dsieger  5248: 
1.184     rillig   5249: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
                   5250: # version can be determined.
                   5251: #
                   5252: .  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
                   5253: BUILTIN_PKG.foo?=       foo-1.0
                   5254: .  endif
                   5255: .endif  # IS_BUILTIN.foo
1.1       dsieger  5256: 
1.184     rillig   5257: .if !defined(USE_BUILTIN.foo)
                   5258: USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
                   5259: .  if defined(BUILTIN_PKG.foo)
                   5260: .    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
                   5261: .      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
                   5262: USE_BUILTIN.foo!=                                                       \
                   5263:         ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}            \
                   5264:         && ${ECHO} "yes" || ${ECHO} "no"
                   5265: .      endif
                   5266: .    endfor
                   5267: .  endif
                   5268: .endif  # USE_BUILTIN.foo
1.1       dsieger  5269: 
1.184     rillig   5270: CHECK_BUILTIN.foo?=     no
                   5271: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
                   5272: #
                   5273: # Here we place code that depends on whether USE_BUILTIN.foo is set to
                   5274: # "yes" or "no".
                   5275: #
                   5276: .endif  # CHECK_BUILTIN.foo
1.1       dsieger  5277: 
1.184     rillig   5278: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
                   5279: base system. This should not be a base system software with similar
                   5280: functionality to pkg; it should only be "yes" if the actual package is included
                   5281: as part of the base system. This variable is only used internally within the
                   5282: builtin.mk file.
1.1       dsieger  5283: 
1.184     rillig   5284: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
                   5285: system if it exists (if IS_BUILTIN.pkg is "yes"). This variable is only used
                   5286: internally within the builtin.mk file.
1.1       dsieger  5287: 
1.184     rillig   5288: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
                   5289: The code in this section must make the determination whether the built-in
                   5290: software is adequate to satisfy the dependencies listed in
                   5291: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
                   5292: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg 
                   5293: must be set to the correct value by the end of the builtin.mk file. Note that
                   5294: USE_BUILTIN.pkg may be "yes" even if IS_BUILTIN.pkg is "no" because we may make
                   5295: the determination that the built-in version of the software is similar enough
                   5296: to be used as a replacement.
1.1       dsieger  5297: 
1.184     rillig   5298: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
                   5299: the value of USE_BUILTIN.pkg set in the previous section. This typically
                   5300: includes, e.g., adding additional dependency restrictions and listing
                   5301: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
1.1       dsieger  5302: 
1.184     rillig   5303: Chapter 19. PLIST issues
1.1       dsieger  5304: 
1.184     rillig   5305: Table of Contents
1.1       dsieger  5306: 
1.184     rillig   5307: 19.1. RCS ID
                   5308: 19.2. Semi-automatic PLIST generation
                   5309: 19.3. Tweaking output of make print-PLIST
                   5310: 19.4. Variable substitution in PLIST
                   5311: 19.5. Man page compression
                   5312: 19.6. Changing PLIST source with PLIST_SRC
                   5313: 19.7. Platform-specific and differing PLISTs
                   5314: 19.8. Build-specific PLISTs
                   5315: 19.9. Sharing directories between packages
1.1       dsieger  5316: 
1.184     rillig   5317: The PLIST file contains a package's "packing list", i.e. a list of files that
                   5318: belong to the package (relative to the ${PREFIX} directory it's been installed
                   5319: in) plus some additional statements - see the pkg_create(1) man page for a full
                   5320: list. This chapter addresses some issues that need attention when dealing with
                   5321: the PLIST file (or files, see below!).
1.1       dsieger  5322: 
1.184     rillig   5323: 19.1. RCS ID
1.1       dsieger  5324: 
1.184     rillig   5325: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
1.1       dsieger  5326: 
1.184     rillig   5327: @comment $NetBSD $
1.1       dsieger  5328: 
1.184     rillig   5329: An artificial space has been added between NetBSD and $, this is a workaround
                   5330: here to prevent CVS expanding to the filename of the guide. When adding the RCS
                   5331: ID the space should be omitted.
1.38      wiz      5332: 
1.184     rillig   5333: 19.2. Semi-automatic PLIST generation
1.1       dsieger  5334: 
1.184     rillig   5335: You can use the make print-PLIST command to output a PLIST that matches any new
                   5336: files since the package was extracted. See Section 13.17, "Other helpful
                   5337: targets" for more information on this target.
1.11      rillig   5338: 
1.184     rillig   5339: 19.3. Tweaking output of make print-PLIST
1.1       dsieger  5340: 
1.184     rillig   5341: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
                   5342: used to filter the output of print-PLIST. You can append any chunk of AWK
                   5343: scripting you like to it, but be careful with quoting.
1.1       dsieger  5344: 
1.184     rillig   5345: For example, to get all files inside the libdata/foo directory removed from the
                   5346: resulting PLIST:
1.1       dsieger  5347: 
1.184     rillig   5348: PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
1.1       dsieger  5349: 
1.185     wiz      5350: The PRINT_PLIST_AWK transformations are evaluated after the file list and
                   5351: directory list are sorted. EARLY_PRINT_PLIST_AWK is like PRINT_PLIST_AWK except
                   5352: it operates before the file list and directory list are sorted.
                   5353: 
1.184     rillig   5354: 19.4. Variable substitution in PLIST
1.1       dsieger  5355: 
1.184     rillig   5356: A number of variables are substituted automatically in PLISTs when a package is
                   5357: installed on a system. This includes the following variables:
1.1       dsieger  5358: 
1.184     rillig   5359: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
1.1       dsieger  5360: 
1.184     rillig   5361:     Some packages like emacs and perl embed information about which
                   5362:     architecture they were built on into the pathnames where they install their
                   5363:     files. To handle this case, PLIST will be preprocessed before actually
                   5364:     used, and the symbol "${MACHINE_ARCH}" will be replaced by what uname -p
                   5365:     gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
                   5366:     PLIST somewhere - use this on packages that have GNU autoconf-created
                   5367:     configure scripts.
1.1       dsieger  5368: 
1.184     rillig   5369:     Legacy note
1.1       dsieger  5370: 
1.184     rillig   5371:     There used to be a symbol "$ARCH" that was replaced by the output of uname
                   5372:     -m, but that's no longer supported and has been removed.
1.1       dsieger  5373: 
1.184     rillig   5374: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
1.1       dsieger  5375: 
1.184     rillig   5376:     Some packages want to embed the OS name and version into some paths. To do
                   5377:     this, use these variables in the PLIST:
1.1       dsieger  5378: 
1.232     gutterid 5379:       o ${OPSYS} - output of "uname -s"
1.1       dsieger  5380: 
1.232     gutterid 5381:       o ${LOWER_OPSYS} - lowercase common name (eg. "solaris")
1.1       dsieger  5382: 
1.232     gutterid 5383:       o ${OS_VERSION} - "uname -r"
1.1       dsieger  5384: 
1.184     rillig   5385: For a list of values which are replaced by default, the output of make help
                   5386: topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
                   5387: PLIST_SUBST should help.
1.1       dsieger  5388: 
1.184     rillig   5389: If you want to change other variables not listed above, you can add variables
                   5390: and their expansions to this variable in the following way, similar to
                   5391: MESSAGE_SUBST (see Section 12.5, "Optional files"):
1.1       dsieger  5392: 
1.184     rillig   5393: PLIST_SUBST+=   SOMEVAR="somevalue"
1.1       dsieger  5394: 
1.184     rillig   5395: This replaces all occurrences of "${SOMEVAR}" in the PLIST with "somevalue".
1.1       dsieger  5396: 
1.184     rillig   5397: The PLIST_VARS variable can be used to simplify the common case of
                   5398: conditionally including some PLIST entries. It can be done by adding
                   5399: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
                   5400: entry should be included. This will substitute "${PLIST.foo}" in the PLIST with
                   5401: either """" or ""@comment "". For example, in Makefile:
1.1       dsieger  5402: 
1.184     rillig   5403: PLIST_VARS+=    foo
                   5404: .if condition
                   5405: PLIST.foo=      yes
                   5406: .else
1.1       dsieger  5407: 
1.184     rillig   5408: And then in PLIST:
1.1       dsieger  5409: 
1.184     rillig   5410: @comment $NetBSD $
                   5411: bin/bar
                   5412: man/man1/bar.1
                   5413: ${PLIST.foo}bin/foo
                   5414: ${PLIST.foo}man/man1/foo.1
                   5415: ${PLIST.foo}share/bar/foo.data
1.1       dsieger  5416: 
1.184     rillig   5417: An artificial space has been added between NetBSD and $, this is a workaround
                   5418: here to prevent CVS expanding to the filename of the guide. When adding the RCS
1.195     gutterid 5419: ID the space should be omitted.
1.1       dsieger  5420: 
1.184     rillig   5421: 19.5. Man page compression
1.1       dsieger  5422: 
1.184     rillig   5423: Man pages should be installed in compressed form if MANZ is set (in
                   5424: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
                   5425: suffix ".gz" is appended/removed automatically for man pages according to MANZ
                   5426: and MANCOMPRESSED being set or not, see above for details. This modification of
                   5427: the PLIST file is done on a copy of it, not PLIST itself.
1.100     leot     5428: 
1.184     rillig   5429: 19.6. Changing PLIST source with PLIST_SRC
1.100     leot     5430: 
1.184     rillig   5431: To use one or more files as source for the PLIST used in generating the binary
                   5432: package, set the variable PLIST_SRC to the names of that file(s). The files are
                   5433: later concatenated using cat(1), and the order of things is important. The
                   5434: default for PLIST_SRC is ${PKGDIR}/PLIST.
1.1       dsieger  5435: 
1.184     rillig   5436: 19.7. Platform-specific and differing PLISTs
1.1       dsieger  5437: 
1.184     rillig   5438: Some packages decide to install a different set of files based on the operating
                   5439: system being used. These differences can be automatically handled by using the
                   5440: following files:
1.1       dsieger  5441: 
1.184     rillig   5442:   * PLIST.common
1.1       dsieger  5443: 
1.184     rillig   5444:   * PLIST.${OPSYS}
1.1       dsieger  5445: 
1.184     rillig   5446:   * PLIST.${MACHINE_ARCH}
1.1       dsieger  5447: 
1.184     rillig   5448:   * PLIST.${OPSYS}-${MACHINE_ARCH}
1.1       dsieger  5449: 
1.184     rillig   5450:   * PLIST.common_end
1.1       dsieger  5451: 
1.184     rillig   5452: 19.8. Build-specific PLISTs
1.1       dsieger  5453: 
1.184     rillig   5454: Some packages decide to generate hard-to-guess file names during installation
                   5455: that are hard to wire down.
1.1       dsieger  5456: 
1.184     rillig   5457: In such cases, you can set the GENERATE_PLIST variable to shell code terminated
                   5458: (with a semicolon) that will output PLIST entries which will be appended to the
                   5459: PLIST
1.1       dsieger  5460: 
1.184     rillig   5461: You can find one example in editors/xemacs:
1.1       dsieger  5462: 
1.184     rillig   5463: GENERATE_PLIST+=        ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
1.1       dsieger  5464: 
1.184     rillig   5465: which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
1.1       dsieger  5466: 
1.184     rillig   5467: 19.9. Sharing directories between packages
1.1       dsieger  5468: 
1.184     rillig   5469: A "shared directory" is a directory where multiple (and unrelated) packages
                   5470: install files. These directories were problematic because you had to add
                   5471: special tricks in the PLIST to conditionally remove them, or have some
                   5472: centralized package handle them.
1.106     tnn      5473: 
1.184     rillig   5474: In pkgsrc, it is now easy: Each package should create directories and install
                   5475: files as needed; pkg_delete will remove any directories left empty after
                   5476: uninstalling a package.
1.106     tnn      5477: 
1.184     rillig   5478: If a package needs an empty directory to work, create the directory during
                   5479: installation as usual, and also add an entry to the PLIST:
1.1       dsieger  5480: 
1.184     rillig   5481: @pkgdir path/to/empty/directory
1.1       dsieger  5482: 
1.184     rillig   5483: or take a look at MAKE_DIRS and OWN_DIRS.
1.1       dsieger  5484: 
1.184     rillig   5485: Chapter 20. The pkginstall framework
1.1       dsieger  5486: 
1.184     rillig   5487: Table of Contents
1.1       dsieger  5488: 
1.184     rillig   5489: 20.1. Files and directories outside the installation prefix
                   5490:     20.1.1. Directory manipulation
                   5491:     20.1.2. File manipulation
                   5492: 20.2. Configuration files
                   5493:     20.2.1. How PKG_SYSCONFDIR is set
                   5494:     20.2.2. Telling the software where configuration files are
1.239     dholland 5495:     20.2.3. Patching installation
                   5496:     20.2.4. Declaring configuration files
                   5497:     20.2.5. Disabling handling of configuration files
1.184     rillig   5498: 20.3. System startup scripts
                   5499:     20.3.1. Disabling handling of system startup scripts
                   5500: 20.4. System users and groups
                   5501: 20.5. System shells
                   5502:     20.5.1. Disabling shell registration
                   5503: 20.6. Fonts
                   5504:     20.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  5505: 
1.184     rillig   5506: This chapter describes the framework known as pkginstall, whose key features
                   5507: are:
1.1       dsieger  5508: 
1.184     rillig   5509:   * Generic installation and manipulation of directories and files outside the
                   5510:     pkgsrc-handled tree, LOCALBASE.
1.1       dsieger  5511: 
1.184     rillig   5512:   * Automatic handling of configuration files during installation, provided
                   5513:     that packages are correctly designed.
1.1       dsieger  5514: 
1.184     rillig   5515:   * Generation and installation of system startup scripts.
1.1       dsieger  5516: 
1.184     rillig   5517:   * Registration of system users and groups.
1.1       dsieger  5518: 
1.184     rillig   5519:   * Registration of system shells.
1.1       dsieger  5520: 
1.184     rillig   5521:   * Automatic updating of fonts databases.
1.1       dsieger  5522: 
1.184     rillig   5523: The following sections inspect each of the above points in detail.
1.1       dsieger  5524: 
1.184     rillig   5525: You may be thinking that many of the things described here could be easily done
                   5526: with simple code in the package's post-installation target (post-install). This
                   5527: is incorrect, as the code in them is only executed when building from source.
                   5528: Machines using binary packages could not benefit from it at all (as the code
                   5529: itself could be unavailable). Therefore, the only way to achieve any of the
                   5530: items described above is by means of the installation scripts, which are
                   5531: automatically generated by pkginstall.
1.1       dsieger  5532: 
1.184     rillig   5533: 20.1. Files and directories outside the installation prefix
1.95      wiz      5534: 
1.184     rillig   5535: As you already know, the PLIST file holds a list of files and directories that
                   5536: belong to a package. The names used in it are relative to the installation
                   5537: prefix (${PREFIX}), which means that it cannot register files outside this
                   5538: directory (absolute path names are not allowed). Despite this restriction, some
                   5539: packages need to install files outside this location; e.g., under ${VARBASE} or
                   5540: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
                   5541: installation time by using installation scripts.
1.95      wiz      5542: 
1.184     rillig   5543: The generic installation scripts are shell scripts that can contain arbitrary
                   5544: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
                   5545: which defaults to INSTALL. A similar variable exists for package removal
                   5546: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
                   5547: commands, so they have the potential to create and manage files anywhere in the
                   5548: file system.
1.95      wiz      5549: 
1.184     rillig   5550: Using these general installation files is not recommended, but may be needed in
                   5551: some special cases. One reason for avoiding them is that the user has to trust
                   5552: the packager that there is no unwanted or simply erroneous code included in the
                   5553: installation script. Also, previously there were many similar scripts for the
                   5554: same functionality, and fixing a common error involved finding and changing all
                   5555: of them.
1.95      wiz      5556: 
1.184     rillig   5557: The pkginstall framework offers another, standardized way. It provides generic
                   5558: scripts to abstract the manipulation of such files and directories based on
                   5559: variables set in the package's Makefile. The rest of this section describes
                   5560: these variables.
1.1       dsieger  5561: 
1.184     rillig   5562: 20.1.1. Directory manipulation
1.1       dsieger  5563: 
1.184     rillig   5564: The following variables can be set to request the creation of directories
                   5565: anywhere in the file system:
1.1       dsieger  5566: 
1.184     rillig   5567:   * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
                   5568:     and should attempt to be destroyed by the installation scripts. The
                   5569:     difference between the two is that the latter prompts the administrator to
                   5570:     remove any directories that may be left after deinstallation (because they
                   5571:     were not empty), while the former does not. Example:
1.1       dsieger  5572: 
1.184     rillig   5573:     MAKE_DIRS+=             ${VARBASE}/foo/private
1.1       dsieger  5574: 
1.184     rillig   5575:   * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
                   5576:     which directories should be created and should attempt to be destroyed by
                   5577:     the installation scripts. Each tuple holds the following values, separated
                   5578:     by spaces: the directory name, its owner, its group and its numerical mode.
                   5579:     For example:
1.1       dsieger  5580: 
1.184     rillig   5581:     MAKE_DIRS_PERMS+=       ${VARBASE}/foo/private \
                   5582:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  5583: 
1.184     rillig   5584:     The difference between the two is exactly the same as their non-PERMS
                   5585:     counterparts.
1.1       dsieger  5586: 
1.184     rillig   5587: 20.1.2. File manipulation
1.1       dsieger  5588: 
1.184     rillig   5589: Creating non-empty files outside the installation prefix is tricky because the
                   5590: PLIST forces all files to be inside it. To overcome this problem, the only
1.239     dholland 5591: solution is to extract the file in a known place (i.e., inside the installation
                   5592: prefix) and copy it to the appropriate location during installation (done by
                   5593: the installation scripts generated by pkginstall). We will call the former the 
                   5594: reference file in the following paragraphs, which describe the variables that
                   5595: can be used to automatically and consistently handle files outside the
                   5596: installation prefix:
                   5597: 
                   5598:   * REQD_FILES is a list of pairs of reference and target files. At
                   5599:     installation time, the reference file is copied to the target if and only
                   5600:     if the latter does not exist. Upon deinstallation, the reference file is
1.184     rillig   5601:     removed provided that it was not modified by the installation.
1.1       dsieger  5602: 
1.239     dholland 5603:   * REQD_FILES_PERMS contains tuples describing reference files and targets,
                   5604:     including owner, group, and numeric permissions that should be set. For
                   5605:     example:
1.1       dsieger  5606: 
1.184     rillig   5607:     REQD_FILES_PERMS+=      ${PREFIX}/share/somefile ${VARBASE}/somefile \
                   5608:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  5609: 
1.239     dholland 5610:   * CONF_FILES and CONF_FILES_PERMS have the same syntax as REQD_FILES and
                   5611:     REQD_FILES_PERMS respectively. The difference is that these variables are
                   5612:     specifically intended for handling configuration files, for which
                   5613:     additional conventions and constraints apply. See Section 20.2,
                   5614:     "Configuration files" for further discussion. Note in particular that while
                   5615:     handling of configuration files can be disabled by the user (see
                   5616:     Section 20.2.5, "Disabling handling of configuration files"), this setting
                   5617:     does not affect REQD_FILES and REQD_FILES_PERMS.
                   5618: 
                   5619: To install an empty file, one can use these macros and /dev/null as the
                   5620: reference file.
1.1       dsieger  5621: 
1.184     rillig   5622: 20.2. Configuration files
1.1       dsieger  5623: 
1.239     dholland 5624: There are two principles that govern the handling of configuration files in
                   5625: pkgsrc: first, the user's configuration must not be lost or overwritten by
                   5626: upgrades or reinstallations; and second, the default configuration should
                   5627: always be available for reference. To that end, pkgsrc has a framework
                   5628: specifically for handling configuration files. In general, configuration files
                   5629: are installed into ${PREFIX}/share/examples, and copied from there to the
                   5630: pertinent etc directory as a separate step and only as needed.
                   5631: 
                   5632: To make this work, there are three things that need to happen, any of which may
                   5633: require patching. First, the package must be told to read its configuration
                   5634: from the correct place at runtime; this place is ${PKG_SYSCONFDIR} (or possibly
                   5635: a subdirectory of it) which is often but not always ${PREFIX}/etc. Second, the
                   5636: package must be taught to install its default configuration files in ${PREFIX}/
                   5637: share/examples/${PKGBASE}; this is the point at which patching often becomes
                   5638: required because it is not the same place as the runtime location. Third, the
                   5639: configuration files need to be declared in the package makefile; this is the
                   5640: easy part.
                   5641: 
                   5642: With those elements in place, the right things will happen: the package install
                   5643: phase and resulting binary package will not touch ${PKG_SYSCONFDIR}, and the
                   5644: default configuration will be copied into place by the pkgsrc framework only if
                   5645: not already present. Similarly, upon deinstall the configuration will not be
                   5646: removed if it has been modified. (This means that in the case of reinstallation
                   5647: and upgrades, unmodified configuration files are updated but modifications are
                   5648: never discarded.)
                   5649: 
                   5650: The following sections describe how to make these things happen and document
                   5651: other relevant knobs available in the pkgsrc infrastructure.
1.1       dsieger  5652: 
1.184     rillig   5653: 20.2.1. How PKG_SYSCONFDIR is set
1.1       dsieger  5654: 
1.184     rillig   5655: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
                   5656: shall be installed. Its contents are set based upon the following variables:
1.1       dsieger  5657: 
1.184     rillig   5658:   * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
1.239     dholland 5659:     etc although it may be overridden by the user to point to their preferred
1.184     rillig   5660:     location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
1.1       dsieger  5661: 
1.184     rillig   5662:   * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
                   5663:     configuration files for the package being built shall be installed. The
                   5664:     definition of this variable only makes sense in the package's Makefile
                   5665:     (i.e., it is not user-customizable).
1.1       dsieger  5666: 
1.184     rillig   5667:     As an example, consider the Apache package, www/apache24, which places its
                   5668:     configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
                   5669:     should be set in the package Makefile.
1.1       dsieger  5670: 
1.184     rillig   5671:   * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
                   5672:     package's configuration directory (if different from PKG_SYSCONFBASE). It
                   5673:     defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
1.1       dsieger  5674: 
1.184     rillig   5675:   * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
                   5676:     configuration files for the package identified by PKG_SYSCONFVAR's shall be
                   5677:     placed.
1.1       dsieger  5678: 
1.184     rillig   5679: Based on the above variables, pkginstall determines the value of
1.239     dholland 5680: PKG_SYSCONFDIR, which is the only variable that may be used within a package to
1.184     rillig   5681: refer to its configuration directory. The algorithm used to set its value is
                   5682: basically the following:
1.1       dsieger  5683: 
1.184     rillig   5684:  1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
1.1       dsieger  5685: 
1.184     rillig   5686:  2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
                   5687:     package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
                   5688:     {PKG_SYSCONFSUBDIR}.
1.1       dsieger  5689: 
1.184     rillig   5690:  3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
1.1       dsieger  5691: 
1.184     rillig   5692: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
1.239     dholland 5693: OWN_DIRS. This causes it to be automatically created if needed. See
                   5694: Section 20.1.1, "Directory manipulation" for further details. This does not
                   5695: apply to subdirectories of ${PKG_SYSCONFDIR}; they must be manually created
                   5696: with OWN_DIRS or MAKE_DIRS.
1.1       dsieger  5697: 
1.184     rillig   5698: 20.2.2. Telling the software where configuration files are
1.1       dsieger  5699: 
1.184     rillig   5700: Given that pkgsrc (and users!) expect configuration files to be in a known
1.239     dholland 5701: place, you need to teach each package where to install its files. In some cases
                   5702: you will have to patch the package Makefiles to achieve it. If you are lucky,
                   5703: though, it may be as easy as passing an extra flag to the configuration script.
                   5704: This is the case for packages using GNU autoconf:
1.1       dsieger  5705: 
1.184     rillig   5706: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1       dsieger  5707: 
1.184     rillig   5708: Note that this specifies where the package has to look for its configuration
1.239     dholland 5709: files, not where they will be installed. Fortunately, there is a different way
1.240     gutterid 5710: to specify the latter, as seen in the next section, although the combination is
                   5711: rather confusing at first glance.
1.1       dsieger  5712: 
1.239     dholland 5713: 20.2.3. Patching installation
1.1       dsieger  5714: 
1.239     dholland 5715: As discussed above, packages themselves must not touch the contents of $
1.184     rillig   5716: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
                   5717: will, out of the box, mess with the contents of that directory. So what is the
                   5718: correct procedure to fix this issue?
1.1       dsieger  5719: 
1.184     rillig   5720: You must teach the package (usually by manually patching it) to install any
                   5721: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
                   5722: This way, the PLIST registers them and the administrator always has the
                   5723: original copies available.
1.1       dsieger  5724: 
1.239     dholland 5725: It turns out that for packages using GNU autoconf it is possible to create the
                   5726: desired effect by setting sysconfdir on the make command line at install time.
                   5727: Consider this example taken from mail/mutt:
                   5728: 
                   5729: EGDIR=                  ${PREFIX}/share/examples/mutt
                   5730: INSTALL_MAKE_FLAGS=     ${MAKE_FLAGS} sysconfdir=${EGDIR}
                   5731: 
                   5732: Note that the EGDIR variable, though commonly used for this purpose, is local
                   5733: to that package and has no meaning outside it.
1.1       dsieger  5734: 
1.239     dholland 5735: 20.2.4. Declaring configuration files
1.1       dsieger  5736: 
1.239     dholland 5737: Once the required configuration files are in place (i.e., under the examples
                   5738: hierarchy), the pkginstall framework can use them as reference copies during
                   5739: the package installation to update what is in ${PKG_SYSCONFDIR}. To achieve
                   5740: this, the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
                   5741: Section 20.1.2, "File manipulation" for further information about their syntax
                   5742: and their purpose. Here is an example, taken from the mail/mutt package:
                   5743: 
                   5744: EGDIR=                  ${PREFIX}/share/examples/mutt
                   5745: CONF_FILES=             ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
                   5746: 
                   5747: Note that (as in the previous section's example) the EGDIR variable is specific
                   5748: to the package and has no meaning outside it.
                   5749: 
                   5750: For reference, the complete example from Mutt is as follows:
                   5751: 
                   5752: CONFIGURE_ARGS+=        --sysconfdir=${PKG_SYSCONFDIR}
                   5753: EGDIR=                  ${PREFIX}/share/examples/mutt
                   5754: CONF_FILES=             ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
                   5755: INSTALLATION_DIRS+=     ${EGDIR}
                   5756: INSTALL_MAKE_FLAGS=     ${MAKE_FLAGS} sysconfdir=${EGDIR}
1.1       dsieger  5757: 
1.239     dholland 5758: 20.2.5. Disabling handling of configuration files
1.1       dsieger  5759: 
1.184     rillig   5760: The automatic copying of config files can be toggled by setting the environment
                   5761: variable PKG_CONFIG prior to package installation.
1.1       dsieger  5762: 
1.184     rillig   5763: 20.3. System startup scripts
1.1       dsieger  5764: 
1.184     rillig   5765: System startup scripts are special files because they must be installed in a
                   5766: place known by the underlying OS, usually outside the installation prefix.
                   5767: Therefore, the same rules described in Section 20.1, "Files and directories
                   5768: outside the installation prefix" apply, and the same solutions can be used.
                   5769: However, pkginstall provides a special mechanism to handle these files.
1.1       dsieger  5770: 
1.184     rillig   5771: In order to provide system startup scripts, the package has to:
1.1       dsieger  5772: 
1.184     rillig   5773:  1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
1.223     nia      5774:     Considering the print/cups-base package as an example, it has a cupsd.sh in
                   5775:     its files directory.
1.95      wiz      5776: 
1.184     rillig   5777:  2. Tell pkginstall to handle it, appending the name of the script, without its
                   5778:     extension, to the RCD_SCRIPTS variable. Continuing the previous example:
1.95      wiz      5779: 
1.184     rillig   5780:     RCD_SCRIPTS+=   cupsd
1.95      wiz      5781: 
1.184     rillig   5782: Once this is done, pkginstall will do the following steps for each script in an
                   5783: automated fashion:
1.95      wiz      5784: 
1.184     rillig   5785:  1. Process the file found in the files directory applying all the
                   5786:     substitutions described in the FILES_SUBST variable.
1.1       dsieger  5787: 
1.184     rillig   5788:  2. Copy the script from the files directory to the examples hierarchy, $
1.239     dholland 5789:     {PREFIX}/share/examples/rc.d/. Note that this reference file must be
1.184     rillig   5790:     explicitly registered in the PLIST.
1.1       dsieger  5791: 
1.184     rillig   5792:  3. Add code to the installation scripts to copy the startup script from the
                   5793:     examples hierarchy into the system-wide startup scripts directory.
1.1       dsieger  5794: 
1.184     rillig   5795: 20.3.1. Disabling handling of system startup scripts
1.1       dsieger  5796: 
1.184     rillig   5797: The automatic copying of config files can be toggled by setting the environment
                   5798: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
                   5799: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
                   5800: rc.d/, no matter what the value of this variable is.
1.1       dsieger  5801: 
1.184     rillig   5802: 20.4. System users and groups
1.1       dsieger  5803: 
1.184     rillig   5804: If a package needs to create special users and/or groups during installation,
                   5805: it can do so by using the pkginstall framework.
1.1       dsieger  5806: 
1.184     rillig   5807: Users can be created by adding entries to the PKG_USERS variable. Each entry
                   5808: has the following syntax:
1.1       dsieger  5809: 
1.184     rillig   5810: user:group
1.1       dsieger  5811: 
1.184     rillig   5812: Further specification of user details may be done by setting per-user
                   5813: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
                   5814: user's description or comment. PKG_HOME.user is the user's home directory, and
                   5815: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
                   5816: and defaults to /sbin/nologin if not specified.
1.1       dsieger  5817: 
1.184     rillig   5818: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
                   5819: whose syntax is:
1.1       dsieger  5820: 
1.184     rillig   5821: group
1.1       dsieger  5822: 
1.184     rillig   5823: The numeric GID of the group may be set by defining PKG_GID.group.
1.1       dsieger  5824: 
1.184     rillig   5825: If a package needs to create the users and groups at an earlier stage, then it
                   5826: can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
                   5827: the phase before which the users and groups are created. In this case, the
                   5828: numeric UIDs and GIDs of the created users and groups are automatically
                   5829: hardcoded into the final installation scripts.
1.1       dsieger  5830: 
1.184     rillig   5831: 20.5. System shells
1.1       dsieger  5832: 
1.184     rillig   5833: Packages that install system shells should register them in the shell database,
                   5834: /etc/shells, to make things easier to the administrator. This must be done from
                   5835: the installation scripts to keep binary packages working on any system.
                   5836: pkginstall provides an easy way to accomplish this task.
1.1       dsieger  5837: 
1.184     rillig   5838: When a package provides a shell interpreter, it has to set the PKG_SHELL
                   5839: variable to its absolute file name. This will add some hooks to the
                   5840: installation scripts to handle it. Consider the following example, taken from
                   5841: shells/zsh:
1.1       dsieger  5842: 
1.184     rillig   5843: PKG_SHELL=      ${PREFIX}/bin/zsh
1.1       dsieger  5844: 
1.184     rillig   5845: 20.5.1. Disabling shell registration
1.1       dsieger  5846: 
1.184     rillig   5847: The automatic registration of shell interpreters can be disabled by the
                   5848: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
1.1       dsieger  5849: 
1.184     rillig   5850: 20.6. Fonts
1.1       dsieger  5851: 
1.184     rillig   5852: Packages that install X11 fonts should update the database files that index the
                   5853: fonts within each fonts directory. This can easily be accomplished within the
                   5854: pkginstall framework.
1.1       dsieger  5855: 
1.184     rillig   5856: When a package installs X11 fonts, it must list the directories in which fonts
                   5857: are installed in the FONTS_DIRS.type variables, where type can be one of "ttf",
                   5858: "type1" or "x11". This will add hooks to the installation scripts to run the
                   5859: appropriate commands to update the fonts database files within each of those
                   5860: directories. For convenience, if the directory path is relative, it is taken to
                   5861: be relative to the package's installation prefix. Consider the following
                   5862: example, taken from fonts/dbz-ttf:
1.1       dsieger  5863: 
1.184     rillig   5864: FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
1.1       dsieger  5865: 
1.184     rillig   5866: 20.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  5867: 
1.184     rillig   5868: The automatic update of fonts databases can be disabled by the administrator by
                   5869: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
1.1       dsieger  5870: 
1.154     rillig   5871: Chapter 21. Making your package work
1.1       dsieger  5872: 
                   5873: Table of Contents
                   5874: 
1.154     rillig   5875: 21.1. General operation
                   5876:     21.1.1. How to pull in user-settable variables from mk.conf
                   5877:     21.1.2. User interaction
                   5878:     21.1.3. Handling licenses
                   5879:     21.1.4. Restricted packages
                   5880:     21.1.5. Handling dependencies
                   5881:     21.1.6. Handling conflicts with other packages
                   5882:     21.1.7. Packages that cannot or should not be built
                   5883:     21.1.8. Packages which should not be deleted, once installed
                   5884:     21.1.9. Handling packages with security problems
                   5885:     21.1.10. How to handle incrementing versions when fixing an existing
1.232     gutterid 5886:     package
1.154     rillig   5887:     21.1.11. Substituting variable text in the package files (the SUBST
1.232     gutterid 5888:     framework)
1.154     rillig   5889: 21.2. The fetch phase
                   5890:     21.2.1. Packages whose distfiles aren't available for plain downloading
                   5891:     21.2.2. How to handle modified distfiles with the 'old' name
                   5892:     21.2.3. Packages hosted on github.com
                   5893: 21.3. The configure phase
                   5894:     21.3.1. Shared libraries - libtool
                   5895:     21.3.2. Using libtool on GNU packages that already support libtool
                   5896:     21.3.3. GNU Autoconf/Automake
1.223     nia      5897:     21.3.4. Meson / ninja
1.154     rillig   5898: 21.4. Programming languages
                   5899:     21.4.1. C, C++, and Fortran
                   5900:     21.4.2. Java
1.205     wiz      5901:     21.4.3. Go
1.223     nia      5902:     21.4.4. Rust
                   5903:     21.4.5. Packages containing Perl scripts
                   5904:     21.4.6. Packages containing shell scripts
                   5905:     21.4.7. Other programming languages
1.154     rillig   5906: 21.5. The build phase
                   5907:     21.5.1. Compiling C and C++ code conditionally
                   5908:     21.5.2. How to handle compiler bugs
1.172     rillig   5909:     21.5.3. No such file or directory
                   5910:     21.5.4. Undefined reference to "..."
                   5911:     21.5.5. Running out of memory
1.154     rillig   5912: 21.6. The install phase
                   5913:     21.6.1. Creating needed directories
                   5914:     21.6.2. Where to install documentation
                   5915:     21.6.3. Installing highscore files
                   5916:     21.6.4. Adding DESTDIR support to packages
                   5917:     21.6.5. Packages with hardcoded paths to other interpreters
1.203     nia      5918:     21.6.6. Packages installing Perl modules
1.154     rillig   5919:     21.6.7. Packages installing info files
                   5920:     21.6.8. Packages installing man pages
1.203     nia      5921:     21.6.9. Packages installing X11 fonts
                   5922:     21.6.10. Packages installing SGML or XML data
                   5923:     21.6.11. Packages installing extensions to the MIME database
                   5924:     21.6.12. Packages using intltool
                   5925:     21.6.13. Packages installing startup scripts
                   5926:     21.6.14. Packages installing TeX modules
                   5927:     21.6.15. Packages supporting running binaries in emulation
                   5928:     21.6.16. Packages installing hicolor icons
                   5929:     21.6.17. Packages installing desktop files
1.154     rillig   5930: 21.7. Marking packages as having problems
1.1       dsieger  5931: 
1.154     rillig   5932: 21.1. General operation
1.1       dsieger  5933: 
                   5934: One appealing feature of pkgsrc is that it runs on many different platforms. As
                   5935: a result, it is important to ensure, where possible, that packages in pkgsrc
                   5936: are portable. This chapter mentions some particular details you should pay
                   5937: attention to while working on pkgsrc.
                   5938: 
1.154     rillig   5939: 21.1.1. How to pull in user-settable variables from mk.conf
1.1       dsieger  5940: 
                   5941: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4       rillig   5942: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
                   5943: those variables in the preprocessor directives of make(1) (for example .if or
                   5944: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
                   5945: loads the user preferences.
1.1       dsieger  5946: 
                   5947: But note that some variables may not be completely defined after ../../mk/
                   5948: bsd.prefs.mk has been included, as they may contain references to variables
1.108     rillig   5949: that are not yet defined. In shell commands (the lines in Makefile that are
                   5950: indented with a tab) this is no problem, since variables are only expanded when
                   5951: they are used. But in the preprocessor directives mentioned above and in
                   5952: dependency lines (of the form target: dependencies) the variables are expanded
                   5953: at load time.
1.1       dsieger  5954: 
                   5955: Note
                   5956: 
1.108     rillig   5957: To check whether a variable can be used at load time, run pkglint -Wall on your
                   5958: package.
1.1       dsieger  5959: 
1.154     rillig   5960: 21.1.2. User interaction
1.1       dsieger  5961: 
                   5962: Occasionally, packages require interaction from the user, and this can be in a
                   5963: number of ways:
                   5964: 
                   5965:   * When fetching the distfiles, some packages require user interaction such as
                   5966:     entering username/password or accepting a license on a web page.
                   5967: 
                   5968:   * When extracting the distfiles, some packages may ask for passwords.
                   5969: 
                   5970:   * help to configure the package before it is built
                   5971: 
                   5972:   * help during the build process
                   5973: 
                   5974:   * help during the installation of a package
                   5975: 
1.108     rillig   5976: A package can set the INTERACTIVE_STAGE variable to define which stages need
                   5977: interaction. This should be done in the package's Makefile, e.g.:
1.1       dsieger  5978: 
                   5979: INTERACTIVE_STAGE=      configure install
                   5980: 
                   5981: The user can then decide to skip this package by setting the BATCH variable.
1.108     rillig   5982: Packages that require interaction are also excluded from bulk builds.
1.1       dsieger  5983: 
1.154     rillig   5984: 21.1.3. Handling licenses
1.1       dsieger  5985: 
                   5986: Authors of software can choose the licence under which software can be copied.
1.111     sevan    5987: The Free Software Foundation has declared some licenses "Free", and the Open
                   5988: Source Initiative has a definition of "Open Source".
                   5989: 
                   5990: By default, pkgsrc allows packages with Free or Open Source licenses to be
                   5991: built. To allow packages with other licenses to be built as well, the pkgsrc
                   5992: user needs to add these licenses to the ACCEPTABLE_LICENSES variable in mk.conf
                   5993: . Note that this variable only affects which packages may be built, while the
                   5994: license terms often also restrict the actual use of the package and its
                   5995: redistribution.
1.1       dsieger  5996: 
                   5997: One might want to only install packages with a BSD license, or the GPL, and not
1.20      jnemeth  5998: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
1.111     sevan    5999: variable. The pkgsrc user can override the default by setting the
                   6000: ACCEPTABLE_LICENSES variable with "=" instead of "+=". The licenses accepted by
                   6001: default are defined in the DEFAULT_ACCEPTABLE_LICENSES variable in the file
                   6002: pkgsrc/mk/license.mk.
1.1       dsieger  6003: 
                   6004: The license tag mechanism is intended to address copyright-related issues
                   6005: surrounding building, installing and using a package, and not to address
1.20      jnemeth  6006: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
                   6007: redistribution restrictions should set these tags.
1.1       dsieger  6008: 
                   6009: Denoting that a package may be copied according to a particular license is done
                   6010: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
                   6011: string identifying the license, e.g. in graphics/xv:
                   6012: 
                   6013: LICENSE=        xv-license
                   6014: 
                   6015: When trying to build, the user will get a notice that the package is covered by
                   6016: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
                   6017: 
                   6018: % make
                   6019: ===> xv-3.10anb9 has an unacceptable license: xv-license.
                   6020: ===>     To view the license, enter "/usr/bin/make show-license".
                   6021: ===>     To indicate acceptance, add this line to your /etc/mk.conf:
                   6022: ===>     ACCEPTABLE_LICENSES+=xv-license
                   6023: *** Error code 1
                   6024: 
                   6025: The license can be viewed with make show-license, and if the user so chooses,
1.4       rillig   6026: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1       dsieger  6027: should not in the future fail because of that license:
                   6028: 
                   6029: ACCEPTABLE_LICENSES+=xv-license
                   6030: 
1.111     sevan    6031: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
                   6032: is deprecated because it does not crisply refer to a particular license text.
                   6033: Another problem with such usage is that it does not enable a user to tell
                   6034: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
                   6035: for all packages with that tag.
                   6036: 
1.154     rillig   6037: 21.1.3.1. Adding a package with a new license
1.1       dsieger  6038: 
1.49      rodent   6039: When adding a package with a new license, the following steps are required:
                   6040: 
1.111     sevan    6041:  1. Check whether the license qualifies as Free or Open Source by referencing
                   6042:     Various Licenses and Comments about Them and Licenses by Name | Open Source
                   6043:     Initiative. If this is the case, the filename in pkgsrc/licenses/ does not
                   6044:     need the -license suffix, and the license name should be added to:
1.49      rodent   6045: 
                   6046:       + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
                   6047: 
                   6048:       + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
                   6049:         license.c
                   6050: 
                   6051:  2. The license text should be added to pkgsrc/licenses for displaying. A list
                   6052:     of known licenses can be seen in this directory.
1.1       dsieger  6053: 
1.154     rillig   6054: 21.1.3.2. Change to the license
1.1       dsieger  6055: 
1.111     sevan    6056: When the license changes (in a way other than formatting), make sure that the
                   6057: new license has a different name (e.g., append the version number if it exists,
                   6058: or the date). Just because a user told pkgsrc to build programs under a
                   6059: previous version of a license does not mean that pkgsrc should build programs
                   6060: under the new licenses. The higher-level point is that pkgsrc does not evaluate
                   6061: licenses for reasonableness; the only test is a mechanistic test of whether a
                   6062: particular text has been approved by either of two bodies (FSF or OSI).
1.1       dsieger  6063: 
1.154     rillig   6064: 21.1.4. Restricted packages
1.1       dsieger  6065: 
1.111     sevan    6066: Some licenses restrict how software may be re-distributed. By declaring the
                   6067: restrictions, package tools can automatically refrain from e.g. placing binary
                   6068: packages on FTP sites.
                   6069: 
                   6070: There are four possible restrictions, which are the cross product of sources
                   6071: (distfiles) and binaries not being placed on FTP sites and CD-ROMs. Because
                   6072: this is rarely the exact language in any license, and because non-Free licenses
                   6073: tend to be different from each other, pkgsrc adopts a definition of FTP and
                   6074: CD-ROM. "FTP" means making the source or binary file available over the
                   6075: Internet at no charge. "CD-ROM" means making the source or binary available on
                   6076: some kind of media, together with other source and binary packages, which is
                   6077: sold for a distribution charge.
1.1       dsieger  6078: 
                   6079: In order to encode these restrictions, the package system defines five make
                   6080: variables that can be set to note these restrictions:
                   6081: 
                   6082:   * RESTRICTED
                   6083: 
                   6084:     This variable should be set whenever a restriction exists (regardless of
                   6085:     its kind). Set this variable to a string containing the reason for the
                   6086:     restriction. It should be understood that those wanting to understand the
                   6087:     restriction will have to read the license, and perhaps seek advice of
                   6088:     counsel.
                   6089: 
                   6090:   * NO_BIN_ON_CDROM
                   6091: 
                   6092:     Binaries may not be placed on CD-ROM containing other binary packages, for
                   6093:     which a distribution charge may be made. In this case, set this variable to
                   6094:     ${RESTRICTED}.
                   6095: 
                   6096:   * NO_BIN_ON_FTP
                   6097: 
                   6098:     Binaries may not made available on the Internet without charge. In this
                   6099:     case, set this variable to ${RESTRICTED}. If this variable is set, binary
                   6100:     packages will not be included on ftp.NetBSD.org.
                   6101: 
                   6102:   * NO_SRC_ON_CDROM
                   6103: 
                   6104:     Distfiles may not be placed on CD-ROM, together with other distfiles, for
                   6105:     which a fee may be charged. In this case, set this variable to $
                   6106:     {RESTRICTED}.
                   6107: 
                   6108:   * NO_SRC_ON_FTP
                   6109: 
                   6110:     Distfiles may not made available via FTP at no charge. In this case, set
                   6111:     this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
                   6112:     will not be mirrored on ftp.NetBSD.org.
                   6113: 
1.111     sevan    6114: Please note that packages will be removed from pkgsrc when the distfiles are
1.33      wiz      6115: not distributable and cannot be obtained for a period of one full quarter
1.111     sevan    6116: branch. Packages with manual/interactive fetch must have a maintainer and it is
                   6117: his/her responsibility to ensure this.
1.33      wiz      6118: 
1.154     rillig   6119: 21.1.5. Handling dependencies
1.1       dsieger  6120: 
1.175     gutterid 6121: Your package may depend on some other package being present, and there are
                   6122: various ways of expressing this dependency. pkgsrc supports the DEPENDS,
                   6123: BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS definitions, the USE_TOOLS
                   6124: definition, as well as dependencies via buildlink3.mk, which is the preferred
                   6125: way to handle dependencies, and which uses the variables named above. See
1.184     rillig   6126: Chapter 18, Buildlink methodology for more information.
1.175     gutterid 6127: 
                   6128: The basic difference is that the DEPENDS definition registers that
                   6129: pre-requisite in the binary package so it will be pulled in when the binary
                   6130: package is later installed, whilst the BUILD_DEPENDS, TOOL_DEPENDS, and
                   6131: TEST_DEPENDS definitions do not, marking a dependency that is only needed for
1.184     rillig   6132: building or testing the resulting package. See also Chapter 14, Creating a new
1.175     gutterid 6133: pkgsrc package from scratch for more information.
                   6134: 
                   6135: This means that if you only need a package present whilst you are building or
                   6136: testing, it should be noted as a TOOL_DEPENDS, BUILD_DEPENDS, or TEST_DEPENDS.
                   6137: When cross-compiling, TOOL_DEPENDS are native packages, i.e. packages for the
                   6138: architecture where the package is built; BUILD_DEPENDS are target packages,
                   6139: i.e., packages for the architecture for which the package is built.
1.1       dsieger  6140: 
1.175     gutterid 6141: The format for a DEPENDS, BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS
                   6142: definition is:
1.1       dsieger  6143: 
                   6144: <pre-req-package-name>:../../<category>/<pre-req-package>
                   6145: 
                   6146: Please note that the "pre-req-package-name" may include any of the wildcard
                   6147: version numbers recognized by pkg_info(1).
                   6148: 
1.55      wiz      6149:  1. If your package needs another package's binaries or libraries to build and
1.1       dsieger  6150:     run, and if that package has a buildlink3.mk file available, use it:
                   6151: 
                   6152:     .include "../../graphics/jpeg/buildlink3.mk"
                   6153: 
1.55      wiz      6154:  2. If your package needs another package's binaries or libraries only for
                   6155:     building, and if that package has a buildlink3.mk file available, use it:
                   6156: 
                   6157:     .include "../../graphics/jpeg/buildlink3.mk"
                   6158: 
                   6159:     but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
                   6160:     This case is rather rare.
                   6161: 
                   6162:  3. If your package needs binaries from another package to build, use the
1.156     leot     6163:     TOOL_DEPENDS definition:
                   6164: 
                   6165:     TOOL_DEPENDS+= itstool-[0-9]*:../../textproc/itstool
1.1       dsieger  6166: 
1.156     leot     6167:  4. If your package needs static libraries to link against, header files to
                   6168:     include, etc. from another package to build, use the BUILD_DEPENDS
                   6169:     definition.
1.1       dsieger  6170: 
1.156     leot     6171:  5. If your package needs a library with which to link and there is no
1.26      spz      6172:     buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
                   6173:     because the include files and libraries will be hidden from the compiler.
1.1       dsieger  6174: 
1.156     leot     6175:  6. If your package needs some executable to be able to run correctly and if
1.26      spz      6176:     there's no buildlink3.mk file, this is specified using the DEPENDS
                   6177:     variable. The print/lyx package needs to be able to execute the latex
1.129     wiz      6178:     binary from the tex-latex-bin package when it runs, and that is specified:
1.1       dsieger  6179: 
1.129     wiz      6180:     DEPENDS+=        tex-latex-bin-[0-9]*:../../print/tex-latex-bin
1.1       dsieger  6181: 
1.175     gutterid 6182:  7. If your package includes a test suite that has extra dependencies only
                   6183:     required for this purpose (frequently this can be run as a "make test"
                   6184:     target), use the TEST_DEPENDS variable.
                   6185: 
                   6186:  8. You can use wildcards in package dependencies. Note that such wildcard
1.26      spz      6187:     dependencies are retained when creating binary packages. The dependency is
                   6188:     checked when installing the binary package and any package which matches
                   6189:     the pattern will be used. Wildcard dependencies should be used with care.
1.1       dsieger  6190: 
                   6191:     The "-[0-9]*" should be used instead of "-*" to avoid potentially ambiguous
                   6192:     matches such as "tk-postgresql" matching a "tk-*" DEPENDS.
                   6193: 
                   6194:     Wildcards can also be used to specify that a package will only build
                   6195:     against a certain minimum version of a pre-requisite:
                   6196: 
1.26      spz      6197:     DEPENDS+=       ImageMagick>=6.0:../../graphics/ImageMagick
1.1       dsieger  6198: 
1.26      spz      6199:     This means that the package will build using version 6.0 of ImageMagick or
                   6200:     newer. Such a dependency may be warranted if, for example, the command line
                   6201:     options of an executable have changed.
                   6202: 
1.183     wiz      6203:     If you need to depend on minimum versions of libraries, set
                   6204:     BUILDLINK_API_DEPENDS.pkg to the appropriate pattern before including its
                   6205:     buildlink3.mk file, e.g.
                   6206: 
                   6207:     BUILDLINK_API_DEPENDS.jpeg+=    jpeg>=9.0
                   6208:     .include "../../graphics/jpeg/buildlink3.mk"
1.1       dsieger  6209: 
                   6210:     For security fixes, please update the package vulnerabilities file. See
1.154     rillig   6211:     Section 21.1.9, "Handling packages with security problems" for more
1.1       dsieger  6212:     information.
                   6213: 
                   6214: If your package needs files from another package to build, add the relevant
                   6215: distribution files to DISTFILES, so they will be extracted automatically. See
                   6216: the print/ghostscript package for an example. (It relies on the jpeg sources
                   6217: being present in source form during the build.)
                   6218: 
1.154     rillig   6219: 21.1.6. Handling conflicts with other packages
1.1       dsieger  6220: 
1.226     gutterid 6221: Your package may conflict with other packages users might already have
                   6222: installed on their system, e.g., if your package installs the same set of files
1.227     wiz      6223: as another package in the pkgsrc tree.
1.1       dsieger  6224: 
1.142     leot     6225: For example, x11/libXaw3d and x11/Xaw-Xpm install the same shared library, thus
                   6226: you set in pkgsrc/x11/libXaw3d/Makefile:
1.1       dsieger  6227: 
1.142     leot     6228: CONFLICTS=      Xaw-Xpm-[0-9]*
1.1       dsieger  6229: 
1.142     leot     6230: and in pkgsrc/x11/Xaw-Xpm/Makefile:
1.1       dsieger  6231: 
1.142     leot     6232: CONFLICTS=      libXaw3d-[0-9]*
1.1       dsieger  6233: 
1.142     leot     6234: pkg_add(1) is able to detect attempts to install packages that conflict with
                   6235: existing packages and abort. However, in many situations this is too late in
                   6236: the process. Binary package managers will not know about the conflict until
                   6237: they attempt to install the package after already downloading it and all its
                   6238: dependencies. Users may also waste time building a package and its dependencies
                   6239: only to find out at the end that it conflicts with another package they have
                   6240: installed.
                   6241: 
                   6242: To avoid these issues CONFLICTS entries should be added in all cases where it
                   6243: is known that packages conflict with each other. These CONFLICTS entries are
                   6244: exported in pkg_summary(5) files and consumed by binary package managers to
                   6245: inform users that packages cannot be installed onto the target system.
1.1       dsieger  6246: 
1.154     rillig   6247: 21.1.7. Packages that cannot or should not be built
1.1       dsieger  6248: 
                   6249: There are several reasons why a package might be instructed to not build under
                   6250: certain circumstances. If the package builds and runs on most platforms, the
1.83      dholland 6251: exceptions should be noted with BROKEN_ON_PLATFORM. If the package builds and
                   6252: runs on a small handful of platforms, set BROKEN_EXCEPT_ON_PLATFORM instead.
                   6253: Both BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM are OS triples
                   6254: (OS-version-platform) that can use glob-style wildcards.
                   6255: 
1.114     maya     6256: If a package is not appropriate for some platforms (as opposed to merely
1.83      dholland 6257: broken), a different set of variables should be used as this affects failure
                   6258: reporting and statistics. If the package is appropriate for most platforms, the
                   6259: exceptions should be noted with NOT_FOR_PLATFORM. If the package is appropriate
                   6260: for only a small handful of platforms (often exactly one), set
                   6261: ONLY_FOR_PLATFORM instead. Both ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS
                   6262: triples (OS-version-platform) that can use glob-style wildcards.
1.1       dsieger  6263: 
                   6264: Some packages are tightly bound to a specific version of an operating system,
                   6265: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
                   6266: with other versions of the OS, and should be uploaded to a version specific
                   6267: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
                   6268: to "yes". This variable is not currently used by any of the package system
                   6269: internals, but may be used in the future.
                   6270: 
                   6271: If the package should be skipped (for example, because it provides
                   6272: functionality already provided by the system), set PKG_SKIP_REASON to a
                   6273: descriptive message. If the package should fail because some preconditions are
                   6274: not met, set PKG_FAIL_REASON to a descriptive message.
                   6275: 
1.154     rillig   6276: 21.1.8. Packages which should not be deleted, once installed
1.1       dsieger  6277: 
                   6278: To ensure that a package may not be deleted, once it has been installed, the
                   6279: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.25      wiz      6280: carried into any binary package that is made from this pkgsrc entry. A "
                   6281: preserved" package will not be deleted using pkg_delete(1) unless the "-f"
1.1       dsieger  6282: option is used.
                   6283: 
1.154     rillig   6284: 21.1.9. Handling packages with security problems
1.1       dsieger  6285: 
1.247     wiz      6286: When a vulnerability is found, this should be noted in pkgsrc/doc/
                   6287: pkg-vulnerabilities. Entries in that file consist of three parts:
1.205     wiz      6288: 
                   6289:   * package version pattern
                   6290: 
                   6291:   * type of vulnerability (please cut'n'paste an existing one where possible)
                   6292: 
                   6293:   * URL providing additional information about the issue
                   6294: 
                   6295: For the package version pattern please always use `<' to mark an upper bound
                   6296: (not `<='!). This will avoid possible problems due unrelated PKGREVISION bumps
                   6297: not related to security fixes. Lower bounds can be added too, using '>' or '>=
1.206     wiz      6298: '. For example, "foo>=1<1.2" would mark versions 1.0 (included) to 1.2
1.205     wiz      6299: (excluded) of "foo" as affected by the security issue.
                   6300: 
                   6301: Entries should always be added at the bottom of the file.
                   6302: 
                   6303: When fixing packages, please modify the upper bound of the corresponding entry.
                   6304: To continue the previous example, if a fix was backported to version 1.1nb2,
1.206     wiz      6305: change the previous pattern to "foo>=1<1.1nb2".
1.205     wiz      6306: 
                   6307: To locally test a package version pattern against a PKGNAME you can use the 
                   6308: pkg_admin pmatch command.
                   6309: 
                   6310: The URL should be as permanent as possible and provide as much information
                   6311: about the issue as possible. CVE entries are preferred.
                   6312: 
                   6313: After committing that file, ask pkgsrc-security@NetBSD.org to update the file
                   6314: on ftp.NetBSD.org.
1.1       dsieger  6315: 
                   6316: After fixing the vulnerability by a patch, its PKGREVISION should be increased
                   6317: (this is of course not necessary if the problem is fixed by using a newer
1.32      wiz      6318: release of the software), and the pattern in the pkg-vulnerabilities file must
                   6319: be updated.
1.1       dsieger  6320: 
                   6321: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
                   6322: submit a pullup request!
                   6323: 
                   6324: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
                   6325: a weekly cron job.
                   6326: 
1.205     wiz      6327: In case a security issue is disputed, please contact
                   6328: pkgsrc-security@NetBSD.org.
                   6329: 
1.154     rillig   6330: 21.1.10. How to handle incrementing versions when fixing an existing package
1.1       dsieger  6331: 
                   6332: When making fixes to an existing package it can be useful to change the version
                   6333: number in PKGNAME. To avoid conflicting with future versions by the original
                   6334: author, a "nb1", "nb2", ... suffix can be used on package versions by setting
                   6335: PKGREVISION=1 (2, ...). The "nb" is treated like a "." by the package tools.
                   6336: e.g.
                   6337: 
                   6338: DISTNAME=       foo-17.42
                   6339: PKGREVISION=    9
                   6340: 
                   6341: will result in a PKGNAME of "foo-17.42nb9". If you want to use the original
                   6342: value of PKGNAME without the "nbX" suffix, e.g. for setting DIST_SUBDIR, use
                   6343: PKGNAME_NOREV.
                   6344: 
                   6345: When a new release of the package is released, the PKGREVISION should be
                   6346: removed, e.g. on a new minor release of the above package, things should be
                   6347: like:
                   6348: 
                   6349: DISTNAME=       foo-17.43
                   6350: 
                   6351: PKGREVISION should be incremented for any non-trivial change in the resulting
                   6352: binary package. Without a PKGREVISION bump, someone with the previous version
                   6353: installed has no way of knowing that their package is out of date. Thus,
                   6354: changes without increasing PKGREVISION are essentially labeled "this is so
                   6355: trivial that no reasonable person would want to upgrade", and this is the rough
                   6356: test for when increasing PKGREVISION is appropriate. Examples of changes that
                   6357: do not merit increasing PKGREVISION are:
                   6358: 
1.14      jmcneill 6359:   * Changing HOMEPAGE, MAINTAINER, OWNER, or comments in Makefile.
1.1       dsieger  6360: 
                   6361:   * Changing build variables if the resulting binary package is the same.
                   6362: 
                   6363:   * Changing DESCR.
                   6364: 
                   6365:   * Adding PKG_OPTIONS if the default options don't change.
                   6366: 
                   6367: Examples of changes that do merit an increase to PKGREVISION include:
                   6368: 
                   6369:   * Security fixes
                   6370: 
                   6371:   * Changes or additions to a patch file
                   6372: 
                   6373:   * Changes to the PLIST
                   6374: 
1.12      weinem   6375:   * A dependency is changed or renamed.
                   6376: 
1.1       dsieger  6377: PKGREVISION must also be incremented when dependencies have ABI changes.
                   6378: 
1.154     rillig   6379: 21.1.11. Substituting variable text in the package files (the SUBST framework)
1.1       dsieger  6380: 
1.180     rillig   6381: When you want to replace the same text in multiple files, or multiple times in
                   6382: the same file, it is cumbersome to maintain a patch file for this. This is
                   6383: where the SUBST framework steps in. It provides an easy-to-use interface for
                   6384: replacing text in files. It just needs the following information:
1.172     rillig   6385: 
1.180     rillig   6386:   * In which phase of the package build cycle should the replacement happen?
1.172     rillig   6387: 
1.180     rillig   6388:   * In which files should the replacement happen?
1.172     rillig   6389: 
                   6390:   * Which text should be replaced with what?
                   6391: 
1.180     rillig   6392: This information is encoded in a block of SUBST variables. A minimal example
                   6393: is:
                   6394: 
                   6395: SUBST_CLASSES+=         paths
                   6396: SUBST_STAGE.paths=      pre-configure
                   6397: SUBST_FILES.paths=      src/*.c
                   6398: SUBST_SED.paths=        -e 's,/usr/local,${PREFIX},g'
                   6399: 
                   6400: Translated into English, it means: In the pre-configure stage (that is, after
                   6401: applying the patches from the patches/ directory and before running the
                   6402: configure script and the portability check), replace the text /usr/local with
                   6403: the content of the variable PREFIX.
                   6404: 
                   6405: Each SUBST block starts by appending an identifier to SUBST_CLASSES (note the +
                   6406: =). This identifier can be chosen freely by the package. If there should ever
                   6407: be duplicate identifiers, the pkgsrc infrastructure will catch this and fail
                   6408: early, so don't worry about name collisions.
                   6409: 
                   6410: Except for SUBST_CLASSES, all variables in a SUBST block are parameterized
                   6411: using this identifier. In the remainder of this section, these parameterized
                   6412: variables are written as SUBST_STAGE.*.
                   6413: 
                   6414: SUBST_CLASSES+=         paths
                   6415: SUBST_STAGE.paths=      pre-configure
                   6416: SUBST_MESSAGE.paths=    Fixing absolute paths.
                   6417: SUBST_FILES.paths=      src/*.c
                   6418: SUBST_FILES.paths+=     scripts/*.sh
                   6419: SUBST_SED.paths=        -e 's,"/usr/local,"${PREFIX},g'
                   6420: SUBST_SED.paths+=       -e 's,"/var/log,"${VARBASE}/log,g'
                   6421: SUBST_VARS.paths=       LOCALBASE PREFIX PKGVERSION
                   6422: 
                   6423: To get a complete picture about the SUBST substitutions, run bmake
                   6424: show-all-subst. If something doesn't work as expected, run pkglint on the
                   6425: package, which detects several typical mistakes surrounding the SUBST blocks.
                   6426: For any questions that might remain after this, have a look at mk/subst.mk.
                   6427: 
                   6428: 21.1.11.1. Choosing the time where the substitutions happen
                   6429: 
                   6430: The SUBST_STAGE.* is one of {pre,do,post}-
                   6431: {extract,patch,configure,build,test,install}. Of these, pre-configure is used
                   6432: most often, by far. The most popular stages are, in chronological order:
                   6433: 
                   6434: post-extract
                   6435: 
                   6436:     The substitutions are applied immediately after the distfiles are
                   6437:     extracted. Running bmake extract on the package will leave no traces of the
                   6438:     original files.
                   6439: 
                   6440:     When the substitution applies to files for which there is also a patch in
                   6441:     the patches/ directory, this means that the patches will be computed based
                   6442:     on the result of the substitution. When these patches are sent to the
                   6443:     upstream maintainer later, to be fixed in the upstream package, these
                   6444:     patches may no longer match what the upstream author is used to. Because of
                   6445:     this, pre-configure is often a better choice.
                   6446: 
                   6447: pre-configure
                   6448: 
                   6449:     The substitutions are applied after the patches from the patches/
                   6450:     directory. This makes it possible to run bmake patch on the package, after
                   6451:     which the patches can be edited using the tools pkgvi and mkpatches from
                   6452:     the pkgtools/pkgdiff package.
                   6453: 
                   6454:     When updating the patches, it is helpful to explicitly separate the bmake
                   6455:     patch from the bmake configure, and to only edit the patches between these
                   6456:     commands. Otherwise the substitutions from the SUBST block will end up in
                   6457:     the patch file. When this happens in really obvious ways, pkglint will
                   6458:     complain about patches that contain a hard-coded /usr/pkg instead of the
                   6459:     correct and intended @PREFIX@, but it can only detect these really obvious
                   6460:     cases.
                   6461: 
                   6462: do-configure
                   6463: 
                   6464:     This stage should only be used if the package defines a pre-configure
                   6465:     action itself, and the substitution must happen after that. Typical
                   6466:     examples are packages that use the pre-configure stage to regenerate the
                   6467:     GNU configure script from configure.ac.
                   6468: 
                   6469: post-configure
                   6470: 
                   6471:     This stage is used to fix up any mistakes by the configure stage.
                   6472: 
                   6473: pre-build
                   6474: 
                   6475:     This stage should only be used for substitutions that are clearly related
                   6476:     to building the package, not for fixing the configuration. Substitutions
                   6477:     for pathnames (such as replacing /usr/local with ${PREFIX}) or user names
                   6478:     (such as replacing @MY_USER@ with the actual username) belong in
                   6479:     pre-configure or post-configure instead.
                   6480: 
                   6481: post-build
                   6482: 
                   6483:     Just as with pre-build, this stage should only be used for substitutions
                   6484:     that are clearly related to building the package, not for fixing the
                   6485:     configuration. Substitutions for pathnames (such as replacing /usr/local
                   6486:     with ${PREFIX}) or user names (such as replacing @MY_USER@ with the actual
                   6487:     username) belong in pre-configure or post-configure instead.
                   6488: 
                   6489:     A typical use is to update pkg-config files to include the rpath compiler
                   6490:     options.
                   6491: 
                   6492: pre-install
                   6493: 
                   6494:     In general, the install phase should be as simple as possible. As with the
                   6495:     pre-build and post-build stages, it should not be used to fix pathnames or
                   6496:     user names, these belong in pre-configure instead. There are only few
                   6497:     legitimate use cases for applying substitutions in this stage.
                   6498: 
1.181     rillig   6499: 21.1.11.2. Choosing the files where the substitutions happen
1.180     rillig   6500: 
                   6501: The SUBST_FILES.* variable contains a list of filename patterns. These patterns
                   6502: are relative to WRKSRC since that is where most substitutions happen. A typical
                   6503: example is:
                   6504: 
                   6505: SUBST_FILES.path=       Makefile */Makefile */*/Makefile *.[ch]
                   6506: 
                   6507: The above patterns, especially the last, are quite broad. The SUBST
                   6508: implementation checks that each filename pattern that is mentioned here has an
                   6509: effect. For example, if none of the */*/Makefile files contains the patterns to
                   6510: be found and substituted, that filename pattern is redundant and should be left
1.181     rillig   6511: out. By default, the SUBST framework will complain with an error message. If
                   6512: the text to be substituted occurs in some of the files from a single pattern,
                   6513: but not in all of them, that is totally ok, and the SUBST framework will only
                   6514: print an INFO message for those files.
1.180     rillig   6515: 
                   6516: If there is a good reason for having redundant filename patterns, set
1.181     rillig   6517: SUBST_NOOP_OK.* to yes.
1.180     rillig   6518: 
                   6519: Another popular way of choosing the files for the substitutions is via a shell
                   6520: command, like this:
                   6521: 
1.181     rillig   6522: C_FILES_CMD=            cd ${WRKSRC} && ${FIND} . -name '*.c'
1.180     rillig   6523: SUBST_FILES.path=       ${C_FILES_CMD:sh}
                   6524: 
                   6525: The variable name C_FILES_CMD in this example is freely chosen and independent
                   6526: of the SUBST framework.
                   6527: 
                   6528: In this variant, the SUBST_FILES.* variable lists each file individually.
                   6529: Thereby chances are higher that there are filename patterns in which no
                   6530: substitution happens. Since the SUBST framework cannot know whether the
                   6531: filename patterns in SUBST_FILES.* have been explicitly listed in the Makefile
                   6532: (where any redundant filename pattern would be suspicious) or been generated by
                   6533: a shell command (in which redundant filename patterns are more likely and to be
                   6534: expected), it will complain about these redundant filename patterns. Therefore,
                   6535: SUBST blocks that use a shell command to generate the list of filename patterns
                   6536: often need to set SUBST_NOOP_OK.* to yes.
                   6537: 
                   6538: 21.1.11.3. Choosing what to substitute
                   6539: 
                   6540: In most cases, the substitutions are given using one or more sed(1) commands,
                   6541: like this:
                   6542: 
                   6543: SUBST_SED.path=         -e 's|/usr/local|${PREFIX}|g'
                   6544: 
                   6545: Each of the sed commands needs to be preceded by the -e option and should be
                   6546: specified on a line of its own, to avoid hiding short sed commands at the end
                   6547: of a line.
                   6548: 
                   6549: Since the sed commands often contain shell metacharacters as the separator (the
                   6550: | in the above example), it is common to enclose them in single quotes.
                   6551: 
                   6552: A common substitution is to replace placeholders of the form @VARNAME@ with
                   6553: their pkgsrc counterpart variable ${VARNAME}. A typical example is:
                   6554: 
                   6555: SUBST_VARS.path=        PREFIX
                   6556: 
1.181     rillig   6557: This type of substitutions is typically done by the GNU configure scripts
                   6558: during the do-configure stage, but in some cases these need to be overridden.
                   6559: The same pattern is also used when a package defines patches that replace
                   6560: previously hard-coded paths like /usr/local with a @PREFIX@ placeholder first,
                   6561: which then gets substituted by the actual ${PREFIX} in the pre-configure stage.
                   6562: In many of these cases, it works equally well to just use the SUBST framework
                   6563: to directly replace /usr/local with ${PREFIX}, thereby omitting the
                   6564: intermediate patch file.
1.180     rillig   6565: 
                   6566: If the above is not flexible enough, it is possible to not use sed at all for
                   6567: the substitution but to specify an entirely different command, like this:
                   6568: 
                   6569: SUBST_FILTER_CMD.path=  LC_ALL=C ${TR} -d '\r'
1.1       dsieger  6570: 
1.180     rillig   6571: This is used for the few remaining packages in which the distributed files use
                   6572: Windows-style line endings that need to be converted to UNIX-style line
                   6573: endings.
1.1       dsieger  6574: 
1.180     rillig   6575: 21.1.11.4. Other SUBST variables
1.172     rillig   6576: 
1.180     rillig   6577: When a SUBST block is applied during a package build, a message is logged. The
                   6578: default message is fine for most purposes but can be overridden by setting
                   6579: SUBST_MESSAGE.* to an individual message.
1.1       dsieger  6580: 
1.154     rillig   6581: 21.2. The fetch phase
1.1       dsieger  6582: 
1.154     rillig   6583: 21.2.1. Packages whose distfiles aren't available for plain downloading
1.1       dsieger  6584: 
                   6585: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
                   6586: a make fetch will call files/getsite.sh with the name of each file to download
                   6587: as an argument, expecting it to output the URL of the directory from which to
                   6588: download it. graphics/ns-cult3d is an example of this usage.
                   6589: 
                   6590: If the download can't be automated, because the user must submit personal
                   6591: information to apply for a password, or must pay for the source, or whatever,
                   6592: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
                   6593: before aborting the build. Example:
                   6594: 
                   6595: FETCH_MESSAGE=  "Please download the files"
                   6596: FETCH_MESSAGE+= "    "${DISTFILES:Q}
                   6597: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
                   6598: 
1.154     rillig   6599: 21.2.2. How to handle modified distfiles with the 'old' name
1.1       dsieger  6600: 
                   6601: Sometimes authors of a software package make some modifications after the
                   6602: software was released, and they put up a new distfile without changing the
                   6603: package's version number. If a package is already in pkgsrc at that time, the
                   6604: checksum will no longer match. The contents of the new distfile should be
                   6605: compared against the old one before changing anything, to make sure the
                   6606: distfile was really updated on purpose, and that no trojan horse or so crept
                   6607: in. Please mention that the distfiles were compared and what was found in your
1.54      rodent   6608: commit message.
                   6609: 
                   6610: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
1.109     wiz      6611: directory name, usually based on PKGNAME_NOREV (but take care with python or
                   6612: ruby packages, where PKGNAME includes a variable prefix). All DISTFILES and
                   6613: PATCHFILES for this package will be put in that subdirectory of the local
1.154     rillig   6614: distfiles directory. (See Section 21.1.10, "How to handle incrementing versions
1.109     wiz      6615: when fixing an existing package" for more details.) In case this happens more
                   6616: often, PKGNAME can be used (thus including the nbX suffix) or a date stamp can
                   6617: be appended, like ${PKGNAME_NOREV}-YYYYMMDD.
1.54      rodent   6618: 
                   6619: DIST_SUBDIR is also used when a distfile's name does not contain a version and
                   6620: the distfile is apt to change. In cases where the likelihood of this is very
                   6621: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
                   6622: removed unless the distfile name changes, even if a package is being moved or
                   6623: renamed.
                   6624: 
                   6625: Do not forget regenerating the distinfo file after that, since it contains the
                   6626: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
                   6627: installed package is different. Furthermore, a mail to the package's authors
                   6628: seems appropriate telling them that changing distfiles after releases without
                   6629: changing the file names is not good practice.
1.1       dsieger  6630: 
1.154     rillig   6631: 21.2.3. Packages hosted on github.com
1.88      tnn      6632: 
1.90      tnn      6633: Helper methods exist for packages hosted on github.com which will often have
                   6634: distfile names that clash with other packages, for example 1.0.tar.gz. Use one
                   6635: of the three recipes from below:
1.88      tnn      6636: 
1.154     rillig   6637: 21.2.3.1. Fetch based on a tagged release
1.88      tnn      6638: 
1.189     bacon    6639: If your distfile URL looks similar to https://github.com/username/example/
                   6640: archive/v1.0.zip, then you are packaging a tagged release.
1.88      tnn      6641: 
1.189     bacon    6642: DISTNAME=       example-1.0
1.90      tnn      6643: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
1.189     bacon    6644: #GITHUB_PROJECT= example    # can be omitted if same as DISTNAME
1.90      tnn      6645: GITHUB_TAG=     v${PKGVERSION_NOREV}
1.88      tnn      6646: EXTRACT_SUFX=   .zip
                   6647: 
1.230     gutterid 6648: Here, DISTNAME combined with use of GITHUB_TAG leads the file fetching
                   6649: infrastructure to save the resulting file locally as example-1.0.zip.
                   6650: 
1.189     bacon    6651: 21.2.3.2. Fetch based on a specific commit before the first release
                   6652: 
                   6653: If your distfile looks similar to https://github.com/username/example/archive/
                   6654: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit before the first
                   6655: release, then set the package version to 0.0.0.N, where N is the number of
                   6656: commits to the repository, and set GITHUB_TAG to the commit hash. This will
                   6657: (almost) ensure that the first tagged release will have a version greater than
                   6658: this one so that package upgrades will function properly.
                   6659: 
                   6660: DISTNAME=       example-0.0.0.347
                   6661: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6662: #GITHUB_PROJECT= example    # can be omitted if same as DISTNAME
                   6663: GITHUB_TAG=     988881adc9fc3655077dc2d4d757d480b5ea0e11
                   6664: 
                   6665: 21.2.3.3. Fetch based on a specific commit after a release
1.88      tnn      6666: 
1.189     bacon    6667: If your distfile looks similar to https://github.com/username/example/archive/
                   6668: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit after a release,
                   6669: then include the last release version and the commit count since that release
                   6670: in the package version and set GITHUB_TAG to the commit hash. The latest
                   6671: release and commit count are shown in the output of "git describe --tags":
                   6672: 
                   6673: # git clone https://github.com/username/example
                   6674: # cd example
                   6675: # git describe --tags
                   6676: 1.2.3-5-g988881a
1.88      tnn      6677: 
1.189     bacon    6678: DISTNAME=       example-1.2.3.5
                   6679: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6680: #GITHUB_PROJECT= example    # can be omitted if same as DISTNAME
1.90      tnn      6681: GITHUB_TAG=     988881adc9fc3655077dc2d4d757d480b5ea0e11
1.88      tnn      6682: 
1.189     bacon    6683: 21.2.3.4. Fetch based on release
1.88      tnn      6684: 
1.189     bacon    6685: If your distfile URL looks similar to https://github.com/username/example/
                   6686: releases/download/rel-1.6/offensive-1.6.zip, then you are packaging a release.
1.88      tnn      6687: 
1.90      tnn      6688: DISTNAME=       offensive-1.6
1.88      tnn      6689: PKGNAME=        ${DISTNAME:S/offensive/proper/}
1.90      tnn      6690: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
1.189     bacon    6691: GITHUB_PROJECT= example
1.90      tnn      6692: GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
                   6693: EXTRACT_SUFX=   .zip
1.88      tnn      6694: 
1.154     rillig   6695: 21.3. The configure phase
1.1       dsieger  6696: 
1.154     rillig   6697: 21.3.1. Shared libraries - libtool
1.1       dsieger  6698: 
                   6699: pkgsrc supports many different machines, with different object formats like
                   6700: a.out and ELF, and varying abilities to do shared library and dynamic loading
                   6701: at all. To accompany this, varying commands and options have to be passed to
                   6702: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
                   6703: especially if you don't have all the machines at your hand to test things. The
                   6704: devel/libtool pkg can help here, as it just "knows" how to build both static
                   6705: and dynamic libraries from a set of source files, thus being
                   6706: platform-independent.
                   6707: 
                   6708: Here's how to use libtool in a package in seven simple steps:
                   6709: 
                   6710:  1. Add USE_LIBTOOL=yes to the package Makefile.
                   6711: 
                   6712:  2. For library objects, use "${LIBTOOL} --mode=compile ${CC}" in place of "$
                   6713:     {CC}". You could even add it to the definition of CC, if only libraries are
                   6714:     being built in a given Makefile. This one command will build both PIC and
                   6715:     non-PIC library objects, so you need not have separate shared and
                   6716:     non-shared library rules.
                   6717: 
                   6718:  3. For the linking of the library, remove any "ar", "ranlib", and "ld
                   6719:     -Bshareable" commands, and instead use:
                   6720: 
                   6721:     ${LIBTOOL} --mode=link \
                   6722:         ${CC} -o ${.TARGET:.a=.la} \
                   6723:             ${OBJS:.o=.lo} \
                   6724:             -rpath ${PREFIX}/lib \
                   6725:             -version-info major:minor
                   6726: 
                   6727:     Note that the library is changed to have a .la extension, and the objects
                   6728:     are changed to have a .lo extension. Change OBJS as necessary. This
                   6729:     automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
                   6730:     necessary) in the build directory. Be sure to include "-version-info",
                   6731:     especially when major and minor are zero, as libtool will otherwise strip
                   6732:     off the shared library version.
                   6733: 
                   6734:     From the libtool manual:
                   6735: 
                   6736:     So, libtool library versions are described by three integers:
                   6737: 
                   6738:     CURRENT
                   6739:     The most recent interface number that this library implements.
                   6740: 
                   6741:     REVISION
                   6742:     The implementation number of the CURRENT interface.
                   6743: 
                   6744:     AGE
                   6745:     The difference between the newest and oldest interfaces that
                   6746:     this library implements.  In other words, the library implements
                   6747:     all the interface numbers in the range from number `CURRENT -
                   6748:     AGE' to `CURRENT'.
                   6749: 
                   6750:     If two libraries have identical CURRENT and AGE numbers, then the
                   6751:     dynamic linker chooses the library with the greater REVISION number.
                   6752: 
                   6753:     The "-release" option will produce different results for a.out and ELF
1.25      wiz      6754:     (excluding symlinks) in only one case. An ELF library of the form "
                   6755:     libfoo-release.so.x.y" will have a symlink of "libfoo.so.x.y" on an a.out
1.1       dsieger  6756:     platform. This is handled automatically.
                   6757: 
                   6758:     The "-rpath argument" is the install directory of the library being built.
                   6759: 
                   6760:     In the PLIST, include only the .la file, the other files will be added
                   6761:     automatically.
                   6762: 
                   6763:  4. When linking shared object (.so) files, i.e. files that are loaded via
                   6764:     dlopen(3), NOT shared libraries, use "-module -avoid-version" to prevent
                   6765:     them getting version tacked on.
                   6766: 
                   6767:     The PLIST file gets the foo.so entry.
                   6768: 
                   6769:  5. When linking programs that depend on these libraries before they are
                   6770:     installed, preface the cc(1) or ld(1) line with "${LIBTOOL} --mode=link",
                   6771:     and it will find the correct libraries (static or shared), but please be
                   6772:     aware that libtool will not allow you to specify a relative path in -L
                   6773:     (such as "-L../somelib"), because it expects you to change that argument to
                   6774:     be the .la file. e.g.
                   6775: 
                   6776:     ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
                   6777: 
                   6778:     should be changed to:
                   6779: 
                   6780:     ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
                   6781: 
                   6782:     and it will do the right thing with the libraries.
                   6783: 
                   6784:  6. When installing libraries, preface the install(1) or cp(1) command with "$
                   6785:     {LIBTOOL} --mode=install", and change the library name to .la. e.g.
                   6786: 
1.23      jakllsch 6787:     ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1       dsieger  6788: 
                   6789:     This will install the static .a, shared library, any needed symlinks, and
                   6790:     run ldconfig(8).
                   6791: 
                   6792:  7. In your PLIST, include only the .la file (this is a change from previous
                   6793:     behaviour).
                   6794: 
1.154     rillig   6795: 21.3.2. Using libtool on GNU packages that already support libtool
1.1       dsieger  6796: 
                   6797: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
                   6798: own libtool in most cases. For older libtool using packages, libtool is made by
                   6799: ltconfig script during the do-configure step; you can check the libtool script
                   6800: location by doing make configure; find work*/ -name libtool.
                   6801: 
                   6802: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
                   6803: override. By default, it is set to "libtool */libtool */*/libtool". If this
                   6804: does not match the location of the package's libtool script(s), set it as
                   6805: appropriate.
                   6806: 
                   6807: If you do not need *.a static libraries built and installed, then use
                   6808: SHLIBTOOL_OVERRIDE instead.
                   6809: 
                   6810: If your package makes use of the platform-independent library for loading
                   6811: dynamic shared objects, that comes with libtool (libltdl), you should include
                   6812: devel/libltdl/buildlink3.mk.
                   6813: 
                   6814: Some packages use libtool incorrectly so that the package may not work or build
                   6815: in some circumstances. Some of the more common errors are:
                   6816: 
                   6817:   * The inclusion of a shared object (-module) as a dependent library in an
                   6818:     executable or library. This in itself isn't a problem if one of two things
                   6819:     has been done:
                   6820: 
                   6821:      1. The shared object is named correctly, i.e. libfoo.la, not foo.la
                   6822: 
                   6823:      2. The -dlopen option is used when linking an executable.
                   6824: 
                   6825:   * The use of libltdl without the correct calls to initialisation routines.
                   6826:     The function lt_dlinit() should be called and the macro
                   6827:     LTDL_SET_PRELOADED_SYMBOLS included in executables.
                   6828: 
1.154     rillig   6829: 21.3.3. GNU Autoconf/Automake
1.1       dsieger  6830: 
                   6831: If a package needs GNU autoconf or automake to be executed to regenerate the
1.223     nia      6832: configure script and Makefile.in makefile templates from configure.ac and
                   6833: Makefile.am, then they should be executed in a pre-configure target:
1.1       dsieger  6834: 
1.223     nia      6835: USE_TOOLS+=     autoconf automake autoreconf
                   6836: GNU_CONFIGURE=  yes
1.1       dsieger  6837: ...
                   6838: 
                   6839: pre-configure:
1.223     nia      6840:         set -e; cd ${WRKSRC} && autoreconf -fi
1.1       dsieger  6841: ...
                   6842: 
1.223     nia      6843: Packages which use GNU Automake will sometimes require GNU Make (gmake in
                   6844: USE_TOOLS), but not always. Note that autoreconf only needs to be executed if
                   6845: configure.ac or Makefiles are modified, or configure is not present.
1.1       dsieger  6846: 
                   6847: There are times when the configure process makes additional changes to the
                   6848: generated files, which then causes the build process to try to re-execute the
                   6849: automake sequence. This is prevented by touching various files in the configure
                   6850: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
                   6851: NO in the package Makefile.
                   6852: 
1.223     nia      6853: 21.3.4. Meson / ninja
                   6854: 
                   6855: Packages using Meson to configure need to include:
                   6856: 
                   6857: .include "../../devel/meson/build.mk"
                   6858: 
                   6859: In nearly all cases (any program with dependencies), pkg-config needs to be
                   6860: added to USE_TOOLS. If the package installs translation files for non-English
                   6861: languages, also add msgfmt and xgettext:
                   6862: 
                   6863: USE_TOOLS+=     pkg-config msgfmt xgettext
                   6864: 
                   6865: If any options need to be passed to Meson, use MESON_ARGS instead of
                   6866: CONFIGURE_ARGS:
                   6867: 
                   6868: MESON_ARGS+=    -Dx11=false
                   6869: 
1.154     rillig   6870: 21.4. Programming languages
1.1       dsieger  6871: 
1.154     rillig   6872: 21.4.1. C, C++, and Fortran
1.1       dsieger  6873: 
1.244     gutterid 6874: Compilers for the C and C++ languages come with the NetBSD base system. By
1.223     nia      6875: default, pkgsrc assumes that a package is written in C and will hide all other
                   6876: compilers (via the wrapper framework, see Chapter 18, Buildlink methodology).
1.1       dsieger  6877: 
1.243     gutterid 6878: To declare which languages should be made available through pkgsrc's compiler
                   6879: wrappers, use the USE_LANGUAGES variable. Allowed values currently are:
1.212     wiz      6880: 
1.244     gutterid 6881: c, c++, fortran, fortran77, java, objc, obj-c++, and ada.
1.212     wiz      6882: 
                   6883: (and any combination). The default is "c". Packages using GNU configure
                   6884: scripts, even if written in C++, usually need a C compiler for the configure
1.244     gutterid 6885: phase.
1.243     gutterid 6886: 
1.250     jnemeth  6887: To declare which features a package requires from the compiler, set either
1.243     gutterid 6888: USE_CC_FEATURES or USE_CXX_FEATURES. Allowed values for USE_CC_FEATURES are
                   6889: currently:
                   6890: 
                   6891: c11, c99, has_include
                   6892: 
                   6893: Allowed values for USE_CXX_FEATURES are currently:
                   6894: 
                   6895: c++11, c++14, c++17, c++20, has_include, regex, filesystem,
                   6896: charconv, parallelism_ts, unique_ptr, put_time,
                   6897: is_trivially_copy_constructible
1.1       dsieger  6898: 
1.251     gutterid 6899: Note at present these variables only affect use of GCC, not other compilers.
                   6900: 
1.244     gutterid 6901: Language variants like gnu99 and c++11 can be specified in FORCE_C_STD and
                   6902: FORCE_CXX_STD if the package does not explicitly set -std=... when compiling
                   6903: (i.e. the package assumes the compiler defaults to C++11 or some other
                   6904: standard). This is a common bug in upstream build systems.
                   6905: 
                   6906: Allowed values for FORCE_C_STD are currently:
                   6907: 
                   6908: c90, c99, c11, gnu90, gnu99, gnu11
                   6909: 
                   6910: Allowed values for FORCE_CXX_STD are currently:
                   6911: 
                   6912: c++03, c++11, c++14, c++17, c++20,
                   6913: gnu++03, gnu++11, gnu++14, gnu++17, gnu++20
                   6914: 
1.251     gutterid 6915: Note at present these variables only affect use of GCC and Clang.
                   6916: 
1.154     rillig   6917: 21.4.2. Java
1.1       dsieger  6918: 
                   6919: If a program is written in Java, use the Java framework in pkgsrc. The package
                   6920: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
                   6921: variables:
                   6922: 
                   6923:   * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
                   6924:     set to "run", then there is only a runtime dependency on the JDK. The
                   6925:     default is "yes", which also adds a build dependency on the JDK.
                   6926: 
                   6927:   * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
                   6928:     supported values are "yes", "1.4", and "1.5". "yes" accepts any Java2
                   6929:     implementation, "1.4" insists on versions 1.4 or above, and "1.5" only
                   6930:     accepts versions 1.5 or above. This variable is not set by default.
                   6931: 
1.25      wiz      6932:   * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
                   6933:     implementation dependency. It may be used to set JAVA_HOME to a good value
                   6934:     if the program needs this variable to be defined.
                   6935: 
1.205     wiz      6936: 21.4.3. Go
                   6937: 
                   6938: If a program is written in Go and has any dependencies on other Go modules,
                   6939: have the package include ../../lang/go/go-module.mk.
                   6940: 
                   6941:  1. Generate a list of those dependencies with make clean && make patch && make
                   6942:     show-go-modules > go-modules.mk.
                   6943: 
1.223     nia      6944:  2. Prepend .include "go-modules.mk" to any other .includes.
                   6945: 
                   6946:  3. Incorporate these modules in distinfo with make makesum.
1.205     wiz      6947: 
1.223     nia      6948: 21.4.4. Rust
1.205     wiz      6949: 
1.223     nia      6950: If a program is written in Rust and uses Cargo to build, have the package
                   6951: include ../../lang/rust/cargo.mk.
1.205     wiz      6952: 
1.223     nia      6953:  1. Generate a list of those dependencies with make CARGO_ARGS="build
                   6954:     --release" build && make print-cargo-depends > cargo-depends.mk.
1.205     wiz      6955: 
1.223     nia      6956:  2. Prepend .include "cargo-depends.mk" to any other .includes.
1.205     wiz      6957: 
                   6958:  3. Incorporate these modules in distinfo with make makesum.
                   6959: 
1.223     nia      6960: 21.4.5. Packages containing Perl scripts
1.1       dsieger  6961: 
1.203     nia      6962: If your package contains interpreted Perl scripts, add "perl" to the USE_TOOLS
1.1       dsieger  6963: variable and set REPLACE_PERL to ensure that the proper interpreter path is
                   6964: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
1.74      wiz      6965: you want adjusted. Every occurrence of */bin/perl in a she-bang line will be
1.210     gutterid 6966: replaced with the full path to the Perl executable.
1.1       dsieger  6967: 
1.210     gutterid 6968: If a particular version of Perl is needed, set the PERL5_REQD variable to the
1.1       dsieger  6969: version number. The default is "5.0".
                   6970: 
1.203     nia      6971: See Section 21.6.6, "Packages installing Perl modules" for information about
1.210     gutterid 6972: handling Perl modules.
                   6973: 
                   6974: There is also the REPLACE_PERL6 variable for the language now known as Raku.
1.1       dsieger  6975: 
1.223     nia      6976: 21.4.6. Packages containing shell scripts
1.41      wiz      6977: 
                   6978: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
1.225     gutterid 6979: shell she-bangs in files. Please use the appropriate one, preferring REPLACE_SH
                   6980: when this shell is sufficient. Each should contain a list of scripts, relative
                   6981: to WRKSRC, that you want adjusted. Every occurrence of the matching shell in a
                   6982: she-bang line will be replaced with the full path to the shell executable. When
                   6983: using REPLACE_BASH, don't forget to add bash to USE_TOOLS.
1.41      wiz      6984: 
1.223     nia      6985: 21.4.7. Other programming languages
1.1       dsieger  6986: 
1.210     gutterid 6987: There are further similar REPLACE variables available, e.g., REPLACE_AWK for
                   6988: packages containing awk scripts, and REPLACE_R for R. These two, like the
1.211     gutterid 6989: others noted above, have their actions defined centrally in mk/configure/
                   6990: replace-interpreter.mk. Other languages define the actions of these variables
                   6991: within their own dedicated part of the tree, e.g., REPLACE_PHP is actioned in
1.245     gutterid 6992: lang/php/replace.mk, and REPLACE_PYTHON is actioned in lang/python/
1.211     gutterid 6993: application.mk. For other languages, consult the mk files found within their
1.216     gutterid 6994: specific directories (the naming convention varies), or check the list found in
                   6995: Appendix E, Help topics.
1.210     gutterid 6996: 
                   6997: Currently, special handling for other languages varies in pkgsrc. If a compiler
                   6998: package provides a buildlink3.mk file, include that, otherwise just add a
                   6999: (build) dependency on the appropriate compiler package.
1.1       dsieger  7000: 
1.154     rillig   7001: 21.5. The build phase
1.1       dsieger  7002: 
                   7003: The most common failures when building a package are that some platforms do not
                   7004: provide certain header files, functions or libraries, or they provide the
                   7005: functions in a library that the original package author didn't know. To work
                   7006: around this, you can rewrite the source code in most cases so that it does not
                   7007: use the missing functions or provides a replacement function.
                   7008: 
1.154     rillig   7009: 21.5.1. Compiling C and C++ code conditionally
1.1       dsieger  7010: 
                   7011: If a package already comes with a GNU configure script, the preferred way to
                   7012: fix the build failure is to change the configure script, not the code. In the
                   7013: other cases, you can utilize the C preprocessor, which defines certain macros
                   7014: depending on the operating system and hardware architecture it compiles for.
                   7015: These macros can be queried using for example #if defined(__i386). Almost every
                   7016: operating system, hardware architecture and compiler has its own macro. For
                   7017: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
                   7018: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
                   7019: GCC.
                   7020: 
                   7021: The list of the following macros for hardware and operating system depends on
                   7022: the compiler that is used. For example, if you want to conditionally compile
                   7023: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
                   7024: Use __sun instead.
                   7025: 
1.154     rillig   7026: 21.5.1.1. C preprocessor macros to identify the operating system
1.1       dsieger  7027: 
1.223     nia      7028: To distinguish between specific NetBSD versions, you should use the following
                   7029: code.
                   7030: 
                   7031: #ifdef __NetBSD__
                   7032: #include <sys/param.h>
                   7033: #if __NetBSD_Prereq__(9,99,17)
                   7034: /* use a newer feature */
                   7035: #else
                   7036: /* older code */
                   7037: #endif
                   7038: #endif
                   7039: 
                   7040: #ifndef _WIN32
                   7041: /* Unix-like specific code */
                   7042: #endif
                   7043: 
1.1       dsieger  7044: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
                   7045: should use the following code.
                   7046: 
                   7047: #include <sys/param.h>
                   7048: #if (defined(BSD) && BSD >= 199306)
                   7049: /* BSD-specific code goes here */
                   7050: #else
                   7051: /* non-BSD-specific code goes here */
                   7052: #endif
                   7053: 
1.223     nia      7054: You can also test for the following macros:
1.1       dsieger  7055: 
1.46      obache   7056: Cygwin      __CYGWIN__
                   7057: DragonFly   __DragonFly__
1.1       dsieger  7058: FreeBSD     __FreeBSD__
1.46      obache   7059: Haiku       __HAIKU__
1.1       dsieger  7060: Interix     __INTERIX
                   7061: IRIX        __sgi (TODO: get a definite source for this)
1.223     nia      7062: Linux       __linux
1.83      dholland 7063: Mac OS X    __APPLE__
1.46      obache   7064: MirBSD      __MirBSD__ (__OpenBSD__ is also defined)
                   7065: Minix3      __minix
1.1       dsieger  7066: NetBSD      __NetBSD__
                   7067: OpenBSD     __OpenBSD__
                   7068: Solaris     sun, __sun
                   7069: 
1.154     rillig   7070: 21.5.1.2. C preprocessor macros to identify the hardware architecture
1.1       dsieger  7071: 
                   7072: i386        i386, __i386, __i386__
1.223     nia      7073: x86-64      __amd64__, __x86_64__
                   7074: ARM         __arm__
1.1       dsieger  7075: MIPS        __mips
                   7076: SPARC       sparc, __sparc
1.223     nia      7077: PowerPC     __powerpc
1.1       dsieger  7078: 
1.154     rillig   7079: 21.5.1.3. C preprocessor macros to identify the compiler
1.1       dsieger  7080: 
                   7081: GCC         __GNUC__ (major version), __GNUC_MINOR__
                   7082: MIPSpro     _COMPILER_VERSION (0x741 for MIPSpro 7.41)
                   7083: SunPro      __SUNPRO_C (0x570 for Sun C 5.7)
                   7084: SunPro C++  __SUNPRO_CC (0x580 for Sun C++ 5.8)
                   7085: 
1.154     rillig   7086: 21.5.2. How to handle compiler bugs
1.1       dsieger  7087: 
                   7088: Some source files trigger bugs in the compiler, based on combinations of
                   7089: compiler version and architecture and almost always relation to optimisation
                   7090: being enabled. Common symptoms are gcc internal errors or never finishing
                   7091: compiling a file.
                   7092: 
                   7093: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
1.87      tnn      7094: disabling optimisation for that combination of file, MACHINE_ARCH and compiler.
                   7095: 
                   7096: This used to be a big problem in the past, but is rarely needed now as compiler
                   7097: technology has matured. If you still need to add a compiler specific
                   7098: workaround, please do so in the file hacks.mk and describe the symptom and
                   7099: compiler version as detailed as possible.
1.1       dsieger  7100: 
1.172     rillig   7101: 21.5.3. No such file or directory
                   7102: 
                   7103: Compilation sometimes fails with an error message like this:
                   7104: 
                   7105: .../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10:
                   7106:     fatal error: pango/pango.h: No such file or directory
                   7107: 
                   7108: The proper way to fix this problem depends on the type of the header, which is
                   7109: described in the following sections.
                   7110: 
                   7111: 21.5.3.1. Headers from other packages
                   7112: 
                   7113: If the header name looks like it comes from a different package, that other
                   7114: package should be included via the buildlink3 framework.
                   7115: 
                   7116: First, look whether the header is somewhere in the buildlink3 directory below
                   7117: WRKDIR. In the above case of the missing Pango header:
                   7118: 
                   7119: $ find work/.buildlink/ -print | grep -F pango/pango.h
                   7120: 
                   7121: In the case of Pango, the output is:
                   7122: 
                   7123: work/.buildlink/include/pango-1.0/pango/pango.h
                   7124: 
                   7125: If the pango/pango.h file were placed directly in the .buildlink directory, it
                   7126: would have been found automatically. There is an extra pango-1.0 path component
                   7127: though, which means that the compiler command line must contain an option of
                   7128: the form -I${BUILDLINK3_PREFIX.pango}/include/pango-1.0. In most cases this
                   7129: option is generated by the configure script, which can be examined using:
                   7130: 
                   7131: $ $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile
                   7132: -I/usr/pkg/include/pango-1.0
                   7133: -I/usr/pkg/include/pango-1.0
                   7134: -I/usr/pkg/include/pango-1.0
                   7135: -I/usr/pkg/include/pango-1.0
                   7136: -I/usr/pkg/include/pango-1.0
                   7137: 
                   7138: This looks good. These options are transformed by the buildlink wrapper to
                   7139: refer to the correct path inside work/.buildlink.
                   7140: 
                   7141: Since the compilation fails though, examine the compiler command lines in work
                   7142: /.work.log to see whether the -I option is included in the particular command
                   7143: line.
                   7144: 
                   7145: To further analyze the situation, run bmake build-env, which sets up an
                   7146: interactive, realistic environment including all the pkgsrc wrapper commands
                   7147: and environment variables. From there, try to compile some simple example
                   7148: programs that use the header.
                   7149: 
                   7150: 21.5.3.2. Headers generated during the build
                   7151: 
                   7152: If the name of the header seems to come from the package itself, and if the
                   7153: build is run with parallel jobs, the package may have some undeclared
                   7154: dependencies between the .c and the .h files, and a C file is compiled before
                   7155: its required header is generated.
                   7156: 
                   7157: To see whether the build runs with parallel jobs, run bmake show-all-build |
                   7158: grep JOBS. Its output looks like this:
                   7159: 
                   7160:   usr   MAKE_JOBS=              7
                   7161:   pkg   MAKE_JOBS_SAFE          # undefined
                   7162:   def   _MAKE_JOBS_N=           7
                   7163: 
                   7164: In this case the pkgsrc user has asked pkgsrc to build packages with 7 jobs in
                   7165: parallel (MAKE_JOBS). The package could have disabled parallel builds by
                   7166: setting MAKE_JOBS_SAFE to no, but in this case it hasn't.
                   7167: 
                   7168: To see whether the build failure is caused by parallel builds, first save the
                   7169: exact error message and a bit of context, maybe you need it later for reporting
                   7170: a bug. Next, run:
                   7171: 
                   7172: MAKE_JOBS_SAFE=no bmake clean build
                   7173: 
                   7174: If that succeeds, file a bug report against the pkgsrc package, including the
                   7175: exact error message and the contents of your mk.conf file.
                   7176: 
1.173     rillig   7177: 21.5.3.3. Symlinks
                   7178: 
                   7179: Pkgsrc does not work reliably if any of LOCALBASE, VARBASE or WRKDIR contains a
                   7180: symlink. Since 2019Q2, the pkgsrc bootstrap program prevents installing pkgsrc
                   7181: in symlink-based directories. Existing pkgsrc installations are not checked for
                   7182: symlinks though.
                   7183: 
                   7184: The "No such file or directory" error messages are a typical symptom of
                   7185: symlinks, and it's quite difficult to find out that this is the actual cause.
                   7186: 
                   7187: 21.5.3.4. Stale working directories
                   7188: 
                   7189: When building a hierarchy of packages, it may happen that one package is built
                   7190: and then pkgsrc is updated. This situation can provoke various hard to diagnose
                   7191: build errors. To clean up the situation:
                   7192: 
1.223     nia      7193: $ (cd ../../ && cat mk/bsd.pkg.mk >/dev/null && rm -rf */*/work)
1.173     rillig   7194: 
1.223     nia      7195: (The only purpose of the bsd.pkg.mk is to prevent running this command in the
                   7196: wrong directory.)
1.173     rillig   7197: 
                   7198: If you have set WRKOBJDIR in mk.conf, remove that directory as well.
                   7199: 
                   7200: 21.5.3.5. Other possible reasons
                   7201: 
                   7202: On platforms other than BSD, third-party packages are installed in /usr/
                   7203: include, together with the base system. This means that pkgsrc cannot
                   7204: distinguish between headers provided by the base system (which it needs) and
                   7205: headers from third-party packages (which are often included in pkgsrc as well).
                   7206: This can lead to subtle version mismatches.
                   7207: 
                   7208: In pkgsrc installations that have been active for several years, it may happen
                   7209: that some files are manually deleted. To exclude this unlikely reason, run 
                   7210: pkg_admin check.
                   7211: 
                   7212: It may help to run pkg_admin rebuild-tree to check/fix dependencies.
                   7213: 
                   7214: If all of the above doesn't help, see Chapter 2, Getting help for contact
                   7215: information. Be prepared to describe what you have tried so far and what any
                   7216: error messages were.
                   7217: 
1.172     rillig   7218: 21.5.4. Undefined reference to "..."
1.1       dsieger  7219: 
                   7220: This error message often means that a package did not link to a shared library
                   7221: it needs. The following functions are known to cause this error message over
                   7222: and over.
                   7223: 
                   7224: +-----------------------------------------------------+
                   7225: |        Function         |Library |Affected platforms|
                   7226: |-------------------------+--------+------------------|
                   7227: |accept, bind, connect    |-lsocket|Solaris           |
                   7228: |-------------------------+--------+------------------|
                   7229: |crypt                    |-lcrypt |DragonFly, NetBSD |
                   7230: |-------------------------+--------+------------------|
                   7231: |dlopen, dlsym            |-ldl    |Linux             |
                   7232: |-------------------------+--------+------------------|
                   7233: |gethost*                 |-lnsl   |Solaris           |
                   7234: |-------------------------+--------+------------------|
                   7235: |inet_aton                |-lresolv|Solaris           |
                   7236: |-------------------------+--------+------------------|
                   7237: |nanosleep, sem_*, timer_*|-lrt    |Solaris           |
                   7238: |-------------------------+--------+------------------|
                   7239: |openpty                  |-lutil  |Linux             |
                   7240: +-----------------------------------------------------+
                   7241: 
1.223     nia      7242: To fix these linker errors, it is often sufficient to add LIBS.OperatingSystem+
                   7243: = -lfoo to the package Makefile and then run bmake clean; bmake.
1.1       dsieger  7244: 
1.223     nia      7245: 21.5.4.1. The SunPro compiler and inline functions
1.1       dsieger  7246: 
                   7247: When you are using the SunPro compiler, there is another possibility. That
                   7248: compiler cannot handle the following code:
                   7249: 
                   7250: extern int extern_func(int);
                   7251: 
                   7252: static inline int
                   7253: inline_func(int x)
                   7254: {
                   7255:         return extern_func(x);
                   7256: }
                   7257: 
                   7258: int main(void)
                   7259: {
                   7260:         return 0;
                   7261: }
                   7262: 
                   7263: It generates the code for inline_func even if that function is never used. This
                   7264: code then refers to extern_func, which can usually not be resolved. To solve
                   7265: this problem you can try to tell the package to disable inlining of functions.
                   7266: 
1.228     gutterid 7267: 21.5.4.2. Missing atomic functions
                   7268: 
                   7269: When building for older machine architectures (e.g., i386, PowerPC), builds may
                   7270: fail because the package expects modern 64-bit atomic functions which the
                   7271: underlying hardware either doesn't support, or will only support with specific
                   7272: compiler flags. This is generally handled via inclusion of mk/atomic64.mk.
                   7273: 
1.172     rillig   7274: 21.5.5. Running out of memory
1.1       dsieger  7275: 
                   7276: Sometimes packages fail to build because the compiler runs into an operating
                   7277: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
1.223     nia      7278: told to unlimit the resources. The allowed values are any combination of "
                   7279: cputime", "datasize", "memorysize", "stacksize" and "virtualsize". Setting this
                   7280: variable is similar to running the shell builtin ulimit command to raise the
                   7281: maximum data segment size or maximum stack size of a process, respectively, to
                   7282: their hard limits.
1.1       dsieger  7283: 
1.154     rillig   7284: 21.6. The install phase
1.1       dsieger  7285: 
1.154     rillig   7286: 21.6.1. Creating needed directories
1.1       dsieger  7287: 
                   7288: The BSD-compatible install supplied with some operating systems cannot create
                   7289: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
                   7290: like this:
                   7291: 
                   7292: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
                   7293: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
                   7294: 
1.223     nia      7295: Instead of running the install commands directly, you can also append "dir1
                   7296: dir2" to the INSTALLATION_DIRS variable, which will automatically do the right
                   7297: thing.
1.1       dsieger  7298: 
1.154     rillig   7299: 21.6.2. Where to install documentation
1.1       dsieger  7300: 
                   7301: In general, documentation should be installed into ${PREFIX}/share/doc/$
1.223     nia      7302: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME_NOREV} (the latter includes the
                   7303: version number of the package).
1.1       dsieger  7304: 
                   7305: Many modern packages using GNU autoconf allow to set the directory where HTML
                   7306: documentation is installed with the "--with-html-dir" option. Sometimes using
                   7307: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
1.223     nia      7308: share/doc/html or other places. In pkgsrc, the HTML documentation should go
                   7309: into the package-specific directory, just like any other documentation.
1.1       dsieger  7310: 
                   7311: An exception to the above is that library API documentation generated with the
                   7312: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
                   7313: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
                   7314: can be recognized from files ending in .devhelp or .devhelp2. (It is also
                   7315: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
                   7316: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
                   7317: then, no additional subdirectory level is allowed in this case. This is usually
                   7318: achieved by using "--with-html-dir=${PREFIX}/share/doc". ${PREFIX}/share/
                   7319: gtk-doc is preferred though.)
                   7320: 
1.154     rillig   7321: 21.6.3. Installing highscore files
1.1       dsieger  7322: 
                   7323: Certain packages, most of them in the games category, install a score file that
                   7324: allows all users on the system to record their highscores. In order for this to
                   7325: work, the binaries need to be installed setgid and the score files owned by the
1.36      wiz      7326: appropriate group and/or owner (traditionally the "games" user/group). Set
                   7327: USE_GAMESGROUP to yes to support this. The following variables, documented in
                   7328: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
1.100     leot     7329: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER. Other useful variables are:
                   7330: GAMEDIR_PERMS, GAMEDATA_PERMS and SETGID_GAMES_PERMS.
                   7331: 
                   7332: An example that illustrates some of the variables described above is games/
                   7333: moon-buggy. OWN_DIRS_PERMS is used to properly set directory permissions of the
                   7334: directory where the scorefile is saved, REQD_FILES_PERMS is used to create a
                   7335: dummy scorefile (mbscore) with the proper permissions and SPECIAL_PERMS is used
                   7336: to install setgid the game binary:
                   7337: 
                   7338: USE_GAMESGROUP=         yes
                   7339: 
                   7340: BUILD_DEFS+=            VARBASE
                   7341: 
                   7342: OWN_DIRS_PERMS+=        ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
                   7343: REQD_FILES_PERMS+=      /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
                   7344: SPECIAL_PERMS+=         ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
                   7345: 
                   7346: Various INSTALL_* variables are also available: INSTALL_GAME to install setgid
                   7347: game binaries, INSTALL_GAME_DIR to install game directories that are needed to
                   7348: be accessed by setgid games and INSTALL_GAME_DATA to install scorefiles.
1.1       dsieger  7349: 
1.14      jmcneill 7350: A package should therefore never hard code file ownership or access permissions
1.100     leot     7351: but rely on *_PERMS as described above or alternatively on INSTALL_GAME,
                   7352: INSTALL_GAME_DATA and INSTALL_GAME_DIR to set these correctly.
1.1       dsieger  7353: 
1.154     rillig   7354: 21.6.4. Adding DESTDIR support to packages
1.4       rillig   7355: 
1.14      jmcneill 7356: DESTDIR support means that a package installs into a staging directory, not the
                   7357: final location of the files. Then a binary package is created which can be used
                   7358: for installation as usual. There are two ways: Either the package must install
1.25      wiz      7359: as root ("destdir") or the package can install as non-root user ("user-destdir"
                   7360: ).
1.14      jmcneill 7361: 
1.113     leot     7362:   * PKG_DESTDIR_SUPPORT has to be set to "destdir" or "user-destdir". By
                   7363:     default PKG_DESTDIR_SUPPORT is set to "user-destdir" to help catching more
                   7364:     potential packaging problems. If bsd.prefs.mk is included in the Makefile,
                   7365:     PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14      jmcneill 7366: 
1.4       rillig   7367:   * All installation operations have to be prefixed with ${DESTDIR}.
                   7368: 
                   7369:   * automake gets this DESTDIR mostly right automatically. Many manual rules
                   7370:     and pre/post-install often are incorrect; fix them.
                   7371: 
1.17      imil     7372:   * If files are installed with special owner/group use SPECIAL_PERMS.
1.4       rillig   7373: 
                   7374:   * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
                   7375: 
1.154     rillig   7376: 21.6.5. Packages with hardcoded paths to other interpreters
1.1       dsieger  7377: 
                   7378: Your package may also contain scripts with hardcoded paths to other
1.203     nia      7379: interpreters besides (or as well as) Perl. To correct the full pathname to the
1.1       dsieger  7380: script interpreter, you need to set the following definitions in your Makefile
                   7381: (we shall use tclsh in this example):
                   7382: 
                   7383: REPLACE_INTERPRETER+=   tcl
                   7384: REPLACE.tcl.old=        .*/bin/tclsh
                   7385: REPLACE.tcl.new=        ${PREFIX}/bin/tclsh
                   7386: REPLACE_FILES.tcl=      # list of tcl scripts which need to be fixed,
                   7387: # relative to ${WRKSRC}, just as in REPLACE_PERL
                   7388: 
1.203     nia      7389: 21.6.6. Packages installing Perl modules
1.1       dsieger  7390: 
                   7391: Makefiles of packages providing perl5 modules should include the Makefile
                   7392: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
                   7393: standard perl configuration for such modules as well as various hooks to tune
                   7394: this configuration. See comments in this file for details.
                   7395: 
                   7396: Perl5 modules will install into different places depending on the version of
                   7397: perl used during the build process. To address this, pkgsrc will append lines
                   7398: to the PLIST corresponding to the files listed in the installed .packlist file
                   7399: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48      wiz      7400: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
                   7401: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1       dsieger  7402: 
1.48      wiz      7403: PERL5_PACKLIST= auto/Pg/.packlist
1.1       dsieger  7404: 
1.48      wiz      7405: The perl5 config variables installarchlib, installscript, installvendorbin,
                   7406: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
                   7407: and installvendorman3dir represent those locations in which components of perl5
                   7408: modules may be installed, provided as variable with uppercase and prefixed with
                   7409: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
                   7410: have a packlist. These variables are also substituted for in the PLIST as
                   7411: uppercase prefixed with PERL5_SUB_.
1.1       dsieger  7412: 
1.154     rillig   7413: 21.6.7. Packages installing info files
1.1       dsieger  7414: 
                   7415: Some packages install info files or use the "makeinfo" or "install-info"
                   7416: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
                   7417: and DEINSTALL scripts will be generated to handle registration of the info
                   7418: files in the Info directory file. The "install-info" command used for the info
                   7419: files registration is either provided by the system, or by a special purpose
                   7420: package automatically added as dependency if needed.
                   7421: 
                   7422: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
                   7423: located. PKGINFODIR defaults to "info" and can be overridden by the user.
                   7424: 
                   7425: The info files for the package should be listed in the package PLIST; however
                   7426: any split info files need not be listed.
                   7427: 
                   7428: A package which needs the "makeinfo" command at build time must add "makeinfo"
                   7429: to USE_TOOLS in its Makefile. If a minimum version of the "makeinfo" command is
                   7430: needed it should be noted with the TEXINFO_REQD variable in the package
                   7431: Makefile. By default, a minimum version of 3.12 is required. If the system does
                   7432: not provide a makeinfo command or if it does not match the required minimum, a
                   7433: build dependency on the devel/gtexinfo package will be added automatically.
                   7434: 
                   7435: The build and installation process of the software provided by the package
                   7436: should not use the install-info command as the registration of info files is
1.25      wiz      7437: the task of the package INSTALL script, and it must use the appropriate 
1.1       dsieger  7438: makeinfo command.
                   7439: 
                   7440: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
                   7441: the install-info and makeinfo commands in a directory listed early in PATH.
                   7442: 
                   7443: The script overriding install-info has no effect except the logging of a
                   7444: message. The script overriding makeinfo logs a message and according to the
                   7445: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
                   7446: error.
                   7447: 
1.154     rillig   7448: 21.6.8. Packages installing man pages
1.1       dsieger  7449: 
                   7450: All packages that install manual pages should install them into the same
                   7451: directory, so that there is one common place to look for them. In pkgsrc, this
                   7452: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.25      wiz      7453: packages. The default for PKGMANDIR is "man". Another often-used value is "
                   7454: share/man".
1.1       dsieger  7455: 
                   7456: Note
                   7457: 
                   7458: The support for a custom PKGMANDIR is far from complete.
                   7459: 
                   7460: The PLIST files can just use man/ as the top level directory for the man page
                   7461: file entries, and the pkgsrc framework will convert as needed. In all other
                   7462: places, the correct PKGMANDIR must be used.
                   7463: 
                   7464: Packages that are configured with GNU_CONFIGURE set as "yes", by default will
                   7465: use the ./configure --mandir switch to set where the man pages should be
                   7466: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
                   7467: {PKGMANDIR}.
                   7468: 
                   7469: Packages that use GNU_CONFIGURE but do not use --mandir, can set
                   7470: CONFIGURE_HAS_MANDIR to "no". Or if the ./configure script uses a non-standard
                   7471: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
                   7472: 
1.184     rillig   7473: See Section 19.5, "Man page compression" for information on installation of
1.1       dsieger  7474: compressed manual pages.
                   7475: 
1.203     nia      7476: 21.6.9. Packages installing X11 fonts
1.1       dsieger  7477: 
                   7478: If a package installs font files, you will need to rebuild the fonts database
                   7479: in the directory where they get installed at installation and deinstallation
                   7480: time. This can be automatically done by using the pkginstall framework.
                   7481: 
                   7482: You can list the directories where fonts are installed in the FONTS_DIRS.type
                   7483: variables, where type can be one of "ttf", "type1" or "x11". Also make sure
                   7484: that the database file fonts.dir is not listed in the PLIST.
                   7485: 
                   7486: Note that you should not create new directories for fonts; instead use the
                   7487: standard ones to avoid that the user needs to manually configure his X server
                   7488: to find them.
                   7489: 
1.203     nia      7490: 21.6.10. Packages installing SGML or XML data
1.1       dsieger  7491: 
                   7492: If a package installs SGML or XML data files that need to be registered in
                   7493: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
                   7494: extra steps:
                   7495: 
                   7496:  1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
                   7497:     care of registering those files in system-wide catalogs at installation and
                   7498:     deinstallation time.
                   7499: 
                   7500:  2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
                   7501:     package.
                   7502: 
                   7503:  3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
                   7504:     package.
                   7505: 
                   7506:  4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
                   7507:     These come in groups of three strings; see xmlcatmgr(1) for more
                   7508:     information (specifically, arguments recognized by the 'add' action). Note
                   7509:     that you will normally not use this variable.
                   7510: 
                   7511:  5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
                   7512:     come in groups of three strings; see xmlcatmgr(1) for more information
                   7513:     (specifically, arguments recognized by the 'add' action). Note that you
                   7514:     will normally not use this variable.
                   7515: 
1.203     nia      7516: 21.6.11. Packages installing extensions to the MIME database
1.1       dsieger  7517: 
                   7518: If a package provides extensions to the MIME database by installing .xml files
                   7519: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
                   7520: ensure that the database is kept consistent with respect to these new files:
                   7521: 
                   7522:  1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
                   7523:     buildlink3.mk file from this same directory, which is reserved for
                   7524:     inclusion from other buildlink3.mk files). It takes care of rebuilding the
                   7525:     MIME database at installation and deinstallation time, and disallows any
                   7526:     access to it directly from the package.
                   7527: 
1.25      wiz      7528:  2. Check the PLIST and remove any entries under the share/mime directory, 
1.1       dsieger  7529:     except for files saved under share/mime/packages. The former are handled
                   7530:     automatically by the update-mime-database program, but the latter are
                   7531:     package-dependent and must be removed by the package that installed them in
                   7532:     the first place.
                   7533: 
                   7534:  3. Remove any share/mime/* directories from the PLIST. They will be handled by
                   7535:     the shared-mime-info package.
                   7536: 
1.203     nia      7537: 21.6.12. Packages using intltool
1.1       dsieger  7538: 
                   7539: If a package uses intltool during its build, add intltool to the USE_TOOLS,
                   7540: which forces it to use the intltool package provided by pkgsrc, instead of the
                   7541: one bundled with the distribution file.
                   7542: 
                   7543: This tracks intltool's build-time dependencies and uses the latest available
                   7544: version; this way, the package benefits of any bug fixes that may have appeared
                   7545: since it was released.
                   7546: 
1.203     nia      7547: 21.6.13. Packages installing startup scripts
1.1       dsieger  7548: 
                   7549: If a package contains a rc.d script, it won't be copied into the startup
                   7550: directory by default, but you can enable it, by adding the option
1.4       rillig   7551: PKG_RCD_SCRIPTS=YES in mk.conf. This option will copy the scripts into /etc/
                   7552: rc.d when a package is installed, and it will automatically remove the scripts
                   7553: when the package is deinstalled.
1.1       dsieger  7554: 
1.203     nia      7555: 21.6.14. Packages installing TeX modules
1.1       dsieger  7556: 
                   7557: If a package installs TeX packages into the texmf tree, the ls-R database of
                   7558: the tree needs to be updated.
                   7559: 
                   7560: Note
                   7561: 
1.23      jakllsch 7562: Except the main TeX packages such as kpathsea, packages should install files
                   7563: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1       dsieger  7564: 
1.23      jakllsch 7565:  1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
                   7566:     ls-R database at installation and deinstallation time.
1.1       dsieger  7567: 
1.23      jakllsch 7568:  2. If your package installs files into a texmf tree other than the one at $
                   7569:     {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
                   7570:     trees that need database update.
1.1       dsieger  7571: 
                   7572:     If your package also installs font map files that need to be registered
1.30      dholland 7573:     using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
                   7574:     and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then 
                   7575:     updmap will be run automatically at installation/deinstallation to enable/
                   7576:     disable font map files for TeX output drivers.
1.1       dsieger  7577: 
                   7578:  3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30      dholland 7579:     be removed only by the kpathsea package.
1.1       dsieger  7580: 
1.203     nia      7581: 21.6.15. Packages supporting running binaries in emulation
1.1       dsieger  7582: 
                   7583: There are some packages that provide libraries and executables for running
                   7584: binaries from a one operating system on a different one (if the latter supports
                   7585: it). One example is running Linux binaries on NetBSD.
                   7586: 
                   7587: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
                   7588: 
                   7589: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
                   7590: if all libraries for each installed executable can be found by the dynamic
                   7591: linker. Since the standard dynamic linker is run, this fails for emulation
                   7592: packages, because the libraries used by the emulation are not in the standard
                   7593: directories.
                   7594: 
1.203     nia      7595: 21.6.16. Packages installing hicolor icons
1.1       dsieger  7596: 
                   7597: If a package installs images under the share/icons/hicolor and/or updates the
                   7598: share/icons/hicolor/icon-theme.cache database, you need to take some extra
                   7599: steps to make sure that the shared theme directory is handled appropriately and
                   7600: that the cache database is rebuilt:
                   7601: 
                   7602:  1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
                   7603: 
                   7604:  2. Check the PLIST and remove the entry that refers to the theme cache.
                   7605: 
                   7606:  3. Ensure that the PLIST does not remove the shared icon directories from the
                   7607:     share/icons/hicolor hierarchy because they will be handled automatically.
                   7608: 
                   7609: The best way to verify that the PLIST is correct with respect to the last two
                   7610: points is to regenerate it using make print-PLIST.
                   7611: 
1.203     nia      7612: 21.6.17. Packages installing desktop files
1.1       dsieger  7613: 
                   7614: If a package installs .desktop files under share/applications and these include
1.54      rodent   7615: MIME information (MimeType key), you need to take extra steps to ensure that
                   7616: they are registered into the MIME database:
1.1       dsieger  7617: 
                   7618:  1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
                   7619: 
                   7620:  2. Check the PLIST and remove the entry that refers to the share/applications/
                   7621:     mimeinfo.cache file. It will be handled automatically.
                   7622: 
                   7623: The best way to verify that the PLIST is correct with respect to the last point
                   7624: is to regenerate it using make print-PLIST.
                   7625: 
1.154     rillig   7626: 21.7. Marking packages as having problems
1.1       dsieger  7627: 
1.23      jakllsch 7628: In some cases one does not have the time to solve a problem immediately. In
                   7629: this case, one can plainly mark a package as broken. For this, one just sets
                   7630: the variable BROKEN to the reason why the package is broken (similar to the
1.162     rillig   7631: PKG_FAIL_REASON variable). A user trying to build the package will immediately
                   7632: be shown this message, and the build will not be even tried.
1.1       dsieger  7633: 
1.23      jakllsch 7634: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1       dsieger  7635: 
1.184     rillig   7636: Chapter 22. GNOME packaging and porting
                   7637: 
                   7638: Table of Contents
                   7639: 
                   7640: 22.1. Meta packages
                   7641: 22.2. Packaging a GNOME application
                   7642: 22.3. Updating GNOME to a newer version
                   7643: 22.4. Patching guidelines
                   7644: 
                   7645: Quoting GNOME's web site:
                   7646: 
                   7647:     The GNOME project provides two things: The GNOME desktop environment, an
                   7648:     intuitive and attractive desktop for users, and the GNOME development
                   7649:     platform, an extensive framework for building applications that integrate
                   7650:     into the rest of the desktop.
                   7651: 
                   7652: pkgsrc provides a seamless way to automatically build and install a complete
                   7653: GNOME environment under many different platforms. We can say with confidence
                   7654: that pkgsrc is one of the most advanced build and packaging systems for GNOME
                   7655: due to its included technologies buildlink3, the wrappers and tools framework
                   7656: and automatic configuration file management. Lots of efforts are put into
                   7657: achieving a completely clean deinstallation of installed software components.
                   7658: 
                   7659: Given that pkgsrc is NetBSD's official packaging system, the above also means
                   7660: that great efforts are put into making GNOME work under this operating system.
                   7661: 
                   7662: This chapter is aimed at pkgsrc developers and other people interested in
                   7663: helping our GNOME porting and packaging efforts. It provides instructions on
                   7664: how to manage the existing packages and some important information regarding
                   7665: their internals.
                   7666: 
                   7667: 22.1. Meta packages
                   7668: 
                   7669: pkgsrc includes three GNOME-related meta packages:
                   7670: 
                   7671:   * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
                   7672:     includes the necessary bits to get it to boot correctly, although it may
                   7673:     lack important functionality for daily operation. The idea behind this
                   7674:     package is to let end users build their own configurations on top of this
                   7675:     one, first installing this meta package to achieve a functional setup and
                   7676:     then adding individual applications.
                   7677: 
                   7678:   * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
                   7679:     desktop as defined by the GNOME project; this is based on the components
                   7680:     distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
                   7681:     directories of the official FTP server. Developer-only tools found in those
                   7682:     directories are not installed unless required by some other component to
                   7683:     work properly. Similarly, packages from the bindings set (bindings/x.y/
                   7684:     x.y.z/sources) are not pulled in unless required as a dependency for an
                   7685:     end-user component. This package "extends" meta-pkgs/gnome-base.
                   7686: 
                   7687:   * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
                   7688:     component when fetched from the CVS repository. These are required to let
                   7689:     the autogen.sh scripts work appropriately.
                   7690: 
                   7691: In all these packages, the DEPENDS lines are sorted in a way that eases
                   7692: updates: a package may depend on other packages listed before it but not on any
                   7693: listed after it. It is very important to keep this order to ease updates so... 
                   7694: do not change it to alphabetical sorting!
                   7695: 
                   7696: 22.2. Packaging a GNOME application
                   7697: 
                   7698: Almost all GNOME applications are written in C and use a common set of tools as
                   7699: their build system. Things get different with the new bindings to other
                   7700: languages (such as Python), but the following will give you a general idea on
                   7701: the minimum required tools:
                   7702: 
                   7703:   * Almost all GNOME applications use the GNU Autotools as their build system.
                   7704:     As a general rule you will need to tell this to your package:
                   7705: 
1.223     nia      7706:     GNU_CONFIGURE=  yes
                   7707:     USE_LIBTOOL=    yes
                   7708:     USE_TOOLS+=     gmake
1.184     rillig   7709: 
                   7710:   * If the package uses pkg-config to detect dependencies, add this tool to the
                   7711:     list of required utilities:
                   7712: 
1.223     nia      7713:     USE_TOOLS+=     pkg-config
1.184     rillig   7714: 
                   7715:     Also use pkgtools/verifypc at the end of the build process to ensure that
                   7716:     you did not miss to specify any dependency in your package and that the
                   7717:     version requirements are all correct.
                   7718: 
                   7719:   * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
                   7720:     handle dependencies and to force the package to use the latest available
                   7721:     version.
                   7722: 
                   7723:   * If the package uses gtk-doc (a documentation generation utility), do not
                   7724:     add a dependency on it. The tool is rather big and the distfile should come
                   7725:     with pregenerated documentation anyway; if it does not, it is a bug that
                   7726:     you ought to report. For such packages you should disable gtk-doc (unless
                   7727:     it is the default):
                   7728: 
1.223     nia      7729:     CONFIGURE_ARGS+=        --disable-gtk-doc
1.184     rillig   7730: 
                   7731:     The default location of installed HTML files (share/gtk-doc/<package-name>)
                   7732:     is correct and should not be changed unless the package insists on
                   7733:     installing them somewhere else. Otherwise programs as devhelp will not be
                   7734:     able to open them. You can do that with an entry similar to:
1.1       dsieger  7735: 
1.223     nia      7736:     CONFIGURE_ARGS+=        --with-html-dir=${PREFIX}/share/gtk-doc/...
1.1       dsieger  7737: 
1.184     rillig   7738: GNOME uses multiple shared directories and files under the installation prefix
                   7739: to maintain databases. In this context, shared means that those exact same
                   7740: directories and files are used among several different packages, leading to
                   7741: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
                   7742: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
                   7743: your file lists and omitting shared files from them. If you find yourself doing
                   7744: those, your package is most likely incorrect.
1.1       dsieger  7745: 
1.184     rillig   7746: The following table lists the common situations that result in using shared
                   7747: directories or files. For each of them, the appropriate solution is given.
                   7748: After applying the solution be sure to regenerate the package's file list with 
                   7749: make print-PLIST and ensure it is correct.
1.1       dsieger  7750: 
1.184     rillig   7751: Table 22.1. PLIST handling for GNOME packages
1.1       dsieger  7752: 
1.184     rillig   7753: +-----------------------------------------------------------------------------+
                   7754: |             If the package...             |             Then...             |
                   7755: |-------------------------------------------+---------------------------------|
1.203     nia      7756: |Installs icons under the share/icons/      |See Section 21.6.16, "Packages   |
                   7757: |hicolor hierarchy or updates share/icons/  |installing hicolor icons".       |
1.184     rillig   7758: |hicolor/icon-theme.cache.                  |                                 |
                   7759: |-------------------------------------------+---------------------------------|
1.203     nia      7760: |                                           |See Section 21.6.11, "Packages   |
1.184     rillig   7761: |Installs files under share/mime/packages.  |installing extensions to the MIME|
                   7762: |                                           |database".                       |
                   7763: |-------------------------------------------+---------------------------------|
1.203     nia      7764: |Installs .desktop files under share/       |See Section 21.6.17, "Packages   |
1.184     rillig   7765: |applications and these include MIME        |installing desktop files".       |
                   7766: |information.                               |                                 |
                   7767: +-----------------------------------------------------------------------------+
1.1       dsieger  7768: 
                   7769: 
1.184     rillig   7770: 22.3. Updating GNOME to a newer version
1.1       dsieger  7771: 
1.184     rillig   7772: When seeing GNOME as a whole, there are two kinds of updates:
1.1       dsieger  7773: 
1.184     rillig   7774: Major update
1.1       dsieger  7775: 
1.184     rillig   7776:     Given that there is still a very long way for GNOME 3 (if it ever appears),
                   7777:     we consider a major update one that goes from a 2.X version to a 2.Y one,
                   7778:     where Y is even and greater than X. These are hard to achieve because they
                   7779:     introduce lots of changes in the components' code and almost all GNOME
                   7780:     distfiles are updated to newer versions. Some of them can even break API
                   7781:     and ABI compatibility with the previous major version series. As a result,
                   7782:     the update needs to be done all at once to minimize breakage.
1.1       dsieger  7783: 
1.184     rillig   7784:     A major update typically consists of around 80 package updates and the
                   7785:     addition of some new ones.
1.1       dsieger  7786: 
1.184     rillig   7787: Minor update
1.1       dsieger  7788: 
1.184     rillig   7789:     We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
                   7790:     one where Y is greater than X. These are easy to achieve because they do
                   7791:     not update all GNOME components, can be done in an incremental way and do
                   7792:     not break API nor ABI compatibility.
1.1       dsieger  7793: 
1.184     rillig   7794:     A minor update typically consists of around 50 package updates, although
                   7795:     the numbers here may vary a lot.
1.1       dsieger  7796: 
1.184     rillig   7797: In order to update the GNOME components in pkgsrc to a new stable release
                   7798: (either major or minor), the following steps should be followed:
1.1       dsieger  7799: 
1.184     rillig   7800:  1. Get a list of all the tarballs that form the new release by using the
                   7801:     following commands. These will leave the full list of the components'
                   7802:     distfiles into the list.txt file:
1.1       dsieger  7803: 
1.184     rillig   7804:     % echo ls "*.tar.bz2" | \
                   7805:         ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
                   7806:         awk '{ print $9 }' >list.txt
                   7807:     % echo ls "*.tar.bz2" | \
                   7808:         ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
                   7809:         awk '{ print $9 }' >>list.txt
1.1       dsieger  7810: 
1.184     rillig   7811:  2. Open each meta package's Makefile and bump their version to the release you
                   7812:     are updating them to. The three meta packages should be always consistent
                   7813:     with versioning. Obviously remove any PKGREVISIONs that might be in them.
1.1       dsieger  7814: 
1.184     rillig   7815:  3. For each meta package, update all its DEPENDS lines to match the latest
                   7816:     versions as shown by the above commands. Do not list any newer version
                   7817:     (even if found in the FTP) because the meta packages are supposed to list
                   7818:     the exact versions that form a specific GNOME release. Exceptions are
                   7819:     permitted here if a newer version solves a serious issue in the overall
                   7820:     desktop experience; these typically come in the form of a revision bump in
                   7821:     pkgsrc, not in newer versions from the developers.
1.1       dsieger  7822: 
1.184     rillig   7823:     Packages not listed in the list.txt file should be updated to the latest
                   7824:     version available (if found in pkgsrc). This is the case, for example, of
                   7825:     the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
                   7826:     package.
1.1       dsieger  7827: 
1.184     rillig   7828:  4. Generate a patch from the modified meta packages and extract the list of
                   7829:     "new" lines. This will provide you an outline on what packages need to be
                   7830:     updated in pkgsrc and in what order:
1.1       dsieger  7831: 
1.184     rillig   7832:     % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
1.1       dsieger  7833: 
1.184     rillig   7834:  5. For major desktop updates it is recommended to zap all your installed
                   7835:     packages and start over from scratch at this point.
1.1       dsieger  7836: 
1.184     rillig   7837:  6. Now comes the longest step by far: iterate over the contents of todo.txt
                   7838:     and update the packages listed in it in order. For major desktop updates
                   7839:     none of these should be committed until the entire set is completed because
                   7840:     there are chances of breaking not-yet-updated packages.
1.1       dsieger  7841: 
1.184     rillig   7842:  7. Once the packages are up to date and working, commit them to the tree one
                   7843:     by one with appropriate log messages. At the end, commit the three meta
                   7844:     package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
                   7845:     and pkgsrc/doc/TODO files.
1.1       dsieger  7846: 
1.184     rillig   7847: 22.4. Patching guidelines
1.1       dsieger  7848: 
1.184     rillig   7849: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
                   7850: it is very important that you always, always, always feed back any portability
                   7851: fixes you do to a GNOME package to the mainstream developers (see
                   7852: Section 12.3.5, "Feedback to the author"). This is the only way to get their
                   7853: attention on portability issues and to ensure that future versions can be built
                   7854: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
                   7855: updates are. Those developers in charge of issuing major GNOME updates will be
                   7856: grateful if you do that.
1.1       dsieger  7857: 
1.200     cirnatda 7858: The most common places to report bugs are the GNOME's GitLab and the
                   7859: freedesktop.org's GitLab. Not all components use these to track bugs, but most
                   7860: of them do. Do not be short on your reports: always provide detailed
1.184     rillig   7861: explanations of the current failure, how it can be improved to achieve maximum
1.200     cirnatda 7862: portability and, if at all possible, provide a patch against the main Git
                   7863: branch. The more verbose you are, the higher chances of your patch being
                   7864: accepted.
1.1       dsieger  7865: 
1.184     rillig   7866: Also, please avoid using preprocessor magic to fix portability issues. While
                   7867: the FreeBSD GNOME people are doing a great job in porting GNOME to their
                   7868: operating system, the official GNOME sources are now plagued by conditionals
                   7869: that check for __FreeBSD__ and similar macros. This hurts portability. Please
                   7870: see our patching guidelines (Section 12.3.4, "Patching guidelines") for more
                   7871: details.
1.1       dsieger  7872: 
1.154     rillig   7873: Chapter 23. Submitting and Committing
1.1       dsieger  7874: 
                   7875: Table of Contents
                   7876: 
1.154     rillig   7877: 23.1. Submitting binary packages
                   7878: 23.2. Submitting source packages (for non-NetBSD-developers)
                   7879: 23.3. General notes when adding, updating, or removing packages
                   7880: 23.4. Commit Messages
                   7881: 23.5. Committing: Adding a package to CVS
                   7882: 23.6. Updating a package to a newer version
                   7883: 23.7. Renaming a package in pkgsrc
                   7884: 23.8. Moving a package in pkgsrc
1.1       dsieger  7885: 
1.154     rillig   7886: 23.1. Submitting binary packages
1.1       dsieger  7887: 
                   7888: Our policy is that we accept binaries only from pkgsrc developers to guarantee
                   7889: that the packages don't contain any trojan horses etc. This is not to annoy
                   7890: anyone but rather to protect our users! You're still free to put up your
                   7891: home-made binary packages and tell the world where to get them. NetBSD
1.154     rillig   7892: developers doing bulk builds and wanting to upload them please see Chapter 8, 
1.66      asau     7893: Creating binary packages for everything in pkgsrc (bulk builds).
1.1       dsieger  7894: 
1.154     rillig   7895: 23.2. Submitting source packages (for non-NetBSD-developers)
1.1       dsieger  7896: 
1.218     nia      7897: Firstly, you can import new packages into pkgsrc-wip ("pkgsrc work-in-progress"
                   7898: ); see the homepage at https://pkgsrc.org/wip/ for details.
                   7899: 
                   7900: Next, check that your package is complete, compiles and runs well; see
1.184     rillig   7901: Chapter 14, Creating a new pkgsrc package from scratch and the rest of this
1.218     nia      7902: document. Run the pkgtools/pkglint tool and fix any errors that appear.
                   7903: 
                   7904: Finally, send a report to the pkgsrc bug tracking system, either with the
                   7905: send-pr(1) command, or if you don't have that, go to the web page https://
                   7906: www.NetBSD.org/support/send-pr.html, which contains some instructions and a
                   7907: link to a form where you can submit packages. The sysutils/gtk-send-pr package
                   7908: is also available as a substitute for either of the above two tools.
1.1       dsieger  7909: 
                   7910: In the form of the problem report, the category should be "pkg", the synopsis
                   7911: should include the package name and version number, and the description field
                   7912: should contain a short description of your package (contents of the COMMENT
1.218     nia      7913: variable or DESCR file are OK).
1.1       dsieger  7914: 
1.154     rillig   7915: 23.3. General notes when adding, updating, or removing packages
1.1       dsieger  7916: 
                   7917: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
                   7918: CHANGES-YYYY. It's very important to keep this file up to date and conforming
                   7919: to the existing format, because it will be used by scripts to automatically
                   7920: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
                   7921: doc/TODO file and remove the entry for the package you updated or removed, in
                   7922: case it was mentioned there.
                   7923: 
                   7924: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
                   7925: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
                   7926: that result from a dependency being updated should not be mentioned. In all
                   7927: other cases it's the developer's decision.
                   7928: 
                   7929: There is a make target that helps in creating proper CHANGES-YYYY entries: make
                   7930: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
                   7931: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
                   7932: (to avoid having to resolve conflicts later-on) and then to cd to the package
                   7933: directory. For package updates, make changes-entry is enough. For new packages,
                   7934: or package moves or removals, set the CTYPE variable on the command line to
1.4       rillig   7935: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23      jakllsch 7936: your local login name is not the same as your NetBSD login name. The target
                   7937: also automatically removes possibly existing entries for the package in the
                   7938: TODO file. Don't forget to commit the changes, e.g. by using make
1.66      asau     7939: commit-changes-entry! If you are not using a checkout directly from
1.23      jakllsch 7940: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
                   7941: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1       dsieger  7942: 
1.154     rillig   7943: 23.4. Commit Messages
1.130     wiz      7944: 
                   7945: For several years, there have been mirrors of pkgsrc in fossil, git, and hg.
                   7946: Standard practise when using these tools is to make the first line of a commit
                   7947: message function as a summary that can be read without the rest, such as is
                   7948: commonly done with "git log --oneline". For this reason, we have the following
                   7949: guidelines for pkgsrc commit messages:
                   7950: 
1.131     wiz      7951:   * Start the commit message with a line that explains the big picture in 65
1.130     wiz      7952:     characters or less. When a commit is for one package, include the name of
                   7953:     the package. For updates, include the version to which it is updated.
                   7954: 
                   7955:   * Leave the next line empty.
                   7956: 
                   7957:   * Then come the details for the commit (changes in that package, reason for a
                   7958:     change) and any relevant PRs. Wrap this section.
                   7959: 
                   7960: Here is an example:
                   7961: 
1.238     wiz      7962: libxslt: update to 1.0.30
1.130     wiz      7963: 
1.238     wiz      7964: Changes since 1.0.29:
                   7965: ...
1.130     wiz      7966: 
                   7967: Here is another example:
                   7968: 
1.238     wiz      7969: mk/bsd.pkg.mk: enable SSP by default on NetBSD
1.130     wiz      7970: 
1.238     wiz      7971: (rationale)
1.130     wiz      7972: 
                   7973: Commit messages are final: no "cvs admin" is allowed on the pkgsrc repository
                   7974: to change commit messages.
                   7975: 
1.154     rillig   7976: 23.5. Committing: Adding a package to CVS
1.1       dsieger  7977: 
                   7978: This section is only of interest for pkgsrc developers with write access to the
1.34      wiz      7979: pkgsrc repository.
                   7980: 
                   7981: When the package is finished, "cvs add" the files. Start by adding the
                   7982: directory and then files in the directory. Don't forget to add the new package
                   7983: to the category's Makefile. Make sure you don't forget any files; you can check
                   7984: by running "cvs status". An example:
                   7985: 
                   7986: $ cd .../pkgsrc/category
                   7987: $ cvs add pkgname
                   7988: $ cd pkgname
                   7989: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
                   7990: $ cvs add patches/p*
                   7991: $ cvs status | less
1.35      wiz      7992: $ cvs commit
1.34      wiz      7993: $ cd ..
1.236     gutterid 7994: $ vi Makefile # add SUBDIR+=pkgname line
1.35      wiz      7995: $ cvs commit Makefile
1.66      asau     7996: $ cd pkgname
1.73      jnemeth  7997: $ make CTYPE=Added commit-changes-entry
1.1       dsieger  7998: 
                   7999: The commit message of the initial import should include part of the DESCR file,
                   8000: so people reading the mailing lists know what the package is/does.
                   8001: 
1.34      wiz      8002: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
                   8003: 
                   8004: Previously, "cvs import" was suggested, but it was much easier to get wrong
                   8005: than "cvs add".
1.1       dsieger  8006: 
1.154     rillig   8007: 23.6. Updating a package to a newer version
1.1       dsieger  8008: 
                   8009: Please always put a concise, appropriate and relevant summary of the changes
                   8010: between old and new versions into the commit log when updating a package. There
                   8011: are various reasons for this:
                   8012: 
                   8013:   * A URL is volatile, and can change over time. It may go away completely or
                   8014:     its information may be overwritten by newer information.
                   8015: 
                   8016:   * Having the change information between old and new versions in our CVS
                   8017:     repository is very useful for people who use either cvs or anoncvs.
                   8018: 
                   8019:   * Having the change information between old and new versions in our CVS
                   8020:     repository is very useful for people who read the pkgsrc-changes mailing
                   8021:     list, so that they can make tactical decisions about when to upgrade the
                   8022:     package.
                   8023: 
                   8024: Please also recognize that, just because a new version of a package has been
                   8025: released, it should not automatically be upgraded in the CVS repository. We
                   8026: prefer to be conservative in the packages that are included in pkgsrc -
                   8027: development or beta packages are not really the best thing for most places in
                   8028: which pkgsrc is used. Please use your judgement about what should go into
                   8029: pkgsrc, and bear in mind that stability is to be preferred above new and
                   8030: possibly untested features.
                   8031: 
1.154     rillig   8032: 23.7. Renaming a package in pkgsrc
1.21      snj      8033: 
                   8034: Renaming packages is not recommended.
                   8035: 
1.175     gutterid 8036: When renaming packages, be sure to fix any references to the old name in other
1.21      snj      8037: Makefiles, options, buildlink files, etc.
                   8038: 
1.175     gutterid 8039: Also, when renaming a package, please add the package name and version pattern
1.167     leot     8040: (s) of the previous package to SUPERSEDES. This may be repeated for multiple
                   8041: renames. The new package would be an exact replacement. Example:
                   8042: 
                   8043: SUPERSEDES+=    p5-IO-Compress-Zlib<2.017
                   8044: SUPERSEDES+=    optcomp-[0-9]*
1.21      snj      8045: 
                   8046: Note that "successor" in the CHANGES-YYYY file doesn't necessarily mean that it
                   8047: supersedes, as that successor may not be an exact replacement but is a
                   8048: suggestion for the replaced functionality.
                   8049: 
1.154     rillig   8050: 23.8. Moving a package in pkgsrc
1.21      snj      8051: 
                   8052: It is preferred that packages are not renamed or moved, but if needed please
                   8053: follow these steps.
1.1       dsieger  8054: 
                   8055:  1. Make a copy of the directory somewhere else.
                   8056: 
                   8057:  2. Remove all CVS dirs.
                   8058: 
                   8059:     Alternatively to the first two steps you can also do:
                   8060: 
                   8061:     % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
                   8062: 
                   8063:     and use that for further work.
                   8064: 
1.25      wiz      8065:  3. Fix CATEGORIES and any DEPENDS paths that just did "../package" instead of 
1.1       dsieger  8066:     "../../category/package".
                   8067: 
1.21      snj      8068:  4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
                   8069:     previous category/package pathname. The PREV_PKGPATH can be used by tools
                   8070:     for doing an update using pkgsrc building; for example, it can search the
                   8071:     pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
                   8072:     the corresponding new PKGPATH for that moved package. Note that it may have
                   8073:     multiple matches, so the tool should also check on the PKGBASE too. The
                   8074:     PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
                   8075:     PKGBASE stays the same.
                   8076: 
1.237     gutterid 8077:  5. cvs add the modified package in the new place.
1.1       dsieger  8078: 
1.21      snj      8079:  6. Check if any package depends on it:
1.1       dsieger  8080: 
                   8081:     % cd /usr/pkgsrc
                   8082:     % grep /package */*/Makefile* */*/buildlink*
                   8083: 
1.21      snj      8084:  7. Fix paths in packages from step 5 to point to new location.
1.1       dsieger  8085: 
1.21      snj      8086:  8. cvs rm (-f) the package at the old location.
1.1       dsieger  8087: 
1.21      snj      8088:  9. Remove from oldcategory/Makefile.
1.1       dsieger  8089: 
1.21      snj      8090: 10. Add to newcategory/Makefile.
1.1       dsieger  8091: 
1.21      snj      8092: 11. Commit the changed and removed files:
1.1       dsieger  8093: 
                   8094:     % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
                   8095: 
                   8096:     (and any packages from step 5, of course).
                   8097: 
1.154     rillig   8098: Chapter 24. Frequently Asked Questions
1.1       dsieger  8099: 
                   8100: This section contains the answers to questions that may arise when you are
                   8101: writing a package. If you don't find your question answered here, first have a
                   8102: look in the other chapters, and if you still don't have the answer, ask on the
                   8103: pkgsrc-users mailing list.
                   8104: 
1.154     rillig   8105: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
                   8106: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
                   8107: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.223     nia      8108: 24.4. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
                   8109: 24.5. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.232     gutterid 8110: the := inside it.
1.223     nia      8111: 24.6. Which mailing lists are there for package developers?
                   8112: 24.7. Where is the pkgsrc documentation?
                   8113: 24.8. I have a little time to kill. What shall I do?
1.1       dsieger  8114: 
1.154     rillig   8115: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1       dsieger  8116: 
                   8117:       MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
1.223     nia      8118:       (1).
                   8119: 
                   8120:       MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM when
                   8121:       building the package.
                   8122: 
                   8123:       .MAKEFLAGS is an internal variable of bmake and should not be used by
                   8124:       packages.
1.1       dsieger  8125: 
1.154     rillig   8126: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1       dsieger  8127: 
                   8128:       MAKE is the path to the make(1) program that is used in the pkgsrc
1.223     nia      8129:       infrastructure.
                   8130: 
                   8131:       GMAKE is the path to GNU Make, but you need to say USE_TOOLS+=gmake to
                   8132:       use that.
                   8133: 
                   8134:       MAKE_PROGRAM is the path to the Make program that is used for building
                   8135:       the package.
1.1       dsieger  8136: 
1.154     rillig   8137: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1       dsieger  8138: 
                   8139:       CC is the path to the real C compiler, which can be configured by the
1.223     nia      8140:       pkgsrc user.
1.1       dsieger  8141: 
1.223     nia      8142:       PKG_CC is the path to the compiler wrapper.
1.1       dsieger  8143: 
1.223     nia      8144:       PKGSRC_COMPILER is not a path to a compiler, but the type of compiler
                   8145:       that should be used. See mk/compiler.mk for more information about the
                   8146:       latter variable.
1.1       dsieger  8147: 
1.223     nia      8148: 24.4. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1       dsieger  8149: 
1.25      wiz      8150:       For optimization reasons, some variables are only available in the "
                   8151:       wrapper" phase and later. To "simulate" the wrapper phase, append 
1.1       dsieger  8152:       PKG_PHASE=wrapper to the above command.
                   8153: 
1.223     nia      8154: 24.5. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1       dsieger  8155:       the := inside it.
                   8156: 
1.223     nia      8157:       The := is not an assignment operator, even though it may look like one.
1.108     rillig   8158:       Instead, it is a degenerate form of ${LIST:old_string=new_string}, which
                   8159:       is documented in the make(1) man page and which is commonly used in the
                   8160:       form ${SRCS:.c=.o}. In the case of MASTER_SITE_*, old_string is the empty
                   8161:       string and new_string is package/. That's where the : and the = fall
                   8162:       together.
1.1       dsieger  8163: 
1.223     nia      8164: 24.6. Which mailing lists are there for package developers?
1.1       dsieger  8165: 
                   8166:       tech-pkg
                   8167: 
                   8168:           This is a list for technical discussions related to pkgsrc
                   8169:           development, e.g. soliciting feedback for changes to pkgsrc
                   8170:           infrastructure, proposed new features, questions related to porting
                   8171:           pkgsrc to a new platform, advice for maintaining a package, patches
                   8172:           that affect many packages, help requests moved from pkgsrc-users when
                   8173:           an infrastructure bug is found, etc.
                   8174: 
                   8175:       pkgsrc-bugs
                   8176: 
                   8177:           All bug reports in category "pkg" sent with send-pr(1) appear here.
                   8178:           Please do not report your bugs here directly; use one of the other
                   8179:           mailing lists.
                   8180: 
1.223     nia      8181: 24.7. Where is the pkgsrc documentation?
1.1       dsieger  8182: 
                   8183:       There are many places where you can find documentation about pkgsrc:
                   8184: 
                   8185:         * The pkgsrc guide (this document) is a collection of chapters that
                   8186:           explain large parts of pkgsrc, but some chapters tend to be outdated.
                   8187:           Which ones they are is hard to say.
                   8188: 
1.174     leot     8189:         * On the mailing list archives (see https://mail-index.NetBSD.org/),
                   8190:           you can find discussions about certain features, announcements of new
1.1       dsieger  8191:           parts of the pkgsrc infrastructure and sometimes even announcements
                   8192:           that a certain feature has been marked as obsolete. The benefit here
                   8193:           is that each message has a date appended to it.
                   8194: 
                   8195:         * Many of the files in the mk/ directory start with a comment that
                   8196:           describes the purpose of the file and how it can be used by the
                   8197:           pkgsrc user and package authors. An easy way to find this
                   8198:           documentation is to run bmake help.
                   8199: 
                   8200:         * The CVS log messages are a rich source of information, but they tend
                   8201:           to be highly abbreviated, especially for actions that occur often.
                   8202:           Some contain a detailed description of what has changed, but they are
                   8203:           geared towards the other pkgsrc developers, not towards an average
                   8204:           pkgsrc user. They also only document changes, so if you don't know
                   8205:           what has been before, these messages may not be worth too much to
                   8206:           you.
                   8207: 
                   8208:         * Some parts of pkgsrc are only "implicitly documented", that is the
                   8209:           documentation exists only in the mind of the developer who wrote the
                   8210:           code. To get this information, use the cvs annotate command to see
                   8211:           who has written it and ask on the tech-pkg mailing list, so that
                   8212:           others can find your questions later (see above). To be sure that the
                   8213:           developer in charge reads the mail, you may CC him or her.
                   8214: 
1.223     nia      8215: 24.8. I have a little time to kill. What shall I do?
1.1       dsieger  8216: 
                   8217:       This is not really an FAQ yet, but here's the answer anyway.
                   8218: 
                   8219:         * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
                   8220:           about newer versions of installed packages that are available, but
                   8221:           not yet updated in pkgsrc.
                   8222: 
1.198     leot     8223:         * Browse pkgsrc/doc/TODO -- it contains a list of suggested new
                   8224:           packages and a list of cleanups and enhancements for pkgsrc that
                   8225:           would be nice to have.
1.1       dsieger  8226: 
1.71      wiz      8227:         * Review packages for which review was requested on the tech-pkg
                   8228:           mailing list.
1.1       dsieger  8229: 
                   8230: Part III. The pkgsrc infrastructure internals
                   8231: 
                   8232: This part of the guide deals with everything from the infrastructure that is
                   8233: behind the interfaces described in the developer's guide. A casual package
                   8234: maintainer should not need anything from this part.
                   8235: 
                   8236: Table of Contents
                   8237: 
1.184     rillig   8238: 25. Design of the pkgsrc infrastructure
                   8239:     25.1. The meaning of variable definitions
                   8240:     25.2. Avoiding problems before they arise
                   8241:     25.3. Variable evaluation
                   8242:         25.3.1. At load time
                   8243:         25.3.2. At runtime
                   8244:     25.4. How can variables be specified?
                   8245:     25.5. Designing interfaces for Makefile fragments
                   8246:         25.5.1. Procedures with parameters
                   8247:         25.5.2. Actions taken on behalf of parameters
                   8248:     25.6. The order in which files are loaded
                   8249:         25.6.1. The order in bsd.prefs.mk
                   8250:         25.6.2. The order in bsd.pkg.mk
                   8251: 26. Regression tests
                   8252:     26.1. Running the regression tests
                   8253:     26.2. Adding a new regression test
                   8254:         26.2.1. Overridable functions
                   8255:         26.2.2. Helper functions
                   8256: 27. Porting pkgsrc
                   8257:     27.1. Porting pkgsrc to a new operating system
1.1       dsieger  8258: 
1.184     rillig   8259: Chapter 25. Design of the pkgsrc infrastructure
1.1       dsieger  8260: 
                   8261: Table of Contents
                   8262: 
1.184     rillig   8263: 25.1. The meaning of variable definitions
                   8264: 25.2. Avoiding problems before they arise
                   8265: 25.3. Variable evaluation
                   8266:     25.3.1. At load time
                   8267:     25.3.2. At runtime
                   8268: 25.4. How can variables be specified?
                   8269: 25.5. Designing interfaces for Makefile fragments
                   8270:     25.5.1. Procedures with parameters
                   8271:     25.5.2. Actions taken on behalf of parameters
                   8272: 25.6. The order in which files are loaded
                   8273:     25.6.1. The order in bsd.prefs.mk
                   8274:     25.6.2. The order in bsd.pkg.mk
1.1       dsieger  8275: 
                   8276: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
                   8277: fragment needs a properly specified interface. This chapter explains how such
                   8278: an interface looks like.
                   8279: 
1.184     rillig   8280: 25.1. The meaning of variable definitions
1.1       dsieger  8281: 
                   8282: Whenever a variable is defined in the pkgsrc infrastructure, the location and
                   8283: the way of definition provide much information about the intended use of that
                   8284: variable. Additionally, more documentation may be found in a header comment or
                   8285: in this pkgsrc guide.
                   8286: 
                   8287: A special file is mk/defaults/mk.conf, which lists all variables that are
                   8288: intended to be user-defined. They are either defined using the ?= operator or
                   8289: they are left undefined because defining them to anything would effectively
                   8290: mean "yes". All these variables may be overridden by the pkgsrc user in the
                   8291: MAKECONF file.
                   8292: 
                   8293: Outside this file, the following conventions apply: Variables that are defined
                   8294: using the ?= operator may be overridden by a package.
                   8295: 
                   8296: Variables that are defined using the = operator may be used read-only at
                   8297: run-time.
                   8298: 
                   8299: Variables whose name starts with an underscore must not be accessed outside the
                   8300: pkgsrc infrastructure at all. They may change without further notice.
                   8301: 
                   8302: Note
                   8303: 
                   8304: These conventions are currently not applied consistently to the complete pkgsrc
                   8305: infrastructure.
                   8306: 
1.184     rillig   8307: 25.2. Avoiding problems before they arise
1.1       dsieger  8308: 
                   8309: All variables that contain lists of things should default to being empty. Two
                   8310: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
                   8311: variables cannot simply be modified using the += operator in package Makefiles
                   8312: (or other files included by them), since there is no guarantee whether the
                   8313: variable is already set or not, and what its value is. In the case of
                   8314: DISTFILES, the packages "know" the default value and just define it as in the
                   8315: following example.
                   8316: 
                   8317: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   8318: 
                   8319: Because of the selection of this default value, the same value appears in many
                   8320: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
                   8321: value ("c") is so short that it doesn't stand out. Nevertheless it is mentioned
                   8322: in many files.
                   8323: 
1.184     rillig   8324: 25.3. Variable evaluation
1.1       dsieger  8325: 
1.184     rillig   8326: 25.3.1. At load time
1.1       dsieger  8327: 
                   8328: Variable evaluation takes place either at load time or at runtime, depending on
                   8329: the context in which they occur. The contexts where variables are evaluated at
                   8330: load time are:
                   8331: 
                   8332:   * The right hand side of the := and != operators,
                   8333: 
                   8334:   * Make directives like .if or .for,
                   8335: 
                   8336:   * Dependency lines.
                   8337: 
                   8338: A special exception are references to the iteration variables of .for loops,
                   8339: which are expanded inline, no matter in which context they appear.
                   8340: 
                   8341: As the values of variables may change during load time, care must be taken not
                   8342: to evaluate them by accident. Typical examples for variables that should not be
                   8343: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
                   8344: clear, here is an example:
                   8345: 
                   8346: CONFIGURE_ARGS=         # none
                   8347: CFLAGS=                 -O
                   8348: CONFIGURE_ARGS+=        CFLAGS=${CFLAGS:Q}
                   8349: 
                   8350: CONFIGURE_ARGS:=        ${CONFIGURE_ARGS}
                   8351: 
                   8352: CFLAGS+=                -Wall
                   8353: 
                   8354: This code shows how the use of the := operator can quickly lead to unexpected
                   8355: results. The first paragraph is fairly common code. The second paragraph
                   8356: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
                   8357: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
                   8358: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
                   8359: typically occur in completely unrelated files.
                   8360: 
1.184     rillig   8361: 25.3.2. At runtime
1.1       dsieger  8362: 
                   8363: After all the files have been loaded, the values of the variables cannot be
                   8364: changed anymore. Variables that are used in the shell commands are expanded at
                   8365: this point.
                   8366: 
1.184     rillig   8367: 25.4. How can variables be specified?
1.1       dsieger  8368: 
                   8369: There are many ways in which the definition and use of a variable can be
                   8370: restricted in order to detect bugs and violations of the (mostly unwritten)
1.108     rillig   8371: policies. A package can be checked with pkglint -Wall to see whether it meets
                   8372: these rules.
1.1       dsieger  8373: 
1.184     rillig   8374: 25.5. Designing interfaces for Makefile fragments
1.1       dsieger  8375: 
                   8376: Most of the .mk files fall into one of the following classes. Cases where a
                   8377: file falls into more than one class should be avoided as it often leads to
                   8378: subtle bugs.
                   8379: 
1.184     rillig   8380: 25.5.1. Procedures with parameters
1.1       dsieger  8381: 
                   8382: In a traditional imperative programming language some of the .mk files could be
1.198     leot     8383: described as procedures. They take some input parameters and--after
                   8384: inclusion--provide a result in output parameters. Since all variables in
1.23      jakllsch 8385: Makefiles have global scope care must be taken not to use parameter names that
                   8386: have already another meaning. For example, PKGNAME is a bad choice for a
                   8387: parameter name.
1.1       dsieger  8388: 
                   8389: Procedures are completely evaluated at preprocessing time. That is, when
                   8390: calling a procedure all input parameters must be completely resolvable. For
                   8391: example, CONFIGURE_ARGS should never be an input parameter since it is very
                   8392: likely that further text will be added after calling the procedure, which would
                   8393: effectively apply the procedure to only a part of the variable. Also,
1.108     rillig   8394: references to other variables will be modified after calling the procedure.
1.1       dsieger  8395: 
                   8396: A procedure can declare its output parameters either as suitable for use in
                   8397: preprocessing directives or as only available at runtime. The latter
                   8398: alternative is for variables that contain references to other runtime
                   8399: variables.
                   8400: 
                   8401: Procedures shall be written such that it is possible to call the procedure more
                   8402: than once. That is, the file must not contain multiple-inclusion guards.
                   8403: 
                   8404: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
                   8405: To express that the parameters are evaluated at load time, they should be
                   8406: assigned using the := operator, which should be used only for this purpose.
                   8407: 
1.184     rillig   8408: 25.5.2. Actions taken on behalf of parameters
1.1       dsieger  8409: 
                   8410: Action files take some input parameters and may define runtime variables. They
                   8411: shall not define loadtime variables. There are action files that are included
                   8412: implicitly by the pkgsrc infrastructure, while other must be included
                   8413: explicitly.
                   8414: 
                   8415: An example for action files is mk/subst.mk.
                   8416: 
1.184     rillig   8417: 25.6. The order in which files are loaded
1.1       dsieger  8418: 
                   8419: Package Makefiles usually consist of a set of variable definitions, and include
                   8420: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
                   8421: include various other *.mk files if they need to query the availability of
                   8422: certain features like the type of compiler or the X11 implementation. Due to
                   8423: the heavy use of preprocessor directives like .if and .for, the order in which
                   8424: the files are loaded matters.
                   8425: 
                   8426: This section describes at which point the various files are loaded and gives
                   8427: reasons for that order.
                   8428: 
1.184     rillig   8429: 25.6.1. The order in bsd.prefs.mk
1.1       dsieger  8430: 
                   8431: The very first action in bsd.prefs.mk is to define some essential variables
                   8432: like OPSYS, OS_VERSION and MACHINE_ARCH.
                   8433: 
1.4       rillig   8434: Then, the user settings are loaded from the file specified in MAKECONF, which
                   8435: is usually mk.conf. After that, those variables that have not been overridden
                   8436: by the user are loaded from mk/defaults/mk.conf.
1.1       dsieger  8437: 
                   8438: After the user settings, the system settings and platform settings are loaded,
                   8439: which may override the user settings.
                   8440: 
                   8441: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
                   8442: This only happens when building a package, so the proper variables must be used
                   8443: instead of the direct tool names.
                   8444: 
                   8445: As the last steps, some essential variables from the wrapper and the package
                   8446: system flavor are loaded, as well as the variables that have been cached in
                   8447: earlier phases of a package build.
                   8448: 
1.184     rillig   8449: 25.6.2. The order in bsd.pkg.mk
1.1       dsieger  8450: 
                   8451: First, bsd.prefs.mk is loaded.
                   8452: 
                   8453: Then, the various *-vars.mk files are loaded, which fill default values for
                   8454: those variables that have not been defined by the package. These variables may
                   8455: later be used even in unrelated files.
                   8456: 
                   8457: Then, the file bsd.pkg.error.mk provides the target error-check that is added
                   8458: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
                   8459: DELAYED_WARNING_MSG.
                   8460: 
                   8461: Then, the package-specific hacks from hacks.mk are included.
                   8462: 
                   8463: Then, various other files follow. Most of them don't have any dependencies on
                   8464: what they need to have included before or after them, though some do.
                   8465: 
                   8466: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
                   8467: restricts the use of these variables to all the files that have been included
                   8468: before. Appearances in later files will be silently ignored.
                   8469: 
                   8470: Then, the files for the main targets are included, in the order of later
                   8471: execution, though the actual order should not matter.
                   8472: 
                   8473: At last, some more files are included that don't set any interesting variables
                   8474: but rather just define make targets to be executed.
                   8475: 
1.184     rillig   8476: Chapter 26. Regression tests
1.1       dsieger  8477: 
                   8478: Table of Contents
                   8479: 
1.184     rillig   8480: 26.1. Running the regression tests
                   8481: 26.2. Adding a new regression test
                   8482:     26.2.1. Overridable functions
                   8483:     26.2.2. Helper functions
1.1       dsieger  8484: 
                   8485: The pkgsrc infrastructure consists of a large codebase, and there are many
                   8486: corners where every little bit of a file is well thought out, making pkgsrc
                   8487: likely to fail as soon as anything is changed near those parts. To prevent most
                   8488: changes from breaking anything, a suite of regression tests should go along
                   8489: with every important part of the pkgsrc infrastructure. This chapter describes
                   8490: how regression tests work in pkgsrc and how you can add new tests.
                   8491: 
1.184     rillig   8492: 26.1. Running the regression tests
1.1       dsieger  8493: 
1.25      wiz      8494: You first need to install the pkgtools/pkg_regress package, which provides the 
1.1       dsieger  8495: pkg_regress command. Then you can simply run that command, which will run all
1.168     rillig   8496: tests in the regress/ directory.
1.1       dsieger  8497: 
1.184     rillig   8498: 26.2. Adding a new regression test
1.1       dsieger  8499: 
1.168     rillig   8500: Every directory in the regress/ directory that contains a file called spec is
1.1       dsieger  8501: considered a regression test. This file is a shell program that is included by
                   8502: the pkg_regress command. The following functions can be overridden to suit your
                   8503: needs.
                   8504: 
1.184     rillig   8505: 26.2.1. Overridable functions
1.1       dsieger  8506: 
1.108     rillig   8507: These functions do not take any parameters. Although they are called in "set -e
1.168     rillig   8508: " mode, they don't stop at the first failing command. See this Stack Overflow
1.108     rillig   8509: question for details.
1.1       dsieger  8510: 
1.108     rillig   8511: do_setup
1.1       dsieger  8512: 
                   8513:     This function prepares the environment for the test. By default it does
                   8514:     nothing.
                   8515: 
1.108     rillig   8516: do_test
1.1       dsieger  8517: 
                   8518:     This function runs the actual test. By default, it calls TEST_MAKE with the
                   8519:     arguments MAKEARGS_TEST and writes its output including error messages into
                   8520:     the file TEST_OUTFILE.
                   8521: 
1.108     rillig   8522:     When defining this function, make sure that all output that needs to be
                   8523:     checked is written to the correct output file. Example:
                   8524: 
                   8525:     do_test() {
                   8526:             echo "Example output"
                   8527:     } 1>$TEST_OUTFILE 2>&1
                   8528: 
                   8529: check_result
1.1       dsieger  8530: 
                   8531:     This function is run after the test and is typically used to compare the
                   8532:     actual output from the one that is expected. It can make use of the various
1.108     rillig   8533:     helper functions from the next section. Example:
                   8534: 
                   8535:     check_result() {
                   8536:             exit_status 0
                   8537:             output_require "Example"
                   8538:             output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
                   8539:             output_prohibit "no such file or directory"
1.169     rillig   8540:             regress_fail "expected $expected but got $actual for input $input"
1.108     rillig   8541:     }
1.1       dsieger  8542: 
1.108     rillig   8543: do_cleanup
1.1       dsieger  8544: 
                   8545:     This function cleans everything up after the test has been run. By default
                   8546:     it does nothing.
                   8547: 
1.184     rillig   8548: 26.2.2. Helper functions
1.1       dsieger  8549: 
1.168     rillig   8550: regress_fail message...
                   8551: 
                   8552:     This function makes the test fail with the given error message.
                   8553: 
1.108     rillig   8554: exit_status expected
1.1       dsieger  8555: 
1.108     rillig   8556:     This function compares the exitcode of the do_test function with its first
                   8557:     parameter. If they differ, the test will fail.
1.1       dsieger  8558: 
1.108     rillig   8559: output_require regex...
1.1       dsieger  8560: 
                   8561:     This function checks for each of its parameters if the output from do_test
1.108     rillig   8562:     matches the extended regular expression. If it does not, the test will
                   8563:     fail. Example:
                   8564: 
                   8565:     output_require "looks fine"
                   8566:     output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
1.1       dsieger  8567: 
1.177     leot     8568: output_prohibit regex...
1.1       dsieger  8569: 
                   8570:     This function checks for each of its parameters if the output from do_test
                   8571:     () does not match the extended regular expression. If any of the regular
                   8572:     expressions matches, the test will fail.
                   8573: 
1.184     rillig   8574: Chapter 27. Porting pkgsrc
1.1       dsieger  8575: 
                   8576: Table of Contents
                   8577: 
1.184     rillig   8578: 27.1. Porting pkgsrc to a new operating system
1.1       dsieger  8579: 
                   8580: The pkgsrc system has already been ported to many operating systems, hardware
                   8581: architectures and compilers. This chapter explains the necessary steps to make
                   8582: pkgsrc even more portable.
                   8583: 
1.184     rillig   8584: 27.1. Porting pkgsrc to a new operating system
1.1       dsieger  8585: 
                   8586: To port pkgsrc to a new operating system (called MyOS in this example), you
                   8587: need to touch the following files:
                   8588: 
                   8589: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
                   8590: 
                   8591:     This file contains some basic definitions, for example the name of the C
                   8592:     compiler.
                   8593: 
                   8594: mk/bsd.prefs.mk
                   8595: 
1.212     wiz      8596:     Insert code that defines the variables OPSYS, OS_VERSION, OPSYS_VERSION,
1.1       dsieger  8597:     LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
                   8598:     that appear in this file.
                   8599: 
                   8600: mk/platform/MyOS.mk
                   8601: 
                   8602:     This file contains the platform-specific definitions that are used by
                   8603:     pkgsrc. Start by copying one of the other files and edit it to your needs.
                   8604: 
                   8605: mk/tools/tools.MyOS.mk
                   8606: 
                   8607:     This file defines the paths to all the tools that are needed by one or the
                   8608:     other package in pkgsrc, as well as by pkgsrc itself. Find out where these
                   8609:     tools are on your platform and add them.
                   8610: 
                   8611: Now, you should be able to build some basic packages, like lang/perl5, shells/
                   8612: bash.
                   8613: 
                   8614: Appendix A. A simple example package: bison
                   8615: 
                   8616: Table of Contents
                   8617: 
                   8618: A.1. files
                   8619:     A.1.1. Makefile
                   8620:     A.1.2. DESCR
                   8621:     A.1.3. PLIST
                   8622:     A.1.4. Checking a package with pkglint
                   8623: A.2. Steps for building, installing, packaging
                   8624: 
                   8625: We checked to find a piece of software that wasn't in the packages collection,
1.25      wiz      8626: and picked GNU bison. Quite why someone would want to have bison when Berkeley 
1.1       dsieger  8627: yacc is already present in the tree is beyond us, but it's useful for the
                   8628: purposes of this exercise.
                   8629: 
                   8630: A.1. files
                   8631: 
                   8632: A.1.1. Makefile
                   8633: 
1.2       rillig   8634: # $NetBSD$
1.1       dsieger  8635: #
                   8636: 
                   8637: DISTNAME=       bison-1.25
                   8638: CATEGORIES=     devel
1.171     rillig   8639: MASTER_SITES=   ${MASTER_SITE_GNU:=bison/}
1.1       dsieger  8640: 
1.30      dholland 8641: MAINTAINER=     pkgsrc-users@NetBSD.org
1.174     leot     8642: HOMEPAGE=       https://www.gnu.org/software/bison/bison.html
1.1       dsieger  8643: COMMENT=        GNU yacc clone
                   8644: 
                   8645: GNU_CONFIGURE=  yes
1.47      wiz      8646: INFO_FILES=     yes
1.1       dsieger  8647: 
                   8648: .include "../../mk/bsd.pkg.mk"
                   8649: 
                   8650: A.1.2. DESCR
                   8651: 
                   8652: GNU version of yacc.  Can make re-entrant parsers, and numerous other
                   8653: improvements.  Why you would want this when Berkeley yacc(1) is part
                   8654: of the NetBSD source tree is beyond me.
                   8655: 
                   8656: A.1.3. PLIST
                   8657: 
1.2       rillig   8658: @comment $NetBSD$
1.1       dsieger  8659: bin/bison
                   8660: man/man1/bison.1.gz
                   8661: share/bison.simple
                   8662: share/bison.hairy
                   8663: 
                   8664: A.1.4. Checking a package with pkglint
                   8665: 
                   8666: The NetBSD package system comes with pkgtools/pkglint which helps to check the
                   8667: contents of these files. After installation it is quite easy to use, just
1.171     rillig   8668: change to the directory of the package you wish to examine and run pkglint:
1.1       dsieger  8669: 
                   8670: $ pkglint
1.171     rillig   8671: ERROR: Makefile: Each package must define its LICENSE.
                   8672: WARN: Makefile:9: HOMEPAGE should migrate from http to https.
                   8673: NOTE: PLIST:3: The .gz extension is unnecessary for manual pages.
                   8674: WARN: PLIST:5: "share/bison.hairy" should be sorted before "share/bison.simple".
                   8675: 1 error, 2 warnings and 1 note found.
                   8676: (Run "pkglint -e" to show explanations.)
                   8677: (Run "pkglint -fs" to show what can be fixed automatically.)
1.172     rillig   8678: (Run "pkglint -F" to automatically fix some issues.)
1.1       dsieger  8679: 
                   8680: Depending on the supplied command line arguments (see pkglint(1)), more checks
1.170     rillig   8681: will be performed. Use e.g. pkglint -Wall for a very thorough check.
1.1       dsieger  8682: 
                   8683: A.2. Steps for building, installing, packaging
                   8684: 
                   8685: Create the directory where the package lives, plus any auxiliary directories:
                   8686: 
                   8687: # cd /usr/pkgsrc/lang
                   8688: # mkdir bison
                   8689: # cd bison
                   8690: # mkdir patches
                   8691: 
1.184     rillig   8692: Create Makefile, DESCR and PLIST (see Chapter 12, Package components - files,
1.1       dsieger  8693: directories and contents) then continue with fetching the distfile:
                   8694: 
                   8695: # make fetch
                   8696: >> bison-1.25.tar.gz doesn't seem to exist on this system.
                   8697: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
                   8698: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8699: ftp: Error retrieving file: 500 Internal error
                   8700: 
                   8701: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
                   8702: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8703: ftp: Error retrieving file: 500 Internal error
                   8704: 
                   8705: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
                   8706: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8707: Successfully retrieved file.
                   8708: 
                   8709: Generate the checksum of the distfile into distinfo:
                   8710: 
                   8711: # make makedistinfo
                   8712: 
                   8713: Now compile:
                   8714: 
                   8715: # make
                   8716: >> Checksum OK for bison-1.25.tar.gz.
                   8717: ===>  Extracting for bison-1.25
                   8718: ===>  Patching for bison-1.25
                   8719: ===>   Ignoring empty patch directory
                   8720: ===>  Configuring for bison-1.25
                   8721: creating cache ./config.cache
                   8722: checking for gcc... cc
                   8723: checking whether we are using GNU C... yes
                   8724: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
                   8725: checking how to run the C preprocessor... cc -E
                   8726: checking for minix/config.h... no
                   8727: checking for POSIXized ISC... no
                   8728: checking whether cross-compiling... no
                   8729: checking for ANSI C header files... yes
                   8730: checking for string.h... yes
                   8731: checking for stdlib.h... yes
                   8732: checking for memory.h... yes
                   8733: checking for working const... yes
                   8734: checking for working alloca.h... no
                   8735: checking for alloca... yes
                   8736: checking for strerror... yes
                   8737: updating cache ./config.cache
                   8738: creating ./config.status
                   8739: creating Makefile
                   8740: ===>  Building for bison-1.25
                   8741: 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
                   8742: 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
                   8743: 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
                   8744: 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
                   8745: 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
                   8746: 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
                   8747: 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
                   8748: 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
                   8749: 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
                   8750: 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
                   8751: 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
                   8752: 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
                   8753: 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
                   8754: 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
                   8755: 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
                   8756: 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
                   8757: 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
                   8758: 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
                   8759: 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
                   8760: 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
                   8761: 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
                   8762: 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
                   8763: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
                   8764: rm -f bison.s1
                   8765: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
                   8766: 
                   8767: Everything seems OK, so install the files:
                   8768: 
                   8769: # make install
                   8770: >> Checksum OK for bison-1.25.tar.gz.
                   8771: ===>  Installing for bison-1.25
                   8772: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
                   8773: rm -f /usr/pkg/bin/bison
                   8774: cd /usr/pkg/share; rm -f bison.simple bison.hairy
                   8775: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
                   8776: install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
                   8777: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
                   8778: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
                   8779: cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
                   8780: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
                   8781: ===>  Registering installation for bison-1.25
                   8782: 
                   8783: You can now use bison, and also - if you decide so - remove it with pkg_delete
                   8784: bison. Should you decide that you want a binary package, do this now:
                   8785: 
                   8786: # make package
                   8787: >> Checksum OK for bison-1.25.tar.gz.
                   8788: ===>  Building package for bison-1.25
                   8789: Creating package bison-1.25.tgz
                   8790: Registering depends:.
                   8791: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
                   8792: 
                   8793: Now that you don't need the source and object files any more, clean up:
                   8794: 
                   8795: # make clean
                   8796: ===>  Cleaning for bison-1.25
                   8797: 
1.207     leot     8798: Appendix B. Security hardening
                   8799: 
                   8800: Table of Contents
                   8801: 
                   8802: B.1. Mechanisms
                   8803:     B.1.1. Enabled by default
                   8804:     B.1.2. Not enabled by default
                   8805: B.2. Caveats
                   8806:     B.2.1. Problems with PKGSRC_MKPIE
                   8807:     B.2.2. Problems with PKGSRC_USE_FORTIFY
                   8808:     B.2.3. Problems with PKGSRC_USE_RELRO
                   8809:     B.2.4. Problems with PKGSRC_USE_SSP
                   8810: B.3. Auditing the system
                   8811:     B.3.1. Checking for PIE
                   8812:     B.3.2. Checking for partial RELRO
                   8813:     B.3.3. Checking for full RELRO
                   8814:     B.3.4. Checking for SSP
                   8815: 
                   8816: A number of mechanisms are available in pkgsrc to improve the security of the
                   8817: resulting system. This page describes the mechanisms, and gives hints about
                   8818: detecting and fixing problems.
                   8819: 
                   8820: Mechanisms can be enabled individually in mk.conf, and are individually
                   8821: described below.
                   8822: 
                   8823: Typically, a feature will cause some programs to fail to build or work when
                   8824: first enabled. This can be due to latent problems in the program, and can be
                   8825: due to other reasons. After enough testing to have confidence that user
                   8826: problems will be quite rare, individual mechanisms will be enabled by default.
                   8827: 
                   8828: For each mechanism, see the Caveats section below for an explanation of what
                   8829: might go wrong at compile time and at run time, and how to notice and address
                   8830: these problems.
                   8831: 
                   8832: B.1. Mechanisms
                   8833: 
                   8834: B.1.1. Enabled by default
                   8835: 
                   8836: B.1.1.1. PKGSRC_USE_FORTIFY
                   8837: 
                   8838: This allows substitute wrappers to be used for some commonly used library
                   8839: functions that do not have built-in bounds checking - but could in some cases.
                   8840: 
                   8841: Two mitigation levels are available:
                   8842: 
                   8843:   * "weak" only enables checks at compile-time.
                   8844: 
                   8845:   * "strong" enables checks at compile-time and runtime.
                   8846: 
                   8847: "strong" has been enabled by default since pkgsrc-2017Q3.
                   8848: 
                   8849: B.1.1.2. PKGSRC_USE_SSP
                   8850: 
                   8851: This enables a stack-smashing protection mitigation. It is done by adding a
                   8852: guard variable to functions with vulnerable objects. The guards are initialized
                   8853: when a function is entered and then checked when the function exits. The guard
                   8854: check will fail and the program forcibly exited if the variable was modified in
                   8855: the meantime. This can happen in case of buffer overflows or memory corruption,
                   8856: and therefore exposing these bugs.
                   8857: 
                   8858: Different mitigation levels are available:
                   8859: 
                   8860:   * "yes", which will only protect functions considered vulnerable by the
                   8861:     compiler;
                   8862: 
                   8863:   * "all", which will protect every function;
                   8864: 
                   8865:   * "strong", the default, which will apply a better balance between the two
                   8866:     settings above.
                   8867: 
                   8868: This mitigation is supported by both GCC and clang. It may be supported in
                   8869: additional compilers, possibly under a different name. It is particularly
                   8870: useful for unsafe programming languages, such as C/C++.
                   8871: 
                   8872:   * "yes" is enabled by default where known supported since pkgsrc-2017Q3.
                   8873: 
                   8874:   * "strong" is enabled by default where known supported since pkgsrc-2021Q4.
                   8875: 
                   8876: More details can be found here:
                   8877: 
                   8878:   * Buffer overflow protection on Wikipedia
                   8879: 
                   8880: B.1.1.3. PKGSRC_MKPIE
                   8881: 
                   8882: This requests the creation of PIE (Position Independent Executables) for all
                   8883: executables. The PIE mechanism is normally used for shared libraries, so that
                   8884: they can be loaded at differing addresses at runtime. PIE itself does not have
                   8885: useful security properties; however, it is necessary to fully leverage some,
                   8886: such as ASLR. Some operating systems support Address Space Layout Randomization
                   8887: (ASLR), which causes different addresses to be used each time a program is run.
                   8888: This makes it more difficult for an attacker to guess addresses and thus makes
                   8889: exploits harder to construct. With PIE, ASLR can really be applied to the
                   8890: entire program, instead of the stack and heap only.
                   8891: 
                   8892: PIE executables will only be built for toolchains that are known to support
                   8893: PIE. Currently, this means NetBSD on x86, ARM, SPARC64, m68k, and MIPS.
                   8894: 
                   8895: PKGSRC_MKPIE was enabled by default after the pkgsrc-2021Q3 branch.
                   8896: 
1.219     nia      8897: B.1.1.4. PKGSRC_USE_RELRO
1.207     leot     8898: 
                   8899: This also makes the exploitation of some security vulnerabilities more
                   8900: difficult in some cases.
                   8901: 
                   8902: Two different mitigation levels are available:
                   8903: 
1.219     nia      8904:   * partial (the default): the ELF sections are reordered so that internal data
                   8905:     sections precede the program's own data sections, and non-PLT GOT is
                   8906:     read-only;
1.207     leot     8907: 
                   8908:   * full: in addition to partial RELRO, every relocation is performed
1.218     nia      8909:     immediately when starting the program, allowing the entire GOT to be
                   8910:     read-only. This can greatly slow down startup of large programs.
1.207     leot     8911: 
                   8912: This is currently supported by GCC. Many software distributions now enable this
1.220     nia      8913: feature by default, at the "partial" level.
1.207     leot     8914: 
                   8915: More details can be found here:
                   8916: 
                   8917:   * Hardening ELF binaries using Relocation Read-Only (RELRO)
                   8918: 
1.219     nia      8919: B.1.2. Not enabled by default
                   8920: 
                   8921: B.1.2.1. PKGSRC_MKREPRO
                   8922: 
                   8923: With this option, pkgsrc will try to build packages reproducibly. This allows
                   8924: packages built from the same tree and with the same options, to produce
                   8925: identical results bit by bit. This option should be combined with ASLR and
                   8926: PKGSRC_MKPIE to avoid predictable address offsets for attackers attempting to
                   8927: exploit security vulnerabilities.
                   8928: 
                   8929: More details can be found here:
                   8930: 
                   8931:   * Reproducible Builds - a set of software development practices that create
                   8932:     an independently-verifiable path from source to binary code
                   8933: 
                   8934: More work likely needs to be done before pkgsrc is fully reproducible.
                   8935: 
                   8936: B.1.2.2. PKGSRC_USE_STACK_CHECK
1.207     leot     8937: 
                   8938: This uses -fstack-check with GCC for another stack protection mitigation.
                   8939: 
                   8940: It asks the compiler to generate code verifying that it does not corrupt the
                   8941: stack. According to GCC's manual page, this is really only useful for
                   8942: multi-threaded programs.
                   8943: 
                   8944: B.2. Caveats
                   8945: 
                   8946: B.2.1. Problems with PKGSRC_MKPIE
                   8947: 
                   8948: B.2.1.1. Packages failing to build
                   8949: 
                   8950: A number of packages may fail to build with this option enabled. The failures
                   8951: are often related to the absence of the -fPIC compilation flag when building
                   8952: libraries or executables (or ideally -fPIE in the latter case). This flag is
                   8953: added to the CFLAGS already, but requires the package to actually support it.
                   8954: 
                   8955: B.2.1.1.1. How to fix
                   8956: 
                   8957: These instructions are meant as a reference only; they likely need to be
                   8958: adapted for many packages individually.
                   8959: 
                   8960: For packages using Makefiles:
                   8961: 
                   8962: MAKE_FLAGS+=    CFLAGS=${CFLAGS:Q}
                   8963: MAKE_FLAGS+=    LDFLAGS=${LDFLAGS:Q}
                   8964: 
                   8965: For packages using Imakefiles:
                   8966: 
                   8967: MAKE_FLAGS+=    CCOPTIONS=${CFLAGS:Q}
                   8968: MAKE_FLAGS+=    LOCAL_LDFLAGS=${LDFLAGS:Q}
                   8969: 
                   8970: B.2.1.2. Run-time crashes
                   8971: 
                   8972: Some programs may fail to run, or crash at random times once built as PIE. Two
                   8973: scenarios are essentially possible. This is nearly always due to a bug in the
                   8974: program being exposed due to ASLR.
                   8975: 
                   8976: B.2.1.3. Disabling PKGSRC_MKPIE on a per-package basis
                   8977: 
                   8978: Ideally, packages should be fixed for compatibility with MKPIE. However, in
                   8979: some cases this is very difficult, due to complex build systems, packages using
                   8980: non-standard toolchains, or programming languages with odd bootstrapping
                   8981: mechanisms.
                   8982: 
                   8983: To disable PKGSRC_MKPIE on a per-package basis, set MKPIE_SUPPORTED= no in the
                   8984: package's Makefile before bsd.prefs.mk is included.
                   8985: 
                   8986: B.2.2. Problems with PKGSRC_USE_FORTIFY
                   8987: 
                   8988: B.2.2.1. Packages failing to build
                   8989: 
                   8990: This feature makes use of pre-processing directives to look for hardened,
                   8991: alternative implementations of essential library calls. Some programs may fail
                   8992: to build as a result; this usually happens for those trying too hard to be
                   8993: portable, or otherwise abusing definitions in the standard library.
                   8994: 
                   8995: B.2.2.2. Run-time crashes
                   8996: 
                   8997: This feature may cause some programs to crash, usually indicating an actual bug
                   8998: in the program. The fix will typically involve patching the original program's
                   8999: source code.
                   9000: 
                   9001: B.2.2.3. Optimization is required
                   9002: 
                   9003: At least in the case of GCC, FORTIFY will only be applied if optimization is
                   9004: applied while compiling. This means that the CFLAGS should also contain -O, -O2
                   9005: or another optimization level. This cannot easily be applied globally, as some
                   9006: packages may require specific optimization levels.
                   9007: 
                   9008: B.2.2.4. Disabling FORTIFY on a per-package basis
                   9009: 
                   9010: Note
                   9011: 
                   9012: FORTIFY should not be disabled to work around runtime crashes in the program!
                   9013: This is a very bad idea and will expose you to security vulnerabilities.
                   9014: 
                   9015: To disable FORTIFY on a per-package basis, set the following in the package's
                   9016: Makefile before bsd.prefs.mk is included:
                   9017: 
                   9018: FORTIFY_SUPPORTED=      no
                   9019: 
                   9020: B.2.3. Problems with PKGSRC_USE_RELRO
                   9021: 
                   9022: B.2.3.1. Performance impact
                   9023: 
                   9024: For better protection, full RELRO requires every symbol to be resolved when the
                   9025: program starts, rather than simply when required at run-time. This will have
                   9026: more impact on programs using a lot of symbols, or linked to libraries exposing
                   9027: a lot of symbols. Therefore, daemons or programs otherwise running in
                   9028: background are affected only when started. Programs loading plug-ins at
                   9029: run-time are affected when loading the plug-ins.
                   9030: 
                   9031: The impact is not expected to be noticeable on modern hardware, except in some
                   9032: cases for big programs.
                   9033: 
                   9034: B.2.3.2. Run-time crashes
                   9035: 
                   9036: Some programs handle plug-ins and dependencies in a way that conflicts with
                   9037: RELRO: for instance, with an initialization routine listing any other plug-in
                   9038: required. With full RELRO, the missing symbols are resolved before the
                   9039: initialization routine can run, and the dynamic loader will not be able to find
                   9040: them directly and abort as a result. Unfortunately, this is how Xorg loads its
                   9041: drivers. Partial RELRO can be applied instead in this case.
                   9042: 
                   9043: B.2.3.3. Disabling RELRO on a per-package basis
                   9044: 
                   9045: To disable RELRO on a per-package basis, set the following in the package's
                   9046: Makefile before bsd.prefs.mk is included:
                   9047: 
                   9048: RELRO_SUPPORTED=        no
                   9049: 
1.209     nia      9050: It is also possible to at most enable partial RELRO, by setting RELRO_SUPPORTED
                   9051: to partial.
                   9052: 
1.207     leot     9053: B.2.4. Problems with PKGSRC_USE_SSP
                   9054: 
                   9055: B.2.4.1. Packages failing to build
                   9056: 
                   9057: The stack-smashing protection provided by this option does not work for some
                   9058: programs. The most common situation in which this happens is when the program
                   9059: allocates variables on the stack, with the size determined at run-time.
                   9060: 
                   9061: B.2.4.2. Run-time crashes
                   9062: 
                   9063: Again, this feature may cause some programs to crash via a SIGABRT, usually
                   9064: indicating an actual bug in the program.
                   9065: 
                   9066: On NetBSD LOG_CRIT level syslog messages are sent and - by default - appended
                   9067: to /var/log/messages, e.g.:
                   9068: 
                   9069: Jan  6 15:42:51 hostname -: hostname program - - - buffer overflow detected; terminated
                   9070: 
                   9071: (where hostname is the hostname(1) and program is the basename(1) of the
                   9072: program crashed).
                   9073: 
                   9074: Patching the original program is then required.
                   9075: 
                   9076: Rebuilding the package via:
                   9077: 
                   9078: % env CFLAGS=-g INSTALL_UNSTRIPPED=yes make replace
                   9079: 
                   9080: and inspecting the backtrace of the coredump via the debugger should point out
                   9081: the problematic call by inspecting the frame calling the _chk() (SSP) function.
                   9082: 
                   9083: B.2.4.3. Performance impact
                   9084: 
                   9085: The compiler emits extra code when using this feature: a check for buffer
                   9086: overflows is performed when entering and exiting functions, requiring an extra
                   9087: variable on the stack. The level of protection can otherwise be adjusted to
                   9088: affect only those functions considered more sensitive by the compiler (with
                   9089: -fstack-protector instead of -fstack-protector-all).
                   9090: 
                   9091: The impact is not expected to be noticeable on modern hardware. However,
                   9092: programs with a hard requirement to run at the fastest possible speed should
                   9093: avoid using this feature, or using libraries built with this feature.
                   9094: 
                   9095: B.2.4.4. Disabling SSP on a per-package basis
                   9096: 
                   9097: Note
                   9098: 
                   9099: SSP should not be disabled to work around runtime crashes in the program! This
                   9100: is a very bad idea and will expose you to security vulnerabilities.
                   9101: 
                   9102: To disable SSP on a per-package basis, set the following in the package's
                   9103: Makefile before bsd.prefs.mk is included:
                   9104: 
                   9105: SSP_SUPPORTED=  no
                   9106: 
                   9107: B.3. Auditing the system
                   9108: 
                   9109: The illusion of security is worse than having no security at all. This section
                   9110: lists a number of ways to ensure the security features requested are actually
                   9111: effective.
                   9112: 
                   9113: These instructions were obtained and tested on a system derived from NetBSD 7
                   9114: (amd64). YMMV.
                   9115: 
                   9116: B.3.1. Checking for PIE
                   9117: 
                   9118: The ELF executable type in use changes for binaries built as PIE; without:
                   9119: 
                   9120: $ file /path/to/bin/ary
                   9121: /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
                   9122: 
                   9123: as opposed to the following binary, built as PIE:
                   9124: 
                   9125: $ file /path/to/pie/bin/ary
                   9126: /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
                   9127: 
                   9128: The latter result is then what is expected.
                   9129: 
                   9130: B.3.2. Checking for partial RELRO
                   9131: 
                   9132: The following command should list a section called RELRO:
                   9133: 
                   9134: $ objdump -p /path/to/bin/ary
                   9135: 
                   9136: /path/to/bin/ary:     file format elf64-x86-64
                   9137: 
                   9138: Program Header:
                   9139: [...]
                   9140:    RELRO off    0x0000000000000d78 vaddr 0x0000000000600d78 paddr 0x0000000000600d78 align 2**0
                   9141: 
                   9142: This check is now performed automatically if PKG_DEVELOPER is set and RELRO is
                   9143: enabled.
                   9144: 
                   9145: B.3.3. Checking for full RELRO
                   9146: 
                   9147: The dynamic loader will apply RELRO immediately when detecting the presence of
                   9148: the BIND_NOW flag:
                   9149: 
                   9150: $ objdump -x /path/to/bin/ary
                   9151: 
                   9152: /path/to/bin/ary:     file format elf64-x86-64
                   9153: 
                   9154: Dynamic Section:
                   9155: [...]
                   9156:   BIND_NOW             0x0000000000000000
                   9157: 
                   9158: This has to be combined with partial RELRO (see above) to be fully efficient.
                   9159: 
                   9160: This check is now performed automatically (where supported) if PKG_DEVELOPER is
                   9161: set.
                   9162: 
                   9163: B.3.4. Checking for SSP
                   9164: 
1.208     nia      9165: Note
                   9166: 
                   9167: Checking for SSP using this method only works where the operating system uses
                   9168: libssp. libssp is not used on recent NetBSD/FreeBSD/Linux versions.
                   9169: 
1.207     leot     9170: Building objects, binaries and libraries with SSP will affect the presence of
                   9171: additional symbols in the resulting file:
                   9172: 
                   9173: $ nm /path/to/bin/ary
                   9174: [...]
                   9175:                  U __stack_chk_fail
                   9176: 0000000000600ea0 B __stack_chk_guard
                   9177: 
                   9178: This is an indicator that the program was indeed built with support for SSP.
                   9179: 
                   9180: This check is now performed automatically (where supported) if PKG_DEVELOPER is
                   9181: set and SSP is enabled.
                   9182: 
                   9183: Appendix C. Build logs
1.1       dsieger  9184: 
                   9185: Table of Contents
                   9186: 
1.207     leot     9187: C.1. Building figlet
                   9188: C.2. Packaging figlet
1.1       dsieger  9189: 
1.207     leot     9190: C.1. Building figlet
1.1       dsieger  9191: 
                   9192: # make
                   9193: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   9194: => figlet221.tar.gz doesn't seem to exist on this system.
                   9195: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
                   9196: => [172219 bytes]
                   9197: Connected to ftp.plig.net.
                   9198: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
                   9199: 331 Guest login ok, send your complete e-mail address as password.
                   9200: 230-You are user #5 of 500 simultaneous users allowed.
                   9201: 230-
                   9202: 230-  ___ _             _ _
                   9203: 230- |  _| |_ ___   ___| |_|___   ___ ___ ___
                   9204: 230- |  _|  _| . |_| . | | | . |_| . |  _| . |
                   9205: 230- |_| |_| |  _|_|  _|_|_|_  |_|___|_| |_  |
                   9206: 230-         |_|   |_|     |___|         |___|
                   9207: 230-
                   9208: 230-** Welcome to ftp.plig.org **
                   9209: 230-
                   9210: 230-Please note that all transfers from this FTP site are logged. If you
                   9211: 230-do not like this, please disconnect now.
                   9212: 230-
1.19      snj      9213: 230-This archive is available via
1.1       dsieger  9214: 230-
                   9215: 230-HTTP:  http://ftp.plig.org/
                   9216: 230-FTP:   ftp://ftp.plig.org/     (max 500 connections)
                   9217: 230-RSYNC: rsync://ftp.plig.org/   (max  30 connections)
                   9218: 230-
                   9219: 230-Please email comments, bug reports and requests for packages to be
                   9220: 230-mirrored to ftp-admin@plig.org.
                   9221: 230-
                   9222: 230-
                   9223: 230 Logged in anonymously.
                   9224: Remote system type is UNIX.
                   9225: Using binary mode to transfer files.
                   9226: 200 Type okay.
                   9227: 250 "/pub" is new cwd.
                   9228: 250-"/pub/figlet" is new cwd.
                   9229: 250-
                   9230: 250-Welcome to the figlet archive at ftp.figlet.org
                   9231: 250-
                   9232: 250-    ftp://ftp.figlet.org/pub/figlet/
                   9233: 250-
                   9234: 250-The official FIGlet web page is:
                   9235: 250-    http://www.figlet.org/
                   9236: 250-
                   9237: 250-If you have questions, please mailto:info@figlet.org. If you want to
                   9238: 250-contribute a font or something else, you can email us.
                   9239: 250
                   9240: 250 "/pub/figlet/program" is new cwd.
                   9241: 250 "/pub/figlet/program/unix" is new cwd.
                   9242: local: figlet221.tar.gz remote: figlet221.tar.gz
                   9243: 502 Unimplemented command.
                   9244: 227 Entering Passive Mode (195,40,6,41,246,104)
                   9245: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
                   9246: 38% |**************                       | 65800      64.16 KB/s    00:01 ETA
                   9247: 226 Transfer completed.
                   9248: 172219 bytes received in 00:02 (75.99 KB/s)
                   9249: 221 Goodbye.
                   9250: => Checksum OK for figlet221.tar.gz.
                   9251: ===> Extracting for figlet-2.2.1nb2
                   9252: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
                   9253: ===> Patching for figlet-2.2.1nb2
                   9254: ===> Applying pkgsrc patches for figlet-2.2.1nb2
                   9255: ===> Overriding tools for figlet-2.2.1nb2
                   9256: ===> Creating toolchain wrappers for figlet-2.2.1nb2
                   9257: ===> Configuring for figlet-2.2.1nb2
                   9258: ===> Building for figlet-2.2.1nb2
                   9259: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\"  -DDEFAULTFONTFILE=\"standard.flf\"  figlet.c zipio.c crc.c inflate.c -o figlet
                   9260: chmod a+x figlet
                   9261: gcc -O2 -o chkfont chkfont.c
                   9262: => Unwrapping files-to-be-installed.
                   9263: #
                   9264: # make install
                   9265: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   9266: ===> Installing for figlet-2.2.1nb2
                   9267: install -d -o root -g wheel -m 755 /usr/pkg/bin
                   9268: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
                   9269: mkdir -p /usr/pkg/share/figlet
                   9270: cp figlet /usr/pkg/bin
                   9271: cp chkfont /usr/pkg/bin
                   9272: chmod 555 figlist showfigfonts
                   9273: cp figlist /usr/pkg/bin
                   9274: cp showfigfonts /usr/pkg/bin
                   9275: cp fonts/*.flf /usr/pkg/share/figlet
                   9276: cp fonts/*.flc /usr/pkg/share/figlet
                   9277: cp figlet.6 /usr/pkg/man/man6
                   9278: ===> Registering installation for figlet-2.2.1nb2
                   9279: #
                   9280: 
1.207     leot     9281: C.2. Packaging figlet
1.1       dsieger  9282: 
                   9283: # make package
                   9284: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   9285: ===> Packaging figlet-2.2.1nb2
                   9286: ===> Building binary package for figlet-2.2.1nb2
                   9287: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
                   9288: Using SrcDir value of /usr/pkg
                   9289: Registering depends:.
                   9290: #
                   9291: 
1.207     leot     9292: Appendix D. Directory layout of the pkgsrc FTP server
1.1       dsieger  9293: 
                   9294: Table of Contents
                   9295: 
1.207     leot     9296: D.1. distfiles: The distributed source files
                   9297: D.2. misc: Miscellaneous things
                   9298: D.3. packages: Binary packages
                   9299: D.4. reports: Bulk build reports
                   9300: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  9301: 
                   9302: As in other big projects, the directory layout of pkgsrc is quite complex for
                   9303: newbies. This chapter explains where you find things on the FTP server. The
                   9304: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
                   9305: different, but inside this directory, everything should look the same, no
                   9306: matter on which server you are. This directory contains some subdirectories,
                   9307: which are explained below.
                   9308: 
1.207     leot     9309: D.1. distfiles: The distributed source files
1.1       dsieger  9310: 
                   9311: The directory distfiles contains lots of archive files from all pkgsrc
                   9312: packages, which are mirrored here. The subdirectories are called after their
                   9313: package names and are used when the distributed files have names that don't
                   9314: explicitly contain a version number or are otherwise too generic (for example
                   9315: release.tar.gz).
                   9316: 
1.207     leot     9317: D.2. misc: Miscellaneous things
1.1       dsieger  9318: 
                   9319: This directory contains things that individual pkgsrc developers find worth
                   9320: publishing.
                   9321: 
1.207     leot     9322: D.3. packages: Binary packages
1.1       dsieger  9323: 
1.3       rillig   9324: This directory contains binary packages for the various platforms that are
                   9325: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
                   9326: The meaning of these variables is:
                   9327: 
                   9328:   * OPSYS is the name of the operating system for which the packages have been
1.9       rillig   9329:     built. The name is taken from the output of the uname command, so it may
                   9330:     differ from the one you are used to hear.
1.3       rillig   9331: 
1.8       rillig   9332:   * ARCH is the hardware architecture of the platform for which the packages
1.10      hubertf  9333:     have been built. It also includes the ABI (Application Binary Interface)
                   9334:     for platforms that have several of them.
1.3       rillig   9335: 
1.8       rillig   9336:   * OSVERSION is the version of the operating system. For version numbers that
                   9337:     change often (for example NetBSD-current), the often-changing part should
                   9338:     be replaced with an x, for example 4.99.x.
1.3       rillig   9339: 
1.23      jakllsch 9340:   * TAG is either 20xxQy for a stable branch, or head for packages built from
1.8       rillig   9341:     the HEAD branch. The latter should only be used when the packages are
                   9342:     updated on a regular basis. Otherwise the date from checking out pkgsrc
                   9343:     should be appended, for example head_20071015.
1.3       rillig   9344: 
                   9345: The rationale for exactly this scheme is that the pkgsrc users looking for
                   9346: binary packages can quickly click through the directories on the server and
                   9347: find the best binary packages for their machines. Since they usually know the
                   9348: operating system and the hardware architecture, OPSYS and ARCH are placed
                   9349: first. After these choices, they can select the best combination of OSVERSION
                   9350: and TAG together, since it is usually the case that packages stay compatible
                   9351: between different version of the operating system.
                   9352: 
                   9353: In each of these directories, there is a whole binary packages collection for a
                   9354: specific platform. It has a directory called All which contains all binary
                   9355: packages. Besides that, there are various category directories that contain
                   9356: symbolic links to the real binary packages.
1.1       dsieger  9357: 
1.207     leot     9358: D.4. reports: Bulk build reports
1.8       rillig   9359: 
                   9360: Here are the reports from bulk builds, for those who want to fix packages that
                   9361: didn't build on some of the platforms. The structure of subdirectories should
1.207     leot     9362: look like the one in Section D.3, "packages: Binary packages".
1.8       rillig   9363: 
1.207     leot     9364: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  9365: 
                   9366: These directories contain the "real" pkgsrc, that is the files that define how
                   9367: to create binary packages from source archives.
                   9368: 
1.149     leot     9369: Each of the current, stable and pkgsrc-20xxQy directories share the same
                   9370: structure. They each contain a pkgsrc directory and pkgsrc.tar.{bz,gz,xz} file.
                   9371: 
1.1       dsieger  9372: The directory pkgsrc contains a snapshot of the CVS repository, which is
1.149     leot     9373: updated regularly. The file pkgsrc.tar.{bz,gz,xz} contains the same as the
                   9374: directory, ready to be downloaded as a whole.
1.1       dsieger  9375: 
1.149     leot     9376: The current directory contains files related to the HEAD branch of the CVS
                   9377: repository. In this directory there is an additional file called
                   9378: pkgsrc-readmes.tar.{bz,gz,xz} that contains all pkgsrc READMEs with information
                   9379: about categories and packages.
                   9380: 
                   9381: The stable directory is a symlink to the latest pkgsrc-20xxQy.
                   9382: 
                   9383: The pkgsrc-20xxQy. directories contain files related to the -20xxQy stable
                   9384: branch of the CVS repository. In these directories there is an additional file
                   9385: called pkgsrc-20xxQy.tar.{bz,gz,xz}, which contains the state of pkgsrc when it
                   9386: was branched.
1.148     leot     9387: 
1.207     leot     9388: Appendix E. Help topics
1.154     rillig   9389: 
                   9390: The following list contains all help topics that are available when running 
                   9391: bmake help topic=:index.
                   9392: 
1.243     gutterid 9393: #!                                -lintl
                   9394: 32bit                             64bit
                   9395: ABI                               ACCEPTABLE_LICENSES
                   9396: ACROREAD_FONTPATH                 ADDITIONAL
                   9397: AFAIK                             AIX
                   9398: ALLOW_NEWER_COMPILER              ALLOW_VULNERABLE_PACKAGES
1.249     gutterid 9399: ALL_ENV                           ALTERNATIVES_SRC
                   9400: AMANDA_TMP                        AMANDA_USER
                   9401: AMANDA_VAR                        APACHE_GROUP
                   9402: APACHE_MODULE_NAME                APACHE_MODULE_SRC
                   9403: APACHE_MODULE_SRCDIR              APACHE_PKG_PREFIX
                   9404: APACHE_SUEXEC_CONFIGURE_ARGS      APACHE_SUEXEC_DOCROOT
                   9405: APACHE_USER                       APPEND_ABI
                   9406: APPEND_ELF                        ARLA_CACHE
                   9407: AUDIT_PACKAGES_FLAGS              AUTOCONF_REQD
                   9408: AUTOMAKE_OVERRIDE                 AUTOMAKE_REQD
                   9409: AUTO_MKDIRS                       BDB185_DEFAULT
                   9410: BDBBASE                           BDB_ACCEPTED
                   9411: BDB_DEFAULT                       BDB_LIBS
                   9412: BDB_TYPE                          BINCIMAP_GROUP
                   9413: BINCIMAP_USER                     BIND_DIR
                   9414: BIND_GROUP                        BIND_USER
                   9415: BINOWN                            BINPKG_SITES
                   9416: BIN_INSTALL_FLAGS                 BISON_PKGDATADIR
                   9417: BLAS                              BLAS_ACCEPTED
                   9418: BLAS_C_INTERFACE                  BLAS_INCLUDES
                   9419: BLAS_INDEX64                      BLAS_LIBS
                   9420: BLAS_PC                           BLAS_TYPE
                   9421: BOOTSTRAP_DEPENDS                 BROKEN
                   9422: BROKEN_EXCEPT_ON_PLATFORM         BROKEN_ON_PLATFORM
                   9423: BSDSRCDIR                         BSDXSRCDIR
                   9424: BSD_MAKE_ENV                      BUILDLINK_AUTO_DIRS
                   9425: BUILDLINK_AUTO_VARS               BUILDLINK_CFLAGS
                   9426: BUILDLINK_CONTENTS_FILTER         BUILDLINK_CPPFLAGS
1.243     gutterid 9427: BUILDLINK_FILES                   BUILDLINK_FILES_CMD
                   9428: BUILDLINK_FNAME_TRANSFORM         BUILDLINK_LDFLAGS
                   9429: BUILDLINK_LIBS                    BUILDLINK_OPSYS_SUPPORT_PTHREAD
                   9430: BUILDLINK_PKGNAME                 BUILDLINK_PREFIX
                   9431: BUILDLINK_RPATHDIRS               BUILDLINK_TREE
                   9432: BUILD_DEFS                        BUILD_DEFS_EFFECTS
                   9433: BUILD_DEPENDS                     BUILD_DIRS
                   9434: BUILD_ENV_SHELL                   BUILD_MAKE_CMD
                   9435: BUILD_MAKE_FLAGS                  BUILD_TARGET
                   9436: BUILTIN_FIND_FILES                BUILTIN_FIND_FILES_VAR
                   9437: BUILTIN_FIND_GREP                 BUILTIN_FIND_HEADERS
                   9438: BUILTIN_FIND_HEADERS_VAR          BUILTIN_FIND_PKGCONFIG
                   9439: BUILTIN_FIND_PKGCONFIG_VAR        BUILTIN_PKG
                   9440: BUILTIN_TEST_CURSES_DEFINES       BUILTIN_TEST_CURSES_FUNCS
                   9441: BUILTIN_VERSION_SCRIPT            BUILTIN_X11_TYPE
                   9442: BUILTIN_X11_VERSION               CACTI_GROUP
                   9443: CACTI_USER                        CANNA_GROUP
                   9444: CANNA_USER                        CAT
                   9445: CBLAS_LIBS                        CBLAS_PC
                   9446: CCACHE_BASE                       CCACHE_DIR
                   9447: CCACHE_LOGFILE                    CC_VERSION
                   9448: CC_VERSION_STRING                 CDRECORD_CONF
                   9449: CDROM_PKG_URL_DIR                 CDROM_PKG_URL_HOST
1.249     gutterid 9450: CHANGES                           CHECK_COMPILER
                   9451: CHECK_FAKEHOME                    CHECK_FILES
                   9452: CHECK_FILES_SKIP                  CHECK_FILES_STRICT
                   9453: CHECK_HEADERS                     CHECK_HEADERS_SKIP
                   9454: CHECK_INTERPRETER                 CHECK_INTERPRETER_SKIP
                   9455: CHECK_PERMS                       CHECK_PERMS_AUTOFIX
                   9456: CHECK_PERMS_SKIP                  CHECK_PIE
                   9457: CHECK_PIE_SKIP                    CHECK_PIE_SUPPORTED
                   9458: CHECK_PORTABILITY                 CHECK_PORTABILITY_EXPERIMENTAL
                   9459: CHECK_PORTABILITY_SKIP            CHECK_RELRO
                   9460: CHECK_RELRO_SKIP                  CHECK_RELRO_SUPPORTED
                   9461: CHECK_SHLIBS                      CHECK_SHLIBS_SKIP
                   9462: CHECK_SHLIBS_SUPPORTED            CHECK_SHLIBS_TOXIC
                   9463: CHECK_SSP                         CHECK_SSP_SKIP
                   9464: CHECK_SSP_SUPPORTED               CHECK_STRIPPED
                   9465: CHECK_STRIPPED_SKIP               CHECK_WRKREF
                   9466: CHECK_WRKREF_EXTRA_DIRS           CHECK_WRKREF_SKIP
                   9467: CLAMAV_DBDIR                      CLAMAV_GROUP
                   9468: CLAMAV_USER                       CLANGBASE
                   9469: CLEANDEPENDS                      CMAKE_DEPENDENCIES_REWRITE
                   9470: CMAKE_INSTALL_NAME_DIR            CMAKE_INSTALL_PREFIX
                   9471: CMAKE_MODULE_PATH_OVERRIDE        CMAKE_PKGSRC_BUILD_FLAGS
                   9472: CMAKE_PREFIX_PATH                 CMAKE_USE_GNU_INSTALL_DIRS
1.243     gutterid 9473: COMPILER_RPATH_FLAG               COMPILER_USE_SYMLINKS
                   9474: CONFIGURE_ARGS                    CONFIGURE_DIRS
                   9475: CONFIGURE_ENV                     CONFIGURE_ENV_SHELL
                   9476: CONFIGURE_HAS_INFODIR             CONFIGURE_HAS_MANDIR
                   9477: CONFIGURE_SCRIPT                  CONFIG_SHELL
                   9478: CONFIG_SHELL_FLAGS                CONF_FILES
                   9479: CONF_FILES_MODE                   CONF_FILES_PERMS
                   9480: CONSERVER_DEFAULTHOST             CONSERVER_DEFAULTPORT
                   9481: CP                                CPE
                   9482: CPE_EDITION                       CPE_LANG
                   9483: CPE_OTHER                         CPE_PART
                   9484: CPE_PRODUCT                       CPE_SW_EDITION
                   9485: CPE_TARGET_HW                     CPE_TARGET_SW
                   9486: CPE_UPDATE                        CPE_URI
                   9487: CPE_VENDOR                        CPE_VERSION
                   9488: CPP                               CPP_PRECOMP_FLAGS
                   9489: CREATE_WRKDIR_SYMLINK             CROSSBASE
                   9490: CTFCONVERT                        CTF_FILES_SKIP
                   9491: CTF_SUPPORTED                     CTYPE
                   9492: CUPS_GROUP                        CUPS_SYSTEM_GROUPS
                   9493: CUPS_USER                         CURSES_DEFAULT
1.249     gutterid 9494: CURSES_TYPE                       CXX
                   9495: CYRUS_GROUP                       CYRUS_IDLE
                   9496: CYRUS_USER                        DAEMONTOOLS_GROUP
                   9497: DAEMONTOOLS_LOG_USER              DARWIN_NO_SYSTEM_LIBS
                   9498: DARWIN_REQUIRES_FILTER            DBUS_GROUP
                   9499: DBUS_USER                         DEFANG_GROUP
                   9500: DEFANG_USER                       DEFAULT_ACCEPTABLE_LICENSES
                   9501: DEFAULT_DISTFILES                 DEFAULT_IRC_SERVER
                   9502: DEFAULT_SERIAL_DEVICE             DEF_UMASK
                   9503: DEINSTALLDEPENDS                  DEINSTALL_SRC
                   9504: DEINSTALL_TEMPLATES               DELAYED_ERROR_MSG
                   9505: DELAYED_WARNING_MSG               DEPENDS
                   9506: DEPENDS_TARGET                    DEPENDS_TYPE
                   9507: DESTDIR                           DESTDIR_VARNAME
                   9508: DIALER_GROUP                      DIGEST_REQD
                   9509: DISTDIR                           DISTFILES
                   9510: DISTINFO_FILE                     DISTNAME
                   9511: DIST_PATH                         DIST_SUBDIR
                   9512: DJBDNS_AXFR_USER                  DJBDNS_CACHE_USER
                   9513: DJBDNS_DJBDNS_GROUP               DJBDNS_LOG_USER
                   9514: DJBDNS_RBL_USER                   DJBDNS_TINY_USER
                   9515: DLOPEN_REQUIRE_PTHREADS           DL_AUTO_VARS
                   9516: DL_CFLAGS                         DL_LDFLAGS
                   9517: DL_LIBS                           DNS
                   9518: DOCOWN                            DOWNLOADED_DISTFILE
                   9519: DQCACHE_GROUP                     DQCACHE_USER
                   9520: DT_LAYOUT                         DYNAMIC_SITES_CMD
                   9521: DYNAMIC_SITES_SCRIPT              ECHO
                   9522: ECHO_N                            ELK_GUI
                   9523: EMACS_TYPE                        EMULDIR
                   9524: EMULSUBDIR                        EMULSUBDIRSLASH
                   9525: EMUL_ARCH                         EMUL_DISTRO
                   9526: EMUL_EXEC_FMT                     EMUL_IS_NATIVE
                   9527: EMUL_MODULES                      EMUL_OPSYS
                   9528: EMUL_PKG_FMT                      EMUL_PLATFORM
                   9529: EMUL_PLATFORMS                    EMUL_PREFER
                   9530: EMUL_REQD                         EMUL_TYPE
                   9531: ERROR_MSG                         EXIM_GROUP
                   9532: EXIM_USER                         EXPORT_SYMBOLS_LDFLAGS
                   9533: EXTRACTOR                         EXTRACT_CMD
                   9534: EXTRACT_CMD_DEFAULT               EXTRACT_DIR
                   9535: EXTRACT_ELEMENTS                  EXTRACT_ENV
                   9536: EXTRACT_ONLY                      EXTRACT_OPTS
                   9537: EXTRACT_SUFX                      EXTRACT_USING
                   9538: FAIL                              FAILOVER_FETCH
                   9539: FAIL_MSG                          FAKE_NCURSES
                   9540: FAM                               FAM_ACCEPTED
                   9541: FAM_DEFAULT                       FAM_SERVER
                   9542: FCPATH                            FEATURE_CPPFLAGS
                   9543: FEATURE_LDFLAGS                   FEATURE_LIBS
                   9544: FETCH_AFTER_ARGS                  FETCH_BEFORE_ARGS
                   9545: FETCH_CMD                         FETCH_OUTPUT_ARGS
                   9546: FETCH_PROXY                       FETCH_RESUME_ARGS
                   9547: FETCH_TIMEOUT                     FETCH_USE_IPV4_ONLY
                   9548: FETCH_USING                       FILES_SUBST
                   9549: FILES_SUBST_SED                   FIX_SYSTEM_HEADERS
1.243     gutterid 9550: FONTS_DIRS                        FONTS_VERBOSE
1.244     gutterid 9551: FOO_HACKS_MK                      FORCE_CXX_STD
1.249     gutterid 9552: FORCE_C_STD                       FOX_USE_XUNICODE
1.243     gutterid 9553: FREEWNN_GROUP                     FREEWNN_USER
                   9554: FTP_PKG_URL_DIR                   FTP_PKG_URL_HOST
                   9555: GAMEDATAMODE                      GAMEDATA_PERMS
                   9556: GAMEDIRMODE                       GAMEDIR_PERMS
                   9557: GAMEGRP                           GAMEMODE
                   9558: GAMEOWN                           GAMES_GROUP
                   9559: GAMES_USER                        GCC
                   9560: GCCBASE                           GCC_REQD
                   9561: GCC_VERSION_SUFFIX                GEM_BUILD
                   9562: GEM_CLEANBUILD                    GEM_CLEANBUILD_EXTENSIONS
                   9563: GEM_DOCDIR                        GEM_EXTSDIR
                   9564: GEM_HOME                          GEM_KEEPBUILD
                   9565: GEM_LIBDIR                        GEM_NAME
                   9566: GEM_PATH                          GEM_PLUGINSDIR
                   9567: GEM_SPECFILE                      GENERATE_PLIST
                   9568: GHC                               GHOSTSCRIPT_REQD
                   9569: GITHUB_PROJECT                    GITHUB_RELEASE
                   9570: GITHUB_SUBMODULES                 GITHUB_TAG
                   9571: GITHUB_TYPE                       GITLAB_PROJECT
                   9572: GITLAB_RELEASE                    GITLAB_SUBMODULES
                   9573: GITLAB_TAG                        GITLAB_TYPE
1.249     gutterid 9574: GNU                               GNU_CONFIGURE
                   9575: GNU_CONFIGURE_INFODIR             GNU_CONFIGURE_MANDIR
                   9576: GNU_CONFIGURE_QUIET               GNU_CONFIGURE_STRICT
                   9577: GODEP_REDIRECTS                   GO_BUILD_PATTERN
                   9578: GO_DEPS                           GO_DIST_BASE
                   9579: GO_EXTRA_MOD_DIRS                 GO_MODULE_FILES
                   9580: GO_SRCPATH                        GROUP_SPECIFIC_PKGS
                   9581: GRUB_NETWORK_CARDS                GRUB_PRESET_COMMAND
                   9582: GRUB_SCAN_ARGS                    GZIP
1.243     gutterid 9583: HASKELL_ENABLE_DYNAMIC_EXECUTABLE HASKELL_ENABLE_HADDOCK_DOCUMENTATION
                   9584: HASKELL_ENABLE_LIBRARY_PROFILING  HASKELL_ENABLE_SHARED_LIBRARY
                   9585: HASKELL_ENABLE_TESTS              HASKELL_OPTIMIZATION_LEVEL
                   9586: HASKELL_PKG_NAME                  HASKELL_UNRESTRICT_DEPENDENCIES
1.249     gutterid 9587: HEADER_TEMPLATES                  HOMEPAGE
                   9588: HOST_PKGTOOLS_ARGS                HOST_SPECIFIC_PKGS
                   9589: HOWL_GROUP                        HOWL_USER
                   9590: ICCBASE                           ICECAST_CHROOTDIR
                   9591: ICON_THEMES                       IDOBASE
                   9592: IGNORE_CCACHE                     IGNORE_INFO_DIRS
                   9593: IGNORE_INTERACTIVE_FETCH          IMAKE
                   9594: IMAKEOPTS                         IMAKE_MAKE
                   9595: IMAKE_MANINSTALL                  IMAP_UW_CCLIENT_MBOX_FMT
                   9596: IMDICTDIR                         INCOMPAT_CURSES
                   9597: INFO_DIR                          INFO_FILES
                   9598: INFO_MSG                          INIT_SYSTEM
                   9599: INN_DATA_DIR                      INN_GROUP
                   9600: INN_USER                          INSTALLATION_DIRS
                   9601: INSTALLATION_DIRS_FROM_PLIST      INSTALL_ENV
                   9602: INSTALL_SH_OVERRIDE               INSTALL_SRC
                   9603: INSTALL_TEMPLATES                 INSTALL_UNSTRIPPED
                   9604: IRCD_HYBRID_IRC_GROUP             IRCD_HYBRID_IRC_USER
                   9605: IRCD_HYBRID_MAXCONN               IRCD_HYBRID_NICLEN
                   9606: IRCD_HYBRID_SYSLOG_EVENTS         IRCD_HYBRID_SYSLOG_FACILITY
                   9607: IRCD_HYBRID_TOPICLEN              IRIX
                   9608: IRRD_USE_PGP                      JABBERD_GROUP
                   9609: JABBERD_LOGDIR                    JABBERD_PIDDIR
                   9610: JABBERD_SPOOLDIR                  JABBERD_USER
                   9611: JAVA_BINPREFIX                    JAVA_CLASSPATH
                   9612: JAVA_HOME                         JAVA_LD_LIBRARY_PATH
                   9613: JAVA_NAME                         JAVA_UNLIMIT
                   9614: JAVA_WRAPPERS                     JPEG_ACCEPTED
                   9615: JPEG_DEFAULT                      KERBEROS
                   9616: KERMIT_SUID_UUCP                  KJS_USE_PCRE
                   9617: KNEWS_DOMAIN_FILE                 KNEWS_DOMAIN_NAME
                   9618: KRB5_ACCEPTED                     KRB5_DEFAULT
                   9619: LANGUAGES                         LAPACKE_LIBS
                   9620: LAPACKE_PC                        LAPACK_LIBS
                   9621: LAPACK_PC                         LATEX2HTML_ICONPATH
                   9622: LDCONFIG_ADD_CMD                  LDCONFIG_REMOVE_CMD
                   9623: LDD                               LEAFNODE_DATA_DIR
                   9624: LEAFNODE_GROUP                    LEAFNODE_USER
                   9625: LIBDVDCSS_HOMEPAGE                LIBDVDCSS_MASTER_SITES
                   9626: LIBIMAGEQUANT_TYPE                LIBRSVG_TYPE
                   9627: LIBTOOL                           LIBTOOLIZE_PLIST
                   9628: LIBTOOL_M4_OVERRIDE               LIBUSB_TYPE
                   9629: LICENSE                           LINKER_RPATH_FLAG
                   9630: LINK_RPATH_FLAG                   LINUX_LOCALES
1.244     gutterid 9631: LOCALBASE                         LOCALBASE_LOCKTYPE
                   9632: LOCALPATCHES                      LOVE_DATA
                   9633: LOVE_GAME                         LOVE_VERSION
                   9634: LP32PLATFORMS                     LP64PLATFORMS
                   9635: LUA_BUSTED_ARGS                   LUA_CDIR
                   9636: LUA_COMPILER                      LUA_DOCDIR
                   9637: LUA_EXAMPLESDIR                   LUA_INCDIR
                   9638: LUA_INTERPRETER                   LUA_LDIR
                   9639: LUA_LINKER_MAGIC                  LUA_PKGPREFIX
                   9640: LUA_SELF_CONFLICT                 LUA_USE_BUSTED
                   9641: LUA_VERSIONS_ACCEPTED             LUA_VERSIONS_INCOMPATIBLE
                   9642: LUA_VERSION_DEFAULT               LUA_VERSION_REQD
                   9643: Lua                               MACHINE_PLATFORM
                   9644: MAILAGENT_DOMAIN                  MAILAGENT_EMAIL
                   9645: MAILAGENT_FQDN                    MAILAGENT_ORGANIZATION
1.249     gutterid 9646: MAJORDOMO_HOMEDIR                 MAKEINFO_ARGS
                   9647: MAKE_DIRS                         MAKE_DIRS_PERMS
                   9648: MAKE_ENV                          MAKE_FILE
                   9649: MAKE_FLAGS                        MAKE_JOBS
                   9650: MAKE_JOBS_SAFE                    MAKE_PROGRAM
                   9651: MANCOMPRESSED_IF_MANZ             MANINSTALL
                   9652: MANZ                              MARIADB_VERSIONS_ALL
                   9653: MASTER_SITES                      MASTER_SITE_BACKUP
                   9654: MASTER_SITE_LOCAL                 MASTER_SITE_MOZILLA
                   9655: MASTER_SITE_OVERRIDE              MASTER_SITE_PERL_CPAN
                   9656: MASTER_SORT                       MASTER_SORT_RANDOM
                   9657: MASTER_SORT_REGEX                 MECAB_CHARSET
                   9658: MEDIATOMB_GROUP                   MEDIATOMB_USER
                   9659: MIPSPROBASE                       MIREDO_GROUP
                   9660: MIREDO_USER                       MISSING_FEATURES
                   9661: MKDIR                             MKPIE_SUPPORTED
                   9662: MLDONKEY_GROUP                    MLDONKEY_HOME
                   9663: MLDONKEY_USER                     MONOTONE_GROUP
                   9664: MONOTONE_USER                     MOTIFBASE
                   9665: MOTIF_TYPE                        MOTIF_TYPE_DEFAULT
                   9666: MPI_TYPE                          MSGFMT_STRIP_MSGCTXT
                   9667: MSGFMT_STRIP_MSGID_PLURAL         MTOOLS_ENABLE_FLOPPYD
1.244     gutterid 9668: MV                                MYSQL_CHARSET
                   9669: MYSQL_DATADIR                     MYSQL_EXTRA_CHARSET
                   9670: MYSQL_GROUP                       MYSQL_USER
                   9671: MYSQL_VERSION                     MYSQL_VERSIONS_ACCEPTED
                   9672: MYSQL_VERSION_DEFAULT             NAGIOSCMD_GROUP
                   9673: NAGIOSDIR                         NAGIOS_GROUP
                   9674: NAGIOS_USER                       NATIVE_APPEND_ABI
                   9675: NATIVE_APPEND_ELF                 NATIVE_EXEC_FMT
                   9676: NATIVE_MACHINE_PLATFORM           NATIVE_OBJECT_FMT
                   9677: NBPAX_PROGRAM_PREFIX              NETBSD_LOGIN_NAME
                   9678: NMH_EDITOR                        NMH_MTA
                   9679: NMH_PAGER                         NODE_VERSIONS_ACCEPTED
                   9680: NODE_VERSIONS_INCOMPATIBLE        NODE_VERSION_DEFAULT
                   9681: NODE_VERSION_REQD                 NOLOGIN
                   9682: NOTE                              NOT_FOR_PLATFORM
                   9683: NOT_PAX_ASLR_SAFE                 NOT_PAX_MPROTECT_SAFE
                   9684: NO_BUILD                          NO_CHECKSUM
                   9685: NO_CONFIGURE                      NO_SKIP
                   9686: NS_PREFERRED                      NULLMAILER_GROUP
                   9687: NULLMAILER_USER                   OBJHOSTNAME
                   9688: OBJMACHINE                        OCAML_FINDLIB_DIRS
                   9689: OCAML_FINDLIB_REGISTER            OCAML_FINDLIB_REGISTER_VERBOSE
                   9690: OCAML_SITELIBDIR                  OMF
                   9691: ONLY_FOR_COMPILER                 ONLY_FOR_PLATFORM
                   9692: OPENSSH_CHROOT                    OPENSSH_GROUP
                   9693: OPENSSH_USER                      OPSYS
                   9694: OPSYS_EMULDIR                     OPSYS_VERSION
                   9695: OS                                OSS_TYPE
1.249     gutterid 9696: OSX                               OS_VARIANT
1.244     gutterid 9697: OS_VERSION                        OTF_FONTS_DIR
                   9698: OVERRIDE_DIRDEPTH                 OVERRIDE_GEMSPEC
1.249     gutterid 9699: OVERRIDE_GNU_CONFIG_SCRIPTS       OWN_DIRS
                   9700: OWN_DIRS_PERMS                    P4GROUP
                   9701: P4PORT                            P4ROOT
                   9702: P4USER                            PACKAGES
                   9703: PALMOS_DEFAULT_SDK                PAMBASE
                   9704: PAM_DEFAULT                       PAPERSIZE
                   9705: PASSIVE_FETCH                     PATCHDIR
                   9706: PATCHFILES                        PATCH_ARGS
                   9707: PATCH_DEBUG                       PATCH_DIST_ARGS
                   9708: PATCH_DIST_CAT                    PATCH_DIST_STRIP
                   9709: PATCH_FUZZ_FACTOR                 PATCH_STRIP
                   9710: PATH                              PCCBASE
                   9711: PEAR_CMD                          PEAR_LIB
                   9712: PEAR_PACKAGE_XML                  PERL5
                   9713: PERL5_CONFIGURE                   PERL5_CONFIGURE_DIRS
                   9714: PERL5_LDFLAGS                     PERL5_LICENSE
                   9715: PERL5_MODULE_TYPE                 PERL5_PACKLIST
                   9716: PERL5_PACKLIST_DIR                PERL5_PERLBASE
                   9717: PERL5_SITEBASE                    PERL5_USE_PACKLIST
                   9718: PERL5_VENDORBASE                  PFCTL
                   9719: PFVAR_H                           PF_VERSION
                   9720: PGGROUP                           PGHOME
                   9721: PGPKGSRCDIR                       PGSQL_TYPE
                   9722: PGSQL_VERSION                     PGSQL_VERSIONS_ACCEPTED
                   9723: PGSQL_VERSION_DEFAULT             PGUSER
                   9724: PG_LIB_EXT                        PHP
                   9725: PHPCOMMON_MK                      PHPPKGSRCDIR
                   9726: PHP_BASE_VERS                     PHP_CHECK_INSTALLED
                   9727: PHP_EXTENSION_DIR                 PHP_INITIAL_TEENY
                   9728: PHP_PKG_PREFIX                    PHP_VERSION
                   9729: PHP_VERSIONS_ACCEPTED             PHP_VERSIONS_INCOMPATIBLE
                   9730: PHP_VERSION_DEFAULT               PHP_VERSION_REQD
                   9731: PILRC_USE_GTK                     PKGCONFIG_BASE
                   9732: PKGCONFIG_FILE                    PKGCONFIG_OVERRIDE
                   9733: PKGCONFIG_OVERRIDE_STAGE          PKGDIR
                   9734: PKGGNUDIR                         PKGINFODIR
                   9735: PKGLOCALEDIR                      PKGMANDIR
                   9736: PKGNAME                           PKGNAME_REQD
                   9737: PKGPATH                           PKGREVISION
                   9738: PKGSRC_BLAS_TYPES                 PKGSRC_CHANGES
                   9739: PKGSRC_COMPILER                   PKGSRC_KEEP_BIN_PKGS
                   9740: PKGSRC_LOCKTYPE                   PKGSRC_MAKE_ENV
                   9741: PKGSRC_MESSAGE_RECIPIENTS         PKGSRC_MKPIE
                   9742: PKGSRC_MKREPRO                    PKGSRC_OVERRIDE_MKPIE
                   9743: PKGSRC_RUN_TEST                   PKGSRC_SETENV
                   9744: PKGSRC_SLEEPSECS                  PKGSRC_TODO
                   9745: PKGSRC_USE_CTF                    PKGSRC_USE_FORTIFY
                   9746: PKGSRC_USE_MKTOOLS                PKGSRC_USE_RELRO
                   9747: PKGSRC_USE_SSP                    PKGSRC_USE_STACK_CHECK
                   9748: PKGTASKS_DATAFILE                 PKGTOOLS_ARGS
                   9749: PKGTOOLS_ENV                      PKG_ALTERNATIVES
                   9750: PKG_APACHE                        PKG_APACHE_ACCEPTED
                   9751: PKG_APACHE_DEFAULT                PKG_BEST_EXISTS
                   9752: PKG_BUILD_OPTIONS                 PKG_COMPRESSION
                   9753: PKG_CONFIG                        PKG_CONFIG_PERMS
                   9754: PKG_CREATE_USERGROUP              PKG_DB_TMPDIR
                   9755: PKG_DEBUG_LEVEL                   PKG_DEFAULT_OPTIONS
                   9756: PKG_DESTDIR_SUPPORT               PKG_DEVELOPER
                   9757: PKG_DISABLED_OPTIONS              PKG_FATAL_ERRORS
                   9758: PKG_FC                            PKG_FILELIST_CMD
                   9759: PKG_GECOS                         PKG_GID
                   9760: PKG_GROUPS                        PKG_GROUPS_VARS
                   9761: PKG_HOME                          PKG_INIT_SCRIPTS
                   9762: PKG_JAVA_HOME                     PKG_JVM
                   9763: PKG_JVMS_ACCEPTED                 PKG_JVM_DEFAULT
                   9764: PKG_LEGACY_OPTIONS                PKG_LIBTOOL
                   9765: PKG_MKSYMLINKS                    PKG_OPTIONS
                   9766: PKG_OPTIONS_DEPRECATED_WARNINGS   PKG_OPTIONS_LEGACY_OPTS
                   9767: PKG_OPTIONS_LEGACY_VARS           PKG_OPTIONS_NONEMPTY_SETS
                   9768: PKG_OPTIONS_OPTIONAL_GROUPS       PKG_OPTIONS_REQUIRED_GROUPS
                   9769: PKG_OPTIONS_VAR                   PKG_PHP
                   9770: PKG_PHP_MAJOR_VERS                PKG_PHP_VERSION
                   9771: PKG_RCD_SCRIPTS                   PKG_REFCOUNT_DBDIR
                   9772: PKG_REGISTER_SHELLS               PKG_RESUME_TRANSFERS
                   9773: PKG_SHELL                         PKG_SUGGESTED_OPTIONS
                   9774: PKG_SUPPORTED_OPTIONS             PKG_SYSCONFBASE
                   9775: PKG_SYSCONFBASEDIR                PKG_SYSCONFDIR
                   9776: PKG_SYSCONFDIR_PERMS              PKG_SYSCONFSUBDIR
                   9777: PKG_SYSCONFVAR                    PKG_TOOLS_BIN
                   9778: PKG_UID                           PKG_UPDATE_FONTS_DB
                   9779: PKG_USERS                         PKG_USERS_VARS
                   9780: PKG_VERBOSE                       PLEASE
                   9781: PLIST                             PLIST_AWK
                   9782: PLIST_AWK_ENV                     PLIST_SRC
                   9783: PLIST_SUBST                       PLIST_TYPE
                   9784: PLIST_VARS                        POPTOP_USE_MPPE
                   9785: POSSIBLE_GFORTRAN_VERSION         POST_FETCH_HOOK
                   9786: PREFER                            PREFER_NATIVE
                   9787: PREFER_NATIVE_PTHREADS            PREFER_PKGSRC
                   9788: PREFIX                            PREPEND_PATH
                   9789: PRE_ROOT_CMD                      PRIVILEGED_STAGES
                   9790: PS                                PTHREAD_AUTO_VARS
                   9791: PTHREAD_CFLAGS                    PTHREAD_LDFLAGS
                   9792: PTHREAD_LIBS                      PTHREAD_OPTS
                   9793: PTHREAD_TYPE                      PVM_SSH
                   9794: PYPKGPREFIX                       PYTHON_FOR_BUILD_ONLY
                   9795: PYTHON_SELF_CONFLICT              PYTHON_VERSION
                   9796: PYTHON_VERSIONED_DEPENDENCIES     PYTHON_VERSIONS_ACCEPTED
                   9797: PYTHON_VERSIONS_INCOMPATIBLE      PYTHON_VERSION_DEFAULT
                   9798: PYTHON_VERSION_REQD               PYVERSSUFFIX
                   9799: QMAILDIR                          QMAIL_ALIAS_USER
                   9800: QMAIL_DAEMON_USER                 QMAIL_LOG_USER
                   9801: QMAIL_NOFILES_GROUP               QMAIL_PASSWD_USER
                   9802: QMAIL_QMAIL_GROUP                 QMAIL_QUEUE_DIR
                   9803: QMAIL_QUEUE_EXTRA                 QMAIL_QUEUE_USER
                   9804: QMAIL_REMOTE_USER                 QMAIL_ROOT_USER
                   9805: QMAIL_SEND_USER                   QORE_LATEST_MODULE_API
                   9806: QORE_MODULE_API                   QORE_MODULE_DIR
                   9807: QORE_USER_MODULE_DIR              QORE_VERSION
                   9808: QPOPPER_FAC                       QPOPPER_SPOOL_DIR
                   9809: QPOPPER_USER                      RAKE_NAME
                   9810: RASMOL_DEPTH                      RCD_SCRIPTS
                   9811: RCD_SCRIPTS_DIR                   RCD_SCRIPTS_EXAMPLEDIR
                   9812: RCD_SCRIPTS_MODE                  RCD_SCRIPTS_SHELL
                   9813: RCD_SCRIPT_SRC                    RDOC
1.244     gutterid 9814: READLINE_DEFAULT                  READLINE_TYPE
                   9815: REAL_ROOT_GROUP                   REAL_ROOT_USER
                   9816: RECURSIVE_MAKE                    RELAY_CTRL_DIR
                   9817: RELRO_SUPPORTED                   REPLACE_AWK
                   9818: REPLACE_BASH                      REPLACE_CSH
                   9819: REPLACE_KSH                       REPLACE_LUA
                   9820: REPLACE_NODEJS                    REPLACE_OCTAVE
                   9821: REPLACE_PERL                      REPLACE_PERL6
                   9822: REPLACE_PHP                       REPLACE_PYTHON
                   9823: REPLACE_QORE                      REPLACE_R
                   9824: REPLACE_RUBY                      REPLACE_RUBY_DIRS
                   9825: REPLACE_RUBY_PAT                  REPLACE_SH
                   9826: REPLACE_TEXLUA                    REPLACE_WISH
                   9827: REQD_DIRS                         REQD_DIRS_PERMS
                   9828: REQD_FILES                        REQD_FILES_MODE
                   9829: REQD_FILES_PERMS                  RESOLV_AUTO_VARS
                   9830: RESOLV_LDFLAGS                    RESOLV_LIBS
1.249     gutterid 9831: RM                                ROOT_CMD
1.244     gutterid 9832: ROOT_GROUP                        ROOT_USER
                   9833: RPCGEN                            RPM
                   9834: RPM2PKG_PLIST                     RPM2PKG_PREFIX
                   9835: RPM2PKG_STAGE                     RPM2PKG_STRIP
                   9836: RPM2PKG_SUBPREFIX                 RPMFILES
                   9837: RPMIGNOREPATH                     RPM_DB_PREFIX
                   9838: RSSH_CVS_PATH                     RSSH_RDIST_PATH
                   9839: RSSH_RSYNC_PATH                   RSSH_SCP_PATH
                   9840: RSSH_SFTP_SERVER_PATH             RUBY
                   9841: RUBYGEM                           RUBYGEM_MANPAGES
                   9842: RUBYGEM_NAME                      RUBYGEM_OPTIONS
                   9843: RUBYGEM_USE_MANPAGES              RUBYGEM_VERBOSE
                   9844: RUBY_ABI_VERSION                  RUBY_ARCH
                   9845: RUBY_ARCHINC                      RUBY_ARCHLIB
                   9846: RUBY_BASE                         RUBY_BASERIDIR
                   9847: RUBY_BUILD_DOCUMENT               RUBY_DLEXT
                   9848: RUBY_DOC                          RUBY_DYNAMIC_DIRS
                   9849: RUBY_EG                           RUBY_ENCODING_ARG
                   9850: RUBY_EXTCONF                      RUBY_EXTCONF_CHECK
                   9851: RUBY_EXTCONF_DEBUG                RUBY_EXTCONF_MAKEFILE
                   9852: RUBY_GEM_ARCH                     RUBY_GEM_BASE
                   9853: RUBY_INC                          RUBY_LIB
                   9854: RUBY_LIB_BASE                     RUBY_NAME
                   9855: RUBY_NOVERSION                    RUBY_PKGPREFIX
                   9856: RUBY_RAILS                        RUBY_RAILS61_VERSION
1.251     gutterid 9857: RUBY_RAILS70_VERSION              RUBY_RAILS71_VERSION
                   9858: RUBY_RAILS_ACCEPTED               RUBY_RAILS_DEFAULT
                   9859: RUBY_RAILS_REQD                   RUBY_RAILS_STRICT_DEP
                   9860: RUBY_RIDIR                        RUBY_SETUP
                   9861: RUBY_SHLIB                        RUBY_SHLIBALIAS
                   9862: RUBY_SHLIBVER                     RUBY_SIMPLE_INSTALL
                   9863: RUBY_SITEARCHLIB                  RUBY_SITELIB
                   9864: RUBY_SITELIB_BASE                 RUBY_SITERIDIR
                   9865: RUBY_SLEXT                        RUBY_SRCDIR
                   9866: RUBY_STATICLIB                    RUBY_SUFFIX
                   9867: RUBY_SYSRIDIR                     RUBY_USE_PTHREAD
                   9868: RUBY_VENDORARCHLIB                RUBY_VENDORLIB
                   9869: RUBY_VENDORLIB_BASE               RUBY_VER
                   9870: RUBY_VERSION                      RUBY_VERSIONS_ACCEPTED
                   9871: RUBY_VERSIONS_INCOMPATIBLE        RUBY_VERSION_DEFAULT
                   9872: RUBY_VERSION_REQD                 RUBY_VER_DIR
                   9873: RUN                               RUN_LDCONFIG
                   9874: RUST_TYPE                         SCO
                   9875: SCREWS_GROUP                      SCREWS_USER
                   9876: SCRIPTS_ENV                       SCROLLKEEPER_DATADIR
                   9877: SCROLLKEEPER_REBUILDDB            SCROLLKEEPER_UPDATEDB
                   9878: SDIST_PAWD                        SDL12_TYPE
                   9879: SERIAL_DEVICES                    SETGIDGAME
                   9880: SETGID_GAMES_PERMS                SETUID_ROOT_PERMS
                   9881: SH                                SHLIB
                   9882: SIGN_PACKAGES                     SILC_CLIENT_WITH_PERL
                   9883: SITE_SPECIFIC_PKGS                SKIP_DEPENDS
                   9884: SMF_INSTANCES                     SMF_MANIFEST
                   9885: SMF_METHODS                       SMF_METHOD_SHELL
                   9886: SMF_METHOD_SRC                    SMF_NAME
                   9887: SMF_PREFIX                        SMF_SRCDIR
                   9888: SNIPROXY_GROUP                    SNIPROXY_USER
                   9889: SOURCE_BUFFSIZE                   SPECIAL_PERMS
                   9890: SPECIFIC_PKGS                     SSH_SUID
                   9891: SSP_SUPPORTED                     SSYNC_PAWD
                   9892: STEP_MSG                          STRIP
                   9893: STRIP_DBG                         STRIP_DEBUG
                   9894: STRIP_DEBUG_SUPPORTED             STRIP_FILES_SKIP
                   9895: SU                                SUBDIR
                   9896: SUBST                             SUBST_CLASSES
                   9897: SUBST_FILES                       SUBST_FILTER_CMD
                   9898: SUBST_MESSAGE                     SUBST_NOOP_OK
                   9899: SUBST_SED                         SUBST_SHOW_DIFF
                   9900: SUBST_SKIP_TEXT_CHECK             SUBST_STAGE
                   9901: SUBST_VARS                        SUNWSPROBASE
                   9902: SUSE_PREFER                       SU_CMD
                   9903: SYSCONFBASE                       TARGET_ARCH
                   9904: TBL                               TERMCAP_TYPE
                   9905: TERMINFO_DEFAULT                  TERMINFO_TYPE
                   9906: TEST                              TEST_DEPENDS
                   9907: TEST_DIRS                         TEST_ENV
                   9908: TEST_ENV_SHELL                    TEST_MAKE_CMD
                   9909: TEST_MAKE_FLAGS                   TEST_TARGET
                   9910: TEXLIVE_IGNORE_PATTERNS           TEXLIVE_REV
                   9911: TEXLIVE_UNVERSIONED               TEXMFSITE
                   9912: TEX_FORMATS                       TEX_HYPHEN_DAT
                   9913: TEX_HYPHEN_DEF                    TEX_TEXMF_DIRS
                   9914: THTTPD_LOG_FACILITY               TINYDYN_USER
                   9915: TLSWRAPPER_CHROOT                 TO
                   9916: TOOLS_ALIASES                     TOOLS_ALWAYS_WRAP
                   9917: TOOLS_ARGS                        TOOLS_BROKEN
                   9918: TOOLS_CMD                         TOOLS_CMDLINE_SED
                   9919: TOOLS_CREATE                      TOOLS_CROSS_DESTDIR
                   9920: TOOLS_DIR                         TOOLS_FAIL
                   9921: TOOLS_GNU_MISSING                 TOOLS_LDCONFIG
                   9922: TOOLS_NOOP                        TOOLS_PATH
                   9923: TOOLS_SCRIPT                      TOOLS_USE_CROSS_COMPILE
                   9924: TOOL_DEPENDS                      TTF_FONTS_DIR
                   9925: TYPE                              UAC_REQD_EXECS
                   9926: UCSPI_SSL_GROUP                   UCSPI_SSL_USER
                   9927: UNLIMIT_RESOURCES                 UNPRIVILEGED
                   9928: UNPRIVILEGED_GROUP                UNPRIVILEGED_GROUPS
                   9929: UNPRIVILEGED_USER                 UNWRAP_FILES
                   9930: UNWRAP_PATTERNS                   UPDATE_GEMSPEC
                   9931: UPDATE_TARGET                     URI
                   9932: USERGROUP_PHASE                   USERPPP_GROUP
                   9933: USER_SPECIFIC_PKGS                USE_ABI_DEPENDS
                   9934: USE_APR                           USE_BSD_MAKEFILE
                   9935: USE_BUILTIN                       USE_CC_FEATURES
                   9936: USE_CROSS_COMPILE                 USE_CURSES
                   9937: USE_CWRAPPERS                     USE_CXX_FEATURES
                   9938: USE_DB185                         USE_FEATURES
                   9939: USE_GAMESGROUP                    USE_GCC_RUNTIME
                   9940: USE_IMAKE                         USE_JAVA
                   9941: USE_JAVA2                         USE_LANGUAGES
                   9942: USE_LIBTOOL                       USE_NATIVE_GCC
                   9943: USE_NETBSD_REPO                   USE_PKGSRC_GCC
                   9944: USE_PKGSRC_GCC_RUNTIME            USE_PKGTASKS
                   9945: USE_PKG_ADMIN_DIGEST              USE_RUBY_EXTCONF
                   9946: USE_RUBY_INSTALL                  USE_RUBY_SETUP
                   9947: USE_RUBY_SETUP_PKG                USE_TOOLS
                   9948: UUCP_GROUP                        UUCP_USER
                   9949: VARBASE                           VARNAME
                   9950: VIM_EXTRA_OPTS                    WARNING_MSG
                   9951: WCALC_CGIDIR                      WCALC_CGIPATH
                   9952: WCALC_HTMLDIR                     WCALC_HTMLPATH
                   9953: WDM_MANAGERS                      WRAPPER_CC
                   9954: WRAPPER_REORDER_CMDS              WRKDIR
                   9955: WRKDIR_BASENAME                   WRKDIR_LOCKTYPE
                   9956: WRKLOG                            WRKOBJDIR
                   9957: WRKSRC                            X10_PORT
                   9958: X11                               X11BASE
                   9959: X11_PKGSRCDIR                     X11_TYPE
                   9960: X509_CERTIFICATE                  X509_KEY
                   9961: XAW_TYPE                          XLOCK_DEFAULT_MODE
                   9962: XMKMF                             XMKMF_FLAGS
                   9963: XXX                               YES
                   9964: ZSH_STATIC                        __stdc__
                   9965: _vargroups                        accept
                   9966: acquire-localbase-lock            acquire-lock
                   9967: add                               added
                   9968: administrator                     alloca
                   9969: alternatives                      aslr
                   9970: asprintf                          atlas
                   9971: autoconf                          automake
                   9972: autoreconf                        awk
                   9973: bash                              big-endian
                   9974: bin-install                       bind
                   9975: binpkg-list                       blas
                   9976: bootstrap-depends                 broken
                   9977: broken_on_platform                bsd
                   9978: bsd.prog.mk                       build
                   9979: build-env                         buildlink-directories
                   9980: buildlink-oss-soundcard-h         built-in
                   9981: builtin                           c
                   9982: c++                               ccache
                   9983: cce                               cdefs
                   9984: ceil                              changes
                   9985: changes-entry                     changes-entry-noupdate
                   9986: check                             check-clean
                   9987: check-files                       check-files-clean
                   9988: check-vulnerable                  checksum
                   9989: checksum-phase                    clean
                   9990: clean-depends                     cleandir
                   9991: commit                            commit-changes-entry
                   9992: compact                           compiler
                   9993: conf                              config.guess
                   9994: config.sub                        configuration
                   9995: configure                         configure-env
                   9996: configure-help                    configure_args
                   9997: connect                           cos
                   9998: cpe                               cputime
                   9999: create-usergroup                  csh
                   10000: ctf                               debug
                   10001: declaration                       declare
                   10002: defined                           depend
                   10003: dependencies                      depends
                   10004: depends-checksum                  depends-fetch
                   10005: deps                              describe
                   10006: destdir                           disable
                   10007: distclean                         distinfo
                   10008: dl                                dlopen
                   10009: do-buildlink                      do-clean
                   10010: do-configure                      do-configure-post-hook
                   10011: do-extract                        do-fetch
                   10012: do-install                        emul
                   10013: emul-distinfo                     emul-fetch
                   10014: emulation                         emulator
                   10015: enable                            endian
                   10016: enomem                            ensurepip
                   10017: err                               errx
                   10018: etc                               exp
                   10019: extract-rpm                       fabs
                   10020: feature                           features
                   10021: fetch                             fetch-list
                   10022: follows                           forbids
                   10023: form                              format
                   10024: fortify                           fortify_source
                   10025: friend                            fts
                   10026: fts_close                         fts_open
                   10027: fts_read                          fts_set
                   10028: gcc                               gethostbyaddr
                   10029: gethostbyname                     gethostbyname2
                   10030: getopt_long                       getprogname
                   10031: getservbyname                     getservbyport
                   10032: getservent                        gettext
                   10033: github                            gitlab
                   10034: glob                              gnu
                   10035: gnu_configure_strict              go
                   10036: go-deps                           golang
                   10037: guess-license                     hashbang
                   10038: heimdal                           help
                   10039: imake                             in-tree
                   10040: increment                         indirect
                   10041: inet_aton                         interp
                   10042: interpreter                       intl
                   10043: ip4                               ip6
                   10044: ipv4                              ipv6
                   10045: iso                               kerberos
                   10046: krb                               krb5
                   10047: ksh                               lapack
                   10048: latex                             libintl_bindtextdomain
                   10049: libintl_gettext                   libintl_textdomain
                   10050: libnbcompat                       libs
                   10051: libtool                           licence
                   10052: license                           lintl
                   10053: little-endian                     lock
                   10054: locking                           lua
                   10055: lvalue                            make
                   10056: makesum                           memory
                   10057: meta                              meta-package
                   10058: meta_package                      mit-krb5
                   10059: mk.conf                           mkl
                   10060: mount                             move
                   10061: moved                             mprotect
                   10062: mremap                            native
                   10063: nb                                nbcompat
                   10064: netlib                            node
                   10065: node.js                           nodejs
                   10066: obstack                           obstack_ptr_grow
                   10067: occurs                            only
                   10068: openblas                          options
                   10069: options.mk                        order
                   10070: override                          override-intltool
                   10071: override-message-intltool         package
                   10072: parallel                          path
                   10073: pax                               paxctl
                   10074: pbulk-index                       pc
                   10075: perl                              perl5
                   10076: perms                             php
                   10077: pkg-build-options                 pkg-config
                   10078: pkg_build_options                 pkgsrc
                   10079: platform                          plist
                   10080: post-extract                      post-fetch
                   10081: post-wrapper                      pre-build-checks-hook
                   10082: pre-configure-checks-hook         pre-extract
                   10083: pre-fetch                         print-go-deps
                   10084: print-plist                       print-summary-data
                   10085: privileged-install-hook           pypi
                   10086: python                            r
                   10087: readme-all                        recursive
                   10088: recv                              recvfrom
                   10089: regcomp                           release-localbase-lock
                   10090: release-lock                      relro
                   10091: remove                            removed
                   10092: rename                            renamed
                   10093: reorder                           replace
                   10094: replace_interpreter               reproducible
                   10095: resolv                            root
                   10096: ruby                              send
                   10097: sendfile                          sendto
                   10098: setenv                            setgid
                   10099: setprogname                       setuid
                   10100: sh                                shebang
                   10101: show                              show-all
                   10102: show-build-defs                   show-depends
                   10103: show-depends-dirs                 show-depends-pkgpaths
                   10104: show-depends-recursive            show-deps
                   10105: show-distfiles                    show-downlevel
                   10106: show-subdir-var                   show-tools
                   10107: show-var                          show-vars
                   10108: snprintf                          socket
                   10109: ssp                               st_mode
                   10110: stage-install                     strcasestr
                   10111: strict                            strip
                   10112: strndup                           strnlen
                   10113: strsep                            subst
                   10114: substitutions                     sun
                   10115: sunpro                            sunwspro
                   10116: symlink                           test
                   10117: test-env                          tex
                   10118: texlive                           tmp
                   10119: todo                              tool
                   10120: tools                             tools-libtool-m4-override
                   10121: transitive                        type
                   10122: ulimit                            undefined
                   10123: undo-replace                      unlimit
                   10124: unprivileged                      unprivileged-install-hook
                   10125: unstripped                        update
                   10126: updated                           upload
                   10127: upload-distfiles                  use_tools
                   10128: user                              utimes
                   10129: vasprintf                         verbose
                   10130: vsnprintf                         warn
                   10131: warning                           warnings
                   10132: warnx                             wattr_off
                   10133: wattr_on                          work
                   10134: wrapper                           wrkdir
1.154     rillig   10135: 
1.207     leot     10136: Appendix F. Editing guidelines for the pkgsrc guide
1.1       dsieger  10137: 
                   10138: Table of Contents
                   10139: 
1.207     leot     10140: F.1. Make targets
                   10141: F.2. Procedure
1.1       dsieger  10142: 
                   10143: This section contains information on editing the pkgsrc guide itself.
                   10144: 
1.207     leot     10145: F.1. Make targets
1.1       dsieger  10146: 
                   10147: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
                   10148: files are created from it:
                   10149: 
                   10150:   * pkgsrc/doc/pkgsrc.txt
                   10151: 
                   10152:   * pkgsrc/doc/pkgsrc.html
                   10153: 
1.174     leot     10154:   * https://www.NetBSD.org/docs/pkgsrc/
1.1       dsieger  10155: 
1.174     leot     10156:   * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the
                   10157:     pkgsrc guide.
1.1       dsieger  10158: 
1.174     leot     10159:   * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
1.2       rillig   10160:     pkgsrc guide.
1.1       dsieger  10161: 
1.207     leot     10162: F.2. Procedure
1.1       dsieger  10163: 
                   10164: The procedure to edit the pkgsrc guide is:
                   10165: 
1.190     bacon    10166:  1. Make sure you have checked out the htdocs repository into a sibling
                   10167:     directory of your pkgsrc directory. You will need the ability to commit
                   10168:     from both pkgsrc and htdocs.
                   10169: 
                   10170:  2. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46      obache   10171:     other XML-based NetBSD documentation) installed. These are automatically
                   10172:     installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1       dsieger  10173: 
1.190     bacon    10174:  3. Run cd doc/guide to get to the right directory. All further steps will take
1.1       dsieger  10175:     place here.
                   10176: 
1.190     bacon    10177:  4. Edit the XML file(s) in files/.
1.1       dsieger  10178: 
1.190     bacon    10179:  5. Run bmake to check the pkgsrc guide for valid XML and to build the final
1.1       dsieger  10180:     output files. If you get any errors at this stage, you can just edit the
                   10181:     files, as there are only symbolic links in the working directory, pointing
                   10182:     to the files in files/.
                   10183: 
1.190     bacon    10184:  6. (cd files && cvs commit)
1.1       dsieger  10185: 
1.190     bacon    10186:  7. Run bmake clean && bmake to regenerate the output files with the proper RCS
1.1       dsieger  10187:     Ids.
                   10188: 
1.190     bacon    10189:  8. Run bmake regen to install and commit the files in both pkgsrc/doc and
1.1       dsieger  10190:     htdocs.
                   10191: 
                   10192:     Note
                   10193: 
                   10194:     If you have added, removed or renamed some chapters, you need to
                   10195:     synchronize them using cvs add or cvs delete in the htdocs directory.
                   10196: 

CVSweb <webmaster@jp.NetBSD.org>