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

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.196     jnemeth    15: Copyright   1994-2021 The NetBSD Foundation, Inc
1.1       dsieger    16: 
1.207     leot       17: $NetBSD: pkgsrc.xml,v 1.40 2021/10/01 17:20:27 nia 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: 
                     32:     1.1. Introduction
                     33: 
                     34:         1.1.1. Why pkgsrc?
                     35:         1.1.2. Supported platforms
                     36: 
                     37:     1.2. Overview
                     38:     1.3. Terminology
                     39: 
                     40:         1.3.1. Roles involved in pkgsrc
                     41: 
                     42:     1.4. Typography
                     43: 
                     44: I. The pkgsrc user's guide
                     45: 
1.154     rillig     46:     2. Getting help
                     47:     3. Where to get pkgsrc and how to keep it up-to-date
1.1       dsieger    48: 
1.154     rillig     49:         3.1. Getting pkgsrc for the first time
1.1       dsieger    50: 
1.154     rillig     51:             3.1.1. As tar archive
                     52:             3.1.2. Via anonymous CVS
1.1       dsieger    53: 
1.154     rillig     54:         3.2. Keeping pkgsrc up-to-date
1.1       dsieger    55: 
1.154     rillig     56:             3.2.1. Via tar files
                     57:             3.2.2. Via CVS
1.1       dsieger    58: 
1.154     rillig     59:     4. Using pkgsrc on systems other than NetBSD
1.1       dsieger    60: 
1.154     rillig     61:         4.1. Binary distribution
                     62:         4.2. Bootstrapping pkgsrc
1.1       dsieger    63: 
1.154     rillig     64:     5. Using pkgsrc
1.1       dsieger    65: 
1.154     rillig     66:         5.1. Using binary packages
1.1       dsieger    67: 
1.154     rillig     68:             5.1.1. Finding binary packages
                     69:             5.1.2. Installing binary packages
1.202     nia        70:             5.1.3. Updating packages
                     71:             5.1.4. Deinstalling packages
                     72:             5.1.5. Getting information about installed packages
                     73:             5.1.6. Checking for security vulnerabilities in installed packages
                     74:             5.1.7. Finding if newer versions of your installed packages are in
1.1       dsieger    75:                 pkgsrc
1.202     nia        76:             5.1.8. Other administrative functions
1.1       dsieger    77: 
1.154     rillig     78:         5.2. Building packages from source
1.1       dsieger    79: 
1.154     rillig     80:             5.2.1. Requirements
                     81:             5.2.2. Fetching distfiles
                     82:             5.2.3. How to build and install
1.1       dsieger    83: 
1.154     rillig     84:     6. Configuring pkgsrc
1.1       dsieger    85: 
1.154     rillig     86:         6.1. General configuration
                     87:         6.2. Variables affecting the build process
                     88:         6.3. Variables affecting the installation process
                     89:         6.4. Selecting and configuring the compiler
1.1       dsieger    90: 
1.154     rillig     91:             6.4.1. Selecting the compiler
                     92:             6.4.2. Additional flags to the compiler (CFLAGS)
                     93:             6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger    94: 
1.154     rillig     95:         6.5. Developer/advanced settings
                     96:         6.6. Selecting Build Options
1.1       dsieger    97: 
1.154     rillig     98:     7. Creating binary packages
1.1       dsieger    99: 
1.154     rillig    100:         7.1. Building a single binary package
                    101:         7.2. Settings for creation of binary packages
1.1       dsieger   102: 
1.154     rillig    103:     8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig    104: 
1.154     rillig    105:         8.1. Preparations
1.180     rillig    106:         8.2. Running a bulk build
1.6       rillig    107: 
1.154     rillig    108:             8.2.1. Configuration
1.6       rillig    109: 
1.154     rillig    110:         8.3. Requirements of a full bulk build
1.178     rillig    111:         8.4. Bulk build variants
1.6       rillig    112: 
1.179     rillig    113:             8.4.1. Detect unknown configure options
                    114:             8.4.2. Detect classes of bugs by forcing compiler warnings
1.181     rillig    115:             8.4.3. Force compiler options only in the build phase
                    116:             8.4.4. Use custom directories
                    117:             8.4.5. Turn warnings into errors
                    118:             8.4.6. Reject packages for which pkglint reports errors
                    119:             8.4.7. Reject packages that contain forbidden strings
                    120:             8.4.8. Reject packages whose self-test fails
                    121:             8.4.9. Reject packages that use undefined shell variables
                    122:             8.4.10. Turn off verbose logging
1.178     rillig    123: 
                    124:         8.5. Creating a multiple CD-ROM packages collection
                    125: 
                    126:             8.5.1. Example of cdpack
1.6       rillig    127: 
1.154     rillig    128:     9. Directory layout of the installed files
1.6       rillig    129: 
1.154     rillig    130:         9.1. File system layout in ${LOCALBASE}
                    131:         9.2. File system layout in ${VARBASE}
1.6       rillig    132: 
1.154     rillig    133:     10. Frequently Asked Questions
1.6       rillig    134: 
1.154     rillig    135:         10.1. Are there any mailing lists for pkg-related discussion?
                    136:         10.2. Utilities for package management (pkgtools)
                    137:         10.3. How to use pkgsrc as non-root
                    138:         10.4. How to resume transfers when fetching distfiles?
                    139:         10.5. How can I install/use modular X.org from pkgsrc?
                    140:         10.6. How to fetch files from behind a firewall
                    141:         10.7. How to fetch files from HTTPS sites
                    142:         10.8. How do I tell make fetch to do passive FTP?
                    143:         10.9. How to fetch all distfiles at once
                    144:         10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc"
1.24      wiz       145:             mean?
1.154     rillig    146:         10.11. What does "Could not find bsd.own.mk" mean?
                    147:         10.12. Using 'sudo' with pkgsrc
                    148:         10.13. How do I change the location of configuration files?
                    149:         10.14. Automated security checks
                    150:         10.15. Why do some packages ignore my CFLAGS?
                    151:         10.16. A package does not build. What shall I do?
                    152:         10.17. What does "Makefile appears to contain unresolved cvs/rcs/???
1.24      wiz       153:             merge conflicts" mean?
1.1       dsieger   154: 
                    155: II. The pkgsrc developer's guide
                    156: 
1.154     rillig    157:     11. Getting help
1.184     rillig    158:     12. Package components - files, directories and contents
1.1       dsieger   159: 
1.184     rillig    160:         12.1. Makefile
                    161:         12.2. distinfo
                    162:         12.3. patches/*
1.1       dsieger   163: 
1.184     rillig    164:             12.3.1. Structure of a single patch file
                    165:             12.3.2. Creating patch files
                    166:             12.3.3. Sources where the patch files come from
                    167:             12.3.4. Patching guidelines
                    168:             12.3.5. Feedback to the author
1.1       dsieger   169: 
1.184     rillig    170:         12.4. Other mandatory files
                    171:         12.5. Optional files
1.1       dsieger   172: 
1.184     rillig    173:             12.5.1. Files affecting the binary package
                    174:             12.5.2. Files affecting the build process
                    175:             12.5.3. Files affecting nothing at all
1.1       dsieger   176: 
1.184     rillig    177:         12.6. work*
                    178:         12.7. files/*
1.1       dsieger   179: 
1.184     rillig    180:     13. The build process
1.1       dsieger   181: 
1.184     rillig    182:         13.1. Introduction
                    183:         13.2. Program location
                    184:         13.3. Directories used during the build process
                    185:         13.4. Running a phase
                    186:         13.5. The fetch phase
1.1       dsieger   187: 
1.184     rillig    188:             13.5.1. What to fetch and where to get it from
                    189:             13.5.2. How are the files fetched?
1.1       dsieger   190: 
1.184     rillig    191:         13.6. The checksum phase
                    192:         13.7. The extract phase
                    193:         13.8. The patch phase
                    194:         13.9. The tools phase
                    195:         13.10. The wrapper phase
                    196:         13.11. The configure phase
                    197:         13.12. The build phase
                    198:         13.13. The test phase
                    199:         13.14. The install phase
                    200:         13.15. The package phase
                    201:         13.16. Cleaning up
                    202:         13.17. Other helpful targets
1.1       dsieger   203: 
1.184     rillig    204:     14. Creating a new pkgsrc package from scratch
1.1       dsieger   205: 
1.184     rillig    206:         14.1. Common types of packages
1.1       dsieger   207: 
1.184     rillig    208:             14.1.1. Perl modules
                    209:             14.1.2. Python modules and programs
                    210:             14.1.3. R packages
                    211:             14.1.4. TeXlive packages
1.1       dsieger   212: 
1.184     rillig    213:         14.2. Examples
1.1       dsieger   214: 
1.184     rillig    215:             14.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger   216: 
1.184     rillig    217:     15. Programming in Makefiles
1.1       dsieger   218: 
1.184     rillig    219:         15.1. Caveats
                    220:         15.2. Makefile variables
1.1       dsieger   221: 
1.184     rillig    222:             15.2.1. Naming conventions
1.1       dsieger   223: 
1.184     rillig    224:         15.3. Code snippets
1.1       dsieger   225: 
1.184     rillig    226:             15.3.1. Adding things to a list
                    227:             15.3.2. Echoing a string exactly as-is
                    228:             15.3.3. Passing CFLAGS to GNU configure scripts
                    229:             15.3.4. Handling possibly empty variables
1.1       dsieger   230: 
1.184     rillig    231:     16. Options handling
1.1       dsieger   232: 
1.184     rillig    233:         16.1. Global default options
                    234:         16.2. Converting packages to use bsd.options.mk
                    235:         16.3. Option Names
                    236:         16.4. Determining the options of dependencies
1.1       dsieger   237: 
1.184     rillig    238:     17. Tools needed for building or running
1.1       dsieger   239: 
1.184     rillig    240:         17.1. Tools for pkgsrc builds
                    241:         17.2. Tools needed by packages
                    242:         17.3. Tools provided by platforms
1.1       dsieger   243: 
1.184     rillig    244:     18. Buildlink methodology
1.1       dsieger   245: 
1.184     rillig    246:         18.1. Converting packages to use buildlink3
                    247:         18.2. Writing buildlink3.mk files
1.1       dsieger   248: 
1.184     rillig    249:             18.2.1. Anatomy of a buildlink3.mk file
                    250:             18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
                    251:                 BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
1.1       dsieger   252: 
1.184     rillig    253:         18.3. Writing builtin.mk files
1.1       dsieger   254: 
1.184     rillig    255:             18.3.1. Anatomy of a builtin.mk file
                    256:             18.3.2. Global preferences for native or pkgsrc software
1.1       dsieger   257: 
1.184     rillig    258:     19. PLIST issues
1.1       dsieger   259: 
1.184     rillig    260:         19.1. RCS ID
                    261:         19.2. Semi-automatic PLIST generation
                    262:         19.3. Tweaking output of make print-PLIST
                    263:         19.4. Variable substitution in PLIST
                    264:         19.5. Man page compression
                    265:         19.6. Changing PLIST source with PLIST_SRC
                    266:         19.7. Platform-specific and differing PLISTs
                    267:         19.8. Build-specific PLISTs
                    268:         19.9. Sharing directories between packages
1.1       dsieger   269: 
1.184     rillig    270:     20. The pkginstall framework
1.1       dsieger   271: 
1.184     rillig    272:         20.1. Files and directories outside the installation prefix
1.1       dsieger   273: 
1.184     rillig    274:             20.1.1. Directory manipulation
                    275:             20.1.2. File manipulation
1.1       dsieger   276: 
1.184     rillig    277:         20.2. Configuration files
1.1       dsieger   278: 
1.184     rillig    279:             20.2.1. How PKG_SYSCONFDIR is set
                    280:             20.2.2. Telling the software where configuration files are
                    281:             20.2.3. Patching installations
                    282:             20.2.4. Disabling handling of configuration files
1.1       dsieger   283: 
1.184     rillig    284:         20.3. System startup scripts
1.1       dsieger   285: 
1.184     rillig    286:             20.3.1. Disabling handling of system startup scripts
1.1       dsieger   287: 
1.184     rillig    288:         20.4. System users and groups
                    289:         20.5. System shells
1.1       dsieger   290: 
1.184     rillig    291:             20.5.1. Disabling shell registration
1.1       dsieger   292: 
1.184     rillig    293:         20.6. Fonts
1.1       dsieger   294: 
1.184     rillig    295:             20.6.1. Disabling automatic update of the fonts databases
1.1       dsieger   296: 
1.154     rillig    297:     21. Making your package work
1.1       dsieger   298: 
1.154     rillig    299:         21.1. General operation
1.1       dsieger   300: 
1.154     rillig    301:             21.1.1. How to pull in user-settable variables from mk.conf
                    302:             21.1.2. User interaction
                    303:             21.1.3. Handling licenses
                    304:             21.1.4. Restricted packages
                    305:             21.1.5. Handling dependencies
                    306:             21.1.6. Handling conflicts with other packages
                    307:             21.1.7. Packages that cannot or should not be built
                    308:             21.1.8. Packages which should not be deleted, once installed
                    309:             21.1.9. Handling packages with security problems
                    310:             21.1.10. How to handle incrementing versions when fixing an
1.1       dsieger   311:                 existing package
1.154     rillig    312:             21.1.11. Substituting variable text in the package files (the SUBST
1.1       dsieger   313:                 framework)
                    314: 
1.154     rillig    315:         21.2. The fetch phase
1.1       dsieger   316: 
1.154     rillig    317:             21.2.1. Packages whose distfiles aren't available for plain
1.1       dsieger   318:                 downloading
1.154     rillig    319:             21.2.2. How to handle modified distfiles with the 'old' name
                    320:             21.2.3. Packages hosted on github.com
1.1       dsieger   321: 
1.154     rillig    322:         21.3. The configure phase
1.1       dsieger   323: 
1.154     rillig    324:             21.3.1. Shared libraries - libtool
                    325:             21.3.2. Using libtool on GNU packages that already support libtool
                    326:             21.3.3. GNU Autoconf/Automake
                    327: 
                    328:         21.4. Programming languages
                    329: 
                    330:             21.4.1. C, C++, and Fortran
                    331:             21.4.2. Java
1.205     wiz       332:             21.4.3. Go
                    333:             21.4.4. Packages containing Perl scripts
                    334:             21.4.5. Packages containing shell scripts
                    335:             21.4.6. Other programming languages
1.154     rillig    336: 
                    337:         21.5. The build phase
                    338: 
                    339:             21.5.1. Compiling C and C++ code conditionally
                    340:             21.5.2. How to handle compiler bugs
1.172     rillig    341:             21.5.3. No such file or directory
                    342:             21.5.4. Undefined reference to "..."
                    343:             21.5.5. Running out of memory
1.154     rillig    344: 
                    345:         21.6. The install phase
                    346: 
                    347:             21.6.1. Creating needed directories
                    348:             21.6.2. Where to install documentation
                    349:             21.6.3. Installing highscore files
                    350:             21.6.4. Adding DESTDIR support to packages
                    351:             21.6.5. Packages with hardcoded paths to other interpreters
1.203     nia       352:             21.6.6. Packages installing Perl modules
1.154     rillig    353:             21.6.7. Packages installing info files
                    354:             21.6.8. Packages installing man pages
1.203     nia       355:             21.6.9. Packages installing X11 fonts
                    356:             21.6.10. Packages installing SGML or XML data
                    357:             21.6.11. Packages installing extensions to the MIME database
                    358:             21.6.12. Packages using intltool
                    359:             21.6.13. Packages installing startup scripts
                    360:             21.6.14. Packages installing TeX modules
                    361:             21.6.15. Packages supporting running binaries in emulation
                    362:             21.6.16. Packages installing hicolor icons
                    363:             21.6.17. Packages installing desktop files
1.154     rillig    364: 
                    365:         21.7. Marking packages as having problems
                    366: 
1.184     rillig    367:     22. GNOME packaging and porting
                    368: 
                    369:         22.1. Meta packages
                    370:         22.2. Packaging a GNOME application
                    371:         22.3. Updating GNOME to a newer version
                    372:         22.4. Patching guidelines
                    373: 
1.154     rillig    374:     23. Submitting and Committing
                    375: 
                    376:         23.1. Submitting binary packages
                    377:         23.2. Submitting source packages (for non-NetBSD-developers)
                    378:         23.3. General notes when adding, updating, or removing packages
                    379:         23.4. Commit Messages
                    380:         23.5. Committing: Adding a package to CVS
                    381:         23.6. Updating a package to a newer version
                    382:         23.7. Renaming a package in pkgsrc
                    383:         23.8. Moving a package in pkgsrc
                    384: 
                    385:     24. Frequently Asked Questions
1.1       dsieger   386: 
                    387: III. The pkgsrc infrastructure internals
                    388: 
1.184     rillig    389:     25. Design of the pkgsrc infrastructure
1.1       dsieger   390: 
1.184     rillig    391:         25.1. The meaning of variable definitions
                    392:         25.2. Avoiding problems before they arise
                    393:         25.3. Variable evaluation
1.1       dsieger   394: 
1.184     rillig    395:             25.3.1. At load time
                    396:             25.3.2. At runtime
1.1       dsieger   397: 
1.184     rillig    398:         25.4. How can variables be specified?
                    399:         25.5. Designing interfaces for Makefile fragments
1.1       dsieger   400: 
1.184     rillig    401:             25.5.1. Procedures with parameters
                    402:             25.5.2. Actions taken on behalf of parameters
1.1       dsieger   403: 
1.184     rillig    404:         25.6. The order in which files are loaded
1.1       dsieger   405: 
1.184     rillig    406:             25.6.1. The order in bsd.prefs.mk
                    407:             25.6.2. The order in bsd.pkg.mk
1.1       dsieger   408: 
1.184     rillig    409:     26. Regression tests
1.1       dsieger   410: 
1.184     rillig    411:         26.1. Running the regression tests
                    412:         26.2. Adding a new regression test
1.1       dsieger   413: 
1.184     rillig    414:             26.2.1. Overridable functions
                    415:             26.2.2. Helper functions
1.1       dsieger   416: 
1.184     rillig    417:     27. Porting pkgsrc
1.1       dsieger   418: 
1.184     rillig    419:         27.1. Porting pkgsrc to a new operating system
1.1       dsieger   420: 
                    421: A. A simple example package: bison
                    422: 
                    423:     A.1. files
                    424: 
                    425:         A.1.1. Makefile
                    426:         A.1.2. DESCR
                    427:         A.1.3. PLIST
                    428:         A.1.4. Checking a package with pkglint
                    429: 
                    430:     A.2. Steps for building, installing, packaging
                    431: 
1.207     leot      432: B. Security hardening
1.1       dsieger   433: 
1.207     leot      434:     B.1. Mechanisms
1.1       dsieger   435: 
1.207     leot      436:         B.1.1. Enabled by default
                    437:         B.1.2. Not enabled by default
1.1       dsieger   438: 
1.207     leot      439:     B.2. Caveats
1.1       dsieger   440: 
1.207     leot      441:         B.2.1. Problems with PKGSRC_MKPIE
                    442:         B.2.2. Problems with PKGSRC_USE_FORTIFY
                    443:         B.2.3. Problems with PKGSRC_USE_RELRO
                    444:         B.2.4. Problems with PKGSRC_USE_SSP
1.1       dsieger   445: 
1.207     leot      446:     B.3. Auditing the system
                    447: 
                    448:         B.3.1. Checking for PIE
                    449:         B.3.2. Checking for partial RELRO
                    450:         B.3.3. Checking for full RELRO
                    451:         B.3.4. Checking for SSP
                    452: 
                    453: C. Build logs
                    454: 
                    455:     C.1. Building figlet
                    456:     C.2. Packaging figlet
                    457: 
                    458: D. Directory layout of the pkgsrc FTP server
                    459: 
                    460:     D.1. distfiles: The distributed source files
                    461:     D.2. misc: Miscellaneous things
                    462:     D.3. packages: Binary packages
                    463:     D.4. reports: Bulk build reports
                    464:     D.5. current, stable, pkgsrc-20xxQy: source packages
                    465: 
                    466: E. Help topics
                    467: F. Editing guidelines for the pkgsrc guide
                    468: 
                    469:     F.1. Make targets
                    470:     F.2. Procedure
1.1       dsieger   471: 
                    472: List of Tables
                    473: 
                    474: 1.1. Platforms supported by pkgsrc
1.184     rillig    475: 12.1. Patching examples
                    476: 22.1. PLIST handling for GNOME packages
1.1       dsieger   477: 
                    478: Chapter 1. What is pkgsrc?
                    479: 
                    480: Table of Contents
                    481: 
                    482: 1.1. Introduction
                    483: 
                    484:     1.1.1. Why pkgsrc?
                    485:     1.1.2. Supported platforms
                    486: 
                    487: 1.2. Overview
                    488: 1.3. Terminology
                    489: 
                    490:     1.3.1. Roles involved in pkgsrc
                    491: 
                    492: 1.4. Typography
                    493: 
                    494: 1.1. Introduction
                    495: 
                    496: There is a lot of software freely available for Unix-based systems, which is
                    497: usually available in form of the source code. Before such software can be used,
                    498: it needs to be configured to the local system, compiled and installed, and this
                    499: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
                    500: some basic commands to handle binary packages, so that not every user has to
                    501: build the packages for himself, which is a time-costly task.
                    502: 
                    503: pkgsrc currently contains several thousand packages, including:
                    504: 
1.104     sevan     505:   * www/apache24 - The Apache web server
1.1       dsieger   506: 
                    507:   * www/firefox - The Firefox web browser
                    508: 
                    509:   * meta-pkgs/gnome - The GNOME Desktop Environment
                    510: 
1.102     ryoon     511:   * meta-pkgs/kde4 - The K Desktop Environment
1.1       dsieger   512: 
1.108     rillig    513: ? just to name a few.
1.1       dsieger   514: 
                    515: pkgsrc has built-in support for handling varying dependencies, such as pthreads
                    516: and X11, and extended features such as IPv6 support on a range of platforms.
                    517: 
                    518: 1.1.1. Why pkgsrc?
                    519: 
                    520: pkgsrc provides the following key features:
                    521: 
                    522:   * Easy building of software from source as well as the creation and
                    523:     installation of binary packages. The source and latest patches are
                    524:     retrieved from a master or mirror download site, checksum verified, then
                    525:     built on your system. Support for binary-only distributions is available
                    526:     for both native platforms and NetBSD emulated platforms.
                    527: 
                    528:   * All packages are installed in a consistent directory tree, including
                    529:     binaries, libraries, man pages and other documentation.
                    530: 
1.104     sevan     531:   * Tracking of package dependencies automatically, including when performing
                    532:     updates, to ensure required packages are installed. The configuration files
                    533:     of various packages are handled automatically during updates, so local
                    534:     changes are preserved.
1.1       dsieger   535: 
                    536:   * Like NetBSD, pkgsrc is designed with portability in mind and consists of
                    537:     highly portable code. This allows the greatest speed of development when
1.26      spz       538:     porting to a new platform. This portability also ensures that pkgsrc is 
1.1       dsieger   539:     consistent across all platforms.
                    540: 
                    541:   * The installation prefix, acceptable software licenses, international
                    542:     encryption requirements and build-time options for a large number of
                    543:     packages are all set in a simple, central configuration file.
                    544: 
                    545:   * The entire source (not including the distribution files) is freely
                    546:     available under a BSD license, so you may extend and adapt pkgsrc to your
                    547:     needs. Support for local packages and patches is available right out of the
                    548:     box, so you can configure it specifically for your environment.
                    549: 
                    550: The following principles are basic to pkgsrc:
                    551: 
1.198     leot      552:   * "It should only work if it's right." -- That means, if a package contains
1.1       dsieger   553:     bugs, it's better to find them and to complain about them rather than to
                    554:     just install the package and hope that it works. There are numerous checks
1.175     gutterid  555:     in pkgsrc that try to find such bugs: static analysis tools (pkgtools/
1.1       dsieger   556:     pkglint), build-time checks (portability of shell scripts), and
                    557:     post-installation checks (installed files, references to shared libraries,
                    558:     script interpreters).
                    559: 
1.198     leot      560:   * "If it works, it should work everywhere" -- Like NetBSD has been ported to
1.1       dsieger   561:     many hardware architectures, pkgsrc has been ported to many operating
                    562:     systems. Care is taken that packages behave the same on all platforms.
                    563: 
                    564: 1.1.2. Supported platforms
                    565: 
                    566: pkgsrc consists of both a source distribution and a binary distribution for
                    567: these operating systems. After retrieving the required source or binaries, you
                    568: can be up and running with pkgsrc in just minutes!
                    569: 
                    570: pkgsrc was derived from FreeBSD's ports system, and initially developed for
                    571: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
                    572: platforms:
                    573: 
                    574: Table 1.1. Platforms supported by pkgsrc
                    575: 
1.92      sevan     576: +-----------------------------------------------------------------------------+
                    577: |               Platform               | Date Support  |        Notes         |
                    578: |                                      |     Added     |                      |
                    579: |--------------------------------------+---------------+----------------------|
                    580: |NetBSD                                |   Aug 1997    |                      |
                    581: |--------------------------------------+---------------+----------------------|
                    582: |Solaris                               |   Mar 1999    |README.Solaris        |
                    583: |--------------------------------------+---------------+----------------------|
                    584: |Linux                                 |   Jun 1999    |README.Linux          |
                    585: |--------------------------------------+---------------+----------------------|
1.191     bacon     586: |Darwin / Mac OS X / OS X / macOS      |   Oct 2001    |README.macOS          |
1.92      sevan     587: |--------------------------------------+---------------+----------------------|
                    588: |FreeBSD                               |   Nov 2002    |README.FreeBSD        |
                    589: |--------------------------------------+---------------+----------------------|
                    590: |OpenBSD                               |   Nov 2002    |README.OpenBSD        |
                    591: |--------------------------------------+---------------+----------------------|
                    592: |IRIX                                  |   Dec 2002    |README.IRIX           |
                    593: |                                      |               |README.IRIX5.3        |
                    594: |--------------------------------------+---------------+----------------------|
                    595: |BSD/OS                                |   Dec 2003    |                      |
                    596: |--------------------------------------+---------------+----------------------|
                    597: |AIX                                   |   Dec 2003    |README.AIX            |
                    598: |--------------------------------------+---------------+----------------------|
                    599: |Interix (Microsoft Windows Services   |   Mar 2004    |README.Interix        |
                    600: |for Unix)                             |               |                      |
                    601: |--------------------------------------+---------------+----------------------|
                    602: |DragonFlyBSD                          |   Oct 2004    |                      |
                    603: |--------------------------------------+---------------+----------------------|
                    604: |OSF/1                                 |   Nov 2004    |README.OSF1           |
                    605: |--------------------------------------+---------------+----------------------|
                    606: |HP-UX                                 |   Apr 2007    |README.HPUX           |
                    607: |--------------------------------------+---------------+----------------------|
                    608: |Haiku                                 |   Sep 2010    |README.Haiku          |
                    609: |--------------------------------------+---------------+----------------------|
                    610: |MirBSD                                |   Jan 2011    |                      |
                    611: |--------------------------------------+---------------+----------------------|
                    612: |Minix3                                |   Nov 2011    |README.Minix3         |
                    613: |--------------------------------------+---------------+----------------------|
                    614: |Cygwin                                |   Mar 2013    |README.Cygwin         |
                    615: |--------------------------------------+---------------+----------------------|
                    616: |GNU/kFreeBSD                          |   Jul 2013    |README.GNUkFreeBSD    |
1.104     sevan     617: |--------------------------------------+---------------+----------------------|
                    618: |Bitrig                                |   Jun 2014    |README.Bitrig         |
1.92      sevan     619: +-----------------------------------------------------------------------------+
1.1       dsieger   620: 
                    621: 
                    622: 1.2. Overview
                    623: 
                    624: This document is divided into three parts. The first, The pkgsrc user's guide,
                    625: describes how one can use one of the packages in the Package Collection, either
                    626: by installing a precompiled binary package, or by building one's own copy using
                    627: the NetBSD package system. The second part, The pkgsrc developer's guide,
                    628: explains how to prepare a package so it can be easily built by other NetBSD
                    629: users without knowing about the package's building details. The third part, The
                    630: pkgsrc infrastructure internals is intended for those who want to understand
                    631: how pkgsrc is implemented.
                    632: 
                    633: This document is available in various formats: HTML, PDF, PS, TXT.
                    634: 
                    635: 1.3. Terminology
                    636: 
                    637: There has been a lot of talk about "ports", "packages", etc. so far. Here is a
                    638: description of all the terminology used within this document.
                    639: 
                    640: Package
                    641: 
                    642:     A set of files and building instructions that describe what's necessary to
                    643:     build a certain piece of software using pkgsrc. Packages are traditionally
1.123     wiz       644:     stored under /usr/pkgsrc, but may be stored in any location, referred to as
                    645:     PKGSRCDIR.
1.1       dsieger   646: 
                    647: The NetBSD package system
                    648: 
                    649:     This is the former name of "pkgsrc". It is part of the NetBSD operating
                    650:     system and can be bootstrapped to run on non-NetBSD operating systems as
                    651:     well. It handles building (compiling), installing, and removing of
                    652:     packages.
                    653: 
                    654: Distfile
                    655: 
                    656:     This term describes the file or files that are provided by the author of
                    657:     the piece of software to distribute his work. All the changes necessary to
                    658:     build on NetBSD are reflected in the corresponding package. Usually the
                    659:     distfile is in the form of a compressed tar-archive, but other types are
                    660:     possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
                    661: 
                    662: Port
                    663: 
                    664:     This is the term used by FreeBSD and OpenBSD people for what we call a
                    665:     package. In NetBSD terminology, "port" refers to a different architecture.
                    666: 
                    667: Precompiled/binary package
                    668: 
                    669:     A set of binaries built with pkgsrc from a distfile and stuffed together in
                    670:     a single .tgz file so it can be installed on machines of the same machine
                    671:     architecture without the need to recompile. Packages are usually generated
                    672:     in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
                    673: 
                    674:     Sometimes, this is referred to by the term "package" too, especially in the
                    675:     context of precompiled packages.
                    676: 
                    677: Program
                    678: 
                    679:     The piece of software to be installed which will be constructed from all
                    680:     the files in the distfile by the actions defined in the corresponding
                    681:     package.
                    682: 
                    683: 1.3.1. Roles involved in pkgsrc
                    684: 
                    685: pkgsrc users
                    686: 
                    687:     The pkgsrc users are people who use the packages provided by pkgsrc.
                    688:     Typically they are system administrators. The people using the software
                    689:     that is inside the packages (maybe called "end users") are not covered by
                    690:     the pkgsrc guide.
                    691: 
                    692:     There are two kinds of pkgsrc users: Some only want to install pre-built
                    693:     binary packages. Others build the pkgsrc packages from source, either for
                    694:     installing them directly or for building binary packages themselves. For
                    695:     pkgsrc users Part I, "The pkgsrc user's guide" should provide all necessary
                    696:     documentation.
                    697: 
                    698: package maintainers
                    699: 
                    700:     A package maintainer creates packages as described in Part II, "The pkgsrc
                    701:     developer's guide".
                    702: 
                    703: infrastructure developers
                    704: 
                    705:     These people are involved in all those files that live in the mk/ directory
                    706:     and below. Only these people should need to read through Part III, "The
                    707:     pkgsrc infrastructure internals", though others might be curious, too.
                    708: 
                    709: 1.4. Typography
                    710: 
                    711: When giving examples for commands, shell prompts are used to show if the
                    712: command should/can be issued as root, or if "normal" user privileges are
1.115     sevan     713: sufficient. We use a # for root's shell prompt, a % for users' shell prompt,
                    714: assuming they use the C-shell or tcsh and a $ for bourne shell and derivatives.
1.1       dsieger   715: 
                    716: Part I. The pkgsrc user's guide
                    717: 
                    718: Table of Contents
                    719: 
1.154     rillig    720: 2. Getting help
                    721: 3. Where to get pkgsrc and how to keep it up-to-date
1.1       dsieger   722: 
1.154     rillig    723:     3.1. Getting pkgsrc for the first time
1.1       dsieger   724: 
1.154     rillig    725:         3.1.1. As tar archive
                    726:         3.1.2. Via anonymous CVS
1.1       dsieger   727: 
1.154     rillig    728:     3.2. Keeping pkgsrc up-to-date
1.1       dsieger   729: 
1.154     rillig    730:         3.2.1. Via tar files
                    731:         3.2.2. Via CVS
1.1       dsieger   732: 
1.154     rillig    733: 4. Using pkgsrc on systems other than NetBSD
1.1       dsieger   734: 
1.154     rillig    735:     4.1. Binary distribution
                    736:     4.2. Bootstrapping pkgsrc
1.1       dsieger   737: 
1.154     rillig    738: 5. Using pkgsrc
1.1       dsieger   739: 
1.154     rillig    740:     5.1. Using binary packages
1.1       dsieger   741: 
1.154     rillig    742:         5.1.1. Finding binary packages
                    743:         5.1.2. Installing binary packages
1.202     nia       744:         5.1.3. Updating packages
                    745:         5.1.4. Deinstalling packages
                    746:         5.1.5. Getting information about installed packages
                    747:         5.1.6. Checking for security vulnerabilities in installed packages
                    748:         5.1.7. Finding if newer versions of your installed packages are in
1.1       dsieger   749:             pkgsrc
1.202     nia       750:         5.1.8. Other administrative functions
1.1       dsieger   751: 
1.154     rillig    752:     5.2. Building packages from source
1.1       dsieger   753: 
1.154     rillig    754:         5.2.1. Requirements
                    755:         5.2.2. Fetching distfiles
                    756:         5.2.3. How to build and install
1.1       dsieger   757: 
1.154     rillig    758: 6. Configuring pkgsrc
1.1       dsieger   759: 
1.154     rillig    760:     6.1. General configuration
                    761:     6.2. Variables affecting the build process
                    762:     6.3. Variables affecting the installation process
                    763:     6.4. Selecting and configuring the compiler
1.1       dsieger   764: 
1.154     rillig    765:         6.4.1. Selecting the compiler
                    766:         6.4.2. Additional flags to the compiler (CFLAGS)
                    767:         6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger   768: 
1.154     rillig    769:     6.5. Developer/advanced settings
                    770:     6.6. Selecting Build Options
1.1       dsieger   771: 
1.154     rillig    772: 7. Creating binary packages
1.1       dsieger   773: 
1.154     rillig    774:     7.1. Building a single binary package
                    775:     7.2. Settings for creation of binary packages
1.1       dsieger   776: 
1.154     rillig    777: 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig    778: 
1.154     rillig    779:     8.1. Preparations
1.180     rillig    780:     8.2. Running a bulk build
1.6       rillig    781: 
1.154     rillig    782:         8.2.1. Configuration
1.6       rillig    783: 
1.154     rillig    784:     8.3. Requirements of a full bulk build
1.178     rillig    785:     8.4. Bulk build variants
                    786: 
1.179     rillig    787:         8.4.1. Detect unknown configure options
                    788:         8.4.2. Detect classes of bugs by forcing compiler warnings
1.181     rillig    789:         8.4.3. Force compiler options only in the build phase
                    790:         8.4.4. Use custom directories
                    791:         8.4.5. Turn warnings into errors
                    792:         8.4.6. Reject packages for which pkglint reports errors
                    793:         8.4.7. Reject packages that contain forbidden strings
                    794:         8.4.8. Reject packages whose self-test fails
                    795:         8.4.9. Reject packages that use undefined shell variables
                    796:         8.4.10. Turn off verbose logging
1.6       rillig    797: 
1.178     rillig    798:     8.5. Creating a multiple CD-ROM packages collection
                    799: 
                    800:         8.5.1. Example of cdpack
1.6       rillig    801: 
1.154     rillig    802: 9. Directory layout of the installed files
1.6       rillig    803: 
1.154     rillig    804:     9.1. File system layout in ${LOCALBASE}
                    805:     9.2. File system layout in ${VARBASE}
1.6       rillig    806: 
1.154     rillig    807: 10. Frequently Asked Questions
1.6       rillig    808: 
1.154     rillig    809:     10.1. Are there any mailing lists for pkg-related discussion?
                    810:     10.2. Utilities for package management (pkgtools)
                    811:     10.3. How to use pkgsrc as non-root
                    812:     10.4. How to resume transfers when fetching distfiles?
                    813:     10.5. How can I install/use modular X.org from pkgsrc?
                    814:     10.6. How to fetch files from behind a firewall
                    815:     10.7. How to fetch files from HTTPS sites
                    816:     10.8. How do I tell make fetch to do passive FTP?
                    817:     10.9. How to fetch all distfiles at once
                    818:     10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
                    819:     10.11. What does "Could not find bsd.own.mk" mean?
                    820:     10.12. Using 'sudo' with pkgsrc
                    821:     10.13. How do I change the location of configuration files?
                    822:     10.14. Automated security checks
                    823:     10.15. Why do some packages ignore my CFLAGS?
                    824:     10.16. A package does not build. What shall I do?
                    825:     10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24      wiz       826:         conflicts" mean?
1.1       dsieger   827: 
1.154     rillig    828: Chapter 2. Getting help
                    829: 
                    830: To get help when using pkgsrc, the definitive source is this document, the
                    831: pkgsrc guide. If you don't find anything here, there are alternatives:
                    832: 
                    833:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
                    834:     Run bmake help topic=? to get help for any topic, such as a variable name
                    835:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                    836:     like strcasecmp or any other topic.
                    837: 
1.207     leot      838:     The available help topics are listed in Appendix E, Help topics.
1.154     rillig    839: 
1.163     rillig    840:   * To see the value of a single variable, run bmake show-var VARNAME=X.
                    841: 
                    842:   * To see the values of the most common variables, run bmake show-all. These
                    843:     variables are grouped by topic. To see the variables for a single topic,
                    844:     run bmake show-all-topic, for example bmake show-all-fetch.
                    845: 
1.154     rillig    846:   * The pkgsrc-users mailing list, to which you can subscribe and then ask your
                    847:     questions.
                    848: 
                    849:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                    850:     a specialized chat program such as XChat. Pick any user name and join the
                    851:     channel #pkgsrc.
                    852: 
                    853: Chapter 3. Where to get pkgsrc and how to keep it up-to-date
1.1       dsieger   854: 
                    855: Table of Contents
                    856: 
1.154     rillig    857: 3.1. Getting pkgsrc for the first time
1.1       dsieger   858: 
1.154     rillig    859:     3.1.1. As tar archive
                    860:     3.1.2. Via anonymous CVS
1.1       dsieger   861: 
1.154     rillig    862: 3.2. Keeping pkgsrc up-to-date
1.1       dsieger   863: 
1.154     rillig    864:     3.2.1. Via tar files
                    865:     3.2.2. Via CVS
1.1       dsieger   866: 
                    867: Before you download and extract the files, you need to decide where you want to
                    868: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
                    869: usr/pkgsrc. You are though free to install the sources and binary packages
                    870: wherever you want in your filesystem, provided that the pathname does not
                    871: contain white-space or other characters that are interpreted specially by the
                    872: shell and some other programs. A safe bet is to use only letters, digits,
                    873: underscores and dashes.
                    874: 
1.154     rillig    875: 3.1. Getting pkgsrc for the first time
1.1       dsieger   876: 
1.25      wiz       877: Before you download any pkgsrc files, you should decide whether you want the 
1.1       dsieger   878: current branch or the stable branch. The latter is forked on a quarterly basis
                    879: from the current branch and only gets modified for security updates. The names
                    880: of the stable branches are built from the year and the quarter, for example
1.207     leot      881: 2021Q3.
1.1       dsieger   882: 
                    883: The second step is to decide how you want to download pkgsrc. You can get it as
1.24      wiz       884: a tar file or via CVS. Both ways are described here.
1.1       dsieger   885: 
1.52      asau      886: Note that tar archive contains CVS working copy. Thus you can switch to using
                    887: CVS at any later time.
1.1       dsieger   888: 
1.154     rillig    889: 3.1.1. As tar archive
1.52      asau      890: 
1.151     sevan     891: The primary download location for all pkgsrc files is https://cdn.NetBSD.org/
                    892: pub/pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same
                    893: location). There are a number of subdirectories for different purposes, which
1.207     leot      894: are described in detail in Appendix D, Directory layout of the pkgsrc FTP
1.151     sevan     895: server.
1.1       dsieger   896: 
1.52      asau      897: The tar archive for the current branch is in the directory current and is
1.118     sevan     898: called pkgsrc.tar.gz. It is autogenerated weekly.
1.52      asau      899: 
                    900: To save download time we provide bzip2- and xz-compressed archives which are
                    901: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
                    902: 
                    903: You can fetch the same files using FTP.
1.1       dsieger   904: 
1.207     leot      905: The tar file for the stable branch 2021Q3 is in the directory pkgsrc-2021Q3 and
1.59      jnemeth   906: is also called pkgsrc.tar.gz.
1.1       dsieger   907: 
1.136     leot      908: To download the latest pkgsrc stable tarball, run:
1.12      weinem    909: 
1.207     leot      910: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2021Q3/pkgsrc.tar.gz
1.12      weinem    911: 
1.78      snj       912: If you prefer, you can also fetch it using "wget", "curl", or your web browser.
1.52      asau      913: 
1.12      weinem    914: Then, extract it with:
                    915: 
1.78      snj       916: $ tar -xzf pkgsrc.tar.gz -C /usr
1.12      weinem    917: 
                    918: This will create the directory pkgsrc/ in /usr/ and all the package source will
                    919: be stored under /usr/pkgsrc/.
                    920: 
                    921: To download pkgsrc-current, run:
                    922: 
                    923: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1       dsieger   924: 
1.154     rillig    925: 3.1.2. Via anonymous CVS
1.1       dsieger   926: 
1.24      wiz       927: To fetch a specific pkgsrc stable branch, run:
1.1       dsieger   928: 
1.207     leot      929: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2021Q3 -P pkgsrc
1.13      weinem    930: 
1.24      wiz       931: This will create the directory pkgsrc/ in your /usr/ directory and all the
                    932: package source will be stored under /usr/pkgsrc/.
                    933: 
                    934: To fetch the pkgsrc current branch, run:
1.1       dsieger   935: 
1.40      wiz       936: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   937: 
1.30      dholland  938: Refer to the list of available mirrors to choose a faster CVS mirror, if
                    939: needed.
1.1       dsieger   940: 
1.24      wiz       941: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1       dsieger   942: 
1.40      wiz       943: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   944: 
1.24      wiz       945: Refer to documentation on your command shell how to set CVS_RSH=ssh
                    946: permanently. For Bourne shells, you can set it in your .profile or better
                    947: globally in /etc/profile:
                    948: 
                    949: # set CVS remote shell command
                    950: CVS_RSH=ssh
                    951: export CVS_RSH
1.12      weinem    952: 
1.13      weinem    953: By default, CVS doesn't do things like most people would expect it to do. But
                    954: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12      weinem    955: directory and saving the following lines to it. This file will save you lots of
                    956: headache and some bug reports, so we strongly recommend it. You can find an
                    957: explanation of this file in the CVS documentation.
1.2       rillig    958: 
                    959: # recommended CVS configuration file from the pkgsrc guide
1.155     sevan     960: cvs -q
1.2       rillig    961: checkout -P
1.4       rillig    962: update -dP
                    963: diff -upN
1.2       rillig    964: rdiff -u
1.24      wiz       965: release -d
1.1       dsieger   966: 
1.154     rillig    967: 3.2. Keeping pkgsrc up-to-date
1.1       dsieger   968: 
                    969: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
                    970: have first installed it via a tar file). It saves bandwidth and hard disk
                    971: activity, compared to downloading the tar file again.
                    972: 
1.154     rillig    973: 3.2.1. Via tar files
1.1       dsieger   974: 
                    975: Warning
                    976: 
                    977: When updating from a tar file, you first need to completely remove the old
                    978: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
                    979: the mean time will not be removed on your local disk, resulting in
                    980: inconsistencies. When removing the old files, any changes that you have done to
                    981: the pkgsrc files will be lost after updating. Therefore updating via CVS is
                    982: strongly recommended.
                    983: 
                    984: Note that by default the distfiles and the binary packages are saved in the
                    985: pkgsrc tree, so don't forget to rescue them before updating. You can also
1.78      snj       986: configure pkgsrc to store distfiles and packages in directories outside the
1.154     rillig    987: pkgsrc tree by setting the DISTDIR and PACKAGES variables. See Chapter 6, 
1.78      snj       988: Configuring pkgsrc for the details.
1.1       dsieger   989: 
                    990: To update pkgsrc from a tar file, download the tar file as explained above.
                    991: Then, make sure that you have not made any changes to the files in the pkgsrc
                    992: directory. Remove the pkgsrc directory and extract the new tar file. Done.
                    993: 
1.154     rillig    994: 3.2.2. Via CVS
1.1       dsieger   995: 
1.26      spz       996: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12      weinem    997: 
1.26      spz       998: $ cd /usr/pkgsrc && cvs update -dP
                    999: 
                   1000: If you get error messages from rsh, you need to set CVS_RSH variable as
                   1001: described above. E.g.:
                   1002: 
                   1003: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1       dsieger  1004: 
1.154     rillig   1005: 3.2.2.1. Switching between different pkgsrc branches
1.1       dsieger  1006: 
                   1007: When updating pkgsrc, the CVS program keeps track of the branch you selected.
                   1008: But if you, for whatever reason, want to switch from the stable branch to the
                   1009: current one, you can do it by adding the option "-A" after the "update"
1.25      wiz      1010: keyword. To switch from the current branch back to the stable branch, add the "
1.207     leot     1011: -rpkgsrc-2021Q3" option.
1.1       dsieger  1012: 
1.154     rillig   1013: 3.2.2.2. What happens to my changes when updating?
1.1       dsieger  1014: 
                   1015: When you update pkgsrc, the CVS program will only touch those files that are
                   1016: registered in the CVS repository. That means that any packages that you created
                   1017: on your own will stay unmodified. If you change files that are managed by CVS,
                   1018: later updates will try to merge your changes with those that have been done by
                   1019: others. See the CVS manual, chapter "update" for details.
                   1020: 
1.154     rillig   1021: Chapter 4. Using pkgsrc on systems other than NetBSD
1.1       dsieger  1022: 
                   1023: Table of Contents
                   1024: 
1.154     rillig   1025: 4.1. Binary distribution
                   1026: 4.2. Bootstrapping pkgsrc
1.1       dsieger  1027: 
1.154     rillig   1028: 4.1. Binary distribution
1.1       dsieger  1029: 
1.154     rillig   1030: See Section 5.1, "Using binary packages".
1.1       dsieger  1031: 
1.154     rillig   1032: 4.2. Bootstrapping pkgsrc
1.1       dsieger  1033: 
1.44      asau     1034: pkgsrc can be bootstrapped for use in two different modes: privileged and
                   1035: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45      asau     1036: programs are installed under one particular user and cannot utilise privileged
1.44      asau     1037: operations (packages don't create special users and all special file
                   1038: permissions like setuid are ignored).
                   1039: 
1.1       dsieger  1040: Installing the bootstrap kit from source should be as simple as:
                   1041: 
1.60      asau     1042: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger  1043: # cd pkgsrc/bootstrap
                   1044: # ./bootstrap
                   1045: 
                   1046: 
1.44      asau     1047: To bootstrap in unprivileged mode pass "--unprivileged" flag to bootstrap
                   1048: 
                   1049: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
1.118     sevan    1050: will be installed in, and /usr/pkg/pkgdb for the package database directory
                   1051: where pkgsrc will do its internal bookkeeping, /var is used as varbase, where
1.44      asau     1052: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
1.118     sevan    1053: for prefix, ~/pkg/pkgdb for the package database, and ~/pkg/var for varbase.
1.44      asau     1054: 
                   1055: You can change default layout using command-line arguments. Run "./bootstrap
                   1056: --help" to get details.
1.1       dsieger  1057: 
                   1058: Note
                   1059: 
                   1060: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
                   1061: For examples in this guide, use bmake instead of "make".
                   1062: 
1.44      asau     1063: Note
                   1064: 
                   1065: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
                   1066: directories. Use bmake corresponding to the installation you're working with to
                   1067: build and install packages.
                   1068: 
1.154     rillig   1069: Chapter 5. Using pkgsrc
1.1       dsieger  1070: 
                   1071: Table of Contents
                   1072: 
1.154     rillig   1073: 5.1. Using binary packages
1.1       dsieger  1074: 
1.154     rillig   1075:     5.1.1. Finding binary packages
                   1076:     5.1.2. Installing binary packages
1.202     nia      1077:     5.1.3. Updating packages
                   1078:     5.1.4. Deinstalling packages
                   1079:     5.1.5. Getting information about installed packages
                   1080:     5.1.6. Checking for security vulnerabilities in installed packages
                   1081:     5.1.7. Finding if newer versions of your installed packages are in pkgsrc
                   1082:     5.1.8. Other administrative functions
1.154     rillig   1083: 
                   1084: 5.2. Building packages from source
                   1085: 
                   1086:     5.2.1. Requirements
                   1087:     5.2.2. Fetching distfiles
                   1088:     5.2.3. How to build and install
1.1       dsieger  1089: 
                   1090: Basically, there are two ways of using pkgsrc. The first is to only install the
                   1091: package tools and to use binary packages that someone else has prepared. This
                   1092: is the "pkg" in pkgsrc. The second way is to install the "src" of pkgsrc, too.
                   1093: Then you are able to build your own packages, and you can still use binary
                   1094: packages from someone else.
                   1095: 
1.154     rillig   1096: 5.1. Using binary packages
1.1       dsieger  1097: 
1.151     sevan    1098: On the cdn.NetBSD.org site and mirrors, there are collections of binary
1.9       rillig   1099: packages, ready to be installed. These binary packages have been built using
                   1100: the default settings for the directories, that is:
                   1101: 
                   1102:   * /usr/pkg for LOCALBASE, where most of the files are installed,
                   1103: 
                   1104:   * /usr/pkg/etc for configuration files,
                   1105: 
                   1106:   * /var for VARBASE, where those files are installed that may change after
                   1107:     installation.
                   1108: 
                   1109: If you cannot use these directories for whatever reasons (maybe because you're
                   1110: not root), you cannot use these binary packages, but have to build the packages
1.154     rillig   1111: yourself, which is explained in Section 4.2, "Bootstrapping pkgsrc".
1.1       dsieger  1112: 
1.154     rillig   1113: 5.1.1. Finding binary packages
1.1       dsieger  1114: 
1.5       weinem   1115: To install binary packages, you first need to know from where to get them. The
1.202     nia      1116: first place where you should look is on the main pkgsrc CDN in the directory /
                   1117: pub/pkgsrc/packages.
1.5       weinem   1118: 
                   1119: This directory contains binary packages for multiple platforms. First, select
                   1120: your operating system. (Ignore the directories with version numbers attached to
                   1121: it, they just exist for legacy reasons.) Then, select your hardware
                   1122: architecture, and in the third step, the OS version and the "version" of
1.9       rillig   1123: pkgsrc.
                   1124: 
                   1125: In this directory, you often find a file called bootstrap.tar.gz which contains
                   1126: the package management tools. If the file is missing, it is likely that your
                   1127: operating system already provides those tools. Download the file and extract it
                   1128: in the / directory. It will create the directories /usr/pkg (containing the
1.118     sevan    1129: tools for managing binary packages and the database of installed packages).
1.1       dsieger  1130: 
1.154     rillig   1131: 5.1.2. Installing binary packages
1.1       dsieger  1132: 
1.85      wiz      1133: In the directory from the last section, there is a subdirectory called All/,
1.9       rillig   1134: which contains all the binary packages that are available for the platform,
1.202     nia      1135: excluding those that may not be distributed via HTTP or FTP.
1.9       rillig   1136: 
                   1137: To install packages directly from an FTP or HTTP server, run the following
                   1138: commands in a Bourne-compatible shell (be sure to su to root first):
                   1139: 
1.202     nia      1140: # PATH="/usr/pkg/sbin:/usr/pkg/bin:$PATH"
                   1141: # PKG_PATH="https://cdn.NetBSD.org/pub/pkgsrc/packages"
1.169     rillig   1142: # PKG_PATH="$PKG_PATH/OPSYS/ARCH/VERSIONS/All/"
1.9       rillig   1143: # export PATH PKG_PATH
1.202     nia      1144: # pkg_add pkgin
1.9       rillig   1145: 
                   1146: Instead of URLs, you can also use local paths, for example if you are
                   1147: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
                   1148: to install packages from multiple sources, you can separate them by a semicolon
                   1149: in PKG_PATH.
                   1150: 
                   1151: After these preparations, installing a package is very easy:
                   1152: 
1.202     nia      1153: # pkgin search nginx
                   1154: nginx-1.19.6         Lightweight HTTP server and mail proxy server
                   1155: nginx-1.18.0nb8      Lightweight HTTP server and mail proxy server
                   1156: # pkgin install zsh nginx-1.19.6 vim
1.1       dsieger  1157: 
1.202     nia      1158: Note that pkgin is a user-friendly frontend to the pkg_* tools.
1.1       dsieger  1159: 
1.202     nia      1160: Any prerequisite packages needed to run the package in question will be
                   1161: installed, too, assuming they are present in the repository.
1.1       dsieger  1162: 
                   1163: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
                   1164: in your PATH so you can actually start the just installed program.
                   1165: 
1.202     nia      1166: 5.1.3. Updating packages
1.1       dsieger  1167: 
1.202     nia      1168: To update binary packages, it is recommended that you use pkgin upgrade. This
                   1169: will compare the remote package repository to your locally installed packages
                   1170: and safely replace any older packages.
1.1       dsieger  1171: 
1.202     nia      1172: Note that pkgsrc is released as quarterly branches. If you are updating to a
                   1173: newer quarterly branch of pkgsrc, you may need to adjust the repository in /usr
                   1174: /pkg/etc/pkgin/repositories.conf.
1.1       dsieger  1175: 
1.202     nia      1176: 5.1.4. Deinstalling packages
1.1       dsieger  1177: 
1.202     nia      1178: To deinstall a package, it does not matter whether it was installed from source
                   1179: code or from a binary package. Neither the pkgin or the pkg_delete command need
                   1180: to know.
1.1       dsieger  1181: 
1.202     nia      1182: To delete a package, you can just run pkgin remove package-name. The package
                   1183: name can be given with or without version number.
1.1       dsieger  1184: 
1.202     nia      1185: 5.1.5. Getting information about installed packages
1.1       dsieger  1186: 
                   1187: The pkg_info shows information about installed packages or binary package
1.202     nia      1188: files. As with other management tools, it works with packages installed from
                   1189: source or binaries.
1.1       dsieger  1190: 
1.202     nia      1191: 5.1.6. Checking for security vulnerabilities in installed packages
1.1       dsieger  1192: 
1.202     nia      1193: The pkgsrc Security Team and Packages Groups maintain a list of known
1.164     leot     1194: vulnerabilities to packages which are (or have been) included in pkgsrc. The
1.202     nia      1195: list is available from the NetBSD CDN at https://cdn.NetBSD.org/pub/NetBSD/
1.179     rillig   1196: packages/vulns/pkg-vulnerabilities.
1.1       dsieger  1197: 
1.202     nia      1198: Please note that not every "vulnerability" with a CVE assignment is exploitable
                   1199: in every configuration. Some bugs are marked as active simply because an fix
                   1200: was not marked as such. Operating system specific hardening and mitigation
                   1201: features may also reduce the impact of bugs.
                   1202: 
1.23      jakllsch 1203: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
                   1204: automatically, and a security audit of all packages installed on a system can
                   1205: take place.
                   1206: 
                   1207: There are two components to auditing. The first step, pkg_admin
                   1208: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
                   1209: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
                   1210: your installed packages are vulnerable. If a package is vulnerable, you will
                   1211: see output similar to the following:
1.1       dsieger  1212: 
                   1213: Package samba-2.0.9 has a local-root-shell vulnerability, see
1.174     leot     1214:     https://www.samba.org/samba/whatsnew/macroexploit.html
1.1       dsieger  1215: 
1.23      jakllsch 1216: You may wish to have the vulnerabilities file downloaded daily so that it
                   1217: remains current. This may be done by adding an appropriate entry to the root
                   1218: users crontab(5) entry. For example the entry
                   1219: 
1.121     sevan    1220: # Download vulnerabilities file
1.118     sevan    1221: 0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1.121     sevan    1222: # Audit the installed packages and email results to root
                   1223: 9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
                   1224:             root >/dev/null 2>&1
1.118     sevan    1225: 
                   1226: 
                   1227: will update the vulnerability list every day at 3AM, followed by an audit at
                   1228: 3:09AM. The result of the audit are then emailed to root. On NetBSD this may be
                   1229: accomplished instead by adding the following line to /etc/daily.conf:
                   1230: 
                   1231: fetch_pkg_vulnerabilities=YES
                   1232: 
1.23      jakllsch 1233: 
1.118     sevan    1234: to fetch the vulnerability list from the daily security script. The system is
                   1235: set to audit the packages by default but can be set explicitly, if desired (not
1.123     wiz      1236: required), by adding the following line to /etc/security.conf:
1.23      jakllsch 1237: 
1.118     sevan    1238: check_pkg_vulnerabilities=YES
1.23      jakllsch 1239: 
                   1240: 
1.118     sevan    1241: see daily.conf(5) and security.conf(5) for more details.
1.1       dsieger  1242: 
1.202     nia      1243: 5.1.7. Finding if newer versions of your installed packages are in pkgsrc
1.1       dsieger  1244: 
1.12      weinem   1245: Install pkgtools/lintpkgsrc and run lintpkgsrc with the "-i" argument to check
1.202     nia      1246: if any packages are stale, e.g.
1.1       dsieger  1247: 
                   1248: % lintpkgsrc -i
                   1249: ...
                   1250: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
                   1251: 
                   1252: 
1.202     nia      1253: 5.1.8. Other administrative functions
1.1       dsieger  1254: 
                   1255: The pkg_admin executes various administrative functions on the package system.
                   1256: 
1.154     rillig   1257: 5.2. Building packages from source
1.1       dsieger  1258: 
                   1259: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25      wiz      1260: organized into categories. You can browse the online index of packages, or run 
1.1       dsieger  1261: make readme from the pkgsrc directory to build local README.html files for all
                   1262: packages, viewable with any web browser such as www/lynx or www/firefox.
                   1263: 
                   1264: The default prefix for installed packages is /usr/pkg. If you wish to change
                   1265: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
                   1266: use multiple different LOCALBASE definitions on the same system (inside a
                   1267: chroot is an exception).
                   1268: 
                   1269: The rest of this chapter assumes that the package is already in pkgsrc. If it
                   1270: is not, see Part II, "The pkgsrc developer's guide" for instructions how to
                   1271: create your own packages.
                   1272: 
1.154     rillig   1273: 5.2.1. Requirements
1.1       dsieger  1274: 
                   1275: To build packages from source, you need a working C compiler. On NetBSD, you
                   1276: need to install the "comp" and the "text" distribution sets. If you want to
                   1277: build X11-related packages, the "xbase" and "xcomp" distribution sets are
                   1278: required, too.
                   1279: 
1.154     rillig   1280: 5.2.2. Fetching distfiles
1.1       dsieger  1281: 
                   1282: The first step for building a package is downloading the distfiles (i.e. the
                   1283: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
                   1284: them automatically.
                   1285: 
                   1286: If you have all files that you need in the distfiles directory, you don't need
                   1287: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
                   1288: and add:
                   1289: 
                   1290: DISTDIR=/cdrom/pkgsrc/distfiles
                   1291: 
                   1292: to your mk.conf.
                   1293: 
                   1294: By default a list of distribution sites will be randomly intermixed to prevent
                   1295: huge load on servers which holding popular packages (for example,
                   1296: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
                   1297: distfile all the mirrors will be tried in new (random) order. You can turn this
                   1298: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
                   1299: disabled).
                   1300: 
                   1301: You can overwrite some of the major distribution sites to fit to sites that are
                   1302: close to your own. By setting one or two variables you can modify the order in
                   1303: which the master sites are accessed. MASTER_SORT contains a whitespace
                   1304: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
                   1305: contains a whitespace delimited list of regular expressions. It has higher
                   1306: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
                   1307: some examples. This may save some of your bandwidth and time.
                   1308: 
                   1309: You can change these settings either in your shell's environment, or, if you
1.4       rillig   1310: want to keep the settings, by editing the mk.conf file, and adding the
1.1       dsieger  1311: definitions there.
                   1312: 
1.132     wiz      1313: If a package depends on many other packages (such as meta-pkgs/kde4), the build
1.1       dsieger  1314: process may alternate between periods of downloading source, and compiling. To
                   1315: ensure you have all the source downloaded initially you can run the command:
                   1316: 
                   1317: % make fetch-list | sh
                   1318: 
                   1319: which will output and run a set of shell commands to fetch the necessary files
                   1320: into the distfiles directory. You can also choose to download the files
                   1321: manually.
                   1322: 
1.154     rillig   1323: 5.2.3. How to build and install
1.1       dsieger  1324: 
                   1325: Once the software has downloaded, any patches will be applied, then it will be
                   1326: compiled for you. This may take some time depending on your computer, and how
                   1327: many other packages the software depends on and their compile time.
                   1328: 
                   1329: Note
                   1330: 
                   1331: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
                   1332: command instead of "make" in the examples in this guide.
                   1333: 
                   1334: For example, type
                   1335: 
                   1336: % cd misc/figlet
                   1337: % make
                   1338: 
                   1339: 
                   1340: at the shell prompt to build the various components of the package.
                   1341: 
                   1342: The next stage is to actually install the newly compiled program onto your
                   1343: system. Do this by entering:
                   1344: 
                   1345: % make install
                   1346: 
                   1347: 
                   1348: while you are still in the directory for whatever package you are installing.
                   1349: 
                   1350: Installing the package on your system may require you to be root. However,
                   1351: pkgsrc has a just-in-time-su feature, which allows you to only become root for
                   1352: the actual installation step.
                   1353: 
                   1354: That's it, the software should now be installed and setup for use. You can now
                   1355: enter:
                   1356: 
                   1357: % make clean
                   1358: 
                   1359: 
                   1360: to remove the compiled files in the work directory, as you shouldn't need them
                   1361: any more. If other packages were also added to your system (dependencies) to
                   1362: allow your program to compile, you can tidy these up also with the command:
                   1363: 
                   1364: % make clean-depends
                   1365: 
                   1366: 
                   1367: Taking the figlet utility as an example, we can install it on our system by
1.207     leot     1368: building as shown in Appendix C, Build logs.
1.1       dsieger  1369: 
                   1370: The program is installed under the default root of the packages tree - /usr/
                   1371: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
                   1372: environment, and it will use that value as the root of your packages tree. So,
                   1373: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
                   1374: that you should use a directory which is dedicated to packages and not shared
                   1375: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
                   1376: not try to add any of your own files or directories (such as src/, obj/, or
                   1377: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
                   1378: between programs and other files installed by the package system and whatever
                   1379: else may have been installed there.
                   1380: 
1.4       rillig   1381: Some packages look in mk.conf to alter some configuration options at build
1.1       dsieger  1382: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
                   1383: be set there by default. Environment variables such as LOCALBASE can be set in
1.4       rillig   1384: mk.conf to save having to remember to set them each time you want to use
1.1       dsieger  1385: pkgsrc.
                   1386: 
                   1387: Occasionally, people want to "look under the covers" to see what is going on
                   1388: when a package is building or being installed. This may be for debugging
                   1389: purposes, or out of simple curiosity. A number of utility values have been
                   1390: added to help with this.
                   1391: 
                   1392:  1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
                   1393:     amount of information will be displayed. For example,
                   1394: 
                   1395:     make patch PKG_DEBUG_LEVEL=2
                   1396: 
1.25      wiz      1397:     will show all the commands that are invoked, up to and including the "patch
                   1398:     " stage.
1.1       dsieger  1399: 
                   1400:  2. If you want to know the value of a certain make(1) definition, then the
                   1401:     VARNAME definition should be used, in conjunction with the show-var target.
                   1402:     e.g. to show the expansion of the make(1) variable LOCALBASE:
                   1403: 
                   1404:     % make show-var VARNAME=LOCALBASE
                   1405:     /usr/pkg
                   1406:     %
                   1407: 
                   1408: 
                   1409: If you want to install a binary package that you've either created yourself
                   1410: (see next section), that you put into pkgsrc/packages manually or that is
                   1411: located on a remote FTP server, you can use the "bin-install" target. This
                   1412: target will install a binary package - if available - via pkg_add(1), else do a
                   1413: make package. The list of remote FTP sites searched is kept in the variable
                   1414: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
                   1415: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
                   1416: for more details.
                   1417: 
                   1418: A final word of warning: If you set up a system that has a non-standard setting
                   1419: for LOCALBASE, be sure to set that before any packages are installed, as you
                   1420: cannot use several directories for the same purpose. Doing so will result in
                   1421: pkgsrc not being able to properly detect your installed packages, and fail
                   1422: miserably. Note also that precompiled binary packages are usually built with
                   1423: the default LOCALBASE of /usr/pkg, and that you should not install any if you
                   1424: use a non-standard LOCALBASE.
                   1425: 
1.154     rillig   1426: Chapter 6. Configuring pkgsrc
1.1       dsieger  1427: 
                   1428: Table of Contents
                   1429: 
1.154     rillig   1430: 6.1. General configuration
                   1431: 6.2. Variables affecting the build process
                   1432: 6.3. Variables affecting the installation process
                   1433: 6.4. Selecting and configuring the compiler
                   1434: 
                   1435:     6.4.1. Selecting the compiler
                   1436:     6.4.2. Additional flags to the compiler (CFLAGS)
                   1437:     6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger  1438: 
1.154     rillig   1439: 6.5. Developer/advanced settings
                   1440: 6.6. Selecting Build Options
1.1       dsieger  1441: 
                   1442: The whole pkgsrc system is configured in a single file, usually called mk.conf.
                   1443: In which directory pkgsrc looks for that file depends on the installation. On
                   1444: NetBSD, when you use make(1) from the base system, it is in the directory /etc
                   1445: /. In all other cases the default location is ${PREFIX}/etc/, depending on
                   1446: where you told the bootstrap program to install the binary packages.
                   1447: 
                   1448: The format of the configuration file is that of the usual BSD-style Makefiles.
                   1449: The whole pkgsrc configuration is done by setting variables in this file. Note
                   1450: that you can define all kinds of variables, and no special error checking (for
1.112     rillig   1451: example for spelling mistakes) takes place.
1.1       dsieger  1452: 
1.154     rillig   1453: 6.1. General configuration
1.1       dsieger  1454: 
1.112     rillig   1455: The following variables apply to all pkgsrc packages. A complete list of the
                   1456: variables that can be configured by the user is available in mk/defaults/
                   1457: mk.conf, together with some comments that describe each variable's intent.
1.1       dsieger  1458: 
                   1459:   * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
                   1460:     not mix binary packages with different LOCALBASEs!
                   1461: 
                   1462:   * CROSSBASE: Where "cross" category packages will be installed. The default
                   1463:     is ${LOCALBASE}/cross.
                   1464: 
1.84      wiz      1465:   * X11BASE: Where X11 is installed on the system. The default is /usr/X11R7.
1.1       dsieger  1466: 
                   1467:   * DISTDIR: Where to store the downloaded copies of the original source
                   1468:     distributions used for building pkgsrc packages. The default is $
                   1469:     {PKGSRCDIR}/distfiles.
                   1470: 
                   1471:   * PKG_DBDIR: Where the database about installed packages is stored. The
1.118     sevan    1472:     default is /usr/pkg/pkgdb.
1.1       dsieger  1473: 
                   1474:   * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
                   1475:     value.
                   1476: 
                   1477:   * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
                   1478:     files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.118     sevan    1479:     respectively. The defaults is ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1.1       dsieger  1480:     {DIST_SUBDIR}/.
                   1481: 
                   1482:   * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
                   1483:     with OS release ("2.0", etc.) and architecture ("mipsel", etc.).
                   1484: 
1.23      jakllsch 1485:   * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
                   1486:     case-sensitive. Whenever you try to build a package whose license is not in
                   1487:     this list, you will get an error message. If the license condition is
                   1488:     simple enough, the error message will include specific instructions on how
                   1489:     to change this variable.
1.1       dsieger  1490: 
1.154     rillig   1491: 6.2. Variables affecting the build process
1.1       dsieger  1492: 
                   1493:   * PACKAGES: The top level directory for the binary packages. The default is $
                   1494:     {PKGSRCDIR}/packages.
                   1495: 
                   1496:   * WRKOBJDIR: The top level directory where, if defined, the separate working
                   1497:     directories will get created, and symbolically linked to from ${WRKDIR}
                   1498:     (see below). This is useful for building packages on several architectures,
                   1499:     then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
                   1500:     architecture. (It should be noted that PKGSRCDIR should not be set by the
1.198     leot     1501:     user -- it is an internal definition which refers to the root of the pkgsrc
1.1       dsieger  1502:     tree. It is possible to have many pkgsrc tree instances.)
                   1503: 
                   1504:   * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.184     rillig   1505:     Section 12.3, "patches/*" for more information.
1.1       dsieger  1506: 
                   1507:   * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
                   1508:     Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
                   1509:     up settings used by builds in /usr/src.
                   1510: 
1.154     rillig   1511: 6.3. Variables affecting the installation process
1.1       dsieger  1512: 
1.198     leot     1513:   * PKGSRC_KEEP_BIN_PKGS: By default, binary packages of built packages are
1.150     leot     1514:     preserved in ${PACKAGES}/All. Setting this variable to "no" prevents this.
1.1       dsieger  1515: 
1.107     jnemeth  1516: Packages have to support installation into a subdirectory of WRKDIR. This
                   1517: allows a package to be built, before the actual filesystem is touched. DESTDIR
                   1518: support exists in two variations:
1.4       rillig   1519: 
                   1520:   * Basic DESTDIR support means that the package installation and packaging is
                   1521:     still run as root.
                   1522: 
                   1523:   * Full DESTDIR support can run the complete build, installation and packaging
                   1524:     as normal user. Root privileges are only needed to add packages.
                   1525: 
                   1526: With basic DESTDIR support, make clean needs to be run as root.
                   1527: 
1.17      imil     1528: Considering the foo/bar package, DESTDIR full support can be tested using the
                   1529: following commands
                   1530: 
                   1531: $ id
                   1532: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
                   1533: $ mkdir $HOME/packages
                   1534: $ cd $PKGSRCDIR/foo/bar
                   1535: 
                   1536: Verify DESTDIR full support, no root privileges should be needed
                   1537: 
1.66      asau     1538: $ make stage-install
1.17      imil     1539: 
                   1540: Create a package without root privileges
                   1541: 
1.66      asau     1542: $ make PACKAGES=$HOME/packages package
1.17      imil     1543: 
                   1544: For the following command, you must be able to gain root privileges using su(1)
                   1545: 
1.66      asau     1546: $ make PACKAGES=$HOME/packages install
1.17      imil     1547: 
                   1548: Then, as a simple user
                   1549: 
                   1550: $ make clean
                   1551: 
1.154     rillig   1552: 6.4. Selecting and configuring the compiler
1.4       rillig   1553: 
1.154     rillig   1554: 6.4.1. Selecting the compiler
1.1       dsieger  1555: 
                   1556: By default, pkgsrc will use GCC to build packages. This may be overridden by
                   1557: setting the following variables in /etc/mk.conf:
                   1558: 
                   1559: PKGSRC_COMPILER:
                   1560: 
                   1561:     This is a list of values specifying the chain of compilers to invoke when
                   1562:     building packages. Valid values are:
                   1563: 
1.66      asau     1564:       + ccc: Compaq C Compilers (Tru64)
                   1565: 
                   1566:       + ccache: compiler cache (chainable)
                   1567: 
                   1568:       + clang: Clang C and Objective-C compiler
                   1569: 
1.42      asau     1570:       + distcc: distributed C/C++ (chainable)
1.1       dsieger  1571: 
1.66      asau     1572:       + f2c: Fortran 77 to C compiler (chainable)
                   1573: 
                   1574:       + icc: Intel C++ Compiler (Linux)
                   1575: 
                   1576:       + ido: SGI IRIS Development Option cc (IRIX 5)
1.1       dsieger  1577: 
1.42      asau     1578:       + gcc: GNU C/C++ Compiler
1.1       dsieger  1579: 
1.66      asau     1580:       + hp: HP-UX C/aC++ compilers
                   1581: 
1.42      asau     1582:       + mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1       dsieger  1583: 
1.66      asau     1584:       + mipspro-ucode: Silicon Graphics, Inc. MIPSpro (o32)
1.1       dsieger  1585: 
1.42      asau     1586:       + sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1       dsieger  1587: 
1.118     sevan    1588:       + xlc: IBM's XL C/C++ compiler suite
1.66      asau     1589: 
1.1       dsieger  1590:     The default is "gcc". You can use ccache and/or distcc with an appropriate
                   1591:     PKGSRC_COMPILER setting, e.g. "ccache gcc". This variable should always be
                   1592:     terminated with a value for a real compiler. Note that only one real
                   1593:     compiler should be listed (e.g. "sunpro gcc" is not allowed).
                   1594: 
                   1595: GCC_REQD:
                   1596: 
                   1597:     This specifies the minimum version of GCC to use when building packages. If
                   1598:     the system GCC doesn't satisfy this requirement, then pkgsrc will build and
                   1599:     install one of the GCC packages to use instead.
                   1600: 
1.153     leot     1601: PYTHON_VERSION_DEFAULT:
1.114     maya     1602: 
                   1603:     Specifies which version of python to use when several options are
                   1604:     available.
                   1605: 
                   1606: PKGSRC_FORTRAN:
                   1607: 
1.176     gutterid 1608:     Specifies the Fortran compiler to use. The default is gfortran.
1.114     maya     1609: 
                   1610: GFORTRAN_VERSION:
                   1611: 
                   1612:     If PKGSRC_FORTRAN= gfortran is used, this option specifies which version to
                   1613:     use.
                   1614: 
1.154     rillig   1615: 6.4.2. Additional flags to the compiler (CFLAGS)
1.1       dsieger  1616: 
                   1617: If you wish to set the CFLAGS variable, please make sure to use the += operator
                   1618: instead of the = operator:
                   1619: 
                   1620: CFLAGS+=        -your -flags
                   1621: 
                   1622: Using CFLAGS= (i.e. without the "+") may lead to problems with packages that
1.16      jnemeth  1623: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24      wiz      1624: package if you're interested in optimization specifically for the current CPU.
1.1       dsieger  1625: 
1.154     rillig   1626: 6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger  1627: 
                   1628: If you want to pass flags to the linker, both in the configure step and the
                   1629: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
                   1630: difference between the two is that LIBS will be appended to the command line,
                   1631: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
                   1632: machines depending on the setting of USE_IMAKE or the inclusion of mk/
                   1633: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
                   1634: settings, use the += operator:
                   1635: 
                   1636: LDFLAGS+=        -your -linkerflags
                   1637: 
1.154     rillig   1638: 6.5. Developer/advanced settings
1.1       dsieger  1639: 
                   1640:   * PKG_DEVELOPER: Run some sanity checks that package developers want:
                   1641: 
1.42      asau     1642:       + make sure patches apply with zero fuzz
1.1       dsieger  1643: 
1.42      asau     1644:       + run check-shlibs to see that all binaries will find their shared libs.
1.1       dsieger  1645: 
                   1646:   * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
                   1647:     making and installing the package. The default value for this is 0, which
                   1648:     will not display the commands as they are executed (normal, default, quiet
                   1649:     operation); the value 1 will display all shell commands before their
                   1650:     invocation, and the value 2 will display both the shell commands before
1.112     rillig   1651:     their invocation, as well as their actual execution progress with set -x.
1.1       dsieger  1652: 
1.154     rillig   1653: 6.6. Selecting Build Options
1.1       dsieger  1654: 
                   1655: Some packages have build time options, usually to select between different
                   1656: dependencies, enable optional support for big dependencies or enable
                   1657: experimental features.
                   1658: 
                   1659: To see which options, if any, a package supports, and which options are
                   1660: mutually exclusive, run make show-options, for example:
                   1661: 
                   1662:     The following options are supported by this package:
                   1663:         ssl      Enable SSL support.
                   1664:     Exactly one of the following gecko options is required:
                   1665:         firefox  Use firefox as gecko rendering engine.
                   1666:         mozilla  Use mozilla as gecko rendering engine.
                   1667:     At most one of the following database options may be selected:
                   1668:         mysql    Enable support for MySQL database.
                   1669:         pgsql    Enable support for PostgreSQL database.
                   1670: 
                   1671:     These options are enabled by default: firefox
                   1672:     These options are currently enabled: mozilla ssl
                   1673: 
1.4       rillig   1674: The following variables can be defined in mk.conf to select which options to
                   1675: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1       dsieger  1676: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
                   1677: which can be used to select or disable options specifically for package pkgbase
                   1678: . Options listed in these variables are selected, options preceded by "-" are
                   1679: disabled. A few examples:
                   1680: 
1.4       rillig   1681: $ grep "PKG.*OPTION" mk.conf
1.1       dsieger  1682: PKG_DEFAULT_OPTIONS=    -arts -dvdread -esound
                   1683: PKG_OPTIONS.kdebase=    debug -sasl
                   1684: PKG_OPTIONS.apache=     suexec
                   1685: 
1.11      rillig   1686: It is important to note that options that were specifically suggested by the
1.19      snj      1687: package maintainer must be explicitly removed if you do not wish to include the
                   1688: option. If you are unsure you can view the current state with make show-options
                   1689: .
1.11      rillig   1690: 
1.1       dsieger  1691: The following settings are consulted in the order given, and the last setting
                   1692: that selects or disables an option is used:
                   1693: 
                   1694:  1. the default options as suggested by the package maintainer
                   1695: 
                   1696:  2. the options implied by the settings of legacy variables (see below)
                   1697: 
                   1698:  3. PKG_DEFAULT_OPTIONS
                   1699: 
                   1700:  4. PKG_OPTIONS.pkgbase
                   1701: 
                   1702: For groups of mutually exclusive options, the last option selected is used, all
                   1703: others are automatically disabled. If an option of the group is explicitly
                   1704: disabled, the previously selected option, if any, is used. It is an error if no
                   1705: option from a required group of options is selected, and building the package
                   1706: will fail.
                   1707: 
                   1708: Before the options framework was introduced, build options were selected by
1.4       rillig   1709: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
                   1710: transition to the options framework for the user, these legacy variables are
                   1711: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
                   1712: automatically. A warning is issued to prompt the user to update mk.conf to use
                   1713: the options framework directly. Support for the legacy variables will be
1.1       dsieger  1714: removed eventually.
                   1715: 
1.154     rillig   1716: Chapter 7. Creating binary packages
1.1       dsieger  1717: 
                   1718: Table of Contents
                   1719: 
1.154     rillig   1720: 7.1. Building a single binary package
                   1721: 7.2. Settings for creation of binary packages
1.1       dsieger  1722: 
1.154     rillig   1723: 7.1. Building a single binary package
1.1       dsieger  1724: 
                   1725: Once you have built and installed a package, you can create a binary package
                   1726: which can be installed on another system with pkg_add(1). This saves having to
                   1727: build the same package on a group of hosts and wasting CPU time. It also
                   1728: provides a simple means for others to install your package, should you
                   1729: distribute it.
                   1730: 
                   1731: To create a binary package, change into the appropriate directory in pkgsrc,
                   1732: and run make package:
                   1733: 
1.112     rillig   1734: $ cd misc/figlet
                   1735: $ make package
1.1       dsieger  1736: 
                   1737: This will build and install your package (if not already done), and then build
                   1738: a binary package from what was installed. You can then use the pkg_* tools to
                   1739: manipulate it. Binary packages are created by default in /usr/pkgsrc/packages,
1.207     leot     1740: in the form of a gzipped tar file. See Section C.2, "Packaging figlet" for a
1.1       dsieger  1741: continuation of the above misc/figlet example.
                   1742: 
1.154     rillig   1743: See Chapter 23, Submitting and Committing for information on how to submit such
1.1       dsieger  1744: a binary package.
                   1745: 
1.154     rillig   1746: 7.2. Settings for creation of binary packages
1.1       dsieger  1747: 
1.184     rillig   1748: See Section 13.17, "Other helpful targets".
1.6       rillig   1749: 
1.154     rillig   1750: Chapter 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig   1751: 
                   1752: Table of Contents
                   1753: 
1.154     rillig   1754: 8.1. Preparations
1.180     rillig   1755: 8.2. Running a bulk build
1.6       rillig   1756: 
1.154     rillig   1757:     8.2.1. Configuration
1.6       rillig   1758: 
1.154     rillig   1759: 8.3. Requirements of a full bulk build
1.178     rillig   1760: 8.4. Bulk build variants
                   1761: 
1.179     rillig   1762:     8.4.1. Detect unknown configure options
                   1763:     8.4.2. Detect classes of bugs by forcing compiler warnings
1.181     rillig   1764:     8.4.3. Force compiler options only in the build phase
                   1765:     8.4.4. Use custom directories
                   1766:     8.4.5. Turn warnings into errors
                   1767:     8.4.6. Reject packages for which pkglint reports errors
                   1768:     8.4.7. Reject packages that contain forbidden strings
                   1769:     8.4.8. Reject packages whose self-test fails
                   1770:     8.4.9. Reject packages that use undefined shell variables
                   1771:     8.4.10. Turn off verbose logging
1.6       rillig   1772: 
1.178     rillig   1773: 8.5. Creating a multiple CD-ROM packages collection
                   1774: 
                   1775:     8.5.1. Example of cdpack
1.6       rillig   1776: 
1.175     gutterid 1777: For a number of reasons, you may want to build binary packages for a large
                   1778: selected set of packages in pkgsrc, or even for all pkgsrc packages. For
1.71      wiz      1779: instance, when you have multiple machines that should run the same software, it
                   1780: is wasted time if they all build their packages themselves from source. Or you
                   1781: may want to build a list of packages you want and check them before deploying
1.175     gutterid 1782: onto production systems. There is a way of getting a set of binary packages:
                   1783: the bulk build system, or pbulk ("p" stands for "parallel"). This chapter
                   1784: describes how to set it up.
1.71      wiz      1785: 
1.154     rillig   1786: 8.1. Preparations
1.71      wiz      1787: 
                   1788: First of all, you have to decide whether you build all packages or a limited
                   1789: set of them. Full bulk builds usually consume a lot more resources, both space
1.175     gutterid 1790: and time, than builds for some practical sets of packages. A number of
                   1791: particularly heavy packages exist that are not actually interesting to a wide
                   1792: audience. (The approximate resource consumption for a full bulk build is given
                   1793: in section Section 8.3, "Requirements of a full bulk build".) For limited bulk
                   1794: builds you need to make a list of packages you want to build. Note that all
                   1795: their dependencies will be built, so you don't need to track them manually.
1.71      wiz      1796: 
                   1797: During bulk builds various packages are installed and deinstalled in /usr/pkg
                   1798: (or whatever LOCALBASE is), so make sure that you don't need any package during
1.112     rillig   1799: the builds. Essentially, you should provide a fresh system, either a chroot
1.71      wiz      1800: environment or something even more restrictive, depending on what the operating
                   1801: system provides, or dedicate the whole physical machine. As a useful side
                   1802: effect this makes sure that bulk builds cannot break anything in your system.
                   1803: There have been numerous cases where certain packages tried to install files
                   1804: outside the LOCALBASE or wanted to edit some files in /etc.
1.6       rillig   1805: 
1.180     rillig   1806: 8.2. Running a bulk build
1.6       rillig   1807: 
1.180     rillig   1808: Running a bulk build works roughly as follows:
1.15      rillig   1809: 
                   1810:   * First, build the pbulk infrastructure in a fresh pkgsrc location.
                   1811: 
                   1812:   * Then, build each of the packages from a clean installation directory using
                   1813:     the infrastructure.
                   1814: 
1.154     rillig   1815: 8.2.1. Configuration
1.6       rillig   1816: 
1.112     rillig   1817: To simplify configuration, we provide the helper script mk/pbulk/pbulk.sh.
1.6       rillig   1818: 
1.68      asau     1819: In order to use it, prepare a clear system (real one, chroot environment, jail,
                   1820: zone, virtual machine). Configure network access to fetch distribution files.
1.112     rillig   1821: Create a user with name "pbulk".
1.68      asau     1822: 
                   1823: Fetch and extract pkgsrc. Use a command like one of these:
                   1824: 
1.151     sevan    1825: # (cd /usr && ftp -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
                   1826: # (cd /usr && fetch -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1.72      wiz      1827: # (cd /usr && cvs -Q -z3 -d anoncvs@anoncvs.NetBSD.org:/cvsroot get -P pkgsrc)
1.68      asau     1828: 
                   1829: Or any other way that fits (e.g., curl, wget).
                   1830: 
                   1831: Deploy and configure pbulk tools, e.g.:
                   1832: 
1.118     sevan    1833: # sh pbulk.sh -n # use native make, no bootstrap kit needed (for use on NetBSD)
1.68      asau     1834: # sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment
                   1835: # sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build
                   1836: 
                   1837: Note
                   1838: 
                   1839: mk.conf.frag is a fragment of mk.conf that contains settings you want to apply
                   1840: to packages you build. For instance,
                   1841: 
1.112     rillig   1842: PKG_DEVELOPER=          yes     # perform more checks
                   1843: X11_TYPE=               modular # use pkgsrc X11
                   1844: SKIP_LICENSE_CHECK=     yes     # accept all licences (useful
                   1845:                                 # when building all packages)
1.68      asau     1846: 
                   1847: If configured for limited list, replace the list in /usr/pbulk/etc/pbulk.list
1.112     rillig   1848: with your list of packages, one per line without empty lines or comments. E.g.:
1.68      asau     1849: 
                   1850: www/firefox
                   1851: mail/thunderbird
                   1852: misc/libreoffice4
                   1853: 
1.69      asau     1854: At this point you can also review configuration in /usr/pbulk/etc and make
                   1855: final amendments, if wanted.
                   1856: 
1.68      asau     1857: Start it:
                   1858: 
                   1859: # /usr/pbulk/bin/bulkbuild
                   1860: 
                   1861: After it finishes, you'll have /mnt filled with distribution files, binary
                   1862: packages, and reports, plain text summary in /mnt/bulklog/meta/report.txt
                   1863: 
                   1864: Note
                   1865: 
                   1866: The pbulk.sh script does not cover all possible use cases. While being ready to
                   1867: run, it serves as a good starting point to understand and build more complex
                   1868: setups. The script is kept small enough for better understanding.
                   1869: 
                   1870: Note
                   1871: 
                   1872: The pbulk.sh script supports running unprivileged bulk build and helps
1.205     wiz      1873: configuring distributed bulk builds. Distributed bulk builds support either
                   1874: building in worker chroots (each node is a path to a different chroot) that
                   1875: replicate the target system, including the pbulk prefix, or remote machines
                   1876: (each node is an IP address that must be accessible over SSH without a
                   1877: password).
1.15      rillig   1878: 
1.154     rillig   1879: 8.3. Requirements of a full bulk build
1.71      wiz      1880: 
                   1881: A complete bulk build requires lots of disk space. Some of the disk space can
                   1882: be read-only, some other must be writable. Some can be on remote filesystems
                   1883: (such as NFS) and some should be local. Some can be temporary filesystems,
                   1884: others must survive a sudden reboot.
                   1885: 
1.205     wiz      1886:   * 70 GB for the distfiles (read-write, remote, temporary)
1.71      wiz      1887: 
1.205     wiz      1888:   * 60 GB for the binary packages (read-write, remote, permanent)
1.71      wiz      1889: 
                   1890:   * 1 GB for the pkgsrc tree (read-only, remote, permanent)
                   1891: 
                   1892:   * 5 GB for LOCALBASE (read-write, local, temporary)
                   1893: 
                   1894:   * 10 GB for the log files (read-write, remote, permanent)
                   1895: 
                   1896:   * 5 GB for temporary files (read-write, local, temporary)
                   1897: 
1.178     rillig   1898: 8.4. Bulk build variants
                   1899: 
                   1900: To ensure that pkgsrc packages work in different configurations, it makes sense
                   1901: to run non-default bulk builds from time to time. This section lists some ideas
                   1902: for bulk builds that intentionally let packages fail if they don't follow the
                   1903: pkgsrc style.
                   1904: 
1.179     rillig   1905: 8.4.1. Detect unknown configure options
1.178     rillig   1906: 
                   1907: Add the following line to mk.conf.
                   1908: 
                   1909: GNU_CONFIGURE_STRICT=   yes
                   1910: 
                   1911: When a package fails this additional check, the most common cause is that the
                   1912: configure option was valid for an older version of the package but does not
                   1913: apply anymore. In that case, just remove it.
                   1914: 
1.179     rillig   1915: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.178     rillig   1916: 
                   1917: The job of a compiler is not restricted to producing executable code, most
1.179     rillig   1918: compilers also detect typical programming mistakes. The pkgsrc compiler
                   1919: wrappers make it easy to force compiler options when the package is built. This
                   1920: can be used to find typical bugs across all packages that are in pkgsrc. By
                   1921: reporting these bugs upstream, the packages will be more reliable with the next
                   1922: updates.
1.178     rillig   1923: 
1.179     rillig   1924: Add some of the following lines to mk.conf:
1.178     rillig   1925: 
                   1926: CFLAGS+=        -Werror=char-subscripts
1.179     rillig   1927: CFLAGS+=        -Werror=implicit-function-declaration
1.178     rillig   1928: 
1.179     rillig   1929: When a package fails to build using these stricter compiler options, document
                   1930: the circumstances in which the compiler produced the error message. This
                   1931: includes:
1.178     rillig   1932: 
                   1933:   * The platform (MACHINE_PLATFORM)
                   1934: 
                   1935:   * The source file
                   1936: 
                   1937:   * An excerpt of the code. GCC and Clang already do this as part of the
                   1938:     diagnostic.
                   1939: 
1.179     rillig   1940:   * The exact error message from the compiler.
1.178     rillig   1941: 
1.179     rillig   1942: If a package produces these error messages, but the package is fine, record
                   1943: this in your local mk.conf, like this, to skip this check in the next builds:
1.178     rillig   1944: 
1.179     rillig   1945: .if ${PKGPATH} == category/package
1.178     rillig   1946: # Version ${VERSION} failed on ${MACHINE_PLATFORM}:
                   1947: # error message
                   1948: # code
1.179     rillig   1949: # Reason why the code does not need to be fixed.
1.178     rillig   1950: BUILDLINK_TRANSFORM+=   rm:-Werror=char-subscripts
1.179     rillig   1951: .endif
1.178     rillig   1952: 
                   1953: If the error messages from the compiler are valid and the code needs to be
1.179     rillig   1954: fixed, prepare a local patch (see LOCALPATCHES) and report the bug to the
                   1955: upstream authors of the package, providing them with the information you
                   1956: collected above.
1.178     rillig   1957: 
1.179     rillig   1958: Patches that are not essential for the package to work should only be reported
                   1959: upstream but not committed to pkgsrc, to make future updates easier.
                   1960: 
1.181     rillig   1961: 8.4.3. Force compiler options only in the build phase
                   1962: 
                   1963: When adding custom compiler flags via CFLAGS, these apply to all phases of the
                   1964: package build process. Especially in the configure phase, adding -Werror leads
                   1965: to wrong decisions. The GNU configure scripts feed many small test programs to
                   1966: the C compiler to see whether certain headers are available, functions are
                   1967: defined in a library and programs can be run. In many cases these programs
                   1968: would not survive a strict compiler run with -Wall -Wextra -Werror.
                   1969: 
                   1970: The pkgsrc infrastructure is flexible enough to support compiler options being
                   1971: added between the configure and build phases. It's a little more complicated
                   1972: than the other examples in this section but still easy enough.
                   1973: 
                   1974: The basic idea is to use the pkgsrc compiler wrapper to inject the desired
                   1975: compiler options. The compiler wrapper's original task is to hide unwanted
                   1976: directories of include files and to normalize compiler options. It does this by
                   1977: wrapping the compiler command and rewriting the command line. To see this in
                   1978: action, run bmake patch in a package directory and examine the work/.cwrappers/
                   1979: config directory. It contains individual configurations for the C compiler and
                   1980: the related tools. The plan is to find a hook between the configure and build
                   1981: phases, and to modify these configuration files at that point.
                   1982: 
                   1983: To find this hook, have a look at mk/build/build.mk, which contains among
                   1984: others the pre-build-checks-hook. The word checks doesn't quite fit, but the
                   1985: pre-build-hook sounds good enough.
                   1986: 
                   1987: The code to be included in mk.conf is:
                   1988: 
                   1989: # Just a few example options.
                   1990: BUILD_ONLY_CFLAGS=      -Wall -Werror -O2 -DTEMPDIR='"/tmp"'
                   1991: 
                   1992: .if ${BUILD_ONLY_CFLAGS:U:M*}
                   1993: pre-build-checks-hook: add-build-only-cflags
                   1994: 
                   1995: add-build-only-cflags: .PHONY
                   1996:         ${RUN} cd ${CWRAPPERS_CONFIG_DIR};      \
                   1997:         ${TEST} ! -f ${.TARGET} || exit 0;      \
                   1998:         for flag in ${BUILD_ONLY_CFLAGS}; do    \
                   1999:                 ${ECHO} "append=$$flag" >> cc;  \
                   2000:         done;                                   \
                   2001:         > ${.TARGET}
                   2002: .endif
                   2003: 
                   2004: (When editing the mk.conf, make sure that the commands of the
                   2005: add-build-only-cflags target are indented with a tab, not with spaces.)
                   2006: 
                   2007: The condition in the .if statement contains the :U modifier to prevent parse
                   2008: errors if the variable should be undefined, possibly because it is only defined
                   2009: for a subset of the packages. The :M* modifier ensures that there is at least
                   2010: one compiler option, to prevent a syntax error in the shell parser.
                   2011: 
                   2012: The code around the ${.TARGET} variable ensures that the additional compiler
                   2013: options are only appended once, even if bmake build is run multiple times. To
                   2014: do this, it creates a marker file.
                   2015: 
                   2016: To verify that this setup works, run bmake configure in a package directory. Up
                   2017: to now, everything works as usual. Examine the directory work/.cwrappers/config
                   2018: to see that the compiler options from BUILD_ONLY_CFLAGS are not yet added to
                   2019: the file cc. Examine the tail of the work/.work.log file to see that the normal
                   2020: compiler options are used.
                   2021: 
                   2022: Now run bmake build. This will append the options to the file cc and will
                   2023: create the marker file in the same directory. After that, the build starts as
                   2024: usual, but with the added compiler options. Examine the tail of the file work
                   2025: /.work.log to see that the lines starting with [*] don't contain the compiler
                   2026: options, but the corresponding lines starting with <.> do end with these
                   2027: options.
                   2028: 
                   2029: Building packages using this setup variant and fixing the resulting bugs is the
                   2030: same as in Section 8.4.2, "Detect classes of bugs by forcing compiler warnings"
                   2031: .
                   2032: 
                   2033: 8.4.4. Use custom directories
1.178     rillig   2034: 
                   2035: Some directories like PREFIX, VARBASE, PKG_SYSCONFDIR, PKGMANDIR, PKG_INFODIR
                   2036: can be configured in pkgsrc. Set these to arbitrary paths during bootstrap or
                   2037: afterwards in mk.conf.
                   2038: 
                   2039: PREFIX=         /a-random-uuid
                   2040: PKG_SYSCONFDIR= /a-random-uuid
                   2041: VARBASE=        /a-random-uuid
                   2042: PKGMANDIR=      a-random-uuid
                   2043: PKG_INFODIR=    a-random-uuid
                   2044: 
1.181     rillig   2045: 8.4.5. Turn warnings into errors
1.178     rillig   2046: 
                   2047: When building a package, warnings are typically ignored since they just flow by
                   2048: and do not cause the build to fail immediately. To find these warnings,
                   2049: redefine them to errors in mk.conf.
                   2050: 
                   2051: DELAYED_WARNING_MSG=    ${DELAYED_ERROR_MSG} "(was warning)"
                   2052: WARNING_MSG=            ${FAIL_MSG} "(was warning)"
                   2053: 
                   2054: (There are many more classes of warnings in pkgsrc, and most of them can be
                   2055: redefined with a simple definition like above.
                   2056: 
1.179     rillig   2057: If a package suggests to add USE_TOOLS+=perl to the package Makefile, research
1.178     rillig   2058: whether the package actually needs Perl. If it does, add USE_TOOLS+=perl to the
                   2059: package Makefile, and if it doesn't, add TOOLS_BROKEN+=perl.
                   2060: 
1.181     rillig   2061: 8.4.6. Reject packages for which pkglint reports errors
1.178     rillig   2062: 
                   2063: Using pkglint as part of the regular build process is mostly a waste of time.
                   2064: If you want to fix some of the warnings, just run pkglint recursively on the
                   2065: whole pkgsrc tree. This will take a few minutes (up to 10), which is much
                   2066: faster than a complete bulk build.
                   2067: 
1.181     rillig   2068: 8.4.7. Reject packages that contain forbidden strings
1.178     rillig   2069: 
                   2070: To ensure that the binary packages don't contain references to the build
                   2071: directory, there is already CHECK_WRKREF. If that variable includes the item
                   2072: extra, it is possible to define additional patterns that must not appear in any
                   2073: installed file. This is specified in mk.conf.
                   2074: 
                   2075: CHECK_WRKREF=                   extra
                   2076: CHECK_WRKREF_EXTRA_DIRS+=       /usr/local
                   2077: CHECK_WRKREF_EXTRA_DIRS+=       /usr/pkg
                   2078: CHECK_WRKREF_EXTRA_DIRS+=       @[A-Z][A-Z]*@
                   2079: 
                   2080: The above patterns will probably generate many false positives, therefore the
                   2081: results need to be taken with a grain of salt.
                   2082: 
1.181     rillig   2083: 8.4.8. Reject packages whose self-test fails
1.178     rillig   2084: 
                   2085: To run the test suites that come with each package, add this line to mk.conf.
                   2086: 
                   2087: PKGSRC_RUN_TEST=        yes
                   2088: 
                   2089: Be prepared that even the most basic packages fail this test. When doing a bulk
                   2090: build with this, it will often abort in the early phase where the packages are
                   2091: scanned for their dependencies since there are cyclic dependencies. There is
                   2092: still a lot to do in this area.
                   2093: 
1.181     rillig   2094: 8.4.9. Reject packages that use undefined shell variables
1.178     rillig   2095: 
                   2096: To catch typos in the shell snippets from the Makefile fragments, add the -u
                   2097: flag to most of the commands by adding this line to mk.conf.
                   2098: 
                   2099: RUN=    @set -eu;
                   2100: 
1.181     rillig   2101: After that, ensure that none of the bulk build log files (even those for
                   2102: successfully built packages) contains the string parameter not set or whatever
                   2103: error message the command sh -ceu '$undefined' outputs.
                   2104: 
1.178     rillig   2105: See mk/misc/common.mk for the existing definition.
                   2106: 
1.181     rillig   2107: 8.4.10. Turn off verbose logging
1.178     rillig   2108: 
                   2109: The build logs of a package are often quite long. This allows error messages or
                   2110: other interesting details to hide between the noise. To make the actual error
                   2111: message stand out more, add these lines to mk.conf.
                   2112: 
                   2113: GNU_CONFIGURE_QUIET=    yes
                   2114: MAKE_FLAGS+=            -s
                   2115: 
                   2116: The -s option works for both GNU Make and BSD Make. On exotic platforms with
                   2117: their own make, it may be a little different.
                   2118: 
                   2119: 8.5. Creating a multiple CD-ROM packages collection
1.1       dsieger  2120: 
                   2121: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
                   2122: of the resulting binary packages to assist in installing packages on other
                   2123: machines. The pkgtools/cdpack package provides a simple tool for creating the
                   2124: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
                   2125: keeps all the dependencies for a given package on the same CD as that package.
                   2126: 
1.178     rillig   2127: 8.5.1. Example of cdpack
1.1       dsieger  2128: 
                   2129: Complete documentation for cdpack is found in the cdpack(1) man page. The
                   2130: following short example assumes that the binary packages are left in /usr/
                   2131: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
                   2132: ISO 9660 images.
                   2133: 
                   2134: # mkdir /u2/images
                   2135: # pkg_add /usr/pkgsrc/packages/All/cdpack
                   2136: # cdpack /usr/pkgsrc/packages/All /u2/images
                   2137: 
                   2138: 
                   2139: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
                   2140: CD in the collection, then you need to create a directory which contains these
1.175     gutterid 2141: files, e.g.:
1.1       dsieger  2142: 
                   2143: # mkdir /tmp/common
                   2144: # echo "This is a README" > /tmp/common/README
                   2145: # echo "Another file" > /tmp/common/COPYING
                   2146: # mkdir /tmp/common/bin
                   2147: # echo "#!/bin/sh" > /tmp/common/bin/myscript
                   2148: # echo "echo Hello world" >> /tmp/common/bin/myscript
                   2149: # chmod 755 /tmp/common/bin/myscript
                   2150: 
                   2151: 
                   2152: Now create the images:
                   2153: 
                   2154: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
                   2155: 
                   2156: Each image will contain README, COPYING, and bin/myscript in their root
                   2157: directories.
                   2158: 
1.154     rillig   2159: Chapter 9. Directory layout of the installed files
1.1       dsieger  2160: 
                   2161: Table of Contents
                   2162: 
1.154     rillig   2163: 9.1. File system layout in ${LOCALBASE}
                   2164: 9.2. File system layout in ${VARBASE}
1.1       dsieger  2165: 
                   2166: The files that are installed by pkgsrc are organized in a way that is similar
                   2167: to what you find in the /usr directory of the base system. But some details are
                   2168: different. This is because pkgsrc initially came from FreeBSD and had adopted
                   2169: its file system hierarchy. Later it was largely influenced by NetBSD. But no
                   2170: matter which operating system you are using pkgsrc with, you can expect the
                   2171: same layout for pkgsrc.
                   2172: 
                   2173: There are mainly four root directories for pkgsrc, which are all configurable
                   2174: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
                   2175: default locations are:
                   2176: 
                   2177: LOCALBASE=              /usr/pkg
                   2178: PKG_SYSCONFBASE=        /usr/pkg/etc
                   2179: VARBASE=                /var
1.119     sevan    2180: PKG_DBDIR=              /usr/pkg/pkgdb
1.1       dsieger  2181: 
                   2182: In unprivileged mode (when pkgsrc has been installed as any other user), the
                   2183: default locations are:
                   2184: 
                   2185: LOCALBASE=              ${HOME}/pkg
                   2186: PKG_SYSCONFBASE=        ${HOME}/pkg/etc
                   2187: VARBASE=                ${HOME}/pkg/var
1.119     sevan    2188: PKG_DBDIR=              ${HOME}/pkg/pkgdb
1.1       dsieger  2189: 
                   2190: What these four directories are for, and what they look like is explained
                   2191: below.
                   2192: 
1.25      wiz      2193:   * LOCALBASE corresponds to the /usr directory in the base system. It is the "
                   2194:     main" directory where the files are installed and contains the well-known
1.1       dsieger  2195:     subdirectories like bin, include, lib, share and sbin.
                   2196: 
                   2197:   * VARBASE corresponds to /var in the base system. Some programs (especially
                   2198:     games, network daemons) need write access to it during normal operation.
                   2199: 
                   2200:   * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
                   2201:     configuration files of the packages, as well as pkgsrc's mk.conf itself.
                   2202: 
1.154     rillig   2203: 9.1. File system layout in ${LOCALBASE}
1.1       dsieger  2204: 
                   2205: The following directories exist in a typical pkgsrc installation in $
                   2206: {LOCALBASE}.
                   2207: 
                   2208: bin
                   2209: 
                   2210:     Contains executable programs that are intended to be directly used by the
                   2211:     end user.
                   2212: 
                   2213: emul
                   2214: 
                   2215:     Contains files for the emulation layers of various other operating systems,
                   2216:     especially for NetBSD.
                   2217: 
                   2218: etc (the usual location of ${PKG_SYSCONFDIR})
                   2219: 
                   2220:     Contains the configuration files.
                   2221: 
                   2222: include
                   2223: 
                   2224:     Contains headers for the C and C++ programming languages.
                   2225: 
                   2226: info
                   2227: 
                   2228:     Contains GNU info files of various packages.
                   2229: 
                   2230: lib
                   2231: 
                   2232:     Contains shared and static libraries.
                   2233: 
                   2234: libdata
                   2235: 
                   2236:     Contains data files that don't change after installation. Other data files
                   2237:     belong into ${VARBASE}.
                   2238: 
                   2239: libexec
                   2240: 
                   2241:     Contains programs that are not intended to be used by end users, such as
                   2242:     helper programs or network daemons.
                   2243: 
                   2244: libexec/cgi-bin
                   2245: 
                   2246:     Contains programs that are intended to be executed as CGI scripts by a web
                   2247:     server.
                   2248: 
                   2249: man (the usual value of ${PKGMANDIR})
                   2250: 
                   2251:     Contains brief documentation in form of manual pages.
                   2252: 
                   2253: sbin
                   2254: 
                   2255:     Contains programs that are intended to be used only by the super-user.
                   2256: 
                   2257: share
                   2258: 
                   2259:     Contains platform-independent data files that don't change after
                   2260:     installation.
                   2261: 
                   2262: share/doc
                   2263: 
                   2264:     Contains documentation files provided by the packages.
                   2265: 
                   2266: share/examples
                   2267: 
                   2268:     Contains example files provided by the packages. Among others, the original
                   2269:     configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
                   2270:     installation.
                   2271: 
                   2272: share/examples/rc.d
                   2273: 
                   2274:     Contains the original files for rc.d scripts.
                   2275: 
                   2276: var (the usual location of ${VARBASE})
                   2277: 
                   2278:     Contains files that may be modified after installation.
                   2279: 
1.154     rillig   2280: 9.2. File system layout in ${VARBASE}
1.1       dsieger  2281: 
                   2282: db/pkg (the usual location of ${PKG_DBDIR})
                   2283: 
                   2284:     Contains information about the currently installed packages.
                   2285: 
                   2286: games
                   2287: 
                   2288:     Contains highscore files.
                   2289: 
                   2290: log
                   2291: 
                   2292:     Contains log files.
                   2293: 
                   2294: run
                   2295: 
                   2296:     Contains informational files about daemons that are currently running.
                   2297: 
1.154     rillig   2298: Chapter 10. Frequently Asked Questions
1.1       dsieger  2299: 
                   2300: Table of Contents
                   2301: 
1.154     rillig   2302: 10.1. Are there any mailing lists for pkg-related discussion?
                   2303: 10.2. Utilities for package management (pkgtools)
                   2304: 10.3. How to use pkgsrc as non-root
                   2305: 10.4. How to resume transfers when fetching distfiles?
                   2306: 10.5. How can I install/use modular X.org from pkgsrc?
                   2307: 10.6. How to fetch files from behind a firewall
                   2308: 10.7. How to fetch files from HTTPS sites
                   2309: 10.8. How do I tell make fetch to do passive FTP?
                   2310: 10.9. How to fetch all distfiles at once
                   2311: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
                   2312: 10.11. What does "Could not find bsd.own.mk" mean?
                   2313: 10.12. Using 'sudo' with pkgsrc
                   2314: 10.13. How do I change the location of configuration files?
                   2315: 10.14. Automated security checks
                   2316: 10.15. Why do some packages ignore my CFLAGS?
                   2317: 10.16. A package does not build. What shall I do?
                   2318: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24      wiz      2319:     conflicts" mean?
1.1       dsieger  2320: 
                   2321: This section contains hints, tips & tricks on special things in pkgsrc that we
                   2322: didn't find a better place for in the previous chapters, and it contains items
                   2323: for both pkgsrc users and developers.
                   2324: 
1.154     rillig   2325: 10.1. Are there any mailing lists for pkg-related discussion?
1.1       dsieger  2326: 
                   2327: The following mailing lists may be of interest to pkgsrc users:
                   2328: 
                   2329:   * pkgsrc-users: This is a general purpose list for most issues regarding
                   2330:     pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
                   2331:     configuration, unexpected build failures, using particular packages,
                   2332:     upgrading pkgsrc installations, questions regarding the pkgsrc release
                   2333:     branches, etc. General announcements or proposals for changes that impact
                   2334:     the pkgsrc user community, e.g. major infrastructure changes, new features,
                   2335:     package removals, etc., may also be posted.
                   2336: 
                   2337:   * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
                   2338:     discussed.
                   2339: 
                   2340:   * pkgsrc-changes: This list is for those who are interested in getting a
                   2341:     commit message for every change committed to pkgsrc. It is also available
                   2342:     in digest form, meaning one daily message containing all commit messages
                   2343:     for changes to the package source tree in that 24 hour period.
                   2344: 
                   2345: To subscribe, do:
                   2346: 
                   2347: % echo subscribe listname | mail majordomo@NetBSD.org
                   2348: 
1.174     leot     2349: Archives for all these mailing lists are available from https://
1.1       dsieger  2350: mail-index.NetBSD.org/.
                   2351: 
1.154     rillig   2352: 10.2. Utilities for package management (pkgtools)
1.1       dsieger  2353: 
                   2354: The directory pkgsrc/pkgtools contains a number of useful utilities for both
                   2355: users and developers of pkgsrc. This section attempts only to make the reader
1.121     sevan    2356: aware of some of the utilities and when they might be useful, and not to
                   2357: duplicate the documentation that comes with each package.
1.1       dsieger  2358: 
                   2359: Utilities used by pkgsrc (automatically installed when needed):
                   2360: 
                   2361:   * pkgtools/x11-links: Symlinks for use by buildlink.
                   2362: 
                   2363: OS tool augmentation (automatically installed when needed):
                   2364: 
1.121     sevan    2365:   * pkgtools/digest: Calculates various kinds of checksums (including SHA3).
1.1       dsieger  2366: 
                   2367:   * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
                   2368: 
                   2369:   * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
                   2370: 
                   2371:   * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
                   2372:     for use on operating systems where pkg_install is not present.
                   2373: 
                   2374: Utilities used by pkgsrc (not automatically installed):
                   2375: 
                   2376:   * pkgtools/pkg_tarup: Create a binary package from an already-installed
                   2377:     package. Used by make replace to save the old package.
                   2378: 
                   2379:   * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
                   2380:     distfiles from multiple locations. It currently supports the following
                   2381:     methods: multiple CD-ROMs and network FTP/HTTP connections.
                   2382: 
                   2383:   * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24      wiz      2384:     current CPU and compiler.
1.1       dsieger  2385: 
                   2386: Utilities for keeping track of installed packages, being up to date, etc:
                   2387: 
1.65      wiz      2388:   * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
                   2389:     and upgrade binary packages easily.
                   2390: 
1.1       dsieger  2391:   * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
                   2392:     the latest pkgsrc entries.
                   2393: 
                   2394:   * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
                   2395:     strategy for updating.
                   2396: 
                   2397:   * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
                   2398:     graphviz).
                   2399: 
1.12      weinem   2400:   * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
                   2401: 
                   2402:   * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
                   2403:     complete pkgsrc system.
1.1       dsieger  2404: 
                   2405:   * pkgtools/pkgsurvey: Report what packages you have installed.
                   2406: 
                   2407: Utilities for people maintaining or creating individual packages:
                   2408: 
                   2409:   * pkgtools/pkgdiff: Automate making and maintaining patches for a package
                   2410:     (includes pkgdiff, pkgvi, mkpatches, etc.).
                   2411: 
1.65      wiz      2412:   * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1       dsieger  2413: 
                   2414: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
                   2415: 
                   2416:   * pkgtools/pkg_comp: Build packages in a chrooted area.
                   2417: 
                   2418:   * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
                   2419: 
1.154     rillig   2420: 10.3. How to use pkgsrc as non-root
1.1       dsieger  2421: 
1.108     rillig   2422: To install packages from source as a non-root user, download pkgsrc as
1.154     rillig   2423: described in Chapter 3, Where to get pkgsrc and how to keep it up-to-date, cd
1.108     rillig   2424: into that directory and run the command ./bootstrap/bootstrap --unprivileged.
                   2425: 
                   2426: This will install the binary part of pkgsrc to ~/pkg and put the pkgsrc
                   2427: configuration mk.conf into ~/pkg/etc.
                   2428: 
                   2429: For more details, see mk/unprivileged.mk.
1.1       dsieger  2430: 
1.154     rillig   2431: 10.4. How to resume transfers when fetching distfiles?
1.1       dsieger  2432: 
                   2433: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4       rillig   2434: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
                   2435: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1       dsieger  2436: 
1.61      wiz      2437: You can also use a different program than the platform default program by
                   2438: changing the FETCH_USING variable. You can specify the program by using of ftp,
                   2439: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
                   2440: manual. A value of custom disables the system defaults and dependency tracking
                   2441: for the fetch program. In that case you have to provide FETCH_CMD,
                   2442: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1       dsieger  2443: 
1.16      jnemeth  2444: For example, if you want to use wget to download, you'll have to use something
                   2445: like:
1.1       dsieger  2446: 
1.16      jnemeth  2447: FETCH_USING=    wget
1.1       dsieger  2448: 
1.154     rillig   2449: 10.5. How can I install/use modular X.org from pkgsrc?
1.1       dsieger  2450: 
1.4       rillig   2451: If you want to use modular X.org from pkgsrc instead of your system's own X11
                   2452: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1       dsieger  2453: mk.conf:
                   2454: 
1.4       rillig   2455: X11_TYPE=modular
1.1       dsieger  2456: 
1.154     rillig   2457: 10.6. How to fetch files from behind a firewall
1.1       dsieger  2458: 
                   2459: If you are sitting behind a firewall which does not allow direct connections to
                   2460: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
                   2461: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
                   2462: machine "orpheus.amdahl.com" is one of the firewalls, and it uses port 80 as
                   2463: the proxy port number. So the proxy environment variables are:
                   2464: 
                   2465: ftp_proxy=ftp://orpheus.amdahl.com:80/
                   2466: http_proxy=http://orpheus.amdahl.com:80/
                   2467: 
1.154     rillig   2468: 10.7. How to fetch files from HTTPS sites
1.65      wiz      2469: 
                   2470: Some fetch tools are not prepared to support HTTPS by default (for example, the
                   2471: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
                   2472: openssl dependency that low in the dependency graph).
                   2473: 
                   2474: Usually you won't notice, because distribution files are mirrored weekly to "
                   2475: ftp.NetBSD.org", but that might not be often enough if you are following
                   2476: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to "curl" or
                   2477: "wget", which are both compiled with HTTPS support by default. Of course, these
                   2478: tools need to be installed before you can use them this way.
                   2479: 
1.154     rillig   2480: 10.8. How do I tell make fetch to do passive FTP?
1.1       dsieger  2481: 
                   2482: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
                   2483: FETCH_CMD is assigned the first available command from the following list:
                   2484: 
                   2485:   * ${LOCALBASE}/bin/ftp
                   2486: 
                   2487:   * /usr/bin/ftp
                   2488: 
                   2489: On a default NetBSD installation, this will be /usr/bin/ftp, which
                   2490: automatically tries passive connections first, and falls back to active
                   2491: connections if the server refuses to do passive. For the other tools, add the
1.4       rillig   2492: following to your mk.conf file: PASSIVE_FETCH=1.
1.1       dsieger  2493: 
                   2494: Having that option present will prevent /usr/bin/ftp from falling back to
                   2495: active transfers.
                   2496: 
1.154     rillig   2497: 10.9. How to fetch all distfiles at once
1.1       dsieger  2498: 
                   2499: You would like to download all the distfiles in a single batch from work or
                   2500: university, where you can't run a make fetch. There is an archive of distfiles
                   2501: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
                   2502: 
                   2503: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
                   2504: subdirectories, carry the resulting list to your machine at work/school and use
                   2505: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
                   2506: don't forget to set FETCH_CMD to something that fetches a URL:
                   2507: 
                   2508: At home:
                   2509: 
                   2510: % cd /usr/pkgsrc
                   2511: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
                   2512: % scp /tmp/fetch.sh work:/tmp
                   2513: 
                   2514: At work:
                   2515: 
                   2516: % sh /tmp/fetch.sh
                   2517: 
                   2518: then tar up /tmp/distfiles and take it home.
                   2519: 
                   2520: If you have a machine running NetBSD, and you want to get all distfiles (even
                   2521: ones that aren't for your machine architecture), you can do so by using the
                   2522: above-mentioned make fetch-list approach, or fetch the distfiles directly by
                   2523: running:
                   2524: 
                   2525: % make mirror-distfiles
                   2526: 
                   2527: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
                   2528: everything by running:
                   2529: 
                   2530: % make fetch NO_SKIP=yes
                   2531: 
1.154     rillig   2532: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
1.1       dsieger  2533: 
                   2534: When compiling the pkgtools/pkg_install package, you get the error from make
                   2535: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
                   2536: that you don't have installed the "text" set (nroff, ...) from the NetBSD base
                   2537: distribution on your machine. It is recommended to do that to format man pages.
                   2538: 
                   2539: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4       rillig   2540: NOMAN=YES either in the environment or in mk.conf.
1.1       dsieger  2541: 
1.154     rillig   2542: 10.11. What does "Could not find bsd.own.mk" mean?
1.1       dsieger  2543: 
                   2544: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
                   2545: machine. Please get and install it, by extracting it in /:
                   2546: 
                   2547: # cd /
                   2548: # tar --unlink -zxvpf .../comp.tgz
                   2549: 
                   2550: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
                   2551: release (determine via uname -r).
                   2552: 
1.154     rillig   2553: 10.12. Using 'sudo' with pkgsrc
1.1       dsieger  2554: 
                   2555: When installing packages as non-root user and using the just-in-time su(1)
                   2556: feature of pkgsrc, it can become annoying to type in the root password for each
                   2557: required package installed. To avoid this, the sudo package can be used, which
                   2558: does password caching over a limited time. To use it, install sudo (either as
1.4       rillig   2559: binary package or from security/sudo) and then put the following into your
                   2560: mk.conf, somewhere after the definition of the LOCALBASE variable:
1.1       dsieger  2561: 
                   2562: .if exists(${LOCALBASE}/bin/sudo)
                   2563: SU_CMD=        ${LOCALBASE}/bin/sudo /bin/sh -c
                   2564: .endif
                   2565: 
1.154     rillig   2566: 10.13. How do I change the location of configuration files?
1.1       dsieger  2567: 
                   2568: As the system administrator, you can choose where configuration files are
                   2569: installed. The default settings make all these files go into ${PREFIX}/etc or
                   2570: some of its subdirectories; this may be suboptimal depending on your
                   2571: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
                   2572: configuration of the provided packages).
                   2573: 
                   2574: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4       rillig   2575: (in mk.conf) to point to your preferred configuration directory; some common
                   2576: examples include /etc or /etc/pkg.
1.1       dsieger  2577: 
                   2578: Furthermore, you can change this value on a per-package basis by setting the
                   2579: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
                   2580: matches the name of the package you would like to modify, that is, the contents
                   2581: of PKGBASE.
                   2582: 
                   2583: Note that after changing these settings, you must rebuild and reinstall any
                   2584: affected packages.
                   2585: 
1.154     rillig   2586: 10.14. Automated security checks
1.1       dsieger  2587: 
                   2588: Please be aware that there can often be bugs in third-party software, and some
                   2589: of these bugs can leave a machine vulnerable to exploitation by attackers. In
                   2590: an effort to lessen the exposure, the NetBSD packages team maintains a database
                   2591: of known-exploits to packages which have at one time been included in pkgsrc.
                   2592: The database can be downloaded automatically, and a security audit of all
1.14      jmcneill 2593: packages installed on a system can take place. To do this, refer to the
                   2594: following two tools (installed as part of the pkgtools/pkg_install package):
1.1       dsieger  2595: 
1.21      snj      2596:  1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
                   2597:     security vulnerabilities information. This list is kept up to date by the
1.26      spz      2598:     pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1       dsieger  2599: 
1.177     leot     2600:     https://ftp.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities
1.1       dsieger  2601: 
1.21      snj      2602:  2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24      wiz      2603:     known vulnerability. If a vulnerable package is installed, it will be shown
                   2604:     by output to stdout, including a description of the type of vulnerability,
                   2605:     and a URL containing more information.
1.1       dsieger  2606: 
1.202     nia      2607: Use of these tools is strongly recommended! See Section 5.1.6, "Checking for
1.121     sevan    2608: security vulnerabilities in installed packages" for instructions on how to
                   2609: automate checking and reporting.
                   2610: 
                   2611: If this database is installed, pkgsrc builds will use it to perform a security
                   2612: check before building any package.
1.1       dsieger  2613: 
1.154     rillig   2614: 10.15. Why do some packages ignore my CFLAGS?
1.1       dsieger  2615: 
                   2616: When you add your own preferences to the CFLAGS variable in your mk.conf, these
                   2617: flags are passed in environment variables to the ./configure scripts and to
                   2618: make(1). Some package authors ignore the CFLAGS from the environment variable
                   2619: by overriding them in the Makefiles of their package.
                   2620: 
                   2621: Currently there is no solution to this problem. If you really need the package
                   2622: to use your CFLAGS you should run make patch in the package directory and then
                   2623: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
                   2624: Usually you can remove these lines. But be aware that some "smart" programmers
                   2625: write so bad code that it only works for the specific combination of CFLAGS
                   2626: they have chosen.
                   2627: 
1.172     rillig   2628: To find out where the CFLAGS are ignored, add the following lines to mk.conf:
                   2629: 
                   2630: CPPFLAGS+=              -Dpkgsrc___CPPFLAGS
                   2631: CFLAGS+=                -Dpkgsrc___CFLAGS
                   2632: CXXFLAGS+=              -Dpkgsrc___CXXFLAGS
                   2633: 
                   2634: Then run bmake show-all-configure show-all-build to see whether the above flags
                   2635: are passed to the actual build commands in general.
                   2636: 
                   2637: To find out whether the flags are passed to individual compiler commands, have
                   2638: a look at the file work/.work.log. In most cases, the flags from the original
                   2639: command lines (the lines starting with [*]) are passed unmodified to the actual
                   2640: compiler (the lines starting with <.>). If the flag is missing from the actual
                   2641: compiler command, it must have been removed by the pkgsrc compiler wrappers.
                   2642: 
1.154     rillig   2643: 10.16. A package does not build. What shall I do?
1.1       dsieger  2644: 
                   2645:  1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
                   2646:     is that people only update pkgsrc in parts, because of performance reasons.
                   2647:     Since pkgsrc is one large system, not a collection of many small systems,
                   2648:     there are sometimes changes that only work when the whole pkgsrc tree is
                   2649:     updated.
                   2650: 
1.25      wiz      2651:  2. Make sure that you don't have any CVS conflicts. Search for "<<<<<<" or "
                   2652:     >>>>>>" in all your pkgsrc files.
1.1       dsieger  2653: 
1.25      wiz      2654:  3. Make sure that you don't have old copies of the packages extracted. Run 
1.1       dsieger  2655:     make clean clean-depends to verify this.
                   2656: 
1.108     rillig   2657:  4. If you are a package developer who wants to invest some work, have a look
1.154     rillig   2658:     at Chapter 21, Making your package work.
1.108     rillig   2659: 
                   2660:  5. If the problem still exists, write a mail to the pkgsrc-users mailing list.
1.1       dsieger  2661: 
1.154     rillig   2662: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.1       dsieger  2663: conflicts" mean?
                   2664: 
                   2665: You have modified a file from pkgsrc, and someone else has modified that same
                   2666: file afterwards in the CVS repository. Both changes are in the same region of
                   2667: the file, so when you updated pkgsrc, the cvs command marked the conflicting
                   2668: changes in the file. Because of these markers, the file is no longer a valid
                   2669: Makefile.
                   2670: 
                   2671: Have a look at that file, and if you don't need your local changes anymore, you
                   2672: can remove that file and run cvs -q update -dP in that directory to download
                   2673: the current version.
                   2674: 
                   2675: Part II. The pkgsrc developer's guide
                   2676: 
                   2677: This part of the book deals with creating and modifying packages. It starts
                   2678: with a "HOWTO"-like guide on creating a new package. The remaining chapters are
                   2679: more like a reference manual for pkgsrc.
                   2680: 
                   2681: Table of Contents
                   2682: 
1.154     rillig   2683: 11. Getting help
1.184     rillig   2684: 12. Package components - files, directories and contents
1.1       dsieger  2685: 
1.184     rillig   2686:     12.1. Makefile
                   2687:     12.2. distinfo
                   2688:     12.3. patches/*
1.1       dsieger  2689: 
1.184     rillig   2690:         12.3.1. Structure of a single patch file
                   2691:         12.3.2. Creating patch files
                   2692:         12.3.3. Sources where the patch files come from
                   2693:         12.3.4. Patching guidelines
                   2694:         12.3.5. Feedback to the author
1.1       dsieger  2695: 
1.184     rillig   2696:     12.4. Other mandatory files
                   2697:     12.5. Optional files
1.1       dsieger  2698: 
1.184     rillig   2699:         12.5.1. Files affecting the binary package
                   2700:         12.5.2. Files affecting the build process
                   2701:         12.5.3. Files affecting nothing at all
1.1       dsieger  2702: 
1.184     rillig   2703:     12.6. work*
                   2704:     12.7. files/*
1.1       dsieger  2705: 
1.184     rillig   2706: 13. The build process
1.1       dsieger  2707: 
1.184     rillig   2708:     13.1. Introduction
                   2709:     13.2. Program location
                   2710:     13.3. Directories used during the build process
                   2711:     13.4. Running a phase
                   2712:     13.5. The fetch phase
1.1       dsieger  2713: 
1.184     rillig   2714:         13.5.1. What to fetch and where to get it from
                   2715:         13.5.2. How are the files fetched?
1.1       dsieger  2716: 
1.184     rillig   2717:     13.6. The checksum phase
                   2718:     13.7. The extract phase
                   2719:     13.8. The patch phase
                   2720:     13.9. The tools phase
                   2721:     13.10. The wrapper phase
                   2722:     13.11. The configure phase
                   2723:     13.12. The build phase
                   2724:     13.13. The test phase
                   2725:     13.14. The install phase
                   2726:     13.15. The package phase
                   2727:     13.16. Cleaning up
                   2728:     13.17. Other helpful targets
1.1       dsieger  2729: 
1.184     rillig   2730: 14. Creating a new pkgsrc package from scratch
1.1       dsieger  2731: 
1.184     rillig   2732:     14.1. Common types of packages
1.1       dsieger  2733: 
1.184     rillig   2734:         14.1.1. Perl modules
                   2735:         14.1.2. Python modules and programs
                   2736:         14.1.3. R packages
                   2737:         14.1.4. TeXlive packages
1.1       dsieger  2738: 
1.184     rillig   2739:     14.2. Examples
1.1       dsieger  2740: 
1.184     rillig   2741:         14.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  2742: 
1.184     rillig   2743: 15. Programming in Makefiles
1.1       dsieger  2744: 
1.184     rillig   2745:     15.1. Caveats
                   2746:     15.2. Makefile variables
1.1       dsieger  2747: 
1.184     rillig   2748:         15.2.1. Naming conventions
1.1       dsieger  2749: 
1.184     rillig   2750:     15.3. Code snippets
1.1       dsieger  2751: 
1.184     rillig   2752:         15.3.1. Adding things to a list
                   2753:         15.3.2. Echoing a string exactly as-is
                   2754:         15.3.3. Passing CFLAGS to GNU configure scripts
                   2755:         15.3.4. Handling possibly empty variables
1.1       dsieger  2756: 
1.184     rillig   2757: 16. Options handling
1.1       dsieger  2758: 
1.184     rillig   2759:     16.1. Global default options
                   2760:     16.2. Converting packages to use bsd.options.mk
                   2761:     16.3. Option Names
                   2762:     16.4. Determining the options of dependencies
1.1       dsieger  2763: 
1.184     rillig   2764: 17. Tools needed for building or running
1.1       dsieger  2765: 
1.184     rillig   2766:     17.1. Tools for pkgsrc builds
                   2767:     17.2. Tools needed by packages
                   2768:     17.3. Tools provided by platforms
1.1       dsieger  2769: 
1.184     rillig   2770: 18. Buildlink methodology
1.1       dsieger  2771: 
1.184     rillig   2772:     18.1. Converting packages to use buildlink3
                   2773:     18.2. Writing buildlink3.mk files
1.1       dsieger  2774: 
1.184     rillig   2775:         18.2.1. Anatomy of a buildlink3.mk file
                   2776:         18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
                   2777:             pkg in buildlink3.mk files
1.1       dsieger  2778: 
1.184     rillig   2779:     18.3. Writing builtin.mk files
1.1       dsieger  2780: 
1.184     rillig   2781:         18.3.1. Anatomy of a builtin.mk file
                   2782:         18.3.2. Global preferences for native or pkgsrc software
1.1       dsieger  2783: 
1.184     rillig   2784: 19. PLIST issues
1.1       dsieger  2785: 
1.184     rillig   2786:     19.1. RCS ID
                   2787:     19.2. Semi-automatic PLIST generation
                   2788:     19.3. Tweaking output of make print-PLIST
                   2789:     19.4. Variable substitution in PLIST
                   2790:     19.5. Man page compression
                   2791:     19.6. Changing PLIST source with PLIST_SRC
                   2792:     19.7. Platform-specific and differing PLISTs
                   2793:     19.8. Build-specific PLISTs
                   2794:     19.9. Sharing directories between packages
1.1       dsieger  2795: 
1.184     rillig   2796: 20. The pkginstall framework
1.1       dsieger  2797: 
1.184     rillig   2798:     20.1. Files and directories outside the installation prefix
1.1       dsieger  2799: 
1.184     rillig   2800:         20.1.1. Directory manipulation
                   2801:         20.1.2. File manipulation
1.1       dsieger  2802: 
1.184     rillig   2803:     20.2. Configuration files
1.1       dsieger  2804: 
1.184     rillig   2805:         20.2.1. How PKG_SYSCONFDIR is set
                   2806:         20.2.2. Telling the software where configuration files are
                   2807:         20.2.3. Patching installations
                   2808:         20.2.4. Disabling handling of configuration files
1.1       dsieger  2809: 
1.184     rillig   2810:     20.3. System startup scripts
1.1       dsieger  2811: 
1.184     rillig   2812:         20.3.1. Disabling handling of system startup scripts
1.1       dsieger  2813: 
1.184     rillig   2814:     20.4. System users and groups
                   2815:     20.5. System shells
1.1       dsieger  2816: 
1.184     rillig   2817:         20.5.1. Disabling shell registration
1.1       dsieger  2818: 
1.184     rillig   2819:     20.6. Fonts
1.1       dsieger  2820: 
1.184     rillig   2821:         20.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  2822: 
1.154     rillig   2823: 21. Making your package work
1.1       dsieger  2824: 
1.154     rillig   2825:     21.1. General operation
1.1       dsieger  2826: 
1.154     rillig   2827:         21.1.1. How to pull in user-settable variables from mk.conf
                   2828:         21.1.2. User interaction
                   2829:         21.1.3. Handling licenses
                   2830:         21.1.4. Restricted packages
                   2831:         21.1.5. Handling dependencies
                   2832:         21.1.6. Handling conflicts with other packages
                   2833:         21.1.7. Packages that cannot or should not be built
                   2834:         21.1.8. Packages which should not be deleted, once installed
                   2835:         21.1.9. Handling packages with security problems
                   2836:         21.1.10. How to handle incrementing versions when fixing an existing
1.1       dsieger  2837:             package
1.154     rillig   2838:         21.1.11. Substituting variable text in the package files (the SUBST
1.1       dsieger  2839:             framework)
                   2840: 
1.154     rillig   2841:     21.2. The fetch phase
1.1       dsieger  2842: 
1.154     rillig   2843:         21.2.1. Packages whose distfiles aren't available for plain downloading
                   2844:         21.2.2. How to handle modified distfiles with the 'old' name
                   2845:         21.2.3. Packages hosted on github.com
                   2846: 
                   2847:     21.3. The configure phase
                   2848: 
                   2849:         21.3.1. Shared libraries - libtool
                   2850:         21.3.2. Using libtool on GNU packages that already support libtool
                   2851:         21.3.3. GNU Autoconf/Automake
                   2852: 
                   2853:     21.4. Programming languages
                   2854: 
                   2855:         21.4.1. C, C++, and Fortran
                   2856:         21.4.2. Java
1.205     wiz      2857:         21.4.3. Go
                   2858:         21.4.4. Packages containing Perl scripts
                   2859:         21.4.5. Packages containing shell scripts
                   2860:         21.4.6. Other programming languages
1.154     rillig   2861: 
                   2862:     21.5. The build phase
                   2863: 
                   2864:         21.5.1. Compiling C and C++ code conditionally
                   2865:         21.5.2. How to handle compiler bugs
1.172     rillig   2866:         21.5.3. No such file or directory
                   2867:         21.5.4. Undefined reference to "..."
                   2868:         21.5.5. Running out of memory
1.154     rillig   2869: 
                   2870:     21.6. The install phase
                   2871: 
                   2872:         21.6.1. Creating needed directories
                   2873:         21.6.2. Where to install documentation
                   2874:         21.6.3. Installing highscore files
                   2875:         21.6.4. Adding DESTDIR support to packages
                   2876:         21.6.5. Packages with hardcoded paths to other interpreters
1.203     nia      2877:         21.6.6. Packages installing Perl modules
1.154     rillig   2878:         21.6.7. Packages installing info files
                   2879:         21.6.8. Packages installing man pages
1.203     nia      2880:         21.6.9. Packages installing X11 fonts
                   2881:         21.6.10. Packages installing SGML or XML data
                   2882:         21.6.11. Packages installing extensions to the MIME database
                   2883:         21.6.12. Packages using intltool
                   2884:         21.6.13. Packages installing startup scripts
                   2885:         21.6.14. Packages installing TeX modules
                   2886:         21.6.15. Packages supporting running binaries in emulation
                   2887:         21.6.16. Packages installing hicolor icons
                   2888:         21.6.17. Packages installing desktop files
1.154     rillig   2889: 
                   2890:     21.7. Marking packages as having problems
                   2891: 
1.184     rillig   2892: 22. GNOME packaging and porting
                   2893: 
                   2894:     22.1. Meta packages
                   2895:     22.2. Packaging a GNOME application
                   2896:     22.3. Updating GNOME to a newer version
                   2897:     22.4. Patching guidelines
                   2898: 
1.154     rillig   2899: 23. Submitting and Committing
                   2900: 
                   2901:     23.1. Submitting binary packages
                   2902:     23.2. Submitting source packages (for non-NetBSD-developers)
                   2903:     23.3. General notes when adding, updating, or removing packages
                   2904:     23.4. Commit Messages
                   2905:     23.5. Committing: Adding a package to CVS
                   2906:     23.6. Updating a package to a newer version
                   2907:     23.7. Renaming a package in pkgsrc
                   2908:     23.8. Moving a package in pkgsrc
                   2909: 
                   2910: 24. Frequently Asked Questions
                   2911: 
                   2912: Chapter 11. Getting help
                   2913: 
                   2914: To get help when developing pkgsrc, the definitive source is this document, the
                   2915: pkgsrc guide. If you don't find anything here, there are alternatives:
                   2916: 
                   2917:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
                   2918:     Run bmake help topic=? to get help for any topic, such as a variable name
                   2919:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                   2920:     like strcasecmp or any other topic.
                   2921: 
1.207     leot     2922:     The available help topics are listed in Appendix E, Help topics.
1.154     rillig   2923: 
1.163     rillig   2924:   * To see the value of a single variable, run bmake show-var VARNAME=X.
                   2925: 
                   2926:   * To see the values of the most common variables, run bmake show-all. These
                   2927:     variables are grouped by topic. To see the variables for a single topic,
                   2928:     run bmake show-all-topic, for example bmake show-all-fetch.
                   2929: 
1.154     rillig   2930:   * The tech-pkg mailing list, to which you can subscribe and then ask your
                   2931:     questions.
                   2932: 
                   2933:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                   2934:     a specialized chat program such as XChat. Pick any user name and join the
                   2935:     channel #pkgsrc.
1.1       dsieger  2936: 
1.184     rillig   2937: Chapter 12. Package components - files, directories and contents
1.1       dsieger  2938: 
                   2939: Table of Contents
                   2940: 
1.184     rillig   2941: 12.1. Makefile
                   2942: 12.2. distinfo
                   2943: 12.3. patches/*
                   2944: 
                   2945:     12.3.1. Structure of a single patch file
                   2946:     12.3.2. Creating patch files
                   2947:     12.3.3. Sources where the patch files come from
                   2948:     12.3.4. Patching guidelines
                   2949:     12.3.5. Feedback to the author
                   2950: 
                   2951: 12.4. Other mandatory files
                   2952: 12.5. Optional files
                   2953: 
                   2954:     12.5.1. Files affecting the binary package
                   2955:     12.5.2. Files affecting the build process
                   2956:     12.5.3. Files affecting nothing at all
1.1       dsieger  2957: 
1.184     rillig   2958: 12.6. work*
                   2959: 12.7. files/*
1.1       dsieger  2960: 
1.184     rillig   2961: Whenever you're preparing a package, there are a number of files involved which
                   2962: are described in the following sections.
1.1       dsieger  2963: 
1.184     rillig   2964: 12.1. Makefile
1.1       dsieger  2965: 
1.184     rillig   2966: Building, installation and creation of a binary package are all controlled by
                   2967: the package's Makefile. The Makefile describes various things about a package,
                   2968: for example from where to get it, how to configure, build, and install it.
1.1       dsieger  2969: 
1.184     rillig   2970: A package Makefile contains several sections that describe the package.
1.1       dsieger  2971: 
1.184     rillig   2972: In the first section there are the following variables, which should appear
                   2973: exactly in the order given here. The order and grouping of the variables is
                   2974: mostly historical and has no further meaning.
1.1       dsieger  2975: 
1.184     rillig   2976:   * DISTNAME is the basename of the distribution file to be downloaded from the
                   2977:     package's website.
1.1       dsieger  2978: 
1.184     rillig   2979:   * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
                   2980:     it if DISTNAME (which is the default) is not a good name for the package in
                   2981:     pkgsrc or DISTNAME is not provided (no distribution file is required).
                   2982:     Usually it is the pkgsrc directory name together with the version number.
                   2983:     It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
                   2984:     is, it starts with a letter or digit, and contains only letters, digits,
1.204     nia      2985:     dashes, underscores, dots and plus signs. New packages should have entirely
                   2986:     lower-case names, with the exception of some that must follow pre-existing
                   2987:     conventions (e.g. R packages begin with R-). You can use the :tl variable
                   2988:     modifier to lower-case the package name.
1.26      spz      2989: 
1.184     rillig   2990:   * CATEGORIES is a list of categories which the package fits in. You can
                   2991:     choose any of the top-level directories of pkgsrc for it.
1.1       dsieger  2992: 
1.184     rillig   2993:     Currently the following values are available for CATEGORIES. If more than
                   2994:     one is used, they need to be separated by spaces:
1.1       dsieger  2995: 
1.184     rillig   2996:     archivers     cross         geography     meta-pkgs     security
                   2997:     audio         databases     graphics      misc          shells
                   2998:     benchmarks    devel         ham           multimedia    sysutils
                   2999:     biology       editors       inputmethod   net           textproc
                   3000:     cad           emulators     lang          news          time
                   3001:     chat          finance       mail          parallel      wm
                   3002:     comms         fonts         math          pkgtools      www
                   3003:     converters    games         mbone         print         x11
1.1       dsieger  3004: 
1.184     rillig   3005:   * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
                   3006:     are discussed in detail in Section 13.5, "The fetch phase".
1.1       dsieger  3007: 
1.184     rillig   3008: The second section contains information about separately downloaded patches, if
                   3009: any.
1.1       dsieger  3010: 
1.184     rillig   3011:   * PATCHFILES: Name(s) of additional files that contain distribution patches.
                   3012:     There is no default. pkgsrc will look for them at PATCH_SITES. They will
                   3013:     automatically be uncompressed before patching if the names end with .gz or
                   3014:     .Z.
1.1       dsieger  3015: 
1.184     rillig   3016:   * PATCH_SITES: Primary location(s) for distribution patch files (see
                   3017:     PATCHFILES above) if not found locally.
1.1       dsieger  3018: 
1.184     rillig   3019:   * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
                   3020:     count to help find the correct files to patch. It defaults to -p0.
1.1       dsieger  3021: 
1.184     rillig   3022: The third section contains the following variables.
1.1       dsieger  3023: 
1.184     rillig   3024:   * MAINTAINER is the email address of the person who feels responsible for
                   3025:     this package, and who is most likely to look at problems or questions
                   3026:     regarding this package which have been reported with send-pr(1). Other
                   3027:     developers may contact the MAINTAINER before making changes to the package,
                   3028:     but are not required to do so. When packaging a new program, set MAINTAINER
                   3029:     to yourself. If you really can't maintain the package for future updates,
                   3030:     set it to <pkgsrc-users@NetBSD.org>.
1.1       dsieger  3031: 
1.184     rillig   3032:   * OWNER should be used instead of MAINTAINER when you do not want other
                   3033:     developers to update or change the package without contacting you first. A
                   3034:     package Makefile should contain one of MAINTAINER or OWNER, but not both.
1.1       dsieger  3035: 
1.184     rillig   3036:   * HOMEPAGE is a URL where users can find more information about the package.
1.1       dsieger  3037: 
1.184     rillig   3038:   * COMMENT is a one-line description of the package (should not include the
                   3039:     package name).
1.1       dsieger  3040: 
1.184     rillig   3041:   * LICENSE indicates the license(s) applicable for the package. See
                   3042:     Section 21.1.3, "Handling licenses" for further details.
1.1       dsieger  3043: 
1.184     rillig   3044: Other variables that affect the build:
1.1       dsieger  3045: 
1.184     rillig   3046:   * WRKSRC: The directory where the interesting distribution files of the
                   3047:     package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
                   3048:     most packages.
1.1       dsieger  3049: 
1.184     rillig   3050:     If a package doesn't create a subdirectory for itself (most GNU software
                   3051:     does, for instance), but extracts itself in the current directory, you
                   3052:     should set WRKSRC=${WRKDIR}.
1.1       dsieger  3053: 
1.184     rillig   3054:     If a package doesn't create a subdirectory with the name of DISTNAME but
                   3055:     some different name, set WRKSRC to point to the proper name in ${WRKDIR},
                   3056:     for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
                   3057:     other examples.
1.17      imil     3058: 
1.184     rillig   3059:     The name of the working directory created by pkgsrc is taken from the
                   3060:     WRKDIR_BASENAME variable. By default, its value is work. If you want to use
                   3061:     the same pkgsrc tree for building different kinds of binary packages, you
                   3062:     can change the variable according to your needs. Two other variables handle
                   3063:     common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
                   3064:     defined in mk.conf, the first component of the host's name is attached to
                   3065:     the directory name. If OBJMACHINE is defined, the platform name is
                   3066:     attached, which might look like work.i386 or work.sparc.
1.17      imil     3067: 
1.184     rillig   3068: Please pay attention to the following gotchas:
1.17      imil     3069: 
1.184     rillig   3070:   * Add MANCOMPRESSED if man pages are installed in compressed form by the
                   3071:     package. For packages using BSD-style makefiles which honor MANZ, there is
                   3072:     MANCOMPRESSED_IF_MANZ.
1.17      imil     3073: 
1.184     rillig   3074:   * Replace /usr/local with "${PREFIX}" in all files (see patches, below).
1.103     wiz      3075: 
1.184     rillig   3076:   * If the package installs any info files, see Section 21.6.7, "Packages
                   3077:     installing info files".
1.103     wiz      3078: 
1.184     rillig   3079: 12.2. distinfo
1.17      imil     3080: 
1.184     rillig   3081: The distinfo file contains the message digest, or checksum, of each distfile
                   3082: needed for the package. This ensures that the distfiles retrieved from the
                   3083: Internet have not been corrupted during transfer or altered by a malign force
                   3084: to introduce a security hole. To provide maximum security, all distfiles are
                   3085: protected using three different message digest algorithms (SHA1, RMD160,
                   3086: SHA512), as well as the file size.
1.17      imil     3087: 
1.184     rillig   3088: The distinfo file also contains the checksums for all the patches found in the
                   3089: patches directory (see Section 12.3, "patches/*"). These checksums ensure that
                   3090: patches are only applied intentionally and that they don't accidentally change,
                   3091: e.g. when merging different changes together. They also make sure that new
                   3092: patches are actually added to CVS and old ones are removed. Too see whether the
                   3093: patches and the distinfo file match, run pkglint after changing the patches.
1.17      imil     3094: 
1.184     rillig   3095: To regenerate the distinfo file, use the make distinfo command.
1.17      imil     3096: 
1.184     rillig   3097: Some packages have different sets of distfiles depending on the platform, for
                   3098: example lang/openjdk8. These are kept in the same distinfo file and care should
                   3099: be taken when upgrading such a package to ensure distfile information is not
                   3100: lost.
1.17      imil     3101: 
1.184     rillig   3102: 12.3. patches/*
1.63      wiz      3103: 
1.184     rillig   3104: Some packages don't work out-of-the box on the various platforms that are
                   3105: supported by pkgsrc. These packages need to be patched to make them work. The
                   3106: patch files can be found in the patches/ directory.
1.17      imil     3107: 
1.184     rillig   3108: In the patch phase, these patches are applied to the files in WRKSRC directory
                   3109: after extracting them, in alphabetic order.
1.160     brook    3110: 
1.184     rillig   3111: 12.3.1. Structure of a single patch file
1.160     brook    3112: 
1.184     rillig   3113: The patch-* files should be in diff -bu format, and apply without a fuzz to
                   3114: avoid problems. (To force patches to apply with fuzz you can set
                   3115: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
                   3116: a single file, and no file should be patched by more than one patch file. This
                   3117: helps to keep future modifications simple.
1.160     brook    3118: 
1.184     rillig   3119: Each patch file is structured as follows: In the first line, there is the RCS
                   3120: Id of the patch itself. The second line should be empty for aesthetic reasons.
                   3121: After that, there should be a comment for each change that the patch does.
                   3122: There are a number of standard cases:
1.160     brook    3123: 
1.184     rillig   3124:   * Patches for commonly known vulnerabilities should mention the vulnerability
                   3125:     ID (CAN, CVE).
1.160     brook    3126: 
1.184     rillig   3127:   * Patches that change source code should mention the platform and other
                   3128:     environment (for example, the compiler) that the patch is needed for.
1.160     brook    3129: 
1.184     rillig   3130: The patch should be commented so that any developer who knows the code of the
                   3131: application can make some use of the patch. Special care should be taken for
                   3132: the upstream developers, since we generally want that they accept our patches,
                   3133: so we have less work in the future.
1.160     brook    3134: 
1.184     rillig   3135: 12.3.2. Creating patch files
1.160     brook    3136: 
1.184     rillig   3137: One important thing to mention is to pay attention that no RCS IDs get stored
                   3138: in the patch files, as these will cause problems when later checked into the
                   3139: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
                   3140: avoid these problems.
1.160     brook    3141: 
1.184     rillig   3142: For even more automation, we recommend using mkpatches from the same package to
                   3143: make a whole set of patches. You just have to backup files before you edit them
                   3144: to filename.orig, e.g. with cp -p filename filename.orig or, easier, by using 
                   3145: pkgvi again from the same package. If you upgrade a package this way, you can
                   3146: easily compare the new set of patches with the previously existing one with 
                   3147: patchdiff. The files in patches are replaced by new files, so carefully check
                   3148: if you want to take all the changes.
1.160     brook    3149: 
1.184     rillig   3150: When you have finished a package, remember to generate the checksums for the
                   3151: patch files by using the make makepatchsum command, see Section 12.2,
                   3152: "distinfo".
1.1       dsieger  3153: 
1.184     rillig   3154: When adding a patch that corrects a problem in the distfile (rather than e.g.
                   3155: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
                   3156: report to the maintainer. This benefits non-pkgsrc users of the package, and
                   3157: usually makes it possible to remove the patch in future version.
1.1       dsieger  3158: 
1.184     rillig   3159: The file names of the patch files are usually of the form patch-
                   3160: path_to_file__with__underscores.c. Many packages still use the previous
                   3161: convention patch-[a-z][a-z], but new patches should be of the form containing
                   3162: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
                   3163: automatically.
1.1       dsieger  3164: 
1.184     rillig   3165: 12.3.3. Sources where the patch files come from
1.1       dsieger  3166: 
1.184     rillig   3167: If you want to share patches between multiple packages in pkgsrc, e.g. because
                   3168: they use the same distfiles, set PATCHDIR to the path where the patch files can
                   3169: be found, e.g.:
1.1       dsieger  3170: 
1.184     rillig   3171: PATCHDIR=       ../../editors/xemacs/patches
1.1       dsieger  3172: 
1.184     rillig   3173: Patch files that are distributed by the author or other maintainers can be
                   3174: listed in PATCHFILES.
1.1       dsieger  3175: 
1.184     rillig   3176: If it is desired to store any patches that should not be committed into pkgsrc,
                   3177: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
                   3178: directory tree there is expected to have the same "category/package" structure
                   3179: as pkgsrc, and patches are expected to be stored inside these dirs (also known
                   3180: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
                   3181: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
                   3182: files in the named directory are expected to be patch files, and they are
                   3183: applied after pkgsrc patches are applied.
1.1       dsieger  3184: 
1.184     rillig   3185: 12.3.4. Patching guidelines
1.1       dsieger  3186: 
1.184     rillig   3187: When fixing a portability issue in the code do not use preprocessor magic to
                   3188: check for the current operating system nor platform. Doing so hurts portability
                   3189: to other platforms because the OS-specific details are not abstracted
                   3190: appropriately.
1.1       dsieger  3191: 
1.184     rillig   3192: The general rule to follow is: instead of checking for the operating system the
                   3193: application is being built on, check for the specific features you need. For
                   3194: example, instead of assuming that kqueue is available under NetBSD and using
                   3195: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
1.198     leot     3196: kqueue itself -- yes, this generally involves patching the configure script.
1.184     rillig   3197: There is absolutely nothing that prevents some OSes from adopting interfaces
                   3198: from other OSes (e.g. Linux implementing kqueue), something that the above
                   3199: checks cannot take into account.
1.1       dsieger  3200: 
1.184     rillig   3201: Of course, checking for features generally involves more work on the
                   3202: developer's side, but the resulting changes are cleaner and there are chances
                   3203: they will work on many other platforms. Not to mention that there are higher
                   3204: chances of being later integrated into the mainstream sources. Remember: It
                   3205: doesn't work unless it is right!
1.1       dsieger  3206: 
1.184     rillig   3207: Some typical examples:
1.121     sevan    3208: 
1.184     rillig   3209: Table 12.1. Patching examples
1.1       dsieger  3210: 
1.184     rillig   3211: +-------------------------------------------------------------------------------------------+
                   3212: |  Where  |        Incorrect         |                       Correct                        |
                   3213: |---------+--------------------------+------------------------------------------------------|
                   3214: |         |case ${target_os} in      |                                                      |
                   3215: |configure|netbsd*) have_kvm=yes ;;  |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
                   3216: |script   |*)       have_kvm=no  ;;  |                                                      |
                   3217: |         |esac                      |                                                      |
                   3218: |---------+--------------------------+------------------------------------------------------|
                   3219: |C source |#if defined(__NetBSD__)   |#if defined(HAVE_SYS_EVENT_H)                         |
                   3220: |file     |#  include <sys/event.h>  |#  include <sys/event.h>                              |
                   3221: |         |#endif                    |#endif                                                |
                   3222: |---------+--------------------------+------------------------------------------------------|
                   3223: |         |int                       |int                                                   |
                   3224: |         |monitor_file(...)         |monitor_file(...)                                     |
                   3225: |         |{                         |{                                                     |
                   3226: |         |#if defined(__NetBSD__)   |#if defined(HAVE_KQUEUE)                              |
                   3227: |C source |        int fd = kqueue();|        int fd = kqueue();                            |
                   3228: |file     |        ...               |        ...                                           |
                   3229: |         |#else                     |#else                                                 |
                   3230: |         |        ...               |        ...                                           |
                   3231: |         |#endif                    |#endif                                                |
                   3232: |         |}                         |}                                                     |
                   3233: +-------------------------------------------------------------------------------------------+
1.1       dsieger  3234: 
                   3235: 
1.184     rillig   3236: 12.3.5. Feedback to the author
1.1       dsieger  3237: 
1.184     rillig   3238: Always, always, always feed back any portability fixes or improvements you do
                   3239: to a package to the mainstream developers. This is the only way to get their
                   3240: attention on portability issues and to ensure that future versions can be built
                   3241: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
                   3242: get the fixes straight from the packaged code.
1.1       dsieger  3243: 
1.184     rillig   3244: This generally involves cleaning up the patches (because sometimes the patches
                   3245: that are added to pkgsrc are quick hacks), filing bug reports in the
                   3246: appropriate trackers for the projects and working with the mainstream authors
                   3247: to accept your changes. It is extremely important that you do it so that the
                   3248: packages in pkgsrc are kept simple and thus further changes can be done without
                   3249: much hassle.
1.1       dsieger  3250: 
1.184     rillig   3251: When you have done this, please add a URL to the upstream bug report to the
                   3252: patch comment.
1.1       dsieger  3253: 
1.184     rillig   3254: Support the idea of free software!
1.1       dsieger  3255: 
1.184     rillig   3256: 12.4. Other mandatory files
1.1       dsieger  3257: 
1.184     rillig   3258: DESCR
1.1       dsieger  3259: 
1.184     rillig   3260:     A multi-line description of the piece of software. This should include any
                   3261:     credits where they are due. Please bear in mind that others do not share
                   3262:     your sense of humour (or spelling idiosyncrasies), and that others will
                   3263:     read everything that you write here.
1.1       dsieger  3264: 
1.184     rillig   3265: PLIST
1.1       dsieger  3266: 
1.184     rillig   3267:     This file governs the files that are installed on your system: all the
                   3268:     binaries, manual pages, etc. There are other directives which may be
                   3269:     entered in this file, to control the creation and deletion of directories,
                   3270:     and the location of inserted files. See Chapter 19, PLIST issues for more
                   3271:     information.
1.1       dsieger  3272: 
1.184     rillig   3273: 12.5. Optional files
1.1       dsieger  3274: 
1.184     rillig   3275: 12.5.1. Files affecting the binary package
1.1       dsieger  3276: 
1.184     rillig   3277: INSTALL
1.1       dsieger  3278: 
1.184     rillig   3279:     This shell script is invoked twice by pkg_add(1). First time after package
                   3280:     extraction and before files are moved in place, the second time after the
                   3281:     files to install are moved in place. This can be used to do any custom
                   3282:     procedures not possible with @exec commands in PLIST. See pkg_add(1) and
                   3283:     pkg_create(1) for more information. See also Section 20.1, "Files and
                   3284:     directories outside the installation prefix". Please note that you can
                   3285:     modify variables in it easily by using FILES_SUBST in the package's
                   3286:     Makefile:
1.1       dsieger  3287: 
1.184     rillig   3288:     FILES_SUBST+=  SOMEVAR="somevalue"
1.1       dsieger  3289: 
1.184     rillig   3290:     replaces "@SOMEVAR@" with "somevalue" in the INSTALL. By default,
                   3291:     substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
                   3292:     few others, type make help topic=FILES_SUBST for a complete list.
1.1       dsieger  3293: 
1.184     rillig   3294: DEINSTALL
1.1       dsieger  3295: 
1.184     rillig   3296:     This script is executed before and after any files are removed. It is this
                   3297:     script's responsibility to clean up any additional messy details around the
                   3298:     package's installation, since all pkg_delete knows is how to delete the
                   3299:     files created in the original distribution. See pkg_delete(1) and
                   3300:     pkg_create(1) for more information. The same methods to replace variables
                   3301:     can be used as for the INSTALL file.
1.1       dsieger  3302: 
1.184     rillig   3303: MESSAGE
1.1       dsieger  3304: 
1.198     leot     3305:     This file is displayed after installation of the package. While this was
                   3306:     used often in the past, it has two problems: the display will be missed if
                   3307:     many packages are intalled at once, and the person installing the package
                   3308:     and the one using or configuring it may be different. It should therefore
                   3309:     be used only in exceptional circumstances where lasting negative
                   3310:     consequences would result from someone not reading it.
                   3311: 
                   3312:     MESSAGE should not be used for:
                   3313: 
                   3314:       + exhortations to read the documentation
                   3315: 
                   3316:       + reminders to install rc.d files and set variables
                   3317: 
                   3318:       + anything that should be explained in the installation/configuration
                   3319:         documentation that should come with the package
                   3320: 
                   3321:     If the documentation provided by upstream needs enhancing, create e.g.
                   3322:     files/README.pkgsrc and install it in the package's documentation
                   3323:     directory.
                   3324: 
                   3325:     Note that MESSAGE is shown for all operating systems and all init systems.
                   3326:     If a MESSAGE is necessary, it should be narrowed to only those operating
                   3327:     systems and init systems to which it applies.
                   3328: 
                   3329:     Note that you can modify variables in it easily by using MESSAGE_SUBST in
                   3330:     the package's Makefile:
1.1       dsieger  3331: 
1.184     rillig   3332:     MESSAGE_SUBST+=  SOMEVAR="somevalue"
1.1       dsieger  3333: 
1.184     rillig   3334:     replaces "${SOMEVAR}" with "somevalue" in MESSAGE. By default, substitution
                   3335:     is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11BASE,
                   3336:     PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1       dsieger  3337: 
1.184     rillig   3338:     You can display a different or additional files by setting the MESSAGE_SRC
                   3339:     variable. Its default is MESSAGE, if the file exists.
1.1       dsieger  3340: 
1.184     rillig   3341: ALTERNATIVES
1.1       dsieger  3342: 
1.184     rillig   3343:     This file is used by the alternatives framework. It creates, configures,
                   3344:     and destroys generic wrappers used to run programs with similar interfaces.
                   3345:     See pkg_alternatives(8) from pkgtools/pkg_alternatives for more
                   3346:     information.
1.1       dsieger  3347: 
1.184     rillig   3348:     Each line of the file contains two filenames, first the wrapper and then
                   3349:     the alternative provided by the package. Both paths are relative to PREFIX.
1.1       dsieger  3350: 
1.184     rillig   3351: 12.5.2. Files affecting the build process
1.1       dsieger  3352: 
1.184     rillig   3353: Makefile.common
1.1       dsieger  3354: 
1.184     rillig   3355:     This file contains arbitrary things that could also go into a Makefile, but
                   3356:     its purpose is to be used by more than one package. This file should only
                   3357:     be used when the packages that will use the file are known in advance. For
                   3358:     other purposes it is often better to write a *.mk file and give it a good
                   3359:     name that describes what it does.
1.1       dsieger  3360: 
1.184     rillig   3361: buildlink3.mk
1.1       dsieger  3362: 
1.184     rillig   3363:     This file contains the dependency information for the buildlink3 framework
                   3364:     (see Chapter 18, Buildlink methodology).
1.1       dsieger  3365: 
1.184     rillig   3366: hacks.mk
1.1       dsieger  3367: 
1.184     rillig   3368:     This file contains workarounds for compiler bugs and similar things. It is
                   3369:     included automatically by the pkgsrc infrastructure, so you don't need an
                   3370:     extra .include line for it.
1.1       dsieger  3371: 
1.184     rillig   3372: options.mk
1.1       dsieger  3373: 
1.184     rillig   3374:     This file contains the code for the package-specific options (see
                   3375:     Chapter 16, Options handling) that can be selected by the user. If a
                   3376:     package has only one or two options, it is equally acceptable to put the
                   3377:     code directly into the Makefile.
1.1       dsieger  3378: 
1.184     rillig   3379: 12.5.3. Files affecting nothing at all
1.1       dsieger  3380: 
1.184     rillig   3381: README*
1.1       dsieger  3382: 
1.184     rillig   3383:     These files do not take place in the creation of a package and thus are
                   3384:     purely informative to the package developer.
1.1       dsieger  3385: 
1.184     rillig   3386: TODO
1.1       dsieger  3387: 
1.184     rillig   3388:     This file contains things that need to be done to make the package even
                   3389:     better.
1.1       dsieger  3390: 
1.184     rillig   3391: 12.6. work*
1.1       dsieger  3392: 
1.184     rillig   3393: When you type make, the distribution files are unpacked into the directory
                   3394: denoted by WRKDIR. It can be removed by running make clean. Besides the
                   3395: sources, this directory is also used to keep various timestamp files. The
                   3396: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
                   3397: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
1.1       dsieger  3398: 
1.184     rillig   3399: 12.7. files/*
1.80      wiz      3400: 
1.184     rillig   3401: If you have any files that you wish to be placed in the package prior to
                   3402: configuration or building, you can place these files here and use a ${CP}
                   3403: command in the "post-extract" target to achieve this.
1.1       dsieger  3404: 
1.184     rillig   3405: If you want to share files in this way with other packages, set the FILESDIR
                   3406: variable to point to the other package's files directory, e.g.:
1.1       dsieger  3407: 
1.184     rillig   3408: FILESDIR=       ../../editors/xemacs/files
1.14      jmcneill 3409: 
1.184     rillig   3410: Chapter 13. The build process
1.1       dsieger  3411: 
1.184     rillig   3412: Table of Contents
1.1       dsieger  3413: 
1.184     rillig   3414: 13.1. Introduction
                   3415: 13.2. Program location
                   3416: 13.3. Directories used during the build process
                   3417: 13.4. Running a phase
                   3418: 13.5. The fetch phase
                   3419: 
                   3420:     13.5.1. What to fetch and where to get it from
                   3421:     13.5.2. How are the files fetched?
                   3422: 
                   3423: 13.6. The checksum phase
                   3424: 13.7. The extract phase
                   3425: 13.8. The patch phase
                   3426: 13.9. The tools phase
                   3427: 13.10. The wrapper phase
                   3428: 13.11. The configure phase
                   3429: 13.12. The build phase
                   3430: 13.13. The test phase
                   3431: 13.14. The install phase
                   3432: 13.15. The package phase
                   3433: 13.16. Cleaning up
                   3434: 13.17. Other helpful targets
1.1       dsieger  3435: 
1.184     rillig   3436: 13.1. Introduction
1.122     leot     3437: 
1.184     rillig   3438: This chapter gives a detailed description on how a package is built. Building a
                   3439: package is separated into different phases (for example fetch, build, install),
                   3440: all of which are described in the following sections. Each phase is split into
                   3441: so-called stages, which take the name of the containing phase, prefixed by one
                   3442: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
                   3443: actual work is done in the do-* stages.
1.1       dsieger  3444: 
1.184     rillig   3445: Never override the regular targets (like fetch), if you have to, override the
                   3446: do-* ones instead.
1.1       dsieger  3447: 
1.184     rillig   3448: The basic steps for building a program are always the same. First the program's
                   3449: source (distfile) must be brought to the local system and then extracted. After
                   3450: any pkgsrc-specific patches to compile properly are applied, the software can
                   3451: be configured, then built (usually by compiling), and finally the generated
                   3452: binaries, etc. can be put into place on the system.
1.1       dsieger  3453: 
1.184     rillig   3454: To get more details about what is happening at each step, you can set the
                   3455: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
                   3456: more details about the patch step.
1.1       dsieger  3457: 
1.184     rillig   3458: 13.2. Program location
1.1       dsieger  3459: 
1.184     rillig   3460: Before outlining the process performed by the NetBSD package system in the next
                   3461: section, here's a brief discussion on where programs are installed, and which
                   3462: variables influence this.
1.1       dsieger  3463: 
1.184     rillig   3464: The automatic variable PREFIX indicates where all files of the final program
                   3465: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
                   3466: pkgs in the cross category. The value of PREFIX needs to be put into the
                   3467: various places in the program's source where paths to these files are encoded.
                   3468: See Section 12.3, "patches/*" and Section 21.3.1, "Shared libraries - libtool"
                   3469: for more details.
1.1       dsieger  3470: 
1.184     rillig   3471: When choosing which of these variables to use, follow the following rules:
1.1       dsieger  3472: 
1.184     rillig   3473:   * PREFIX always points to the location where the current pkg will be
                   3474:     installed. When referring to a pkg's own installation path, use "${PREFIX}"
                   3475:     .
1.1       dsieger  3476: 
1.184     rillig   3477:   * LOCALBASE is where all non-X11 pkgs are installed. If you need to construct
                   3478:     a -I or -L argument to the compiler to find includes and libraries
                   3479:     installed by another non-X11 pkg, use "${LOCALBASE}". The name LOCALBASE
                   3480:     stems from FreeBSD, which installed all packages in /usr/local. As pkgsrc
                   3481:     leaves /usr/local for the system administrator, this variable is a
                   3482:     misnomer.
1.1       dsieger  3483: 
1.184     rillig   3484:   * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
                   3485:     installed. When looking for standard X11 includes (not those installed by a
                   3486:     package), use "${X11BASE}".
1.1       dsieger  3487: 
1.184     rillig   3488:   * X11-based packages using imake must set USE_IMAKE to be installed correctly
                   3489:     under LOCALBASE.
1.1       dsieger  3490: 
1.184     rillig   3491:   * Within ${PREFIX}, packages should install files according to hier(7), with
                   3492:     the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
                   3493:     man.
1.1       dsieger  3494: 
1.184     rillig   3495: 13.3. Directories used during the build process
1.2       rillig   3496: 
1.184     rillig   3497: When building a package, various directories are used to store source files,
                   3498: temporary files, pkgsrc-internal files, and so on. These directories are
                   3499: explained here.
1.1       dsieger  3500: 
1.184     rillig   3501: Some of the directory variables contain relative pathnames. There are two
                   3502: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
                   3503: used for directories that are pkgsrc-specific. WRKSRC is used for directories
                   3504: inside the package itself.
1.1       dsieger  3505: 
1.184     rillig   3506: PKGSRCDIR
1.1       dsieger  3507: 
1.184     rillig   3508:     This is an absolute pathname that points to the pkgsrc root directory.
                   3509:     Generally, you don't need it.
1.1       dsieger  3510: 
1.184     rillig   3511: PKGDIR
1.1       dsieger  3512: 
1.184     rillig   3513:     This is an absolute pathname that points to the current package.
1.1       dsieger  3514: 
1.184     rillig   3515: PKGPATH
1.1       dsieger  3516: 
1.184     rillig   3517:     This is a pathname relative to PKGSRCDIR that points to the current
                   3518:     package.
1.1       dsieger  3519: 
1.184     rillig   3520: WRKDIR
1.1       dsieger  3521: 
1.184     rillig   3522:     This is an absolute pathname pointing to the directory where all work takes
                   3523:     place. The distfiles are extracted to this directory. It also contains
                   3524:     temporary directories and log files used by the various pkgsrc frameworks,
                   3525:     like buildlink or the wrappers.
1.1       dsieger  3526: 
1.184     rillig   3527: WRKSRC
1.1       dsieger  3528: 
1.184     rillig   3529:     This is an absolute pathname pointing to the directory where the distfiles
                   3530:     are extracted. It is usually a direct subdirectory of WRKDIR, and often
                   3531:     it's the only directory entry that isn't hidden. This variable may be
                   3532:     changed by a package Makefile.
1.1       dsieger  3533: 
1.184     rillig   3534: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
                   3535: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
                   3536: created in the pkgsrc entry's directory. If users would like to have their
                   3537: pkgsrc trees behave in a read-only manner, then the value of
                   3538: CREATE_WRKDIR_SYMLINK should be set to no.
1.1       dsieger  3539: 
1.184     rillig   3540: 13.4. Running a phase
1.1       dsieger  3541: 
1.184     rillig   3542: You can run a particular phase by typing make phase, where phase is the name of
                   3543: the phase. This will automatically run all phases that are required for this
                   3544: phase. The default phase is build, that is, when you run make without
                   3545: parameters in a package directory, the package will be built, but not
                   3546: installed.
1.1       dsieger  3547: 
1.184     rillig   3548: 13.5. The fetch phase
1.1       dsieger  3549: 
1.184     rillig   3550: The first step in building a package is to fetch the distribution files
                   3551: (distfiles) from the sites that are providing them. This is the task of the 
                   3552: fetch phase.
1.25      wiz      3553: 
1.184     rillig   3554: 13.5.1. What to fetch and where to get it from
1.1       dsieger  3555: 
1.184     rillig   3556: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
                   3557: name is derived from the DISTNAME variable, is fetched. The more complicated
                   3558: cases are described below.
1.1       dsieger  3559: 
1.184     rillig   3560: The variable DISTFILES specifies the list of distfiles that have to be fetched.
                   3561: Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
                   3562: {EXTRACT_SUFX}, so that most packages don't need to define it at all.
                   3563: EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
                   3564: your package requires additional distfiles to the default one, you cannot just
                   3565: append the additional filenames using the += operator, but you have write for
                   3566: example:
1.1       dsieger  3567: 
1.184     rillig   3568: DISTFILES=      ${DEFAULT_DISTFILES} additional-files.tar.gz
1.1       dsieger  3569: 
1.184     rillig   3570: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
                   3571: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
                   3572: can set SITES.distfile to the list of URLs where the file distfile (including
                   3573: the suffix) can be found.
1.1       dsieger  3574: 
1.184     rillig   3575: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
                   3576: DISTFILES+=     foo-file.tar.gz
                   3577: SITES.foo-file.tar.gz= \
                   3578: https://www.somewhere.com/somehow/ \
                   3579: https://www.somewhereelse.com/mirror/somehow/
1.1       dsieger  3580: 
1.184     rillig   3581: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
                   3582: gets the name of each distfile appended to it, without an intermediate slash.
                   3583: Therefore, all site values have to end with a slash or other separator
                   3584: character. This allows for example to set MASTER_SITES to a URL of a CGI script
                   3585: that gets the name of the distfile as a parameter. In this case, the definition
                   3586: would look like:
1.1       dsieger  3587: 
1.184     rillig   3588: MASTER_SITES=   https://www.example.com/download.cgi?file=
1.1       dsieger  3589: 
1.184     rillig   3590: The exception to this rule are URLs starting with a dash. In that case the URL
                   3591: is taken as is, fetched and the result stored under the name of the distfile.
                   3592: You can use this style for the case when the download URL style does not match
                   3593: the above common case. For example, if permanent download URL is a redirector
                   3594: to the real download URL, or the download file name is offered by an HTTP
                   3595: Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
                   3596: created instead of the default v1.0.0.tar.gz.
1.1       dsieger  3597: 
1.184     rillig   3598: DISTNAME=       foo-1.0.0
                   3599: MASTER_SITES=   -https://www.example.com/archive/v1.0.0.tar.gz
1.29      wiz      3600: 
1.184     rillig   3601: There are some predefined values for MASTER_SITES, which can be used in
                   3602: packages. The names of the variables should speak for themselves.
1.29      wiz      3603: 
1.184     rillig   3604: MASTER_SITE_APACHE          MASTER_SITE_BACKUP
                   3605: MASTER_SITE_CRATESIO        MASTER_SITE_CYGWIN
                   3606: MASTER_SITE_DEBIAN          MASTER_SITE_FREEBSD
                   3607: MASTER_SITE_FREEBSD_LOCAL   MASTER_SITE_GENTOO
                   3608: MASTER_SITE_GITHUB          MASTER_SITE_GNOME
                   3609: MASTER_SITE_GNU             MASTER_SITE_GNUSTEP
                   3610: MASTER_SITE_HASKELL_HACKAGE MASTER_SITE_IFARCHIVE
                   3611: MASTER_SITE_KDE             MASTER_SITE_MOZILLA
                   3612: MASTER_SITE_MOZILLA_ALL     MASTER_SITE_MYSQL
                   3613: MASTER_SITE_NETLIB          MASTER_SITE_OPENBSD
                   3614: MASTER_SITE_OPENOFFICE      MASTER_SITE_OSDN
                   3615: MASTER_SITE_PERL_CPAN       MASTER_SITE_PGSQL
                   3616: MASTER_SITE_PYPI            MASTER_SITE_RUBYGEMS
                   3617: MASTER_SITE_R_CRAN          MASTER_SITE_SOURCEFORGE
                   3618: MASTER_SITE_SUNSITE         MASTER_SITE_SUSE
                   3619: MASTER_SITE_TEX_CTAN        MASTER_SITE_XCONTRIB
                   3620: MASTER_SITE_XEMACS          MASTER_SITE_XORG
1.1       dsieger  3621: 
1.184     rillig   3622: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
                   3623: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
                   3624: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
                   3625: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
                   3626: distfiles/LOCAL_PORTS/.
1.1       dsieger  3627: 
1.184     rillig   3628: If you choose one of these predefined sites, you may want to specify a
                   3629: subdirectory of that site. Since these macros may expand to more than one
                   3630: actual site, you must use the following construct to specify a subdirectory:
1.1       dsieger  3631: 
1.184     rillig   3632: MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
                   3633: MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
1.1       dsieger  3634: 
1.184     rillig   3635: Note the trailing slash after the subdirectory name.
1.1       dsieger  3636: 
1.184     rillig   3637: 13.5.2. How are the files fetched?
1.1       dsieger  3638: 
1.184     rillig   3639: The fetch phase makes sure that all the distfiles exist in a local directory
                   3640: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
                   3641: are fetched using commands of the form
1.1       dsieger  3642: 
1.184     rillig   3643: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
1.1       dsieger  3644: 
1.184     rillig   3645: where ${site} varies through several possibilities in turn: first,
                   3646: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
                   3647: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
                   3648: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
                   3649: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
                   3650: MASTER_SORT_AWK or MASTER_SORT_REGEX.
1.1       dsieger  3651: 
1.184     rillig   3652: The specific command and arguments used depend on the FETCH_USING parameter.
                   3653: The example above is for FETCH_USING=custom.
1.66      asau     3654: 
1.184     rillig   3655: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
                   3656: target to mirror the distfiles, if they are freely distributable. Packages
                   3657: setting NO_SRC_ON_FTP (usually to "${RESTRICTED}") will not have their
                   3658: distfiles mirrored.
1.1       dsieger  3659: 
1.184     rillig   3660: 13.6. The checksum phase
1.1       dsieger  3661: 
1.184     rillig   3662: After the distfile(s) are fetched, their checksum is generated and compared
                   3663: with the checksums stored in the distinfo file. If the checksums don't match,
                   3664: the build is aborted. This is to ensure the same distfile is used for building,
                   3665: and that the distfile wasn't changed, e.g. by some malign force, deliberately
                   3666: changed distfiles on the master distribution site or network lossage.
1.1       dsieger  3667: 
1.184     rillig   3668: 13.7. The extract phase
1.1       dsieger  3669: 
1.184     rillig   3670: When the distfiles are present on the local system, they need to be extracted,
                   3671: as they usually come in the form of some compressed archive format.
1.1       dsieger  3672: 
1.184     rillig   3673: By default, all DISTFILES are extracted. If you only need some of them, you can
                   3674: set the EXTRACT_ONLY variable to the list of those files.
1.1       dsieger  3675: 
1.184     rillig   3676: Extracting the files is usually done by a little program, mk/extract/extract,
                   3677: which already knows how to extract various archive formats, so most likely you
                   3678: will not need to change anything here. But if you need, the following variables
                   3679: may help you:
1.1       dsieger  3680: 
1.184     rillig   3681: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
1.1       dsieger  3682: 
1.184     rillig   3683:     Use these variables to override the default options for an extract command,
                   3684:     which are defined in mk/extract/extract.
1.1       dsieger  3685: 
1.184     rillig   3686: EXTRACT_USING
1.1       dsieger  3687: 
1.184     rillig   3688:     This variable can be set to bsdtar, gtar, nbtar (which is the default
                   3689:     value), pax, or an absolute pathname pointing to the command with which tar
                   3690:     archives should be extracted. It is preferred to choose bsdtar over gtar if
                   3691:     NetBSD's pax-as-tar is not good enough.
1.1       dsieger  3692: 
1.184     rillig   3693: If the extract program doesn't serve your needs, you can also override the
                   3694: EXTRACT_CMD variable, which holds the command used for extracting the files.
                   3695: This command is executed in the ${WRKSRC} directory. During execution of this
                   3696: command, the shell variable extract_file holds the absolute pathname of the
                   3697: file that is going to be extracted.
1.1       dsieger  3698: 
1.184     rillig   3699: And if that still does not suffice, you can override the do-extract target in
                   3700: the package Makefile.
1.1       dsieger  3701: 
1.184     rillig   3702: 13.8. The patch phase
1.1       dsieger  3703: 
1.184     rillig   3704: After extraction, all the patches named by the PATCHFILES, those present in the
                   3705: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
                   3706: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
                   3707: are uncompressed before they are applied, files ending in .orig or .rej are
                   3708: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
                   3709: Section 12.3, "patches/*" for more details.
1.1       dsieger  3710: 
1.184     rillig   3711: By default patch(1) is given special arguments to make it fail if the expected
                   3712: text from the patch context is not found in the patched file. If that happens,
                   3713: fix the patch file by comparing it with the actual text in the file to be
                   3714: patched.
1.1       dsieger  3715: 
1.184     rillig   3716: 13.9. The tools phase
1.1       dsieger  3717: 
1.184     rillig   3718: This is covered in Chapter 17, Tools needed for building or running.
1.1       dsieger  3719: 
1.184     rillig   3720: 13.10. The wrapper phase
1.1       dsieger  3721: 
1.184     rillig   3722: This phase creates wrapper programs for the compilers and linkers. The
                   3723: following variables can be used to tweak the wrappers.
1.1       dsieger  3724: 
1.184     rillig   3725: ECHO_WRAPPER_MSG
1.1       dsieger  3726: 
1.184     rillig   3727:     The command used to print progress messages. Does nothing by default. Set
                   3728:     to ${ECHO} to see the progress messages.
1.1       dsieger  3729: 
1.184     rillig   3730: WRAPPER_DEBUG
1.1       dsieger  3731: 
1.184     rillig   3732:     This variable can be set to yes (default) or no, depending on whether you
                   3733:     want additional information in the wrapper log file.
1.1       dsieger  3734: 
1.184     rillig   3735: WRAPPER_UPDATE_CACHE
1.1       dsieger  3736: 
1.184     rillig   3737:     This variable can be set to yes or no, depending on whether the wrapper
                   3738:     should use its cache, which will improve the speed. The default value is
                   3739:     yes, but is forced to no if the platform does not support it.
1.1       dsieger  3740: 
1.184     rillig   3741: WRAPPER_REORDER_CMDS
1.1       dsieger  3742: 
1.184     rillig   3743:     A list of reordering commands. A reordering command has the form reorder:l:
                   3744:     lib1:lib2. It ensures that that -llib1 occurs before -llib2.
1.1       dsieger  3745: 
1.184     rillig   3746: 13.11. The configure phase
1.1       dsieger  3747: 
1.184     rillig   3748: Most pieces of software need information on the header files, system calls, and
                   3749: library routines which are available on the platform they run on. The process
                   3750: of determining this information is known as configuration, and is usually
                   3751: automated. In most cases, a script is supplied with the distfiles, and its
                   3752: invocation results in generation of header files, Makefiles, etc.
1.1       dsieger  3753: 
1.184     rillig   3754: If the package contains a configure script, this can be invoked by setting
                   3755: HAS_CONFIGURE to "yes". If the configure script is a GNU autoconf script, you
1.187     rillig   3756: should set GNU_CONFIGURE to "yes" instead.
1.1       dsieger  3757: 
1.187     rillig   3758: In the do-configure stage, a rough equivalent of the following command is run.
                   3759: See mk/configure/configure.mk, target do-configure-script for the exact
                   3760: definition.
                   3761: 
                   3762: .for dir in ${CONFIGURE_DIRS}
                   3763:         cd ${WRKSRC} && cd ${dir} \
                   3764:         && env ${CONFIGURE_ENV} \
                   3765:             ${CONFIG_SHELL} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
1.184     rillig   3766: .endfor
1.1       dsieger  3767: 
1.184     rillig   3768: CONFIGURE_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In
                   3769: each of these directories, the configure script is run with the environment
                   3770: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
                   3771: CONFIGURE_SCRIPT (default: "./configure") and CONFIGURE_ARGS may all be changed
                   3772: by the package.
1.1       dsieger  3773: 
1.184     rillig   3774: If the program uses the Perl way of configuration (mainly Perl modules, but not
                   3775: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
                   3776: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
                   3777: (e.g., MAKE_PARAMS+=foo=bar
1.1       dsieger  3778: 
1.184     rillig   3779: If the program uses an Imakefile for configuration, the appropriate steps can
                   3780: be invoked by setting USE_IMAKE to "yes". If you only need xmkmf, add it to
                   3781: USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
                   3782: SCRIPTS_ENV variable.
1.1       dsieger  3783: 
1.184     rillig   3784: If the program uses cmake for configuration, the appropriate steps can be
                   3785: invoked by setting USE_CMAKE to "yes". You can add variables to cmake's
                   3786: environment by adding them to the CONFIGURE_ENV variable and arguments to cmake
                   3787: by adding them to the CMAKE_ARGS variable. The top directory argument is given
                   3788: by the CMAKE_ARG_PATH variable, that defaults to "." (relative to
                   3789: CONFIGURE_DIRS)
1.1       dsieger  3790: 
1.184     rillig   3791: If there is no configure step at all, set NO_CONFIGURE to "yes".
1.1       dsieger  3792: 
1.184     rillig   3793: 13.12. The build phase
1.1       dsieger  3794: 
1.187     rillig   3795: For building a package, a rough equivalent of the following code is executed;
                   3796: see mk/build/build.mk, target do-build for the exact definition.
1.154     rillig   3797: 
1.187     rillig   3798: .for dir in ${BUILD_DIRS}
                   3799:         cd ${WRKSRC} && cd ${dir} \
1.184     rillig   3800:         && env ${MAKE_ENV} \
1.187     rillig   3801:             ${MAKE_PROGRAM} ${MAKE_FLAGS} ${BUILD_MAKE_FLAGS} \
1.184     rillig   3802:                 -f ${MAKE_FILE} \
                   3803:                 ${BUILD_TARGET}
                   3804: .endfor
1.1       dsieger  3805: 
1.184     rillig   3806: BUILD_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In each of
                   3807: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
                   3808: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
                   3809: and BUILD_TARGET may all be changed by the package.
1.1       dsieger  3810: 
1.184     rillig   3811: The default value of MAKE_PROGRAM is "gmake" if USE_TOOLS contains "gmake", "
                   3812: make" otherwise. The default value of MAKE_FILE is "Makefile", and BUILD_TARGET
                   3813: defaults to "all".
1.1       dsieger  3814: 
1.184     rillig   3815: If there is no build step at all, set NO_BUILD to "yes".
1.1       dsieger  3816: 
1.184     rillig   3817: 13.13. The test phase
1.1       dsieger  3818: 
1.184     rillig   3819: [TODO]
1.1       dsieger  3820: 
1.184     rillig   3821: 13.14. The install phase
1.1       dsieger  3822: 
1.184     rillig   3823: Once the build stage has completed, the final step is to install the software
                   3824: in public directories, so users can access the programs and files.
1.1       dsieger  3825: 
1.187     rillig   3826: In the install phase, a rough equivalent of the following code is executed; see
                   3827: mk/install/install.mk, target do-install for the exact definition.
                   3828: Additionally, before and after this code, several consistency checks are run
                   3829: against the files-to-be-installed, see mk/check/*.mk for details.
                   3830: 
                   3831: .for dir in ${INSTALL_DIRS}
                   3832:         cd ${WRKSRC} && cd ${dir} \
                   3833:         && env ${INSTALL_ENV} ${MAKE_ENV} \
                   3834:             ${MAKE_PROGRAM} ${MAKE_FLAGS} ${INSTALL_MAKE_FLAGS} \
                   3835:                 -f ${MAKE_FILE} ${INSTALL_TARGET}
1.184     rillig   3836: .endfor
1.1       dsieger  3837: 
1.184     rillig   3838: The variable's meanings are analogous to the ones in the build phase.
                   3839: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is "install" by default,
                   3840: plus "install.man" if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
                   3841: defined.
1.1       dsieger  3842: 
1.184     rillig   3843: In the install phase, the following variables are useful. They are all
                   3844: variations of the install(1) command that have the owner, group and permissions
                   3845: preset. INSTALL is the plain install command. The specialized variants,
                   3846: together with their intended use, are:
1.1       dsieger  3847: 
1.184     rillig   3848: INSTALL_PROGRAM_DIR
1.1       dsieger  3849: 
1.184     rillig   3850:     directories that contain binaries
1.1       dsieger  3851: 
1.184     rillig   3852: INSTALL_SCRIPT_DIR
1.1       dsieger  3853: 
1.184     rillig   3854:     directories that contain scripts
1.1       dsieger  3855: 
1.184     rillig   3856: INSTALL_LIB_DIR
1.1       dsieger  3857: 
1.184     rillig   3858:     directories that contain shared and static libraries
1.1       dsieger  3859: 
1.184     rillig   3860: INSTALL_DATA_DIR
1.108     rillig   3861: 
1.184     rillig   3862:     directories that contain data files
1.108     rillig   3863: 
1.184     rillig   3864: INSTALL_MAN_DIR
1.108     rillig   3865: 
1.184     rillig   3866:     directories that contain man pages
1.108     rillig   3867: 
1.184     rillig   3868: INSTALL_GAME_DIR
1.108     rillig   3869: 
1.184     rillig   3870:     directories that contain data files for games
1.108     rillig   3871: 
1.184     rillig   3872: INSTALL_PROGRAM
1.108     rillig   3873: 
1.184     rillig   3874:     binaries that can be stripped from debugging symbols
1.108     rillig   3875: 
1.184     rillig   3876: INSTALL_SCRIPT
1.108     rillig   3877: 
1.184     rillig   3878:     binaries that cannot be stripped
1.108     rillig   3879: 
1.184     rillig   3880: INSTALL_GAME
1.108     rillig   3881: 
1.184     rillig   3882:     game binaries
1.108     rillig   3883: 
1.184     rillig   3884: INSTALL_LIB
1.108     rillig   3885: 
1.184     rillig   3886:     shared and static libraries
1.108     rillig   3887: 
1.184     rillig   3888: INSTALL_DATA
1.108     rillig   3889: 
1.184     rillig   3890:     data files
1.1       dsieger  3891: 
1.184     rillig   3892: INSTALL_GAME_DATA
1.1       dsieger  3893: 
1.184     rillig   3894:     data files for games
1.108     rillig   3895: 
1.184     rillig   3896: INSTALL_MAN
1.108     rillig   3897: 
1.184     rillig   3898:     man pages
1.1       dsieger  3899: 
1.184     rillig   3900: Some other variables are:
1.1       dsieger  3901: 
1.184     rillig   3902: INSTALL_UNSTRIPPED
1.1       dsieger  3903: 
1.184     rillig   3904:     If set to yes, do not run strip(1) when installing binaries. Any debugging
                   3905:     sections and symbols present in binaries will be preserved.
1.1       dsieger  3906: 
1.184     rillig   3907: INSTALLATION_DIRS
1.1       dsieger  3908: 
1.184     rillig   3909:     A list of directories relative to PREFIX that are created by pkgsrc at the
                   3910:     beginning of the install phase. The package is supposed to create all
                   3911:     needed directories itself before installing files to it and list all other
                   3912:     directories here.
1.1       dsieger  3913: 
1.184     rillig   3914: In the rare cases that a package shouldn't install anything, set NO_INSTALL to 
                   3915: "yes". This is mostly relevant for packages in the regress category.
1.1       dsieger  3916: 
1.184     rillig   3917: 13.15. The package phase
1.121     sevan    3918: 
1.184     rillig   3919: Once the install stage has completed, a binary package of the installed files
                   3920: can be built. These binary packages can be used for quick installation without
                   3921: previous compilation, e.g. by the make bin-install or by using pkg_add.
1.1       dsieger  3922: 
1.184     rillig   3923: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
                   3924: created in ${PACKAGES}/category, one for each category in the CATEGORIES
                   3925: variable. PACKAGES defaults to pkgsrc/packages.
1.1       dsieger  3926: 
1.184     rillig   3927: 13.16. Cleaning up
1.1       dsieger  3928: 
1.184     rillig   3929: Once you're finished with a package, you can clean the work directory by
                   3930: running make clean. If you want to clean the work directories of all
                   3931: dependencies too, use make clean-depends.
1.1       dsieger  3932: 
1.184     rillig   3933: 13.17. Other helpful targets
1.1       dsieger  3934: 
1.184     rillig   3935: pre/post-*
1.1       dsieger  3936: 
1.184     rillig   3937:     For any of the main targets described in the previous section (configure,
                   3938:     build, install, etc.), two auxiliary targets exist with "pre-" and "post-"
                   3939:     used as a prefix for the main target's name. These targets are invoked
                   3940:     before and after the main target is called, allowing extra configuration or
                   3941:     installation steps be performed from a package's Makefile, for example,
                   3942:     which a program's configure script or install target omitted.
                   3943: 
                   3944:     About 5% of the pkgsrc packages define their custom post-extract target,
                   3945:     another 5% define pre-configure, and 10% define post-install. The other pre
                   3946:     /post-* targets are defined even less often.
1.1       dsieger  3947: 
1.184     rillig   3948: do-*
1.182     leot     3949: 
1.184     rillig   3950:     Should one of the main targets do the wrong thing, and should there be no
                   3951:     variable to fix this, you can redefine it with the do-* target. (Note that
                   3952:     redefining the target itself instead of the do-* target is a bad idea, as
                   3953:     the pre-* and post-* targets won't be called anymore, etc.)
1.1       dsieger  3954: 
1.184     rillig   3955:     About 15% of the pkgsrc packages override the default do-install, the other
                   3956:     do-* targets are overridden even less often.
1.1       dsieger  3957: 
1.184     rillig   3958: reinstall
1.1       dsieger  3959: 
1.184     rillig   3960:     If you did a make install and you noticed some file was not installed
                   3961:     properly, you can repeat the installation with this target, which will
                   3962:     ignore the "already installed" flag.
1.1       dsieger  3963: 
1.184     rillig   3964:     This is the default value of DEPENDS_TARGET except in the case of make
                   3965:     update and make package, where the defaults are "package" and "update",
                   3966:     respectively.
1.1       dsieger  3967: 
1.184     rillig   3968: deinstall
1.1       dsieger  3969: 
1.184     rillig   3970:     This target does a pkg_delete(1) in the current directory, effectively
                   3971:     de-installing the package. The following variables can be used to tune the
                   3972:     behaviour:
1.1       dsieger  3973: 
1.184     rillig   3974:     PKG_VERBOSE
1.1       dsieger  3975: 
1.184     rillig   3976:         Add a "-v" to the pkg_delete(1) command.
1.1       dsieger  3977: 
1.184     rillig   3978:     DEINSTALLDEPENDS
1.1       dsieger  3979: 
1.184     rillig   3980:         Remove all packages that require (depend on) the given package. This
                   3981:         can be used to remove any packages that may have been pulled in by a
                   3982:         given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
                   3983:         pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding "-R
                   3984:         " to the pkg_delete(1) command line.
1.1       dsieger  3985: 
1.184     rillig   3986: bin-install
1.1       dsieger  3987: 
1.184     rillig   3988:     Install a binary package from local disk and via FTP from a list of sites
                   3989:     (see the BINPKG_SITES variable), and do a make package if no binary package
                   3990:     is available anywhere. The arguments given to pkg_add can be set via
                   3991:     BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
1.1       dsieger  3992: 
1.184     rillig   3993: install-clean
1.1       dsieger  3994: 
1.184     rillig   3995:     This target removes the state files for the "install" and later phases so
                   3996:     that the "install" target may be re-invoked. This can be used after editing
                   3997:     the PLIST to install the package without rebuilding it.
1.1       dsieger  3998: 
1.184     rillig   3999: build-clean
1.18      mishka   4000: 
1.184     rillig   4001:     This target removes the state files for the "build" and later phases so
                   4002:     that the "build" target may be re-invoked.
1.18      mishka   4003: 
1.184     rillig   4004: update
1.18      mishka   4005: 
1.184     rillig   4006:     This target causes the current package to be updated to the latest version.
                   4007:     The package and all depending packages first get de-installed, then current
                   4008:     versions of the corresponding packages get compiled and installed. This is
                   4009:     similar to manually noting which packages are currently installed, then
                   4010:     performing a series of make deinstall and make install (or whatever
                   4011:     UPDATE_TARGET is set to) for these packages.
1.18      mishka   4012: 
1.184     rillig   4013:     You can use the "update" target to resume package updating in case a
                   4014:     previous make update was interrupted for some reason. However, in this
                   4015:     case, make sure you don't call make clean or otherwise remove the list of
                   4016:     dependent packages in WRKDIR. Otherwise, you lose the ability to
                   4017:     automatically update the current package along with the dependent packages
                   4018:     you have installed.
1.121     sevan    4019: 
1.184     rillig   4020:     Resuming an interrupted make update will only work as long as the package
                   4021:     tree remains unchanged. If the source code for one of the packages to be
                   4022:     updated has been changed, resuming make update will most certainly fail!
1.1       dsieger  4023: 
1.184     rillig   4024:     The following variables can be used either on the command line or in
                   4025:     mk.conf to alter the behaviour of make update:
1.1       dsieger  4026: 
1.184     rillig   4027:     UPDATE_TARGET
1.1       dsieger  4028: 
1.184     rillig   4029:         Install target to recursively use for the updated package and the
                   4030:         dependent packages. Defaults to DEPENDS_TARGET if set, "install"
                   4031:         otherwise for make update. Other good targets are "package" or "
                   4032:         bin-install". Do not set this to "update" or you will get stuck in an
                   4033:         endless loop!
1.1       dsieger  4034: 
1.184     rillig   4035:     NOCLEAN
1.1       dsieger  4036: 
1.184     rillig   4037:         Don't clean up after updating. Useful if you want to leave the work
                   4038:         sources of the updated packages around for inspection or other
                   4039:         purposes. Be sure you eventually clean up the source tree (see the "
                   4040:         clean-update" target below) or you may run into troubles with old
                   4041:         source code still lying around on your next make or make update.
1.1       dsieger  4042: 
1.184     rillig   4043:     REINSTALL
1.1       dsieger  4044: 
1.184     rillig   4045:         Deinstall each package before installing (making DEPENDS_TARGET). This
                   4046:         may be necessary if the "clean-update" target (see below) was called
                   4047:         after interrupting a running make update.
1.1       dsieger  4048: 
1.184     rillig   4049:     DEPENDS_TARGET
1.1       dsieger  4050: 
1.184     rillig   4051:         Allows you to disable recursion and hardcode the target for packages.
                   4052:         The default is "update" for the update target, facilitating a recursive
                   4053:         update of prerequisite packages. Only set DEPENDS_TARGET if you want to
                   4054:         disable recursive updates. Use UPDATE_TARGET instead to just set a
                   4055:         specific target for each package to be installed during make update
                   4056:         (see above).
1.1       dsieger  4057: 
1.184     rillig   4058: clean-update
1.1       dsieger  4059: 
1.184     rillig   4060:     Clean the source tree for all packages that would get updated if make
                   4061:     update was called from the current directory. This target should not be
                   4062:     used if the current package (or any of its depending packages) have already
                   4063:     been de-installed (e.g., after calling make update) or you may lose some
                   4064:     packages you intended to update. As a rule of thumb: only use this target 
                   4065:     before the first time you run make update and only if you have a dirty
                   4066:     package tree (e.g., if you used NOCLEAN).
1.86      wiz      4067: 
1.184     rillig   4068:     If you are unsure about whether your tree is clean, you can either perform
                   4069:     a make clean at the top of the tree, or use the following sequence of
                   4070:     commands from the directory of the package you want to update (before
                   4071:     running make update for the first time, otherwise you lose all the packages
                   4072:     you wanted to update!):
1.86      wiz      4073: 
1.184     rillig   4074:     # make clean-update
                   4075:     # make clean CLEANDEPENDS=YES
                   4076:     # make update
1.86      wiz      4077: 
                   4078: 
1.184     rillig   4079:     The following variables can be used either on the command line or in
                   4080:     mk.conf to alter the behaviour of make clean-update:
1.86      wiz      4081: 
1.184     rillig   4082:     CLEAR_DIRLIST
1.86      wiz      4083: 
1.184     rillig   4084:         After make clean, do not reconstruct the list of directories to update
                   4085:         for this package. Only use this if make update successfully installed
                   4086:         all packages you wanted to update. Normally, this is done automatically
                   4087:         on make update, but may have been suppressed by the NOCLEAN variable
                   4088:         (see above).
1.1       dsieger  4089: 
1.184     rillig   4090: replace
1.1       dsieger  4091: 
1.184     rillig   4092:     Update the installation of the current package. This differs from update in
                   4093:     that it does not replace dependent packages. You will need to install
                   4094:     pkgtools/pkg_tarup for this target to work.
1.1       dsieger  4095: 
1.184     rillig   4096:     Be careful when using this target! There are no guarantees that dependent
                   4097:     packages will still work, in particular they will most certainly break if
                   4098:     you make replace a library package whose shared library major version
                   4099:     changed between your installed version and the new one. For this reason,
                   4100:     this target is not officially supported and only recommended for advanced
                   4101:     users.
1.1       dsieger  4102: 
1.184     rillig   4103: info
1.1       dsieger  4104: 
1.184     rillig   4105:     This target invokes pkg_info(1) for the current package. You can use this
                   4106:     to check which version of a package is installed.
1.86      wiz      4107: 
1.184     rillig   4108: index
1.1       dsieger  4109: 
1.184     rillig   4110:     This is a top-level command, i.e. it should be used in the pkgsrc
                   4111:     directory. It creates a database of all packages in the local pkgsrc tree,
                   4112:     including dependencies, comment, maintainer, and some other useful
                   4113:     information. Individual entries are created by running make describe in the
                   4114:     packages' directories. This index file is saved as pkgsrc/INDEX. It can be
                   4115:     displayed in verbose format by running make print-index. You can search in
                   4116:     it with make search key=something. You can extract a list of all packages
                   4117:     that depend on a particular one by running make show-deps PKG=somepackage.
1.1       dsieger  4118: 
1.184     rillig   4119:     Running this command takes a very long time, some hours even on fast
                   4120:     machines!
1.1       dsieger  4121: 
1.184     rillig   4122: readme
1.1       dsieger  4123: 
1.199     nia      4124:     This target generates a index.html file, which can be viewed using a
1.184     rillig   4125:     browser such as www/firefox or www/links. The generated files contain
                   4126:     references to any packages which are in the PACKAGES directory on the local
                   4127:     host. The generated files can be made to refer to URLs based on
                   4128:     FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
1.199     nia      4129:     index.html files which pointed to binary packages on the local machine, in
1.184     rillig   4130:     the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
                   4131:     FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
                   4132:     subdirectories will be searched for all the binary packages.
1.1       dsieger  4133: 
1.184     rillig   4134:     The target can be run at the toplevel or in category directories, in which
                   4135:     case it descends recursively.
1.1       dsieger  4136: 
1.184     rillig   4137: readme-all
1.1       dsieger  4138: 
1.184     rillig   4139:     This is a top-level command, run it in pkgsrc. Use this target to create a
                   4140:     file README-all.html which contains a list of all packages currently
                   4141:     available in the NetBSD Packages Collection, together with the category
                   4142:     they belong to and a short description. This file is compiled from the
1.199     nia      4143:     pkgsrc/*/index.html files, so be sure to run this after a make readme.
1.1       dsieger  4144: 
1.184     rillig   4145: cdrom-readme
1.1       dsieger  4146: 
1.184     rillig   4147:     This is very much the same as the "readme" target (see above), but is to be
                   4148:     used when generating a pkgsrc tree to be written to a CD-ROM. This target
1.199     nia      4149:     also produces index.html files, and can be made to refer to URLs based on
1.184     rillig   4150:     CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
1.1       dsieger  4151: 
1.184     rillig   4152: show-distfiles
1.1       dsieger  4153: 
1.184     rillig   4154:     This target shows which distfiles and patchfiles are needed to build the
                   4155:     package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
                   4156:     patches/*).
1.1       dsieger  4157: 
1.184     rillig   4158: show-downlevel
1.1       dsieger  4159: 
1.184     rillig   4160:     This target shows nothing if the package is not installed. If a version of
                   4161:     this package is installed, but is not the version provided in this version
                   4162:     of pkgsrc, then a warning message is displayed. This target can be used to
                   4163:     show which of your installed packages are downlevel, and so the old
                   4164:     versions can be deleted, and the current ones added.
1.1       dsieger  4165: 
1.184     rillig   4166: show-pkgsrc-dir
1.1       dsieger  4167: 
1.184     rillig   4168:     This target shows the directory in the pkgsrc hierarchy from which the
                   4169:     package can be built and installed. This may not be the same directory as
                   4170:     the one from which the package was installed. This target is intended to be
                   4171:     used by people who may wish to upgrade many packages on a single host, and
                   4172:     can be invoked from the top-level pkgsrc Makefile by using the "
                   4173:     show-host-specific-pkgs" target.
1.1       dsieger  4174: 
1.184     rillig   4175: show-installed-depends
1.1       dsieger  4176: 
1.184     rillig   4177:     This target shows which installed packages match the current package's
                   4178:     DEPENDS. Useful if out of date dependencies are causing build problems.
1.1       dsieger  4179: 
1.184     rillig   4180: print-build-depends-list
1.1       dsieger  4181: 
1.184     rillig   4182:     This target shows the list of packages that the current package depends on
                   4183:     for building.
1.1       dsieger  4184: 
1.184     rillig   4185: print-run-depends-list
1.1       dsieger  4186: 
1.184     rillig   4187:     This target shows the list of packages that the current package depends on
                   4188:     for running.
1.1       dsieger  4189: 
1.184     rillig   4190: check-shlibs
1.1       dsieger  4191: 
1.184     rillig   4192:     After a package is installed, check all its binaries and (on ELF platforms)
                   4193:     shared libraries to see if they find the shared libs they need. Run by
                   4194:     default if PKG_DEVELOPER is set in mk.conf.
1.1       dsieger  4195: 
1.184     rillig   4196: print-PLIST
1.1       dsieger  4197: 
1.184     rillig   4198:     After a "make install" from a new or upgraded pkg, this prints out an
                   4199:     attempt to generate a new PLIST from a find -newer work/.extract_done. An
                   4200:     attempt is made to care for shared libs etc., but it is strongly
                   4201:     recommended to review the result before putting it into PLIST. On upgrades,
                   4202:     it's useful to diff the output of this command against an already existing
                   4203:     PLIST file.
1.1       dsieger  4204: 
1.184     rillig   4205:     If the package installs files via tar(1) or other methods that don't update
                   4206:     file access times, be sure to add these files manually to your PLIST, as
                   4207:     the "find -newer" command used by this target won't catch them!
1.56      ryoon    4208: 
1.184     rillig   4209:     See Section 19.3, "Tweaking output of make print-PLIST" for more
                   4210:     information on this target.
1.1       dsieger  4211: 
1.184     rillig   4212: Chapter 14. Creating a new pkgsrc package from scratch
1.1       dsieger  4213: 
1.184     rillig   4214: Table of Contents
1.1       dsieger  4215: 
1.184     rillig   4216: 14.1. Common types of packages
1.1       dsieger  4217: 
1.184     rillig   4218:     14.1.1. Perl modules
                   4219:     14.1.2. Python modules and programs
                   4220:     14.1.3. R packages
                   4221:     14.1.4. TeXlive packages
1.1       dsieger  4222: 
1.184     rillig   4223: 14.2. Examples
1.1       dsieger  4224: 
1.184     rillig   4225:     14.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  4226: 
1.184     rillig   4227: When you find a package that is not yet in pkgsrc, you most likely have a URL
                   4228: from where you can download the source code. Starting with this URL, creating a
                   4229: package involves only a few steps.
1.1       dsieger  4230: 
1.184     rillig   4231:  1. In your mk.conf, set PKG_DEVELOPER=yes to enable the basic quality checks.
1.1       dsieger  4232: 
1.184     rillig   4233:  2. Install the package meta-pkgs/pkg_developer, which among others will
                   4234:     install the utilities url2pkg, pkglint, pkgvi and mkpatches:
1.1       dsieger  4235: 
1.184     rillig   4236:     $ cd /usr/pkgsrc
                   4237:     $ (cd meta-pkgs/pkg_developer && bmake update)
1.1       dsieger  4238: 
1.184     rillig   4239:  3. Choose one of the top-level directories as the category in which you want
                   4240:     to place your package. You can also create a directory of your own (maybe
                   4241:     called local). In that category directory, create another directory for
                   4242:     your package and change into it:
1.1       dsieger  4243: 
1.184     rillig   4244:     $ mkdir category/package
                   4245:     $ cd category/package
1.1       dsieger  4246: 
1.184     rillig   4247:  4. Run the program url2pkg, which will ask you for a URL. Enter the URL of the
                   4248:     distribution file (in most cases a .tar.gz file) and watch how the basic
                   4249:     ingredients of your package are created automatically. The distribution
                   4250:     file is extracted automatically to fill in some details in the Makefile
                   4251:     that would otherwise have to be done manually:
1.1       dsieger  4252: 
1.184     rillig   4253:     $ url2pkg https://www.example.org/packages/package-1.0.tar.gz
1.1       dsieger  4254: 
1.184     rillig   4255:  5. Examine the extracted files to determine the dependencies of your package.
                   4256:     Ideally, this is mentioned in some README file, but things may differ. For
                   4257:     each of these dependencies, look where it exists in pkgsrc, and if there is
                   4258:     a file called buildlink3.mk in that directory, add a line to your package
                   4259:     Makefile which includes that file just before the last line. If the
                   4260:     buildlink3.mk file does not exist, it must be created first. The
                   4261:     buildlink3.mk file makes sure that the package's include files and
                   4262:     libraries are provided.
1.1       dsieger  4263: 
1.184     rillig   4264:     If you just need binaries from a package, add a DEPENDS line to the
                   4265:     Makefile, which specifies the version of the dependency and where it can be
                   4266:     found in pkgsrc. This line should be placed in the third paragraph. If the
                   4267:     dependency is only needed for building the package, but not when using it,
                   4268:     use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The difference
                   4269:     between TOOL_DEPENDS and BUILD_DEPENDS occurs when cross-compiling:
                   4270:     TOOL_DEPENDS are native packages, i.e. packages for the architecture where
                   4271:     the package is built; BUILD_DEPENDS are target packages, i.e. packages for
                   4272:     the architecture for which the package is built. There is also
                   4273:     TEST_DEPENDS, which is used to specify a dependency used only for testing
                   4274:     the resulting package built, using the upstream project's included test
                   4275:     suite. Your package may then look like this:
1.1       dsieger  4276: 
1.184     rillig   4277:     [...]
1.1       dsieger  4278: 
1.184     rillig   4279:     TOOL_DEPENDS+=  libxslt-[0-9]*:../../textproc/libxslt
                   4280:     DEPENDS+=       screen-[0-9]*:../../misc/screen
                   4281:     DEPENDS+=       screen>=4.0:../../misc/screen
1.1       dsieger  4282: 
1.184     rillig   4283:     [...]
1.1       dsieger  4284: 
1.184     rillig   4285:     .include "../../category/package/buildlink3.mk"
                   4286:     .include "../../devel/glib2/buildlink3.mk"
                   4287:     .include "../../mk/bsd.pkg.mk"
1.1       dsieger  4288: 
1.184     rillig   4289:  6. Run pkglint to see what things still need to be done to make your package a
                   4290:     "good" one. If you don't know what pkglint's warnings want to tell you, try
                   4291:     pkglint --explain or pkglint -e, which outputs additional explanations.
1.1       dsieger  4292: 
1.184     rillig   4293:  7. In many cases the package is not yet ready to build. You can find
                   4294:     instructions for the most common cases in the next section, Section 14.1,
                   4295:     "Common types of packages". After you have followed the instructions over
                   4296:     there, you can hopefully continue here.
1.1       dsieger  4297: 
1.184     rillig   4298:  8. Run bmake clean to clean the working directory from the extracted files.
                   4299:     Besides these files, a lot of cache files and other system information has
                   4300:     been saved in the working directory, which may become wrong after you
                   4301:     edited the Makefile.
1.1       dsieger  4302: 
1.184     rillig   4303:  9. Now, run bmake to build the package. For the various things that can go
                   4304:     wrong in this phase, consult Chapter 21, Making your package work.
1.1       dsieger  4305: 
1.184     rillig   4306:     If the extracted files from the package need to be fixed, run multiple
                   4307:     rounds of these commands:
1.1       dsieger  4308: 
1.184     rillig   4309:     $ make
                   4310:     $ pkgvi ${WRKSRC}/some/file/that/does/not/compile
                   4311:     $ mkpatches
                   4312:     $ make mps
                   4313:     $ make clean
1.1       dsieger  4314: 
1.184     rillig   4315: 10. When the package builds fine, the next step is to install the package. Run 
                   4316:     bmake install and hope that everything works.
1.1       dsieger  4317: 
1.184     rillig   4318: 11. Up to now, the file PLIST, which contains a list of the files that are
                   4319:     installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
                   4320:     generate a probably correct list. Check the file using your preferred text
                   4321:     editor to see if the list of files looks plausible.
1.1       dsieger  4322: 
1.184     rillig   4323: 12. Run pkglint again to see if the generated PLIST contains garbage or not.
1.1       dsieger  4324: 
1.184     rillig   4325: 13. When you ran bmake install, the package had been registered in the database
                   4326:     of installed files, but with an empty list of files. To fix this, run bmake
                   4327:     deinstall and bmake install again. Now the package is registered with the
                   4328:     list of files from PLIST.
1.48      wiz      4329: 
1.184     rillig   4330: 14. Run bmake package to create a binary package from the set of installed
                   4331:     files.
1.48      wiz      4332: 
1.184     rillig   4333: 15. Run bmake clean update to run everything from above again in a single step,
                   4334:     making sure that the PLIST is correct and the whole package is created as
                   4335:     intended.
1.48      wiz      4336: 
1.184     rillig   4337: 16. Run pkglint to see if there's anything left to do.
1.48      wiz      4338: 
1.184     rillig   4339: 17. Commit the package to pkgsrc-wip or main pkgsrc; see Chapter 23, Submitting
                   4340:     and Committing.
1.50      wiz      4341: 
1.184     rillig   4342: 14.1. Common types of packages
1.1       dsieger  4343: 
1.184     rillig   4344: 14.1.1. Perl modules
1.1       dsieger  4345: 
1.184     rillig   4346: Simple Perl modules are handled automatically by url2pkg, including
                   4347: dependencies.
1.1       dsieger  4348: 
1.184     rillig   4349: 14.1.2. Python modules and programs
1.1       dsieger  4350: 
1.184     rillig   4351: Python modules and programs packages are easily created using a set of
                   4352: predefined variables.
1.1       dsieger  4353: 
1.184     rillig   4354: If some Python versions are not supported by the software, set the
                   4355: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
                   4356: supported, e.g.
1.1       dsieger  4357: 
1.184     rillig   4358: PYTHON_VERSIONS_INCOMPATIBLE=       27
1.1       dsieger  4359: 
1.184     rillig   4360: If the packaged software is a Python module, include one of ../../lang/python/
                   4361: egg.mk, ../../lang/python/distutils.mk, or ../../lang/python/extension.mk.
1.1       dsieger  4362: 
1.184     rillig   4363: Most Python packages use either "distutils" or easy-setup/setuptools ("eggs").
                   4364: If the packaged software is using setuptools, you only need to include "../../
                   4365: lang/python/egg.mk". Otherwise, if the software uses "distutils", include "..
                   4366: /../lang/python/distutils.mk", so pkgsrc will use this framework. "distutils"
                   4367: uses a script called setup.py; if the "distutils" driver is not called
                   4368: setup.py, set the PYSETUP variable to the name of the script.
1.1       dsieger  4369: 
1.184     rillig   4370: Either way, the package directory should be called "py-software" and PKGNAME
                   4371: should be set to "${PYPKGPREFIX}-${DISTNAME}", e.g.
1.1       dsieger  4372: 
1.184     rillig   4373: DISTNAME=   foopymodule-1.2.10
                   4374: PKGNAME=    ${PYPKGPREFIX}-${DISTNAME}
1.1       dsieger  4375: 
1.184     rillig   4376: If it is an application, include "../../lang/python/application.mk". In order
                   4377: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
                   4378: variable and set it to the list of files (paths relative to WRKSRC) that must
                   4379: be corrected. For example:
1.1       dsieger  4380: 
1.184     rillig   4381: REPLACE_PYTHON=   *.py
1.1       dsieger  4382: 
1.184     rillig   4383: Some Python modules have separate distributions for Python-2.x and Python-3.x
                   4384: support. In pkgsrc this is handled by the versioned_dependencies.mk file. Set
                   4385: PYTHON_VERSIONED_DEPENDENCIES to the list of packages that should be depended
                   4386: upon and include "../../lang/python/versioned_dependencies.mk", then the pkgsrc
                   4387: infrastructure will depend on the appropriate package version. For example:
1.1       dsieger  4388: 
1.184     rillig   4389: PYTHON_VERSIONED_DEPENDENCIES=dialog
1.1       dsieger  4390: 
1.184     rillig   4391: Look inside versioned_dependencies.mk for a list of supported packages.
1.1       dsieger  4392: 
1.184     rillig   4393: 14.1.3. R packages
1.1       dsieger  4394: 
1.184     rillig   4395: Simple R packages from CRAN are handled automatically by R2pkg, which is
                   4396: available in pkgtools/R2pkg. Individual packages (and optionally their
                   4397: dependencies) may be created and updated. R packages generally follow the same
                   4398: form, and most of the relevant information needed is contained in a DESCRIPTION
                   4399: file as part of each R package on CRAN. Consequently, R2pkg downloads that
                   4400: information and creates or updates a package in the canonical form. The
                   4401: resulting package should be reviewed for correctness.
1.1       dsieger  4402: 
1.184     rillig   4403: 14.1.4. TeXlive packages
1.1       dsieger  4404: 
1.184     rillig   4405: TeXlive packages from CTAN are handled automatically by texlive2pkg, which is
                   4406: available in pkgtools/texlive2pkg.
1.1       dsieger  4407: 
1.184     rillig   4408: If the TeXlive package name is not known, it may be useful to search CTAN. A "
                   4409: Contained in" field on the package page typically identifies the basename of
                   4410: the package file in the TeXlive archive.
1.1       dsieger  4411: 
1.184     rillig   4412: If the TeXlive package name is known, download the files from the TeXlive
                   4413: archive. For package foo, you will need to download foo.tar.xz. Most TeXlive
                   4414: packages also have associated documentation packages, so download
                   4415: foo.doc.tar.xz at the same time. These files should be placed in the
                   4416: appropriate category directory, which is often but not always print. Then run
                   4417: the following command in the category directory.
1.1       dsieger  4418: 
1.184     rillig   4419: texlive2pkg foo.tar.xz foo.doc.tar.xz
1.1       dsieger  4420: 
1.184     rillig   4421: This will create two packages, tex-foo and tex-foo-doc. Be sure to check that
                   4422: both packages are correct.
1.1       dsieger  4423: 
1.184     rillig   4424: Finally, CTAN currently does not include version information in package
                   4425: filenames and changes their contents periodically when updates occur.
                   4426: Consequently, pkgsrc avoids downloading distfiles directly from CTAN and
                   4427: instead relies on the pkgsrc archives. For each new or updated TeXlive package,
                   4428: e.g., the main one and the corresponding documentation, upload the distfiles
                   4429: with the following command in each package directory.
1.1       dsieger  4430: 
1.184     rillig   4431: make upload-distfiles
1.117     sevan    4432: 
1.184     rillig   4433: 14.2. Examples
1.117     sevan    4434: 
1.184     rillig   4435: 14.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  4436: 
1.184     rillig   4437: 14.2.1.1. The initial package
1.1       dsieger  4438: 
1.184     rillig   4439: Looking at the file pkgsrc/doc/TODO, I saw that the "nvu" package has not yet
                   4440: been imported into pkgsrc. As the description says it has to do with the web,
                   4441: the obvious choice for the category is "www".
1.1       dsieger  4442: 
1.184     rillig   4443: $ mkdir www/nvu
                   4444: $ cd www/nvu
1.1       dsieger  4445: 
1.184     rillig   4446: The web site says that the sources are available as a tar file, so I fed that
                   4447: URL to the url2pkg program:
1.1       dsieger  4448: 
1.184     rillig   4449: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
1.1       dsieger  4450: 
1.184     rillig   4451: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
                   4452: package name should not have the word "sources" in it. I also filled in the
                   4453: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
                   4454: that:
1.1       dsieger  4455: 
1.184     rillig   4456: # $NetBSD $
                   4457: #
1.1       dsieger  4458: 
1.184     rillig   4459: DISTNAME=       nvu-1.0-sources
                   4460: PKGNAME=        nvu-1.0
                   4461: CATEGORIES=     www
                   4462: MASTER_SITES=   http://cvs.nvu.com/download/
                   4463: EXTRACT_SUFX=   .tar.bz2
1.1       dsieger  4464: 
1.184     rillig   4465: MAINTAINER=     rillig@NetBSD.org
                   4466: HOMEPAGE=       http://cvs.nvu.com/
                   4467: COMMENT=        Web Authoring System
1.1       dsieger  4468: 
1.184     rillig   4469: # url2pkg-marker (please do not remove this line.)
                   4470: .include "../../mk/bsd.pkg.mk"
1.1       dsieger  4471: 
1.184     rillig   4472: On the first line of output above, an artificial space has been added between
                   4473: NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
                   4474: the guide.
1.1       dsieger  4475: 
1.184     rillig   4476: Then, I quit the editor and watched pkgsrc downloading a large source archive:
1.1       dsieger  4477: 
1.184     rillig   4478: url2pkg> Running "make makesum" ...
                   4479: => Required installed package digest>=20010302: digest-20060826 found
                   4480: => Fetching nvu-1.0-sources.tar.bz2
                   4481: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
                   4482: 100% |*************************************| 28992 KB  150.77 KB/s00:00 ETA
                   4483: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
                   4484: url2pkg> Running "make extract" ...
                   4485: => Required installed package digest>=20010302: digest-20060826 found
                   4486: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   4487: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   4488: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
                   4489: ===> Installing dependencies for nvu-1.0
                   4490: ===> Overriding tools for nvu-1.0
                   4491: ===> Extracting for nvu-1.0
                   4492: url2pkg> Adjusting the Makefile.
1.1       dsieger  4493: 
1.184     rillig   4494: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
1.1       dsieger  4495: 
1.184     rillig   4496: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
1.1       dsieger  4497: 
1.184     rillig   4498: 14.2.1.2. Fixing all kinds of problems to make the package work
1.1       dsieger  4499: 
1.184     rillig   4500: Now that the package has been extracted, let's see what's inside it. The
                   4501: package has a README.txt, but that only says something about mozilla, so it's
                   4502: probably useless for seeing what dependencies this package has. But since there
                   4503: is a GNU configure script in the package, let's hope that it will complain
                   4504: about everything it needs.
1.1       dsieger  4505: 
1.184     rillig   4506: $ bmake
                   4507: => Required installed package digest>=20010302: digest-20060826 found
                   4508: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   4509: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   4510: ===> Patching for nvu-1.0
                   4511: ===> Creating toolchain wrappers for nvu-1.0
                   4512: ===> Configuring for nvu-1.0
                   4513: [...]
                   4514: configure: error: Perl 5.004 or higher is required.
                   4515: [...]
                   4516: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
                   4517: [...]
1.1       dsieger  4518: 
1.184     rillig   4519: That worked quite well. So I opened the package Makefile in my editor, and
                   4520: since it already has a USE_TOOLS line, I just appended "perl" to it. Since the
                   4521: dependencies of the package have changed now, and since a perl wrapper is
                   4522: automatically installed in the "tools" phase, I need to build the package from
                   4523: scratch.
1.1       dsieger  4524: 
1.184     rillig   4525: $ bmake clean
                   4526: ===> Cleaning for nvu-1.0
                   4527: $ bmake
                   4528: [...]
                   4529: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
                   4530: GNU Make.  You will not be able to build Mozilla without GNU Make.
                   4531: [...]
1.1       dsieger  4532: 
1.184     rillig   4533: So I added "gmake" to the USE_TOOLS line and tried again (from scratch).
1.1       dsieger  4534: 
1.184     rillig   4535: [...]
                   4536: checking for GTK - version >= 1.2.0... no
                   4537: *** Could not run GTK test program, checking why...
                   4538: [...]
1.1       dsieger  4539: 
1.184     rillig   4540: Now to the other dependencies. The first question is: Where is the GTK package
                   4541: hidden in pkgsrc?
1.1       dsieger  4542: 
1.184     rillig   4543: $ echo ../../*/gtk*
                   4544: [many packages ...]
                   4545: $ echo ../../*/gtk
                   4546: ../../x11/gtk
                   4547: $ echo ../../*/gtk2
                   4548: ../../x11/gtk2
                   4549: $ echo ../../*/gtk2/bui*
                   4550: ../../x11/gtk2/buildlink3.mk
1.1       dsieger  4551: 
1.184     rillig   4552: The first try was definitely too broad. The second one had exactly one result,
                   4553: which is very good. But there is one pitfall with GNOME packages. Before GNOME
                   4554: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
                   4555: able to continue to use these packages, the GNOME 2 packages were imported as
                   4556: separate packages, and their names usually have a "2" appended. So I checked
                   4557: whether this was the case here, and indeed it was.
1.1       dsieger  4558: 
1.184     rillig   4559: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
                   4560: easy. I just inserted an .include line before the last line of the package
                   4561: Makefile, so that it now looks like this:
1.1       dsieger  4562: 
1.184     rillig   4563: [...]
                   4564: .include "../../x11/gtk2/buildlink3.mk"
                   4565: .include "../../mk/bsd.pkg.mk
1.1       dsieger  4566: 
1.184     rillig   4567: After another bmake clean && bmake, the answer was:
1.108     rillig   4568: 
1.184     rillig   4569: [...]
                   4570: checking for gtk-config... /home/roland/pkg/bin/gtk-config
                   4571: checking for GTK - version >= 1.2.0... no
                   4572: *** Could not run GTK test program, checking why...
                   4573: *** The test program failed to compile or link. See the file config.log for the
                   4574: *** exact error that occured. This usually means GTK was incorrectly installed
                   4575: *** or that you have moved GTK since it was installed. In the latter case, you
                   4576: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
                   4577: configure: error: Test for GTK failed.
                   4578: [...]
1.1       dsieger  4579: 
1.184     rillig   4580: In this particular case, the assumption that "every package prefers GNOME 2"
                   4581: had been wrong. The first of the lines above told me that this package really
                   4582: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
                   4583: it would have looked for pkg-config instead of gtk-config. So I changed the x11
                   4584: /gtk2 to x11/gtk in the package Makefile, and tried again.
1.1       dsieger  4585: 
1.184     rillig   4586: [...]
                   4587: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\"  [...]
                   4588: In file included from xpidl.c:42:
                   4589: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
                   4590: In file included from xpidl.c:42:
                   4591: xpidl.h:132: error: parse error before "IDL_ns"
                   4592: [...]
1.1       dsieger  4593: 
1.184     rillig   4594: The package still does not find all of its dependencies. Now the question is:
                   4595: Which package provides the libIDL/IDL.h header file?
1.1       dsieger  4596: 
1.184     rillig   4597: $ echo ../../*/*idl*
                   4598: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
                   4599: $ echo ../../*/*IDL*
                   4600: ../../net/libIDL
1.1       dsieger  4601: 
1.184     rillig   4602: Let's take the one from the second try. So I included the ../../net/libIDL/
                   4603: buildlink3.mk file and tried again. But the error didn't change. After digging
                   4604: through some of the code, I concluded that the build process of the package was
                   4605: broken and couldn't have ever worked, but since the Mozilla source tree is
                   4606: quite large, I didn't want to fix it. So I added the following to the package
                   4607: Makefile and tried again:
1.1       dsieger  4608: 
1.184     rillig   4609: CPPFLAGS+=              -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
                   4610: BUILDLINK_TRANSFORM+=   l:IDL:IDL-2
1.1       dsieger  4611: 
1.184     rillig   4612: The latter line is needed because the package expects the library libIDL.so,
                   4613: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
                   4614: that on the fly.
1.1       dsieger  4615: 
1.184     rillig   4616: The next problem was related to a recent change of the FreeType interface. I
                   4617: looked up in www/seamonkey which patch files were relevant for this issue and
                   4618: copied them to the patches directory. Then I retried, fixed the patches so that
                   4619: they applied cleanly and retried again. This time, everything worked.
1.1       dsieger  4620: 
1.184     rillig   4621: 14.2.1.3. Installing the package
1.1       dsieger  4622: 
1.184     rillig   4623: $ bmake CHECK_FILES=no install
                   4624: [...]
                   4625: $ bmake print-PLIST >PLIST
                   4626: $ bmake deinstall
                   4627: $ bmake install
1.1       dsieger  4628: 
1.184     rillig   4629: Chapter 15. Programming in Makefiles
1.1       dsieger  4630: 
1.184     rillig   4631: Table of Contents
1.1       dsieger  4632: 
1.184     rillig   4633: 15.1. Caveats
                   4634: 15.2. Makefile variables
1.1       dsieger  4635: 
1.184     rillig   4636:     15.2.1. Naming conventions
1.1       dsieger  4637: 
1.184     rillig   4638: 15.3. Code snippets
1.1       dsieger  4639: 
1.184     rillig   4640:     15.3.1. Adding things to a list
                   4641:     15.3.2. Echoing a string exactly as-is
                   4642:     15.3.3. Passing CFLAGS to GNU configure scripts
                   4643:     15.3.4. Handling possibly empty variables
1.1       dsieger  4644: 
1.184     rillig   4645: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
                   4646: part of the pkgsrc system. Using the make(1) system as a programming language
                   4647: for a big system like pkgsrc requires some discipline to keep the code correct
                   4648: and understandable.
1.1       dsieger  4649: 
1.184     rillig   4650: The basic ingredients for Makefile programming are variables and shell
                   4651: commands. Among these shell commands may even be more complex ones like awk(1)
                   4652: programs. To make sure that every shell command runs as intended it is
                   4653: necessary to quote all variables correctly when they are used.
1.1       dsieger  4654: 
1.184     rillig   4655: This chapter describes some patterns that appear quite often in Makefiles,
                   4656: including the pitfalls that come along with them.
1.1       dsieger  4657: 
1.184     rillig   4658: 15.1. Caveats
1.1       dsieger  4659: 
1.184     rillig   4660:   * When you are creating a file as a target of a rule, always write the data
                   4661:     to a temporary file first and finally rename that file. Otherwise there
                   4662:     might occur an error in the middle of generating the file, and when the
                   4663:     user runs make(1) for the second time, the file exists and will not be
                   4664:     regenerated properly. Example:
1.1       dsieger  4665: 
1.184     rillig   4666:     wrong:
                   4667:             @echo "line 1" > ${.TARGET}
                   4668:             @echo "line 2" >> ${.TARGET}
                   4669:             @false
1.1       dsieger  4670: 
1.184     rillig   4671:     correct:
                   4672:             @echo "line 1" > ${.TARGET}.tmp
                   4673:             @echo "line 2" >> ${.TARGET}.tmp
                   4674:             @false
                   4675:             @mv ${.TARGET}.tmp ${.TARGET}
1.1       dsieger  4676: 
1.184     rillig   4677:     When you run make wrong twice, the file wrong will exist, although there
                   4678:     was an error message in the first run. On the other hand, running make
                   4679:     correct gives an error message twice, as expected.
1.1       dsieger  4680: 
1.184     rillig   4681:     You might remember that make(1) sometimes removes ${.TARGET} in case of
                   4682:     error, but this only happens when it is interrupted, for example by
                   4683:     pressing Ctrl+C. This does not happen when one of the commands fails (like
                   4684:     false(1) above).
1.1       dsieger  4685: 
1.184     rillig   4686: 15.2. Makefile variables
1.1       dsieger  4687: 
1.184     rillig   4688: Makefile variables contain strings that can be processed using the five
                   4689: operators =, +=, ?=, := and !=, which are described in the make(1) man page.
1.1       dsieger  4690: 
1.184     rillig   4691: When a variable's value is parsed from a Makefile, the hash character # and the
                   4692: backslash character \ are handled specially. If a backslash is the last
                   4693: character in a line, that backslash is removed from the line and the line
                   4694: continues with the next line of the file.
1.1       dsieger  4695: 
1.184     rillig   4696: The # character starts a comment that reaches until the end of the line. To get
                   4697: an actual # character, such as in a URL, write \# instead.
1.1       dsieger  4698: 
1.184     rillig   4699: The evaluation of variables either happens immediately or lazy. It happens
                   4700: immediately when the variable occurs on the right-hand side of the := or the !=
                   4701: operator, in a .if condition or a .for loop. In the other cases, it is
                   4702: evaluated lazily.
1.1       dsieger  4703: 
1.184     rillig   4704: Some of the modifiers split the string into words and then operate on the
                   4705: words, others operate on the string as a whole. When a string is split into
                   4706: words, double quotes and single quotes are interpreted as delimiters, just like
                   4707: in sh(1).
1.1       dsieger  4708: 
1.184     rillig   4709: 15.2.1. Naming conventions
1.1       dsieger  4710: 
1.184     rillig   4711:   * All variable names starting with an underscore are reserved for use by the
                   4712:     pkgsrc infrastructure. They shall not be used by packages.
1.1       dsieger  4713: 
1.184     rillig   4714:   * In .for loops you should use lowercase variable names for the iteration
                   4715:     variables.
1.1       dsieger  4716: 
1.184     rillig   4717:   * All list variables should have a plural name, such as PKG_OPTIONS or
                   4718:     DISTFILES.
1.1       dsieger  4719: 
1.184     rillig   4720: 15.3. Code snippets
1.1       dsieger  4721: 
1.184     rillig   4722: 15.3.1. Adding things to a list
1.1       dsieger  4723: 
1.184     rillig   4724: When adding a string that possibly contains whitespace or quotes to a list
                   4725: (example 1), it must be quoted using the :Q modifier.
1.1       dsieger  4726: 
1.184     rillig   4727: When adding another list to a list (example 2), it must not be quoted, since
                   4728: its elements are already quoted.
1.1       dsieger  4729: 
1.184     rillig   4730: STRING=         foo * bar `date`
                   4731: LIST=           # empty
                   4732: ANOTHER_LIST=   a=b c=d
1.1       dsieger  4733: 
1.184     rillig   4734: LIST+=          ${STRING:Q}       # 1
                   4735: LIST+=          ${ANOTHER_LIST}   # 2
1.1       dsieger  4736: 
1.184     rillig   4737: 15.3.2. Echoing a string exactly as-is
1.1       dsieger  4738: 
1.184     rillig   4739: Echoing a string containing special characters needs special work.
1.1       dsieger  4740: 
1.184     rillig   4741: STRING=         foo bar <    > * `date` $$HOME ' "
                   4742: EXAMPLE_ENV=    string=${STRING:Q} x=multiple\ quoted\ words
1.1       dsieger  4743: 
1.184     rillig   4744: all:
                   4745:         echo ${STRING}                  # 1
                   4746:         echo ${STRING:Q}                # 2
                   4747:         printf '%s\n' ${STRING:Q}''     # 3
                   4748:         env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"'   # 4
1.1       dsieger  4749: 
1.184     rillig   4750: Example 1 leads to a syntax error in the shell, as the characters are just
                   4751: copied.
1.1       dsieger  4752: 
1.184     rillig   4753: Example 2 quotes the string so that the shell interprets it correctly. But the
                   4754: echo command may additionally interpret strings with a leading dash or those
                   4755: containing backslashes.
1.1       dsieger  4756: 
1.184     rillig   4757: Example 3 can handle arbitrary strings, since printf(1) only interprets the
                   4758: format string, but not the next argument. The trailing single quotes handle the
                   4759: case when the string is empty. In that case, the :Q modifier would result in an
                   4760: empty string too, which would then be skipped by the shell. For printf(1) this
                   4761: doesn't make a difference, but other programs may care.
1.1       dsieger  4762: 
1.184     rillig   4763: In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
                   4764: has already been done when adding elements to the list.
1.1       dsieger  4765: 
1.184     rillig   4766: 15.3.3. Passing CFLAGS to GNU configure scripts
1.1       dsieger  4767: 
1.184     rillig   4768: When passing CFLAGS or similar variables to a GNU-style configure script
                   4769: (especially those that call other configure scripts), it must not have leading
                   4770: or trailing whitespace, since otherwise the configure script gets confused. To
                   4771: trim leading and trailing whitespace, use the :M modifier, as in the following
                   4772: example:
1.1       dsieger  4773: 
1.184     rillig   4774: CPPFLAGS=               # empty
                   4775: CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX}\"
                   4776: CPPFLAGS+=              ${MY_CPPFLAGS}
1.1       dsieger  4777: 
1.184     rillig   4778: CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
1.1       dsieger  4779: 
1.184     rillig   4780: all:
                   4781:         echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
                   4782:         echo x${CONFIGURE_ARGS:Q}x      # properly trimmed
1.1       dsieger  4783: 
1.184     rillig   4784: In this example, CPPFLAGS has both leading and trailing whitespace because the
                   4785: += operator always adds a space.
1.1       dsieger  4786: 
1.184     rillig   4787: 15.3.4. Handling possibly empty variables
1.1       dsieger  4788: 
1.184     rillig   4789: When a possibly empty variable is used in a shell program, it may lead to a
                   4790: syntax error.
1.1       dsieger  4791: 
1.184     rillig   4792: EGFILES=        # empty
1.1       dsieger  4793: 
1.184     rillig   4794: install-examples:   # produces a syntax error in the shell
                   4795:         for egfile in ${EGFILES}; do            \
                   4796:                 echo "Installing $$egfile";     \
                   4797:         done
1.1       dsieger  4798: 
1.184     rillig   4799: The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
                   4800: with an empty string by make(1). To fix this syntax error, use one of the
                   4801: snippets below.
1.1       dsieger  4802: 
1.184     rillig   4803: EMPTY=          # empty
1.1       dsieger  4804: 
1.184     rillig   4805: install-examples:
                   4806:         for egfile in ${EGFILES} ""; do         \
                   4807:                 [ -n "$$egfile" ] || continue;  \
                   4808:                 echo "Installing $$egfile";     \
                   4809:         done
1.1       dsieger  4810: 
1.184     rillig   4811: In this case, an empty string is appended to the iteration list (to prevent the
                   4812: syntax error) and filtered out later.
1.1       dsieger  4813: 
1.184     rillig   4814: EGFILES=        # empty
1.1       dsieger  4815: 
1.184     rillig   4816: install-examples:
                   4817: .for egfile in ${EGFILES}
                   4818:         echo "Installing ${egfile}"
                   4819: .endfor
1.1       dsieger  4820: 
1.184     rillig   4821: If one of the filenames contains special characters, it should be enclosed in
                   4822: single or double quotes.
1.1       dsieger  4823: 
1.184     rillig   4824: To have a shell command test whether a make variable is empty, use the
                   4825: following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
1.1       dsieger  4826: 
1.184     rillig   4827: Chapter 16. Options handling
1.1       dsieger  4828: 
                   4829: Table of Contents
                   4830: 
1.184     rillig   4831: 16.1. Global default options
                   4832: 16.2. Converting packages to use bsd.options.mk
                   4833: 16.3. Option Names
                   4834: 16.4. Determining the options of dependencies
1.1       dsieger  4835: 
                   4836: Many packages have the ability to be built to support different sets of
                   4837: features. bsd.options.mk is a framework in pkgsrc that provides generic
                   4838: handling of those options that determine different ways in which the packages
                   4839: can be built. It's possible for the user to specify exactly which sets of
                   4840: options will be built into a package or to allow a set of global default
                   4841: options apply.
                   4842: 
1.7       rillig   4843: There are two broad classes of behaviors that one might want to control via
                   4844: options. One is whether some particular feature is enabled in a program that
                   4845: will be built anyway, often by including or not including a dependency on some
                   4846: other package. The other is whether or not an additional program will be built
                   4847: as part of the package. Generally, it is better to make a split package for
                   4848: such additional programs instead of using options, because it enables binary
                   4849: packages to be built which can then be added separately. For example, the foo
                   4850: package might have minimal dependencies (those packages without which foo
                   4851: doesn't make sense), and then the foo-gfoo package might include the GTK
                   4852: frontend program gfoo. This is better than including a gtk option to foo that
                   4853: adds gfoo, because either that option is default, in which case binary users
                   4854: can't get foo without gfoo, or not default, in which case they can't get gfoo.
                   4855: With split packages, they can install foo without having GTK, and later decide
                   4856: to install gfoo (pulling in GTK at that time). This is an advantage to source
                   4857: users too, avoiding the need for rebuilds.
                   4858: 
                   4859: Plugins with widely varying dependencies should usually be split instead of
                   4860: options.
                   4861: 
                   4862: It is often more work to maintain split packages, especially if the upstream
                   4863: package does not support this. The decision of split vs. option should be made
                   4864: based on the likelihood that users will want or object to the various pieces,
                   4865: the size of the dependencies that are included, and the amount of work.
                   4866: 
                   4867: A further consideration is licensing. Non-free parts, or parts that depend on
                   4868: non-free dependencies (especially plugins) should almost always be split if
                   4869: feasible.
                   4870: 
1.184     rillig   4871: 16.1. Global default options
1.1       dsieger  4872: 
                   4873: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
                   4874: the options that should be built into every package if that option is
1.4       rillig   4875: supported. This variable should be set in mk.conf.
1.1       dsieger  4876: 
1.184     rillig   4877: 16.2. Converting packages to use bsd.options.mk
1.1       dsieger  4878: 
                   4879: The following example shows how bsd.options.mk should be used by the
                   4880: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
                   4881: e.g. options.mk, that is included by the main package Makefile.
                   4882: 
                   4883: PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
                   4884: PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
                   4885: PKG_OPTIONS_OPTIONAL_GROUPS=    database
                   4886: PKG_OPTIONS_GROUP.database=     mysql pgsql
                   4887: PKG_SUGGESTED_OPTIONS=          wibble-foo
                   4888: PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
                   4889: PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
                   4890: 
                   4891: .include "../../mk/bsd.prefs.mk"
                   4892: 
                   4893: # this package was previously named wibble2
                   4894: .if defined(PKG_OPTIONS.wibble2)
                   4895: PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
                   4896: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
                   4897:         "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
                   4898: .endif
                   4899: 
                   4900: .include "../../mk/bsd.options.mk"
                   4901: 
                   4902: # Package-specific option-handling
                   4903: 
                   4904: ###
                   4905: ### FOO support
                   4906: ###
                   4907: .if !empty(PKG_OPTIONS:Mwibble-foo)
                   4908: CONFIGURE_ARGS+=    --enable-foo
                   4909: .endif
                   4910: 
                   4911: ###
                   4912: ### LDAP support
                   4913: ###
                   4914: .if !empty(PKG_OPTIONS:Mldap)
                   4915: .  include "../../databases/openldap-client/buildlink3.mk"
                   4916: CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
                   4917: .endif
                   4918: 
                   4919: ###
                   4920: ### database support
                   4921: ###
                   4922: .if !empty(PKG_OPTIONS:Mmysql)
                   4923: .  include "../../mk/mysql.buildlink3.mk"
                   4924: .endif
                   4925: .if !empty(PKG_OPTIONS:Mpgsql)
                   4926: .  include "../../mk/pgsql.buildlink3.mk"
                   4927: .endif
                   4928: 
                   4929: The first section contains the information about which build options are
                   4930: supported by the package, and any default options settings if needed.
                   4931: 
                   4932:  1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
                   4933:     to override the default options. It should be set to PKG_OPTIONS.pkgbase.
                   4934:     Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
                   4935:     the point where the options are processed.
                   4936: 
                   4937:  2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
                   4938: 
                   4939:  3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
                   4940:     exclusive options. The options in each group are listed in
                   4941:     PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
                   4942:     the group takes precedence over all other options in the group. Options
                   4943:     from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
                   4944: 
                   4945:  4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
                   4946:     building the packages will fail if no option from the group is selected.
                   4947: 
                   4948:  5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
                   4949:     one option from each set must be selected. The options in each set are
                   4950:     listed in PKG_OPTIONS_SET.setname. Options from the sets will be
                   4951:     automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
                   4952:     fail if no option from the set is selected.
                   4953: 
                   4954:  6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
                   4955:     default.
                   4956: 
                   4957:  7. PKG_OPTIONS_LEGACY_VARS is a list of "USE_VARIABLE:option" pairs that map
1.4       rillig   4958:     legacy mk.conf variables to their option counterparts. Pairs should be
1.1       dsieger  4959:     added with "+=" to keep the listing of global legacy variables. A warning
                   4960:     will be issued if the user uses a legacy variable.
                   4961: 
                   4962:  8. PKG_OPTIONS_LEGACY_OPTS is a list of "old-option:new-option" pairs that map
                   4963:     options that have been renamed to their new counterparts. Pairs should be
                   4964:     added with "+=" to keep the listing of global legacy options. A warning
                   4965:     will be issued if the user uses a legacy option.
                   4966: 
                   4967:  9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
                   4968:     used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
                   4969:     PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
                   4970: 
                   4971: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
                   4972:     variables or options used, and what to use instead.
                   4973: 
                   4974: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
                   4975: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
                   4976: options, use PKG_SUGGESTED_OPTIONS.
                   4977: 
                   4978: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
                   4979: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
                   4980: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
                   4981: options if none of them is supported on the current platform), PKG_OPTIONS is
                   4982: set to the empty list and the package is otherwise treated as not using the
                   4983: options framework.
                   4984: 
                   4985: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
                   4986: list of selected build options, properly filtered to remove unsupported and
                   4987: duplicate options.
                   4988: 
                   4989: The remaining sections contain the logic that is specific to each option. The
                   4990: correct way to check for an option is to check whether it is listed in
                   4991: PKG_OPTIONS:
                   4992: 
                   4993: .if !empty(PKG_OPTIONS:Moption)
                   4994: 
1.184     rillig   4995: 16.3. Option Names
1.1       dsieger  4996: 
                   4997: Options that enable similar features in different packages (like optional
                   4998: support for a library) should use a common name in all packages that support it
                   4999: (like the name of the library). If another package already has an option with
                   5000: the same meaning, use the same name.
                   5001: 
                   5002: Options that enable features specific to one package, where it's unlikely that
                   5003: another (unrelated) package has the same (or a similar) optional feature,
                   5004: should use a name prefixed with pkgname-.
                   5005: 
                   5006: If a group of related packages share an optional feature specific to that
                   5007: group, prefix it with the name of the "main" package (e. g.
                   5008: djbware-errno-hack).
                   5009: 
                   5010: For new options, add a line to mk/defaults/options.description. Lines have two
                   5011: fields, separated by tab. The first field is the option name, the second its
                   5012: description. The description should be a whole sentence (starting with an
                   5013: uppercase letter and ending with a period) that describes what enabling the
                   5014: option does. E. g. "Enable ispell support." The file is sorted by option names.
                   5015: 
1.184     rillig   5016: 16.4. Determining the options of dependencies
1.7       rillig   5017: 
                   5018: When writing buildlink3.mk files, it is often necessary to list different
                   5019: dependencies based on the options with which the package was built. For
                   5020: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
                   5021: A typical example looks like this:
                   5022: 
                   5023: pkgbase := libpurple
                   5024: .include "../../mk/pkg-build-options.mk"
                   5025: 
                   5026: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
                   5027: ...
                   5028: .endif
                   5029: 
                   5030: Including pkg-build-options.mk here will set the variable
                   5031: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
                   5032: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
                   5033: pkg-build-options.mk for more details.
                   5034: 
1.184     rillig   5035: Chapter 17. Tools needed for building or running
                   5036: 
                   5037: Table of Contents
                   5038: 
                   5039: 17.1. Tools for pkgsrc builds
                   5040: 17.2. Tools needed by packages
                   5041: 17.3. Tools provided by platforms
                   5042: 
                   5043: The USE_TOOLS definition is used both internally by pkgsrc and also for
                   5044: individual packages to define what commands are needed for building a package
                   5045: (like TOOL_DEPENDS) or for later run-time of an installed packaged (such as
                   5046: DEPENDS). If the native system provides an adequate tool, then in many cases, a
                   5047: pkgsrc package will not be used.
                   5048: 
                   5049: When building a package, the replacement tools are made available in a
                   5050: directory (as symlinks or wrapper scripts) that is early in the executable
                   5051: search path. Just like the buildlink system, this helps with consistent builds.
                   5052: 
                   5053: A tool may be needed to help build a specific package. For example, perl, GNU
                   5054: make (gmake) or yacc may be needed.
                   5055: 
                   5056: Also a tool may be needed, for example, because the native system's supplied
                   5057: tool may be inefficient for building a package with pkgsrc. For example, a
                   5058: package may need GNU awk, bison (instead of yacc) or a better sed.
                   5059: 
                   5060: The tools used by a package can be listed by running make show-tools.
                   5061: 
                   5062: 17.1. Tools for pkgsrc builds
                   5063: 
                   5064: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
                   5065: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
                   5066: seen by running: make show-var VARNAME=USE_TOOLS.
                   5067: 
                   5068: If a package needs a specific program to build then the USE_TOOLS variable can
                   5069: be used to define the tools needed.
                   5070: 
                   5071: 17.2. Tools needed by packages
                   5072: 
                   5073: In the following examples, the :run means that it is needed at run-time (and
                   5074: becomes a DEPENDS). The default is a build dependency which can be set with
                   5075: :build. (So in this example, it is the same as gmake:build and
                   5076: pkg-config:build.)
                   5077: 
                   5078: USE_TOOLS+=     gmake perl:run pkg-config
                   5079: 
                   5080: When using the tools framework, a TOOLS_PATH.foo variable is defined which
                   5081: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
                   5082: could be "/bin/bash" on Linux systems.
                   5083: 
                   5084: If you always need a pkgsrc version of the tool at run-time, then just use
                   5085: DEPENDS instead.
                   5086: 
                   5087: 17.3. Tools provided by platforms
                   5088: 
                   5089: When improving or porting pkgsrc to a new platform, have a look at (or create)
                   5090: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
                   5091: tools.${OPSYS}.mk which defines the name of the common tools. For example:
                   5092: 
                   5093: .if exists(/usr/bin/bzcat)
                   5094: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
                   5095: .elif exists(/usr/bin/bzip2)
                   5096: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
                   5097: .endif
                   5098: 
                   5099: TOOLS_PLATFORM.true?=           true                    # shell builtin
                   5100: 
                   5101: Chapter 18. Buildlink methodology
1.1       dsieger  5102: 
                   5103: Table of Contents
                   5104: 
1.184     rillig   5105: 18.1. Converting packages to use buildlink3
                   5106: 18.2. Writing buildlink3.mk files
                   5107: 
                   5108:     18.2.1. Anatomy of a buildlink3.mk file
                   5109:     18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
                   5110:         buildlink3.mk files
                   5111: 
                   5112: 18.3. Writing builtin.mk files
                   5113: 
                   5114:     18.3.1. Anatomy of a builtin.mk file
                   5115:     18.3.2. Global preferences for native or pkgsrc software
                   5116: 
                   5117: Buildlink is a framework in pkgsrc that controls what headers and libraries are
                   5118: seen by a package's configure and build processes. This is implemented in a two
                   5119: step process:
                   5120: 
                   5121:  1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
                   5122:     default is a subdirectory of WRKDIR.
                   5123: 
                   5124:  2. Create wrapper scripts that are used in place of the normal compiler tools
                   5125:     that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
                   5126:     references to BUILDLINK_DIR. The wrapper scripts also make native compiler
                   5127:     on some operating systems look like GCC, so that packages that expect GCC
                   5128:     won't require modifications to build with those native compilers.
                   5129: 
                   5130: This normalizes the environment in which a package is built so that the package
                   5131: may be built consistently despite what other software may be installed. Please
                   5132: note that the normal system header and library paths, e.g. /usr/include, /usr/
                   5133: lib, etc., are always searched -- buildlink3 is designed to insulate the
                   5134: package build from non-system-supplied software.
                   5135: 
                   5136: 18.1. Converting packages to use buildlink3
1.1       dsieger  5137: 
1.184     rillig   5138: The process of converting packages to use the buildlink3 framework ("bl3ifying"
                   5139: ) is fairly straightforward. The things to keep in mind are:
1.1       dsieger  5140: 
1.184     rillig   5141:  1. Ensure that the build always calls the wrapper scripts instead of the
                   5142:     actual toolchain. Some packages are tricky, and the only way to know for
                   5143:     sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
                   5144:     invoked.
1.1       dsieger  5145: 
1.184     rillig   5146:  2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
                   5147:     standalone shells, etc., because the code to symlink files into $
                   5148:     {BUILDLINK_DIR} looks for files relative to "pkg_info -qp pkgname".
1.1       dsieger  5149: 
1.184     rillig   5150:  3. Remember that only the buildlink3.mk files that you list in a package's
                   5151:     Makefile are added as dependencies for that package.
1.1       dsieger  5152: 
1.184     rillig   5153: If a dependency on a particular package is required for its libraries and
                   5154: headers, then we replace:
1.1       dsieger  5155: 
1.184     rillig   5156: DEPENDS+=       foo>=1.1.0:../../category/foo
1.1       dsieger  5157: 
1.184     rillig   5158: with
1.1       dsieger  5159: 
1.184     rillig   5160: .include "../../category/foo/buildlink3.mk"
1.1       dsieger  5161: 
1.184     rillig   5162: The buildlink3.mk files usually define the required dependencies. If you need a
                   5163: newer version of the dependency when using buildlink3.mk files, then you can
                   5164: define it in your Makefile; for example:
1.1       dsieger  5165: 
1.184     rillig   5166: BUILDLINK_API_DEPENDS.foo+=   foo>=1.1.0
                   5167: .include "../../category/foo/buildlink3.mk"
1.1       dsieger  5168: 
1.184     rillig   5169: There are several buildlink3.mk files in pkgsrc/mk that handle special package
                   5170: issues:
1.1       dsieger  5171: 
1.184     rillig   5172:   * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
                   5173:     implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
1.1       dsieger  5174: 
1.184     rillig   5175:   * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
                   5176:     this will take care to install the devel/ncurses package.
1.1       dsieger  5177: 
1.184     rillig   5178:   * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
                   5179:     a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
                   5180:     implementation.
1.1       dsieger  5181: 
1.184     rillig   5182:   * motif.buildlink3.mk checks for a system-provided Motif installation or adds
                   5183:     a dependency on x11/lesstif or x11/motif. The user can set MOTIF_TYPE to "
                   5184:     dt", "lesstif" or "motif" to choose which Motif version will be used.
1.1       dsieger  5185: 
1.184     rillig   5186:   * readline.buildlink3.mk checks for a system-provided GNU readline or
                   5187:     editline (libedit) installation, or adds a dependency on devel/readline,
                   5188:     devel/editline. The user can set READLINE_DEFAULT to choose readline
                   5189:     implementation. If your package really needs GNU readline library, its
                   5190:     Makefile should include devel/readline/buildlink3.mk instead of
                   5191:     readline.buildlink3.mk.
1.1       dsieger  5192: 
1.184     rillig   5193:   * oss.buildlink3.mk defines several variables that may be used by packages
                   5194:     that use the Open Sound System (OSS) API.
1.1       dsieger  5195: 
1.184     rillig   5196:   * pgsql.buildlink3.mk will accept any of the Postgres versions in the
                   5197:     variable PGSQL_VERSIONS_ACCEPTED and default to the version
                   5198:     PGSQL_VERSION_DEFAULT. See the file for more information.
1.1       dsieger  5199: 
1.184     rillig   5200:   * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
                   5201:     pthreads or adds a dependency on devel/pth as needed.
1.1       dsieger  5202: 
1.184     rillig   5203:   * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
                   5204:     widgets library.
1.1       dsieger  5205: 
1.184     rillig   5206: The comments in those buildlink3.mk files provide a more complete description
                   5207: of how to use them properly.
1.1       dsieger  5208: 
1.184     rillig   5209: 18.2. Writing buildlink3.mk files
1.1       dsieger  5210: 
1.184     rillig   5211: A package's buildlink3.mk file is included by Makefiles to indicate the need to
                   5212: compile and link against header files and libraries provided by the package. A
                   5213: buildlink3.mk file should always provide enough information to add the correct
                   5214: type of dependency relationship and include any other buildlink3.mk files that
                   5215: it needs to find headers and libraries that it needs in turn.
1.1       dsieger  5216: 
1.184     rillig   5217: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
                   5218: pkgtools/createbuildlink package is highly recommended. For most packages, the
                   5219: following command will generate a good starting point for buildlink3.mk files:
1.1       dsieger  5220: 
1.184     rillig   5221: % cd pkgsrc/category/pkgdir
                   5222: % createbuildlink >buildlink3.mk
1.1       dsieger  5223: 
                   5224: 
1.184     rillig   5225: 18.2.1. Anatomy of a buildlink3.mk file
1.1       dsieger  5226: 
1.184     rillig   5227: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
                   5228: tiff:
1.14      jmcneill 5229: 
1.184     rillig   5230: # $NetBSD: buildlink3.mk,v 1.16 2009/03/20 19:24:45 joerg Exp $
1.1       dsieger  5231: 
1.184     rillig   5232: BUILDLINK_TREE+=        tiff
1.1       dsieger  5233: 
1.184     rillig   5234: .if !defined(TIFF_BUILDLINK3_MK)
                   5235: TIFF_BUILDLINK3_MK:=
1.1       dsieger  5236: 
1.184     rillig   5237: BUILDLINK_API_DEPENDS.tiff+=    tiff>=3.6.1
                   5238: BUILDLINK_ABI_DEPENDS.tiff+=    tiff>=3.7.2nb1
                   5239: BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
1.1       dsieger  5240: 
1.184     rillig   5241: .include "../../devel/zlib/buildlink3.mk"
                   5242: .include "../../graphics/jpeg/buildlink3.mk"
                   5243: .endif # TIFF_BUILDLINK3_MK
1.1       dsieger  5244: 
1.184     rillig   5245: BUILDLINK_TREE+=        -tiff
1.1       dsieger  5246: 
1.184     rillig   5247: The header and footer manipulate BUILDLINK_TREE, which is common across all
                   5248: buildlink3.mk files and is used to track the dependency tree.
1.1       dsieger  5249: 
1.184     rillig   5250: The main section is protected from multiple inclusion and controls how the
                   5251: dependency on pkg is added. Several important variables are set in the section:
1.1       dsieger  5252: 
1.185     wiz      5253:   * BUILDLINK_API_DEPENDS.pkg is the dependency version recorded in the
1.184     rillig   5254:     installed package; this should always be set using += to ensure that we're
                   5255:     appending to any pre-existing list of values. This variable should be set
1.185     wiz      5256:     to the last version of the package that had an backwards-incompatible API
1.184     rillig   5257:     change.
1.1       dsieger  5258: 
1.184     rillig   5259:   * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
1.1       dsieger  5260: 
1.184     rillig   5261:   * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
                   5262:     BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
                   5263:     is selected by setting BUILDLINK_DEPMETHOD.pkg to "build". By default, the
                   5264:     full dependency is used.
1.1       dsieger  5265: 
1.184     rillig   5266:   * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
                   5267:     of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
                   5268:     library search paths. These default to "include" and "lib" respectively.
1.1       dsieger  5269: 
1.184     rillig   5270:   * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
                   5271:     to add to CPPFLAGS, which are passed on to the configure and build phases.
                   5272:     The "-I" option should be avoided and instead be handled using
                   5273:     BUILDLINK_INCDIRS.pkg as above.
1.66      asau     5274: 
1.184     rillig   5275: The following variables are all optionally defined within this second section
                   5276: (protected against multiple inclusion) and control which package files are
                   5277: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
                   5278: symlinking:
1.23      jakllsch 5279: 
1.184     rillig   5280:   * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
                   5281:     {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
                   5282:     *.h.
1.1       dsieger  5283: 
1.184     rillig   5284:   * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
                   5285:     to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
                   5286:     resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
                   5287:     takes the +CONTENTS of a pkg and filters it through $
                   5288:     {BUILDLINK_CONTENTS_FILTER.pkg}.
1.1       dsieger  5289: 
1.184     rillig   5290:   * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
                   5291:     filters +CONTENTS input into a list of files relative to $
                   5292:     {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
                   5293:     outputs the contents of the include and lib directories in the package
                   5294:     +CONTENTS.
1.1       dsieger  5295: 
1.184     rillig   5296:   * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
                   5297:     used to transform the name of the source filename into a destination
                   5298:     filename, e.g. -e "s|/curses.h|/ncurses.h|g".
1.1       dsieger  5299: 
1.184     rillig   5300: This section can additionally include any buildlink3.mk needed for pkg's
                   5301: library dependencies. Including these buildlink3.mk files means that the
                   5302: headers and libraries for these dependencies are also symlinked into $
                   5303: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
                   5304: are only added for directly include buildlink3.mk files.
1.1       dsieger  5305: 
1.184     rillig   5306: When providing a buildlink3.mk and including other buildlink3.mk files in it,
                   5307: please only add necessary ones, i.e., those whose libraries or header files are
                   5308: automatically exposed when the package is use.
1.1       dsieger  5309: 
1.184     rillig   5310: In particular, if only an executable (bin/foo) is linked against a library,
                   5311: that library does not need to be propagated in the buildlink3.mk file.
1.1       dsieger  5312: 
1.184     rillig   5313: The following steps should help you decide if a buildlink3.mk file needs to be
                   5314: included:
1.1       dsieger  5315: 
1.184     rillig   5316:   * Look at the installed header files: What headers do they include? The
                   5317:     packages providing these files must be buildlinked.
1.1       dsieger  5318: 
1.184     rillig   5319:   * Run ldd on all installed libraries and look against what other libraries
                   5320:     they link. Some of the packages providing these probably need to be
                   5321:     buildlinked; however, it's not automatic, since e.g. GTK on some systems
                   5322:     pulls in the X libraries, so they will show up in the ldd output, while on
                   5323:     others (like OS X) it won't. ldd output can thus only be used as a hint.
1.1       dsieger  5324: 
1.184     rillig   5325: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
                   5326: buildlink3.mk files
1.16      jnemeth  5327: 
1.185     wiz      5328: Both variables set lower bounds for a version of this package. The two
                   5329: variables differ in that one describes source compatibility (API) and the other
                   5330: binary compatibility (ABI). The difference is that a change in the API breaks
                   5331: compilation of programs while changes in the ABI stop compiled programs from
                   5332: running.
                   5333: 
                   5334: The BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk should be changed
                   5335: very rarely. (One possible scenario: If all packages using this package need a
                   5336: higher version than defined in the buildlink3.mk, BUILDLINK_API_DEPENDS.pkg
                   5337: could be updated to that higher version.)
                   5338: 
                   5339: On the other hand, changes to BUILDLINK_ABI_DEPENDS.pkg are more common. The
                   5340: variable will need to be updated every time the major version of one of its
                   5341: shared libraries is changed, or any other change where a binary built against
                   5342: the previous version of the package will not run against the new version any
                   5343: longer.
                   5344: 
                   5345: In such a case, the package's BUILDLINK_ABI_DEPENDS.pkg must be increased to
                   5346: require the new package version. Then the PKGREVISION of all packages foo that
                   5347: depend on this package need to be increased, and if they have buildlink3.mk
                   5348: files, BUILDLINK_ABI_DEPENDS.foo in their buildlink3.mk files must be increased
                   5349: to the new version as well. This is required so that a package will pull in the
                   5350: versions of the packages that use the new ABI and that the packages'
                   5351: PKGREVISIONs uniquely identify the packages built against the new ABI. The
                   5352: pkgtools/revbump package can help with these updates.
1.1       dsieger  5353: 
1.184     rillig   5354: See Section 21.1.5, "Handling dependencies" for more information about
1.185     wiz      5355: dependencies on other packages, including the BUILDLINK_API_DEPENDS
                   5356: definitions.
1.1       dsieger  5357: 
1.184     rillig   5358: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
1.185     wiz      5359: BUILDLINK_ABI_DEPENDS.pkg in a buildlink3.mk file as we don't want to cause
                   5360: unneeded package deletions and rebuilds. In many cases, new versions of
                   5361: packages work just fine with older dependencies.
1.1       dsieger  5362: 
1.211   ! gutterid 5363: Also, it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
1.184     rillig   5364: BUILDLINK_API_DEPENDS.pkg.
1.1       dsieger  5365: 
1.211   ! gutterid 5366: Note there is also the distinction that users are able to disable enforcement
        !          5367: of ABI dependencies using the USE_ABI_DEPENDS variable, but there is no
        !          5368: equivalent option for API dependencies.
        !          5369: 
1.184     rillig   5370: 18.3. Writing builtin.mk files
1.1       dsieger  5371: 
1.184     rillig   5372: Some packages in pkgsrc install headers and libraries that coincide with
                   5373: headers and libraries present in the base system. Aside from a buildlink3.mk
                   5374: file, these packages should also include a builtin.mk file that includes the
                   5375: necessary checks to decide whether using the built-in software or the pkgsrc
                   5376: software is appropriate.
1.1       dsieger  5377: 
1.184     rillig   5378: The only requirements of a builtin.mk file for pkg are:
1.1       dsieger  5379: 
1.184     rillig   5380:  1. It should set USE_BUILTIN.pkg to either "yes" or "no" after it is included.
1.1       dsieger  5381: 
1.184     rillig   5382:  2. It should not override any USE_BUILTIN.pkg which is already set before the
                   5383:     builtin.mk file is included.
1.1       dsieger  5384: 
1.184     rillig   5385:  3. It should be written to allow multiple inclusion. This is very important
                   5386:     and takes careful attention to Makefile coding.
1.1       dsieger  5387: 
1.184     rillig   5388: 18.3.1. Anatomy of a builtin.mk file
1.1       dsieger  5389: 
1.184     rillig   5390: The following is the recommended template for builtin.mk files:
1.1       dsieger  5391: 
1.184     rillig   5392: .if !defined(IS_BUILTIN.foo)
                   5393: #
                   5394: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
                   5395: # genuinely exists in the system or not.
                   5396: #
                   5397: IS_BUILTIN.foo?=        no
1.1       dsieger  5398: 
1.184     rillig   5399: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
                   5400: # version can be determined.
                   5401: #
                   5402: .  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
                   5403: BUILTIN_PKG.foo?=       foo-1.0
                   5404: .  endif
                   5405: .endif  # IS_BUILTIN.foo
1.1       dsieger  5406: 
1.184     rillig   5407: .if !defined(USE_BUILTIN.foo)
                   5408: USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
                   5409: .  if defined(BUILTIN_PKG.foo)
                   5410: .    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
                   5411: .      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
                   5412: USE_BUILTIN.foo!=                                                       \
                   5413:         ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}            \
                   5414:         && ${ECHO} "yes" || ${ECHO} "no"
                   5415: .      endif
                   5416: .    endfor
                   5417: .  endif
                   5418: .endif  # USE_BUILTIN.foo
1.1       dsieger  5419: 
1.184     rillig   5420: CHECK_BUILTIN.foo?=     no
                   5421: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
                   5422: #
                   5423: # Here we place code that depends on whether USE_BUILTIN.foo is set to
                   5424: # "yes" or "no".
                   5425: #
                   5426: .endif  # CHECK_BUILTIN.foo
1.1       dsieger  5427: 
1.184     rillig   5428: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
                   5429: base system. This should not be a base system software with similar
                   5430: functionality to pkg; it should only be "yes" if the actual package is included
                   5431: as part of the base system. This variable is only used internally within the
                   5432: builtin.mk file.
1.1       dsieger  5433: 
1.184     rillig   5434: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
                   5435: system if it exists (if IS_BUILTIN.pkg is "yes"). This variable is only used
                   5436: internally within the builtin.mk file.
1.1       dsieger  5437: 
1.184     rillig   5438: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
                   5439: The code in this section must make the determination whether the built-in
                   5440: software is adequate to satisfy the dependencies listed in
                   5441: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
                   5442: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg 
                   5443: must be set to the correct value by the end of the builtin.mk file. Note that
                   5444: USE_BUILTIN.pkg may be "yes" even if IS_BUILTIN.pkg is "no" because we may make
                   5445: the determination that the built-in version of the software is similar enough
                   5446: to be used as a replacement.
1.1       dsieger  5447: 
1.184     rillig   5448: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
                   5449: the value of USE_BUILTIN.pkg set in the previous section. This typically
                   5450: includes, e.g., adding additional dependency restrictions and listing
                   5451: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
1.1       dsieger  5452: 
1.184     rillig   5453: 18.3.2. Global preferences for native or pkgsrc software
1.1       dsieger  5454: 
1.184     rillig   5455: When building packages, it's possible to choose whether to set a global
                   5456: preference for using either the built-in (native) version or the pkgsrc version
                   5457: of software to satisfy a dependency. This is controlled by setting
                   5458: PREFER_PKGSRC and PREFER_NATIVE. These variables take values of either "yes", "
                   5459: no", or a list of packages. PREFER_PKGSRC tells pkgsrc to use the pkgsrc
                   5460: versions of software, while PREFER_NATIVE tells pkgsrc to use the built-in
                   5461: versions. Preferences are determined by the most specific instance of the
                   5462: package in either PREFER_PKGSRC or PREFER_NATIVE. If a package is specified in
                   5463: neither or in both variables, then PREFER_PKGSRC has precedence over
                   5464: PREFER_NATIVE. For example, to require using pkgsrc versions of software for
                   5465: all but the most basic bits on a NetBSD system, you can set:
1.1       dsieger  5466: 
1.184     rillig   5467: PREFER_PKGSRC=  yes
                   5468: PREFER_NATIVE=  getopt skey tcp_wrappers
1.1       dsieger  5469: 
1.184     rillig   5470: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
                   5471: it is simply ignored in that list.
1.1       dsieger  5472: 
1.191     bacon    5473: PREFER_PKGSRC and PREFER_NATIVE should be set during bootstrap to ensure that
                   5474: the bootstrap process does not use inapropriate native tools as dependencies
                   5475: for core packages.
                   5476: 
                   5477: # ./bootstrap --prefer-pkgsrc yes --prefer-native openssl
                   5478: 
                   5479: Switching between settings globally at a later date can introduce complications
                   5480: with dependency resolution. This is caused by packages built with the opposite
                   5481: preference being installed alongside each other. Hence, any changes to these
                   5482: variables after bootstrap will necessitate rebuilding all packages depending on
                   5483: one whose preference has been changed. This is not trivial and should be
                   5484: avoided.
                   5485: 
                   5486: When using pkgsrc on Linux systems, there is high risk of "leakage", where
                   5487: programs installed by pkgsrc may inadvertently use a command or library not
                   5488: installed by pkgsrc, e.g. those installed by yum or apt. Such foreign
                   5489: dependencies may be installed, removed, or upgraded to a version incompatible
                   5490: with the pkgsrc package at any time, causing pkgsrc packages to subsequently
                   5491: malfunction. Pkgsrc cannot prevent this, as it has no control over other
                   5492: package managers. Another potential problem is that under Redhat Enterprise and
                   5493: related Linux systems, yum packages are only patched and never upgraded, so
                   5494: eventually they may become too outdated for use by pkgsrc. Even intentionally
                   5495: using foreign dependencies, not considered leakage, can lead to these problems,
                   5496: so it is generally discouraged. In order to minimize such problems,
                   5497: PREFER_PKGSRC defaults to "yes" on Linux systems. This ensures that pkgsrc is
                   5498: aware of any changes to dependency packages and can rebuild or upgrade the
                   5499: entire dependency tree as needed. This default can be overridden by setting
                   5500: --prefer-pkgsrc to "no" or a list of packages, or by setting --prefer-native to
                   5501: "yes".
1.1       dsieger  5502: 
1.184     rillig   5503: Chapter 19. PLIST issues
1.1       dsieger  5504: 
1.184     rillig   5505: Table of Contents
1.1       dsieger  5506: 
1.184     rillig   5507: 19.1. RCS ID
                   5508: 19.2. Semi-automatic PLIST generation
                   5509: 19.3. Tweaking output of make print-PLIST
                   5510: 19.4. Variable substitution in PLIST
                   5511: 19.5. Man page compression
                   5512: 19.6. Changing PLIST source with PLIST_SRC
                   5513: 19.7. Platform-specific and differing PLISTs
                   5514: 19.8. Build-specific PLISTs
                   5515: 19.9. Sharing directories between packages
1.1       dsieger  5516: 
1.184     rillig   5517: The PLIST file contains a package's "packing list", i.e. a list of files that
                   5518: belong to the package (relative to the ${PREFIX} directory it's been installed
                   5519: in) plus some additional statements - see the pkg_create(1) man page for a full
                   5520: list. This chapter addresses some issues that need attention when dealing with
                   5521: the PLIST file (or files, see below!).
1.1       dsieger  5522: 
1.184     rillig   5523: 19.1. RCS ID
1.1       dsieger  5524: 
1.184     rillig   5525: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
1.1       dsieger  5526: 
1.184     rillig   5527: @comment $NetBSD $
1.1       dsieger  5528: 
1.184     rillig   5529: An artificial space has been added between NetBSD and $, this is a workaround
                   5530: here to prevent CVS expanding to the filename of the guide. When adding the RCS
                   5531: ID the space should be omitted.
1.38      wiz      5532: 
1.184     rillig   5533: 19.2. Semi-automatic PLIST generation
1.1       dsieger  5534: 
1.184     rillig   5535: You can use the make print-PLIST command to output a PLIST that matches any new
                   5536: files since the package was extracted. See Section 13.17, "Other helpful
                   5537: targets" for more information on this target.
1.11      rillig   5538: 
1.184     rillig   5539: 19.3. Tweaking output of make print-PLIST
1.1       dsieger  5540: 
1.184     rillig   5541: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
                   5542: used to filter the output of print-PLIST. You can append any chunk of AWK
                   5543: scripting you like to it, but be careful with quoting.
1.1       dsieger  5544: 
1.184     rillig   5545: For example, to get all files inside the libdata/foo directory removed from the
                   5546: resulting PLIST:
1.1       dsieger  5547: 
1.184     rillig   5548: PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
1.1       dsieger  5549: 
1.185     wiz      5550: The PRINT_PLIST_AWK transformations are evaluated after the file list and
                   5551: directory list are sorted. EARLY_PRINT_PLIST_AWK is like PRINT_PLIST_AWK except
                   5552: it operates before the file list and directory list are sorted.
                   5553: 
1.184     rillig   5554: 19.4. Variable substitution in PLIST
1.1       dsieger  5555: 
1.184     rillig   5556: A number of variables are substituted automatically in PLISTs when a package is
                   5557: installed on a system. This includes the following variables:
1.1       dsieger  5558: 
1.184     rillig   5559: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
1.1       dsieger  5560: 
1.184     rillig   5561:     Some packages like emacs and perl embed information about which
                   5562:     architecture they were built on into the pathnames where they install their
                   5563:     files. To handle this case, PLIST will be preprocessed before actually
                   5564:     used, and the symbol "${MACHINE_ARCH}" will be replaced by what uname -p
                   5565:     gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
                   5566:     PLIST somewhere - use this on packages that have GNU autoconf-created
                   5567:     configure scripts.
1.1       dsieger  5568: 
1.184     rillig   5569:     Legacy note
1.1       dsieger  5570: 
1.184     rillig   5571:     There used to be a symbol "$ARCH" that was replaced by the output of uname
                   5572:     -m, but that's no longer supported and has been removed.
1.1       dsieger  5573: 
1.184     rillig   5574: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
1.1       dsieger  5575: 
1.184     rillig   5576:     Some packages want to embed the OS name and version into some paths. To do
                   5577:     this, use these variables in the PLIST:
1.1       dsieger  5578: 
1.184     rillig   5579:       + ${OPSYS} - output of "uname -s"
1.1       dsieger  5580: 
1.184     rillig   5581:       + ${LOWER_OPSYS} - lowercase common name (eg. "solaris")
1.1       dsieger  5582: 
1.184     rillig   5583:       + ${OS_VERSION} - "uname -r"
1.1       dsieger  5584: 
1.184     rillig   5585: For a list of values which are replaced by default, the output of make help
                   5586: topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
                   5587: PLIST_SUBST should help.
1.1       dsieger  5588: 
1.184     rillig   5589: If you want to change other variables not listed above, you can add variables
                   5590: and their expansions to this variable in the following way, similar to
                   5591: MESSAGE_SUBST (see Section 12.5, "Optional files"):
1.1       dsieger  5592: 
1.184     rillig   5593: PLIST_SUBST+=   SOMEVAR="somevalue"
1.1       dsieger  5594: 
1.184     rillig   5595: This replaces all occurrences of "${SOMEVAR}" in the PLIST with "somevalue".
1.1       dsieger  5596: 
1.184     rillig   5597: The PLIST_VARS variable can be used to simplify the common case of
                   5598: conditionally including some PLIST entries. It can be done by adding
                   5599: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
                   5600: entry should be included. This will substitute "${PLIST.foo}" in the PLIST with
                   5601: either """" or ""@comment "". For example, in Makefile:
1.1       dsieger  5602: 
1.184     rillig   5603: PLIST_VARS+=    foo
                   5604: .if condition
                   5605: PLIST.foo=      yes
                   5606: .else
1.1       dsieger  5607: 
1.184     rillig   5608: And then in PLIST:
1.1       dsieger  5609: 
1.184     rillig   5610: @comment $NetBSD $
                   5611: bin/bar
                   5612: man/man1/bar.1
                   5613: ${PLIST.foo}bin/foo
                   5614: ${PLIST.foo}man/man1/foo.1
                   5615: ${PLIST.foo}share/bar/foo.data
1.1       dsieger  5616: 
1.184     rillig   5617: An artificial space has been added between NetBSD and $, this is a workaround
                   5618: here to prevent CVS expanding to the filename of the guide. When adding the RCS
1.195     gutterid 5619: ID the space should be omitted.
1.1       dsieger  5620: 
1.184     rillig   5621: 19.5. Man page compression
1.1       dsieger  5622: 
1.184     rillig   5623: Man pages should be installed in compressed form if MANZ is set (in
                   5624: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
                   5625: suffix ".gz" is appended/removed automatically for man pages according to MANZ
                   5626: and MANCOMPRESSED being set or not, see above for details. This modification of
                   5627: the PLIST file is done on a copy of it, not PLIST itself.
1.100     leot     5628: 
1.184     rillig   5629: 19.6. Changing PLIST source with PLIST_SRC
1.100     leot     5630: 
1.184     rillig   5631: To use one or more files as source for the PLIST used in generating the binary
                   5632: package, set the variable PLIST_SRC to the names of that file(s). The files are
                   5633: later concatenated using cat(1), and the order of things is important. The
                   5634: default for PLIST_SRC is ${PKGDIR}/PLIST.
1.1       dsieger  5635: 
1.184     rillig   5636: 19.7. Platform-specific and differing PLISTs
1.1       dsieger  5637: 
1.184     rillig   5638: Some packages decide to install a different set of files based on the operating
                   5639: system being used. These differences can be automatically handled by using the
                   5640: following files:
1.1       dsieger  5641: 
1.184     rillig   5642:   * PLIST.common
1.1       dsieger  5643: 
1.184     rillig   5644:   * PLIST.${OPSYS}
1.1       dsieger  5645: 
1.184     rillig   5646:   * PLIST.${MACHINE_ARCH}
1.1       dsieger  5647: 
1.184     rillig   5648:   * PLIST.${OPSYS}-${MACHINE_ARCH}
1.1       dsieger  5649: 
1.184     rillig   5650:   * PLIST.common_end
1.1       dsieger  5651: 
1.184     rillig   5652: 19.8. Build-specific PLISTs
1.1       dsieger  5653: 
1.184     rillig   5654: Some packages decide to generate hard-to-guess file names during installation
                   5655: that are hard to wire down.
1.1       dsieger  5656: 
1.184     rillig   5657: In such cases, you can set the GENERATE_PLIST variable to shell code terminated
                   5658: (with a semicolon) that will output PLIST entries which will be appended to the
                   5659: PLIST
1.1       dsieger  5660: 
1.184     rillig   5661: You can find one example in editors/xemacs:
1.1       dsieger  5662: 
1.184     rillig   5663: GENERATE_PLIST+=        ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
1.1       dsieger  5664: 
1.184     rillig   5665: which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
1.1       dsieger  5666: 
1.184     rillig   5667: 19.9. Sharing directories between packages
1.1       dsieger  5668: 
1.184     rillig   5669: A "shared directory" is a directory where multiple (and unrelated) packages
                   5670: install files. These directories were problematic because you had to add
                   5671: special tricks in the PLIST to conditionally remove them, or have some
                   5672: centralized package handle them.
1.106     tnn      5673: 
1.184     rillig   5674: In pkgsrc, it is now easy: Each package should create directories and install
                   5675: files as needed; pkg_delete will remove any directories left empty after
                   5676: uninstalling a package.
1.106     tnn      5677: 
1.184     rillig   5678: If a package needs an empty directory to work, create the directory during
                   5679: installation as usual, and also add an entry to the PLIST:
1.1       dsieger  5680: 
1.184     rillig   5681: @pkgdir path/to/empty/directory
1.1       dsieger  5682: 
1.184     rillig   5683: or take a look at MAKE_DIRS and OWN_DIRS.
1.1       dsieger  5684: 
1.184     rillig   5685: Chapter 20. The pkginstall framework
1.1       dsieger  5686: 
1.184     rillig   5687: Table of Contents
1.1       dsieger  5688: 
1.184     rillig   5689: 20.1. Files and directories outside the installation prefix
1.1       dsieger  5690: 
1.184     rillig   5691:     20.1.1. Directory manipulation
                   5692:     20.1.2. File manipulation
1.1       dsieger  5693: 
1.184     rillig   5694: 20.2. Configuration files
1.1       dsieger  5695: 
1.184     rillig   5696:     20.2.1. How PKG_SYSCONFDIR is set
                   5697:     20.2.2. Telling the software where configuration files are
                   5698:     20.2.3. Patching installations
                   5699:     20.2.4. Disabling handling of configuration files
1.1       dsieger  5700: 
1.184     rillig   5701: 20.3. System startup scripts
1.1       dsieger  5702: 
1.184     rillig   5703:     20.3.1. Disabling handling of system startup scripts
1.1       dsieger  5704: 
1.184     rillig   5705: 20.4. System users and groups
                   5706: 20.5. System shells
1.1       dsieger  5707: 
1.184     rillig   5708:     20.5.1. Disabling shell registration
1.1       dsieger  5709: 
1.184     rillig   5710: 20.6. Fonts
1.1       dsieger  5711: 
1.184     rillig   5712:     20.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  5713: 
1.184     rillig   5714: This chapter describes the framework known as pkginstall, whose key features
                   5715: are:
1.1       dsieger  5716: 
1.184     rillig   5717:   * Generic installation and manipulation of directories and files outside the
                   5718:     pkgsrc-handled tree, LOCALBASE.
1.1       dsieger  5719: 
1.184     rillig   5720:   * Automatic handling of configuration files during installation, provided
                   5721:     that packages are correctly designed.
1.1       dsieger  5722: 
1.184     rillig   5723:   * Generation and installation of system startup scripts.
1.1       dsieger  5724: 
1.184     rillig   5725:   * Registration of system users and groups.
1.1       dsieger  5726: 
1.184     rillig   5727:   * Registration of system shells.
1.1       dsieger  5728: 
1.184     rillig   5729:   * Automatic updating of fonts databases.
1.1       dsieger  5730: 
1.184     rillig   5731: The following sections inspect each of the above points in detail.
1.1       dsieger  5732: 
1.184     rillig   5733: You may be thinking that many of the things described here could be easily done
                   5734: with simple code in the package's post-installation target (post-install). This
                   5735: is incorrect, as the code in them is only executed when building from source.
                   5736: Machines using binary packages could not benefit from it at all (as the code
                   5737: itself could be unavailable). Therefore, the only way to achieve any of the
                   5738: items described above is by means of the installation scripts, which are
                   5739: automatically generated by pkginstall.
1.1       dsieger  5740: 
1.184     rillig   5741: 20.1. Files and directories outside the installation prefix
1.95      wiz      5742: 
1.184     rillig   5743: As you already know, the PLIST file holds a list of files and directories that
                   5744: belong to a package. The names used in it are relative to the installation
                   5745: prefix (${PREFIX}), which means that it cannot register files outside this
                   5746: directory (absolute path names are not allowed). Despite this restriction, some
                   5747: packages need to install files outside this location; e.g., under ${VARBASE} or
                   5748: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
                   5749: installation time by using installation scripts.
1.95      wiz      5750: 
1.184     rillig   5751: The generic installation scripts are shell scripts that can contain arbitrary
                   5752: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
                   5753: which defaults to INSTALL. A similar variable exists for package removal
                   5754: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
                   5755: commands, so they have the potential to create and manage files anywhere in the
                   5756: file system.
1.95      wiz      5757: 
1.184     rillig   5758: Using these general installation files is not recommended, but may be needed in
                   5759: some special cases. One reason for avoiding them is that the user has to trust
                   5760: the packager that there is no unwanted or simply erroneous code included in the
                   5761: installation script. Also, previously there were many similar scripts for the
                   5762: same functionality, and fixing a common error involved finding and changing all
                   5763: of them.
1.95      wiz      5764: 
1.184     rillig   5765: The pkginstall framework offers another, standardized way. It provides generic
                   5766: scripts to abstract the manipulation of such files and directories based on
                   5767: variables set in the package's Makefile. The rest of this section describes
                   5768: these variables.
1.1       dsieger  5769: 
1.184     rillig   5770: 20.1.1. Directory manipulation
1.1       dsieger  5771: 
1.184     rillig   5772: The following variables can be set to request the creation of directories
                   5773: anywhere in the file system:
1.1       dsieger  5774: 
1.184     rillig   5775:   * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
                   5776:     and should attempt to be destroyed by the installation scripts. The
                   5777:     difference between the two is that the latter prompts the administrator to
                   5778:     remove any directories that may be left after deinstallation (because they
                   5779:     were not empty), while the former does not. Example:
1.1       dsieger  5780: 
1.184     rillig   5781:     MAKE_DIRS+=             ${VARBASE}/foo/private
1.1       dsieger  5782: 
1.184     rillig   5783:   * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
                   5784:     which directories should be created and should attempt to be destroyed by
                   5785:     the installation scripts. Each tuple holds the following values, separated
                   5786:     by spaces: the directory name, its owner, its group and its numerical mode.
                   5787:     For example:
1.1       dsieger  5788: 
1.184     rillig   5789:     MAKE_DIRS_PERMS+=       ${VARBASE}/foo/private \
                   5790:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  5791: 
1.184     rillig   5792:     The difference between the two is exactly the same as their non-PERMS
                   5793:     counterparts.
1.1       dsieger  5794: 
1.184     rillig   5795: 20.1.2. File manipulation
1.1       dsieger  5796: 
1.184     rillig   5797: Creating non-empty files outside the installation prefix is tricky because the
                   5798: PLIST forces all files to be inside it. To overcome this problem, the only
                   5799: solution is to extract the file in the known place (i.e., inside the
                   5800: installation prefix) and copy it to the appropriate location during
                   5801: installation (done by the installation scripts generated by pkginstall). We
                   5802: will call the former the master file in the following paragraphs, which
                   5803: describe the variables that can be used to automatically and consistently
                   5804: handle files outside the installation prefix:
1.1       dsieger  5805: 
1.184     rillig   5806:   * CONF_FILES and REQD_FILES are pairs of master and target files. During
                   5807:     installation time, the master file is copied to the target one if and only
                   5808:     if the latter does not exist. Upon deinstallation, the target file is
                   5809:     removed provided that it was not modified by the installation.
1.1       dsieger  5810: 
1.184     rillig   5811:     The difference between the two is that the latter prompts the administrator
                   5812:     to remove any files that may be left after deinstallation (because they
                   5813:     were not empty), while the former does not.
1.1       dsieger  5814: 
1.184     rillig   5815:   * CONF_FILES_PERMS and REQD_FILES_PERMS contain tuples describing master
                   5816:     files as well as their target locations. For each of them, it also
                   5817:     specifies their owner, their group and their numeric permissions, in this
                   5818:     order. For example:
1.1       dsieger  5819: 
1.184     rillig   5820:     REQD_FILES_PERMS+=      ${PREFIX}/share/somefile ${VARBASE}/somefile \
                   5821:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  5822: 
1.184     rillig   5823:     The difference between the two is exactly the same as their non-PERMS
                   5824:     counterparts.
1.1       dsieger  5825: 
1.184     rillig   5826: 20.2. Configuration files
1.1       dsieger  5827: 
1.184     rillig   5828: Configuration files are special in the sense that they are installed in their
                   5829: own specific directory, PKG_SYSCONFDIR, and need special treatment during
                   5830: installation (most of which is automated by pkginstall). The main concept you
                   5831: must bear in mind is that files marked as configuration files are automatically
                   5832: copied to the right place (somewhere inside PKG_SYSCONFDIR) during installation
                   5833: if and only if they didn't exist before. Similarly, they will not be removed if
                   5834: they have local modifications. This ensures that administrators never lose any
                   5835: custom changes they may have made.
1.1       dsieger  5836: 
1.184     rillig   5837: 20.2.1. How PKG_SYSCONFDIR is set
1.1       dsieger  5838: 
1.184     rillig   5839: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
                   5840: shall be installed. Its contents are set based upon the following variables:
1.1       dsieger  5841: 
1.184     rillig   5842:   * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
                   5843:     etc although it may be overridden by the user to point to his preferred
                   5844:     location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
1.1       dsieger  5845: 
1.184     rillig   5846:   * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
                   5847:     configuration files for the package being built shall be installed. The
                   5848:     definition of this variable only makes sense in the package's Makefile
                   5849:     (i.e., it is not user-customizable).
1.1       dsieger  5850: 
1.184     rillig   5851:     As an example, consider the Apache package, www/apache24, which places its
                   5852:     configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
                   5853:     should be set in the package Makefile.
1.1       dsieger  5854: 
1.184     rillig   5855:   * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
                   5856:     package's configuration directory (if different from PKG_SYSCONFBASE). It
                   5857:     defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
1.1       dsieger  5858: 
1.184     rillig   5859:   * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
                   5860:     configuration files for the package identified by PKG_SYSCONFVAR's shall be
                   5861:     placed.
1.1       dsieger  5862: 
1.184     rillig   5863: Based on the above variables, pkginstall determines the value of
                   5864: PKG_SYSCONFDIR, which is the only variable that can be used within a package to
                   5865: refer to its configuration directory. The algorithm used to set its value is
                   5866: basically the following:
1.1       dsieger  5867: 
1.184     rillig   5868:  1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
1.1       dsieger  5869: 
1.184     rillig   5870:  2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
                   5871:     package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
                   5872:     {PKG_SYSCONFSUBDIR}.
1.1       dsieger  5873: 
1.184     rillig   5874:  3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
1.1       dsieger  5875: 
1.184     rillig   5876: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
                   5877: OWN_DIRS. See Section 20.1.1, "Directory manipulation" what this means. This
                   5878: does not apply to subdirectories of ${PKG_SYSCONFDIR}, they still have to be
                   5879: created with OWN_DIRS or MAKE_DIRS.
1.1       dsieger  5880: 
1.184     rillig   5881: 20.2.2. Telling the software where configuration files are
1.1       dsieger  5882: 
1.184     rillig   5883: Given that pkgsrc (and users!) expect configuration files to be in a known
                   5884: place, you need to teach each package where it shall install its files. In some
                   5885: cases you will have to patch the package Makefiles to achieve it. If you are
                   5886: lucky, though, it may be as easy as passing an extra flag to the configuration
                   5887: script; this is the case of GNU Autoconf- generated files:
1.1       dsieger  5888: 
1.184     rillig   5889: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1       dsieger  5890: 
1.184     rillig   5891: Note that this specifies where the package has to look for its configuration
                   5892: files, not where they will be originally installed (although the difference is
                   5893: never explicit, unfortunately).
1.1       dsieger  5894: 
1.184     rillig   5895: 20.2.3. Patching installations
1.1       dsieger  5896: 
1.184     rillig   5897: As said before, pkginstall automatically handles configuration files. This
                   5898: means that the packages themselves must not touch the contents of $
                   5899: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
                   5900: will, out of the box, mess with the contents of that directory. So what is the
                   5901: correct procedure to fix this issue?
1.1       dsieger  5902: 
1.184     rillig   5903: You must teach the package (usually by manually patching it) to install any
                   5904: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
                   5905: This way, the PLIST registers them and the administrator always has the
                   5906: original copies available.
1.1       dsieger  5907: 
1.184     rillig   5908: Once the required configuration files are in place (i.e., under the examples
                   5909: hierarchy), the pkginstall framework can use them as master copies during the
                   5910: package installation to update what is in ${PKG_SYSCONFDIR}. To achieve this,
                   5911: the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
                   5912: Section 20.1.2, "File manipulation" for information about their syntax and
                   5913: their purpose. Here is an example, taken from the mail/mutt package:
1.1       dsieger  5914: 
1.184     rillig   5915: EGDIR=        ${PREFIX}/share/doc/mutt/samples
                   5916: CONF_FILES=   ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1       dsieger  5917: 
1.184     rillig   5918: Note that the EGDIR variable is specific to that package and has no meaning
                   5919: outside it.
1.1       dsieger  5920: 
1.184     rillig   5921: 20.2.4. Disabling handling of configuration files
1.1       dsieger  5922: 
1.184     rillig   5923: The automatic copying of config files can be toggled by setting the environment
                   5924: variable PKG_CONFIG prior to package installation.
1.1       dsieger  5925: 
1.184     rillig   5926: 20.3. System startup scripts
1.1       dsieger  5927: 
1.184     rillig   5928: System startup scripts are special files because they must be installed in a
                   5929: place known by the underlying OS, usually outside the installation prefix.
                   5930: Therefore, the same rules described in Section 20.1, "Files and directories
                   5931: outside the installation prefix" apply, and the same solutions can be used.
                   5932: However, pkginstall provides a special mechanism to handle these files.
1.1       dsieger  5933: 
1.184     rillig   5934: In order to provide system startup scripts, the package has to:
1.1       dsieger  5935: 
1.184     rillig   5936:  1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
                   5937:     Considering the print/cups package as an example, it has a cupsd.sh in its
                   5938:     files directory.
1.95      wiz      5939: 
1.184     rillig   5940:  2. Tell pkginstall to handle it, appending the name of the script, without its
                   5941:     extension, to the RCD_SCRIPTS variable. Continuing the previous example:
1.95      wiz      5942: 
1.184     rillig   5943:     RCD_SCRIPTS+=   cupsd
1.95      wiz      5944: 
1.184     rillig   5945: Once this is done, pkginstall will do the following steps for each script in an
                   5946: automated fashion:
1.95      wiz      5947: 
1.184     rillig   5948:  1. Process the file found in the files directory applying all the
                   5949:     substitutions described in the FILES_SUBST variable.
1.1       dsieger  5950: 
1.184     rillig   5951:  2. Copy the script from the files directory to the examples hierarchy, $
                   5952:     {PREFIX}/share/examples/rc.d/. Note that this master file must be
                   5953:     explicitly registered in the PLIST.
1.1       dsieger  5954: 
1.184     rillig   5955:  3. Add code to the installation scripts to copy the startup script from the
                   5956:     examples hierarchy into the system-wide startup scripts directory.
1.1       dsieger  5957: 
1.184     rillig   5958: 20.3.1. Disabling handling of system startup scripts
1.1       dsieger  5959: 
1.184     rillig   5960: The automatic copying of config files can be toggled by setting the environment
                   5961: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
                   5962: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
                   5963: rc.d/, no matter what the value of this variable is.
1.1       dsieger  5964: 
1.184     rillig   5965: 20.4. System users and groups
1.1       dsieger  5966: 
1.184     rillig   5967: If a package needs to create special users and/or groups during installation,
                   5968: it can do so by using the pkginstall framework.
1.1       dsieger  5969: 
1.184     rillig   5970: Users can be created by adding entries to the PKG_USERS variable. Each entry
                   5971: has the following syntax:
1.1       dsieger  5972: 
1.184     rillig   5973: user:group
1.1       dsieger  5974: 
1.184     rillig   5975: Further specification of user details may be done by setting per-user
                   5976: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
                   5977: user's description or comment. PKG_HOME.user is the user's home directory, and
                   5978: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
                   5979: and defaults to /sbin/nologin if not specified.
1.1       dsieger  5980: 
1.184     rillig   5981: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
                   5982: whose syntax is:
1.1       dsieger  5983: 
1.184     rillig   5984: group
1.1       dsieger  5985: 
1.184     rillig   5986: The numeric GID of the group may be set by defining PKG_GID.group.
1.1       dsieger  5987: 
1.184     rillig   5988: If a package needs to create the users and groups at an earlier stage, then it
                   5989: can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
                   5990: the phase before which the users and groups are created. In this case, the
                   5991: numeric UIDs and GIDs of the created users and groups are automatically
                   5992: hardcoded into the final installation scripts.
1.1       dsieger  5993: 
1.184     rillig   5994: 20.5. System shells
1.1       dsieger  5995: 
1.184     rillig   5996: Packages that install system shells should register them in the shell database,
                   5997: /etc/shells, to make things easier to the administrator. This must be done from
                   5998: the installation scripts to keep binary packages working on any system.
                   5999: pkginstall provides an easy way to accomplish this task.
1.1       dsieger  6000: 
1.184     rillig   6001: When a package provides a shell interpreter, it has to set the PKG_SHELL
                   6002: variable to its absolute file name. This will add some hooks to the
                   6003: installation scripts to handle it. Consider the following example, taken from
                   6004: shells/zsh:
1.1       dsieger  6005: 
1.184     rillig   6006: PKG_SHELL=      ${PREFIX}/bin/zsh
1.1       dsieger  6007: 
1.184     rillig   6008: 20.5.1. Disabling shell registration
1.1       dsieger  6009: 
1.184     rillig   6010: The automatic registration of shell interpreters can be disabled by the
                   6011: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
1.1       dsieger  6012: 
1.184     rillig   6013: 20.6. Fonts
1.1       dsieger  6014: 
1.184     rillig   6015: Packages that install X11 fonts should update the database files that index the
                   6016: fonts within each fonts directory. This can easily be accomplished within the
                   6017: pkginstall framework.
1.1       dsieger  6018: 
1.184     rillig   6019: When a package installs X11 fonts, it must list the directories in which fonts
                   6020: are installed in the FONTS_DIRS.type variables, where type can be one of "ttf",
                   6021: "type1" or "x11". This will add hooks to the installation scripts to run the
                   6022: appropriate commands to update the fonts database files within each of those
                   6023: directories. For convenience, if the directory path is relative, it is taken to
                   6024: be relative to the package's installation prefix. Consider the following
                   6025: example, taken from fonts/dbz-ttf:
1.1       dsieger  6026: 
1.184     rillig   6027: FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
1.1       dsieger  6028: 
1.184     rillig   6029: 20.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  6030: 
1.184     rillig   6031: The automatic update of fonts databases can be disabled by the administrator by
                   6032: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
1.1       dsieger  6033: 
1.154     rillig   6034: Chapter 21. Making your package work
1.1       dsieger  6035: 
                   6036: Table of Contents
                   6037: 
1.154     rillig   6038: 21.1. General operation
1.1       dsieger  6039: 
1.154     rillig   6040:     21.1.1. How to pull in user-settable variables from mk.conf
                   6041:     21.1.2. User interaction
                   6042:     21.1.3. Handling licenses
                   6043:     21.1.4. Restricted packages
                   6044:     21.1.5. Handling dependencies
                   6045:     21.1.6. Handling conflicts with other packages
                   6046:     21.1.7. Packages that cannot or should not be built
                   6047:     21.1.8. Packages which should not be deleted, once installed
                   6048:     21.1.9. Handling packages with security problems
                   6049:     21.1.10. How to handle incrementing versions when fixing an existing
1.1       dsieger  6050:         package
1.154     rillig   6051:     21.1.11. Substituting variable text in the package files (the SUBST
1.1       dsieger  6052:         framework)
                   6053: 
1.154     rillig   6054: 21.2. The fetch phase
1.1       dsieger  6055: 
1.154     rillig   6056:     21.2.1. Packages whose distfiles aren't available for plain downloading
                   6057:     21.2.2. How to handle modified distfiles with the 'old' name
                   6058:     21.2.3. Packages hosted on github.com
                   6059: 
                   6060: 21.3. The configure phase
                   6061: 
                   6062:     21.3.1. Shared libraries - libtool
                   6063:     21.3.2. Using libtool on GNU packages that already support libtool
                   6064:     21.3.3. GNU Autoconf/Automake
                   6065: 
                   6066: 21.4. Programming languages
                   6067: 
                   6068:     21.4.1. C, C++, and Fortran
                   6069:     21.4.2. Java
1.205     wiz      6070:     21.4.3. Go
                   6071:     21.4.4. Packages containing Perl scripts
                   6072:     21.4.5. Packages containing shell scripts
                   6073:     21.4.6. Other programming languages
1.154     rillig   6074: 
                   6075: 21.5. The build phase
                   6076: 
                   6077:     21.5.1. Compiling C and C++ code conditionally
                   6078:     21.5.2. How to handle compiler bugs
1.172     rillig   6079:     21.5.3. No such file or directory
                   6080:     21.5.4. Undefined reference to "..."
                   6081:     21.5.5. Running out of memory
1.154     rillig   6082: 
                   6083: 21.6. The install phase
                   6084: 
                   6085:     21.6.1. Creating needed directories
                   6086:     21.6.2. Where to install documentation
                   6087:     21.6.3. Installing highscore files
                   6088:     21.6.4. Adding DESTDIR support to packages
                   6089:     21.6.5. Packages with hardcoded paths to other interpreters
1.203     nia      6090:     21.6.6. Packages installing Perl modules
1.154     rillig   6091:     21.6.7. Packages installing info files
                   6092:     21.6.8. Packages installing man pages
1.203     nia      6093:     21.6.9. Packages installing X11 fonts
                   6094:     21.6.10. Packages installing SGML or XML data
                   6095:     21.6.11. Packages installing extensions to the MIME database
                   6096:     21.6.12. Packages using intltool
                   6097:     21.6.13. Packages installing startup scripts
                   6098:     21.6.14. Packages installing TeX modules
                   6099:     21.6.15. Packages supporting running binaries in emulation
                   6100:     21.6.16. Packages installing hicolor icons
                   6101:     21.6.17. Packages installing desktop files
1.1       dsieger  6102: 
1.154     rillig   6103: 21.7. Marking packages as having problems
1.1       dsieger  6104: 
1.154     rillig   6105: 21.1. General operation
1.1       dsieger  6106: 
                   6107: One appealing feature of pkgsrc is that it runs on many different platforms. As
                   6108: a result, it is important to ensure, where possible, that packages in pkgsrc
                   6109: are portable. This chapter mentions some particular details you should pay
                   6110: attention to while working on pkgsrc.
                   6111: 
1.154     rillig   6112: 21.1.1. How to pull in user-settable variables from mk.conf
1.1       dsieger  6113: 
                   6114: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4       rillig   6115: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
                   6116: those variables in the preprocessor directives of make(1) (for example .if or
                   6117: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
                   6118: loads the user preferences.
1.1       dsieger  6119: 
                   6120: But note that some variables may not be completely defined after ../../mk/
                   6121: bsd.prefs.mk has been included, as they may contain references to variables
1.108     rillig   6122: that are not yet defined. In shell commands (the lines in Makefile that are
                   6123: indented with a tab) this is no problem, since variables are only expanded when
                   6124: they are used. But in the preprocessor directives mentioned above and in
                   6125: dependency lines (of the form target: dependencies) the variables are expanded
                   6126: at load time.
1.1       dsieger  6127: 
                   6128: Note
                   6129: 
1.108     rillig   6130: To check whether a variable can be used at load time, run pkglint -Wall on your
                   6131: package.
1.1       dsieger  6132: 
1.154     rillig   6133: 21.1.2. User interaction
1.1       dsieger  6134: 
                   6135: Occasionally, packages require interaction from the user, and this can be in a
                   6136: number of ways:
                   6137: 
                   6138:   * When fetching the distfiles, some packages require user interaction such as
                   6139:     entering username/password or accepting a license on a web page.
                   6140: 
                   6141:   * When extracting the distfiles, some packages may ask for passwords.
                   6142: 
                   6143:   * help to configure the package before it is built
                   6144: 
                   6145:   * help during the build process
                   6146: 
                   6147:   * help during the installation of a package
                   6148: 
1.108     rillig   6149: A package can set the INTERACTIVE_STAGE variable to define which stages need
                   6150: interaction. This should be done in the package's Makefile, e.g.:
1.1       dsieger  6151: 
                   6152: INTERACTIVE_STAGE=      configure install
                   6153: 
                   6154: The user can then decide to skip this package by setting the BATCH variable.
1.108     rillig   6155: Packages that require interaction are also excluded from bulk builds.
1.1       dsieger  6156: 
1.154     rillig   6157: 21.1.3. Handling licenses
1.1       dsieger  6158: 
                   6159: Authors of software can choose the licence under which software can be copied.
1.111     sevan    6160: The Free Software Foundation has declared some licenses "Free", and the Open
                   6161: Source Initiative has a definition of "Open Source".
                   6162: 
                   6163: By default, pkgsrc allows packages with Free or Open Source licenses to be
                   6164: built. To allow packages with other licenses to be built as well, the pkgsrc
                   6165: user needs to add these licenses to the ACCEPTABLE_LICENSES variable in mk.conf
                   6166: . Note that this variable only affects which packages may be built, while the
                   6167: license terms often also restrict the actual use of the package and its
                   6168: redistribution.
1.1       dsieger  6169: 
                   6170: One might want to only install packages with a BSD license, or the GPL, and not
1.20      jnemeth  6171: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
1.111     sevan    6172: variable. The pkgsrc user can override the default by setting the
                   6173: ACCEPTABLE_LICENSES variable with "=" instead of "+=". The licenses accepted by
                   6174: default are defined in the DEFAULT_ACCEPTABLE_LICENSES variable in the file
                   6175: pkgsrc/mk/license.mk.
1.1       dsieger  6176: 
                   6177: The license tag mechanism is intended to address copyright-related issues
                   6178: surrounding building, installing and using a package, and not to address
1.20      jnemeth  6179: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
                   6180: redistribution restrictions should set these tags.
1.1       dsieger  6181: 
                   6182: Denoting that a package may be copied according to a particular license is done
                   6183: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
                   6184: string identifying the license, e.g. in graphics/xv:
                   6185: 
                   6186: LICENSE=        xv-license
                   6187: 
                   6188: When trying to build, the user will get a notice that the package is covered by
                   6189: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
                   6190: 
                   6191: % make
                   6192: ===> xv-3.10anb9 has an unacceptable license: xv-license.
                   6193: ===>     To view the license, enter "/usr/bin/make show-license".
                   6194: ===>     To indicate acceptance, add this line to your /etc/mk.conf:
                   6195: ===>     ACCEPTABLE_LICENSES+=xv-license
                   6196: *** Error code 1
                   6197: 
                   6198: The license can be viewed with make show-license, and if the user so chooses,
1.4       rillig   6199: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1       dsieger  6200: should not in the future fail because of that license:
                   6201: 
                   6202: ACCEPTABLE_LICENSES+=xv-license
                   6203: 
1.111     sevan    6204: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
                   6205: is deprecated because it does not crisply refer to a particular license text.
                   6206: Another problem with such usage is that it does not enable a user to tell
                   6207: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
                   6208: for all packages with that tag.
                   6209: 
1.154     rillig   6210: 21.1.3.1. Adding a package with a new license
1.1       dsieger  6211: 
1.49      rodent   6212: When adding a package with a new license, the following steps are required:
                   6213: 
1.111     sevan    6214:  1. Check whether the license qualifies as Free or Open Source by referencing
                   6215:     Various Licenses and Comments about Them and Licenses by Name | Open Source
                   6216:     Initiative. If this is the case, the filename in pkgsrc/licenses/ does not
                   6217:     need the -license suffix, and the license name should be added to:
1.49      rodent   6218: 
                   6219:       + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
                   6220: 
                   6221:       + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
                   6222:         license.c
                   6223: 
                   6224:  2. The license text should be added to pkgsrc/licenses for displaying. A list
                   6225:     of known licenses can be seen in this directory.
1.1       dsieger  6226: 
1.154     rillig   6227: 21.1.3.2. Change to the license
1.1       dsieger  6228: 
1.111     sevan    6229: When the license changes (in a way other than formatting), make sure that the
                   6230: new license has a different name (e.g., append the version number if it exists,
                   6231: or the date). Just because a user told pkgsrc to build programs under a
                   6232: previous version of a license does not mean that pkgsrc should build programs
                   6233: under the new licenses. The higher-level point is that pkgsrc does not evaluate
                   6234: licenses for reasonableness; the only test is a mechanistic test of whether a
                   6235: particular text has been approved by either of two bodies (FSF or OSI).
1.1       dsieger  6236: 
1.154     rillig   6237: 21.1.4. Restricted packages
1.1       dsieger  6238: 
1.111     sevan    6239: Some licenses restrict how software may be re-distributed. By declaring the
                   6240: restrictions, package tools can automatically refrain from e.g. placing binary
                   6241: packages on FTP sites.
                   6242: 
                   6243: There are four possible restrictions, which are the cross product of sources
                   6244: (distfiles) and binaries not being placed on FTP sites and CD-ROMs. Because
                   6245: this is rarely the exact language in any license, and because non-Free licenses
                   6246: tend to be different from each other, pkgsrc adopts a definition of FTP and
                   6247: CD-ROM. "FTP" means making the source or binary file available over the
                   6248: Internet at no charge. "CD-ROM" means making the source or binary available on
                   6249: some kind of media, together with other source and binary packages, which is
                   6250: sold for a distribution charge.
1.1       dsieger  6251: 
                   6252: In order to encode these restrictions, the package system defines five make
                   6253: variables that can be set to note these restrictions:
                   6254: 
                   6255:   * RESTRICTED
                   6256: 
                   6257:     This variable should be set whenever a restriction exists (regardless of
                   6258:     its kind). Set this variable to a string containing the reason for the
                   6259:     restriction. It should be understood that those wanting to understand the
                   6260:     restriction will have to read the license, and perhaps seek advice of
                   6261:     counsel.
                   6262: 
                   6263:   * NO_BIN_ON_CDROM
                   6264: 
                   6265:     Binaries may not be placed on CD-ROM containing other binary packages, for
                   6266:     which a distribution charge may be made. In this case, set this variable to
                   6267:     ${RESTRICTED}.
                   6268: 
                   6269:   * NO_BIN_ON_FTP
                   6270: 
                   6271:     Binaries may not made available on the Internet without charge. In this
                   6272:     case, set this variable to ${RESTRICTED}. If this variable is set, binary
                   6273:     packages will not be included on ftp.NetBSD.org.
                   6274: 
                   6275:   * NO_SRC_ON_CDROM
                   6276: 
                   6277:     Distfiles may not be placed on CD-ROM, together with other distfiles, for
                   6278:     which a fee may be charged. In this case, set this variable to $
                   6279:     {RESTRICTED}.
                   6280: 
                   6281:   * NO_SRC_ON_FTP
                   6282: 
                   6283:     Distfiles may not made available via FTP at no charge. In this case, set
                   6284:     this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
                   6285:     will not be mirrored on ftp.NetBSD.org.
                   6286: 
1.111     sevan    6287: Please note that packages will be removed from pkgsrc when the distfiles are
1.33      wiz      6288: not distributable and cannot be obtained for a period of one full quarter
1.111     sevan    6289: branch. Packages with manual/interactive fetch must have a maintainer and it is
                   6290: his/her responsibility to ensure this.
1.33      wiz      6291: 
1.154     rillig   6292: 21.1.5. Handling dependencies
1.1       dsieger  6293: 
1.175     gutterid 6294: Your package may depend on some other package being present, and there are
                   6295: various ways of expressing this dependency. pkgsrc supports the DEPENDS,
                   6296: BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS definitions, the USE_TOOLS
                   6297: definition, as well as dependencies via buildlink3.mk, which is the preferred
                   6298: way to handle dependencies, and which uses the variables named above. See
1.184     rillig   6299: Chapter 18, Buildlink methodology for more information.
1.175     gutterid 6300: 
                   6301: The basic difference is that the DEPENDS definition registers that
                   6302: pre-requisite in the binary package so it will be pulled in when the binary
                   6303: package is later installed, whilst the BUILD_DEPENDS, TOOL_DEPENDS, and
                   6304: TEST_DEPENDS definitions do not, marking a dependency that is only needed for
1.184     rillig   6305: building or testing the resulting package. See also Chapter 14, Creating a new
1.175     gutterid 6306: pkgsrc package from scratch for more information.
                   6307: 
                   6308: This means that if you only need a package present whilst you are building or
                   6309: testing, it should be noted as a TOOL_DEPENDS, BUILD_DEPENDS, or TEST_DEPENDS.
                   6310: When cross-compiling, TOOL_DEPENDS are native packages, i.e. packages for the
                   6311: architecture where the package is built; BUILD_DEPENDS are target packages,
                   6312: i.e., packages for the architecture for which the package is built.
1.1       dsieger  6313: 
1.175     gutterid 6314: The format for a DEPENDS, BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS
                   6315: definition is:
1.1       dsieger  6316: 
                   6317: <pre-req-package-name>:../../<category>/<pre-req-package>
                   6318: 
                   6319: Please note that the "pre-req-package-name" may include any of the wildcard
                   6320: version numbers recognized by pkg_info(1).
                   6321: 
1.55      wiz      6322:  1. If your package needs another package's binaries or libraries to build and
1.1       dsieger  6323:     run, and if that package has a buildlink3.mk file available, use it:
                   6324: 
                   6325:     .include "../../graphics/jpeg/buildlink3.mk"
                   6326: 
1.55      wiz      6327:  2. If your package needs another package's binaries or libraries only for
                   6328:     building, and if that package has a buildlink3.mk file available, use it:
                   6329: 
                   6330:     .include "../../graphics/jpeg/buildlink3.mk"
                   6331: 
                   6332:     but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
                   6333:     This case is rather rare.
                   6334: 
                   6335:  3. If your package needs binaries from another package to build, use the
1.156     leot     6336:     TOOL_DEPENDS definition:
                   6337: 
                   6338:     TOOL_DEPENDS+= itstool-[0-9]*:../../textproc/itstool
1.1       dsieger  6339: 
1.156     leot     6340:  4. If your package needs static libraries to link against, header files to
                   6341:     include, etc. from another package to build, use the BUILD_DEPENDS
                   6342:     definition.
1.1       dsieger  6343: 
1.156     leot     6344:  5. If your package needs a library with which to link and there is no
1.26      spz      6345:     buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
                   6346:     because the include files and libraries will be hidden from the compiler.
1.1       dsieger  6347: 
1.156     leot     6348:  6. If your package needs some executable to be able to run correctly and if
1.26      spz      6349:     there's no buildlink3.mk file, this is specified using the DEPENDS
                   6350:     variable. The print/lyx package needs to be able to execute the latex
1.129     wiz      6351:     binary from the tex-latex-bin package when it runs, and that is specified:
1.1       dsieger  6352: 
1.129     wiz      6353:     DEPENDS+=        tex-latex-bin-[0-9]*:../../print/tex-latex-bin
1.1       dsieger  6354: 
1.175     gutterid 6355:  7. If your package includes a test suite that has extra dependencies only
                   6356:     required for this purpose (frequently this can be run as a "make test"
                   6357:     target), use the TEST_DEPENDS variable.
                   6358: 
                   6359:  8. You can use wildcards in package dependencies. Note that such wildcard
1.26      spz      6360:     dependencies are retained when creating binary packages. The dependency is
                   6361:     checked when installing the binary package and any package which matches
                   6362:     the pattern will be used. Wildcard dependencies should be used with care.
1.1       dsieger  6363: 
                   6364:     The "-[0-9]*" should be used instead of "-*" to avoid potentially ambiguous
                   6365:     matches such as "tk-postgresql" matching a "tk-*" DEPENDS.
                   6366: 
                   6367:     Wildcards can also be used to specify that a package will only build
                   6368:     against a certain minimum version of a pre-requisite:
                   6369: 
1.26      spz      6370:     DEPENDS+=       ImageMagick>=6.0:../../graphics/ImageMagick
1.1       dsieger  6371: 
1.26      spz      6372:     This means that the package will build using version 6.0 of ImageMagick or
                   6373:     newer. Such a dependency may be warranted if, for example, the command line
                   6374:     options of an executable have changed.
                   6375: 
1.183     wiz      6376:     If you need to depend on minimum versions of libraries, set
                   6377:     BUILDLINK_API_DEPENDS.pkg to the appropriate pattern before including its
                   6378:     buildlink3.mk file, e.g.
                   6379: 
                   6380:     BUILDLINK_API_DEPENDS.jpeg+=    jpeg>=9.0
                   6381:     .include "../../graphics/jpeg/buildlink3.mk"
1.1       dsieger  6382: 
                   6383:     For security fixes, please update the package vulnerabilities file. See
1.154     rillig   6384:     Section 21.1.9, "Handling packages with security problems" for more
1.1       dsieger  6385:     information.
                   6386: 
                   6387: If your package needs files from another package to build, add the relevant
                   6388: distribution files to DISTFILES, so they will be extracted automatically. See
                   6389: the print/ghostscript package for an example. (It relies on the jpeg sources
                   6390: being present in source form during the build.)
                   6391: 
1.154     rillig   6392: 21.1.6. Handling conflicts with other packages
1.1       dsieger  6393: 
                   6394: Your package may conflict with other packages a user might already have
                   6395: installed on his system, e.g. if your package installs the same set of files as
1.80      wiz      6396: another package in the pkgsrc tree or has the same PKGNAME.
1.1       dsieger  6397: 
1.142     leot     6398: For example, x11/libXaw3d and x11/Xaw-Xpm install the same shared library, thus
                   6399: you set in pkgsrc/x11/libXaw3d/Makefile:
1.1       dsieger  6400: 
1.142     leot     6401: CONFLICTS=      Xaw-Xpm-[0-9]*
1.1       dsieger  6402: 
                   6403: 
1.142     leot     6404: and in pkgsrc/x11/Xaw-Xpm/Makefile:
1.1       dsieger  6405: 
1.142     leot     6406: CONFLICTS=      libXaw3d-[0-9]*
1.1       dsieger  6407: 
1.142     leot     6408: 
                   6409: pkg_add(1) is able to detect attempts to install packages that conflict with
                   6410: existing packages and abort. However, in many situations this is too late in
                   6411: the process. Binary package managers will not know about the conflict until
                   6412: they attempt to install the package after already downloading it and all its
                   6413: dependencies. Users may also waste time building a package and its dependencies
                   6414: only to find out at the end that it conflicts with another package they have
                   6415: installed.
                   6416: 
                   6417: To avoid these issues CONFLICTS entries should be added in all cases where it
                   6418: is known that packages conflict with each other. These CONFLICTS entries are
                   6419: exported in pkg_summary(5) files and consumed by binary package managers to
                   6420: inform users that packages cannot be installed onto the target system.
1.1       dsieger  6421: 
1.154     rillig   6422: 21.1.7. Packages that cannot or should not be built
1.1       dsieger  6423: 
                   6424: There are several reasons why a package might be instructed to not build under
                   6425: certain circumstances. If the package builds and runs on most platforms, the
1.83      dholland 6426: exceptions should be noted with BROKEN_ON_PLATFORM. If the package builds and
                   6427: runs on a small handful of platforms, set BROKEN_EXCEPT_ON_PLATFORM instead.
                   6428: Both BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM are OS triples
                   6429: (OS-version-platform) that can use glob-style wildcards.
                   6430: 
1.114     maya     6431: If a package is not appropriate for some platforms (as opposed to merely
1.83      dholland 6432: broken), a different set of variables should be used as this affects failure
                   6433: reporting and statistics. If the package is appropriate for most platforms, the
                   6434: exceptions should be noted with NOT_FOR_PLATFORM. If the package is appropriate
                   6435: for only a small handful of platforms (often exactly one), set
                   6436: ONLY_FOR_PLATFORM instead. Both ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS
                   6437: triples (OS-version-platform) that can use glob-style wildcards.
1.1       dsieger  6438: 
                   6439: Some packages are tightly bound to a specific version of an operating system,
                   6440: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
                   6441: with other versions of the OS, and should be uploaded to a version specific
                   6442: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
                   6443: to "yes". This variable is not currently used by any of the package system
                   6444: internals, but may be used in the future.
                   6445: 
                   6446: If the package should be skipped (for example, because it provides
                   6447: functionality already provided by the system), set PKG_SKIP_REASON to a
                   6448: descriptive message. If the package should fail because some preconditions are
                   6449: not met, set PKG_FAIL_REASON to a descriptive message.
                   6450: 
1.154     rillig   6451: 21.1.8. Packages which should not be deleted, once installed
1.1       dsieger  6452: 
                   6453: To ensure that a package may not be deleted, once it has been installed, the
                   6454: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.25      wiz      6455: carried into any binary package that is made from this pkgsrc entry. A "
                   6456: preserved" package will not be deleted using pkg_delete(1) unless the "-f"
1.1       dsieger  6457: option is used.
                   6458: 
1.154     rillig   6459: 21.1.9. Handling packages with security problems
1.1       dsieger  6460: 
                   6461: When a vulnerability is found, this should be noted in localsrc/security/
1.205     wiz      6462: advisories/pkg-vulnerabilities. Entries in that file consist of three parts:
                   6463: 
                   6464:   * package version pattern
                   6465: 
                   6466:   * type of vulnerability (please cut'n'paste an existing one where possible)
                   6467: 
                   6468:   * URL providing additional information about the issue
                   6469: 
                   6470: For the package version pattern please always use `<' to mark an upper bound
                   6471: (not `<='!). This will avoid possible problems due unrelated PKGREVISION bumps
                   6472: not related to security fixes. Lower bounds can be added too, using '>' or '>=
1.206     wiz      6473: '. For example, "foo>=1<1.2" would mark versions 1.0 (included) to 1.2
1.205     wiz      6474: (excluded) of "foo" as affected by the security issue.
                   6475: 
                   6476: Entries should always be added at the bottom of the file.
                   6477: 
                   6478: When fixing packages, please modify the upper bound of the corresponding entry.
                   6479: To continue the previous example, if a fix was backported to version 1.1nb2,
1.206     wiz      6480: change the previous pattern to "foo>=1<1.1nb2".
1.205     wiz      6481: 
                   6482: To locally test a package version pattern against a PKGNAME you can use the 
                   6483: pkg_admin pmatch command.
                   6484: 
                   6485: The URL should be as permanent as possible and provide as much information
                   6486: about the issue as possible. CVE entries are preferred.
                   6487: 
                   6488: After committing that file, ask pkgsrc-security@NetBSD.org to update the file
                   6489: on ftp.NetBSD.org.
1.1       dsieger  6490: 
                   6491: After fixing the vulnerability by a patch, its PKGREVISION should be increased
                   6492: (this is of course not necessary if the problem is fixed by using a newer
1.32      wiz      6493: release of the software), and the pattern in the pkg-vulnerabilities file must
                   6494: be updated.
1.1       dsieger  6495: 
                   6496: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
                   6497: submit a pullup request!
                   6498: 
                   6499: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
                   6500: a weekly cron job.
                   6501: 
1.205     wiz      6502: In case a security issue is disputed, please contact
                   6503: pkgsrc-security@NetBSD.org.
                   6504: 
1.154     rillig   6505: 21.1.10. How to handle incrementing versions when fixing an existing package
1.1       dsieger  6506: 
                   6507: When making fixes to an existing package it can be useful to change the version
                   6508: number in PKGNAME. To avoid conflicting with future versions by the original
                   6509: author, a "nb1", "nb2", ... suffix can be used on package versions by setting
                   6510: PKGREVISION=1 (2, ...). The "nb" is treated like a "." by the package tools.
                   6511: e.g.
                   6512: 
                   6513: DISTNAME=       foo-17.42
                   6514: PKGREVISION=    9
                   6515: 
                   6516: will result in a PKGNAME of "foo-17.42nb9". If you want to use the original
                   6517: value of PKGNAME without the "nbX" suffix, e.g. for setting DIST_SUBDIR, use
                   6518: PKGNAME_NOREV.
                   6519: 
                   6520: When a new release of the package is released, the PKGREVISION should be
                   6521: removed, e.g. on a new minor release of the above package, things should be
                   6522: like:
                   6523: 
                   6524: DISTNAME=       foo-17.43
                   6525: 
                   6526: PKGREVISION should be incremented for any non-trivial change in the resulting
                   6527: binary package. Without a PKGREVISION bump, someone with the previous version
                   6528: installed has no way of knowing that their package is out of date. Thus,
                   6529: changes without increasing PKGREVISION are essentially labeled "this is so
                   6530: trivial that no reasonable person would want to upgrade", and this is the rough
                   6531: test for when increasing PKGREVISION is appropriate. Examples of changes that
                   6532: do not merit increasing PKGREVISION are:
                   6533: 
1.14      jmcneill 6534:   * Changing HOMEPAGE, MAINTAINER, OWNER, or comments in Makefile.
1.1       dsieger  6535: 
                   6536:   * Changing build variables if the resulting binary package is the same.
                   6537: 
                   6538:   * Changing DESCR.
                   6539: 
                   6540:   * Adding PKG_OPTIONS if the default options don't change.
                   6541: 
                   6542: Examples of changes that do merit an increase to PKGREVISION include:
                   6543: 
                   6544:   * Security fixes
                   6545: 
                   6546:   * Changes or additions to a patch file
                   6547: 
                   6548:   * Changes to the PLIST
                   6549: 
1.12      weinem   6550:   * A dependency is changed or renamed.
                   6551: 
1.1       dsieger  6552: PKGREVISION must also be incremented when dependencies have ABI changes.
                   6553: 
1.154     rillig   6554: 21.1.11. Substituting variable text in the package files (the SUBST framework)
1.1       dsieger  6555: 
1.180     rillig   6556: When you want to replace the same text in multiple files, or multiple times in
                   6557: the same file, it is cumbersome to maintain a patch file for this. This is
                   6558: where the SUBST framework steps in. It provides an easy-to-use interface for
                   6559: replacing text in files. It just needs the following information:
1.172     rillig   6560: 
1.180     rillig   6561:   * In which phase of the package build cycle should the replacement happen?
1.172     rillig   6562: 
1.180     rillig   6563:   * In which files should the replacement happen?
1.172     rillig   6564: 
                   6565:   * Which text should be replaced with what?
                   6566: 
1.180     rillig   6567: This information is encoded in a block of SUBST variables. A minimal example
                   6568: is:
                   6569: 
                   6570: SUBST_CLASSES+=         paths
                   6571: SUBST_STAGE.paths=      pre-configure
                   6572: SUBST_FILES.paths=      src/*.c
                   6573: SUBST_SED.paths=        -e 's,/usr/local,${PREFIX},g'
                   6574: 
                   6575: Translated into English, it means: In the pre-configure stage (that is, after
                   6576: applying the patches from the patches/ directory and before running the
                   6577: configure script and the portability check), replace the text /usr/local with
                   6578: the content of the variable PREFIX.
                   6579: 
                   6580: Each SUBST block starts by appending an identifier to SUBST_CLASSES (note the +
                   6581: =). This identifier can be chosen freely by the package. If there should ever
                   6582: be duplicate identifiers, the pkgsrc infrastructure will catch this and fail
                   6583: early, so don't worry about name collisions.
                   6584: 
                   6585: Except for SUBST_CLASSES, all variables in a SUBST block are parameterized
                   6586: using this identifier. In the remainder of this section, these parameterized
                   6587: variables are written as SUBST_STAGE.*.
                   6588: 
                   6589: SUBST_CLASSES+=         paths
                   6590: SUBST_STAGE.paths=      pre-configure
                   6591: SUBST_MESSAGE.paths=    Fixing absolute paths.
                   6592: SUBST_FILES.paths=      src/*.c
                   6593: SUBST_FILES.paths+=     scripts/*.sh
                   6594: SUBST_SED.paths=        -e 's,"/usr/local,"${PREFIX},g'
                   6595: SUBST_SED.paths+=       -e 's,"/var/log,"${VARBASE}/log,g'
                   6596: SUBST_VARS.paths=       LOCALBASE PREFIX PKGVERSION
                   6597: 
                   6598: To get a complete picture about the SUBST substitutions, run bmake
                   6599: show-all-subst. If something doesn't work as expected, run pkglint on the
                   6600: package, which detects several typical mistakes surrounding the SUBST blocks.
                   6601: For any questions that might remain after this, have a look at mk/subst.mk.
                   6602: 
                   6603: 21.1.11.1. Choosing the time where the substitutions happen
                   6604: 
                   6605: The SUBST_STAGE.* is one of {pre,do,post}-
                   6606: {extract,patch,configure,build,test,install}. Of these, pre-configure is used
                   6607: most often, by far. The most popular stages are, in chronological order:
                   6608: 
                   6609: post-extract
                   6610: 
                   6611:     The substitutions are applied immediately after the distfiles are
                   6612:     extracted. Running bmake extract on the package will leave no traces of the
                   6613:     original files.
                   6614: 
                   6615:     When the substitution applies to files for which there is also a patch in
                   6616:     the patches/ directory, this means that the patches will be computed based
                   6617:     on the result of the substitution. When these patches are sent to the
                   6618:     upstream maintainer later, to be fixed in the upstream package, these
                   6619:     patches may no longer match what the upstream author is used to. Because of
                   6620:     this, pre-configure is often a better choice.
                   6621: 
                   6622: pre-configure
                   6623: 
                   6624:     The substitutions are applied after the patches from the patches/
                   6625:     directory. This makes it possible to run bmake patch on the package, after
                   6626:     which the patches can be edited using the tools pkgvi and mkpatches from
                   6627:     the pkgtools/pkgdiff package.
                   6628: 
                   6629:     When updating the patches, it is helpful to explicitly separate the bmake
                   6630:     patch from the bmake configure, and to only edit the patches between these
                   6631:     commands. Otherwise the substitutions from the SUBST block will end up in
                   6632:     the patch file. When this happens in really obvious ways, pkglint will
                   6633:     complain about patches that contain a hard-coded /usr/pkg instead of the
                   6634:     correct and intended @PREFIX@, but it can only detect these really obvious
                   6635:     cases.
                   6636: 
                   6637: do-configure
                   6638: 
                   6639:     This stage should only be used if the package defines a pre-configure
                   6640:     action itself, and the substitution must happen after that. Typical
                   6641:     examples are packages that use the pre-configure stage to regenerate the
                   6642:     GNU configure script from configure.ac.
                   6643: 
                   6644: post-configure
                   6645: 
                   6646:     This stage is used to fix up any mistakes by the configure stage.
                   6647: 
                   6648: pre-build
                   6649: 
                   6650:     This stage should only be used for substitutions that are clearly related
                   6651:     to building the package, not for fixing the configuration. Substitutions
                   6652:     for pathnames (such as replacing /usr/local with ${PREFIX}) or user names
                   6653:     (such as replacing @MY_USER@ with the actual username) belong in
                   6654:     pre-configure or post-configure instead.
                   6655: 
                   6656: post-build
                   6657: 
                   6658:     Just as with pre-build, this stage should only be used for substitutions
                   6659:     that are clearly related to building the package, not for fixing the
                   6660:     configuration. Substitutions for pathnames (such as replacing /usr/local
                   6661:     with ${PREFIX}) or user names (such as replacing @MY_USER@ with the actual
                   6662:     username) belong in pre-configure or post-configure instead.
                   6663: 
                   6664:     A typical use is to update pkg-config files to include the rpath compiler
                   6665:     options.
                   6666: 
                   6667: pre-install
                   6668: 
                   6669:     In general, the install phase should be as simple as possible. As with the
                   6670:     pre-build and post-build stages, it should not be used to fix pathnames or
                   6671:     user names, these belong in pre-configure instead. There are only few
                   6672:     legitimate use cases for applying substitutions in this stage.
                   6673: 
1.181     rillig   6674: 21.1.11.2. Choosing the files where the substitutions happen
1.180     rillig   6675: 
                   6676: The SUBST_FILES.* variable contains a list of filename patterns. These patterns
                   6677: are relative to WRKSRC since that is where most substitutions happen. A typical
                   6678: example is:
                   6679: 
                   6680: SUBST_FILES.path=       Makefile */Makefile */*/Makefile *.[ch]
                   6681: 
                   6682: The above patterns, especially the last, are quite broad. The SUBST
                   6683: implementation checks that each filename pattern that is mentioned here has an
                   6684: effect. For example, if none of the */*/Makefile files contains the patterns to
                   6685: be found and substituted, that filename pattern is redundant and should be left
1.181     rillig   6686: out. By default, the SUBST framework will complain with an error message. If
                   6687: the text to be substituted occurs in some of the files from a single pattern,
                   6688: but not in all of them, that is totally ok, and the SUBST framework will only
                   6689: print an INFO message for those files.
1.180     rillig   6690: 
                   6691: If there is a good reason for having redundant filename patterns, set
1.181     rillig   6692: SUBST_NOOP_OK.* to yes.
1.180     rillig   6693: 
                   6694: Another popular way of choosing the files for the substitutions is via a shell
                   6695: command, like this:
                   6696: 
1.181     rillig   6697: C_FILES_CMD=            cd ${WRKSRC} && ${FIND} . -name '*.c'
1.180     rillig   6698: SUBST_FILES.path=       ${C_FILES_CMD:sh}
                   6699: 
                   6700: The variable name C_FILES_CMD in this example is freely chosen and independent
                   6701: of the SUBST framework.
                   6702: 
                   6703: In this variant, the SUBST_FILES.* variable lists each file individually.
                   6704: Thereby chances are higher that there are filename patterns in which no
                   6705: substitution happens. Since the SUBST framework cannot know whether the
                   6706: filename patterns in SUBST_FILES.* have been explicitly listed in the Makefile
                   6707: (where any redundant filename pattern would be suspicious) or been generated by
                   6708: a shell command (in which redundant filename patterns are more likely and to be
                   6709: expected), it will complain about these redundant filename patterns. Therefore,
                   6710: SUBST blocks that use a shell command to generate the list of filename patterns
                   6711: often need to set SUBST_NOOP_OK.* to yes.
                   6712: 
                   6713: 21.1.11.3. Choosing what to substitute
                   6714: 
                   6715: In most cases, the substitutions are given using one or more sed(1) commands,
                   6716: like this:
                   6717: 
                   6718: SUBST_SED.path=         -e 's|/usr/local|${PREFIX}|g'
                   6719: 
                   6720: Each of the sed commands needs to be preceded by the -e option and should be
                   6721: specified on a line of its own, to avoid hiding short sed commands at the end
                   6722: of a line.
                   6723: 
                   6724: Since the sed commands often contain shell metacharacters as the separator (the
                   6725: | in the above example), it is common to enclose them in single quotes.
                   6726: 
                   6727: A common substitution is to replace placeholders of the form @VARNAME@ with
                   6728: their pkgsrc counterpart variable ${VARNAME}. A typical example is:
                   6729: 
                   6730: SUBST_VARS.path=        PREFIX
                   6731: 
1.181     rillig   6732: This type of substitutions is typically done by the GNU configure scripts
                   6733: during the do-configure stage, but in some cases these need to be overridden.
                   6734: The same pattern is also used when a package defines patches that replace
                   6735: previously hard-coded paths like /usr/local with a @PREFIX@ placeholder first,
                   6736: which then gets substituted by the actual ${PREFIX} in the pre-configure stage.
                   6737: In many of these cases, it works equally well to just use the SUBST framework
                   6738: to directly replace /usr/local with ${PREFIX}, thereby omitting the
                   6739: intermediate patch file.
1.180     rillig   6740: 
                   6741: If the above is not flexible enough, it is possible to not use sed at all for
                   6742: the substitution but to specify an entirely different command, like this:
                   6743: 
                   6744: SUBST_FILTER_CMD.path=  LC_ALL=C ${TR} -d '\r'
1.1       dsieger  6745: 
1.180     rillig   6746: This is used for the few remaining packages in which the distributed files use
                   6747: Windows-style line endings that need to be converted to UNIX-style line
                   6748: endings.
1.1       dsieger  6749: 
1.180     rillig   6750: 21.1.11.4. Other SUBST variables
1.172     rillig   6751: 
1.180     rillig   6752: When a SUBST block is applied during a package build, a message is logged. The
                   6753: default message is fine for most purposes but can be overridden by setting
                   6754: SUBST_MESSAGE.* to an individual message.
1.1       dsieger  6755: 
1.154     rillig   6756: 21.2. The fetch phase
1.1       dsieger  6757: 
1.154     rillig   6758: 21.2.1. Packages whose distfiles aren't available for plain downloading
1.1       dsieger  6759: 
                   6760: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
                   6761: a make fetch will call files/getsite.sh with the name of each file to download
                   6762: as an argument, expecting it to output the URL of the directory from which to
                   6763: download it. graphics/ns-cult3d is an example of this usage.
                   6764: 
                   6765: If the download can't be automated, because the user must submit personal
                   6766: information to apply for a password, or must pay for the source, or whatever,
                   6767: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
                   6768: before aborting the build. Example:
                   6769: 
                   6770: FETCH_MESSAGE=  "Please download the files"
                   6771: FETCH_MESSAGE+= "    "${DISTFILES:Q}
                   6772: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
                   6773: 
1.154     rillig   6774: 21.2.2. How to handle modified distfiles with the 'old' name
1.1       dsieger  6775: 
                   6776: Sometimes authors of a software package make some modifications after the
                   6777: software was released, and they put up a new distfile without changing the
                   6778: package's version number. If a package is already in pkgsrc at that time, the
                   6779: checksum will no longer match. The contents of the new distfile should be
                   6780: compared against the old one before changing anything, to make sure the
                   6781: distfile was really updated on purpose, and that no trojan horse or so crept
                   6782: in. Please mention that the distfiles were compared and what was found in your
1.54      rodent   6783: commit message.
                   6784: 
                   6785: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
1.109     wiz      6786: directory name, usually based on PKGNAME_NOREV (but take care with python or
                   6787: ruby packages, where PKGNAME includes a variable prefix). All DISTFILES and
                   6788: PATCHFILES for this package will be put in that subdirectory of the local
1.154     rillig   6789: distfiles directory. (See Section 21.1.10, "How to handle incrementing versions
1.109     wiz      6790: when fixing an existing package" for more details.) In case this happens more
                   6791: often, PKGNAME can be used (thus including the nbX suffix) or a date stamp can
                   6792: be appended, like ${PKGNAME_NOREV}-YYYYMMDD.
1.54      rodent   6793: 
                   6794: DIST_SUBDIR is also used when a distfile's name does not contain a version and
                   6795: the distfile is apt to change. In cases where the likelihood of this is very
                   6796: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
                   6797: removed unless the distfile name changes, even if a package is being moved or
                   6798: renamed.
                   6799: 
                   6800: Do not forget regenerating the distinfo file after that, since it contains the
                   6801: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
                   6802: installed package is different. Furthermore, a mail to the package's authors
                   6803: seems appropriate telling them that changing distfiles after releases without
                   6804: changing the file names is not good practice.
1.1       dsieger  6805: 
1.154     rillig   6806: 21.2.3. Packages hosted on github.com
1.88      tnn      6807: 
1.90      tnn      6808: Helper methods exist for packages hosted on github.com which will often have
                   6809: distfile names that clash with other packages, for example 1.0.tar.gz. Use one
                   6810: of the three recipes from below:
1.88      tnn      6811: 
1.154     rillig   6812: 21.2.3.1. Fetch based on a tagged release
1.88      tnn      6813: 
1.189     bacon    6814: If your distfile URL looks similar to https://github.com/username/example/
                   6815: archive/v1.0.zip, then you are packaging a tagged release.
1.88      tnn      6816: 
1.189     bacon    6817: DISTNAME=       example-1.0
1.90      tnn      6818: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
1.189     bacon    6819: #GITHUB_PROJECT= example    # can be omitted if same as DISTNAME
1.90      tnn      6820: GITHUB_TAG=     v${PKGVERSION_NOREV}
1.88      tnn      6821: EXTRACT_SUFX=   .zip
                   6822: 
1.189     bacon    6823: 21.2.3.2. Fetch based on a specific commit before the first release
                   6824: 
                   6825: If your distfile looks similar to https://github.com/username/example/archive/
                   6826: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit before the first
                   6827: release, then set the package version to 0.0.0.N, where N is the number of
                   6828: commits to the repository, and set GITHUB_TAG to the commit hash. This will
                   6829: (almost) ensure that the first tagged release will have a version greater than
                   6830: this one so that package upgrades will function properly.
                   6831: 
                   6832: DISTNAME=       example-0.0.0.347
                   6833: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6834: #GITHUB_PROJECT= example    # can be omitted if same as DISTNAME
                   6835: GITHUB_TAG=     988881adc9fc3655077dc2d4d757d480b5ea0e11
                   6836: 
                   6837: 21.2.3.3. Fetch based on a specific commit after a release
1.88      tnn      6838: 
1.189     bacon    6839: If your distfile looks similar to https://github.com/username/example/archive/
                   6840: 988881adc9fc3655077dc2d4d757d480b5ea0e11 and is from a commit after a release,
                   6841: then include the last release version and the commit count since that release
                   6842: in the package version and set GITHUB_TAG to the commit hash. The latest
                   6843: release and commit count are shown in the output of "git describe --tags":
                   6844: 
                   6845: # git clone https://github.com/username/example
                   6846: # cd example
                   6847: # git describe --tags
                   6848: 1.2.3-5-g988881a
1.88      tnn      6849: 
1.189     bacon    6850: DISTNAME=       example-1.2.3.5
                   6851: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6852: #GITHUB_PROJECT= example    # can be omitted if same as DISTNAME
1.90      tnn      6853: GITHUB_TAG=     988881adc9fc3655077dc2d4d757d480b5ea0e11
1.88      tnn      6854: 
1.189     bacon    6855: 21.2.3.4. Fetch based on release
1.88      tnn      6856: 
1.189     bacon    6857: If your distfile URL looks similar to https://github.com/username/example/
                   6858: releases/download/rel-1.6/offensive-1.6.zip, then you are packaging a release.
1.88      tnn      6859: 
1.90      tnn      6860: DISTNAME=       offensive-1.6
1.88      tnn      6861: PKGNAME=        ${DISTNAME:S/offensive/proper/}
1.90      tnn      6862: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
1.189     bacon    6863: GITHUB_PROJECT= example
1.90      tnn      6864: GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
                   6865: EXTRACT_SUFX=   .zip
1.88      tnn      6866: 
1.154     rillig   6867: 21.3. The configure phase
1.1       dsieger  6868: 
1.154     rillig   6869: 21.3.1. Shared libraries - libtool
1.1       dsieger  6870: 
                   6871: pkgsrc supports many different machines, with different object formats like
                   6872: a.out and ELF, and varying abilities to do shared library and dynamic loading
                   6873: at all. To accompany this, varying commands and options have to be passed to
                   6874: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
                   6875: especially if you don't have all the machines at your hand to test things. The
                   6876: devel/libtool pkg can help here, as it just "knows" how to build both static
                   6877: and dynamic libraries from a set of source files, thus being
                   6878: platform-independent.
                   6879: 
                   6880: Here's how to use libtool in a package in seven simple steps:
                   6881: 
                   6882:  1. Add USE_LIBTOOL=yes to the package Makefile.
                   6883: 
                   6884:  2. For library objects, use "${LIBTOOL} --mode=compile ${CC}" in place of "$
                   6885:     {CC}". You could even add it to the definition of CC, if only libraries are
                   6886:     being built in a given Makefile. This one command will build both PIC and
                   6887:     non-PIC library objects, so you need not have separate shared and
                   6888:     non-shared library rules.
                   6889: 
                   6890:  3. For the linking of the library, remove any "ar", "ranlib", and "ld
                   6891:     -Bshareable" commands, and instead use:
                   6892: 
                   6893:     ${LIBTOOL} --mode=link \
                   6894:         ${CC} -o ${.TARGET:.a=.la} \
                   6895:             ${OBJS:.o=.lo} \
                   6896:             -rpath ${PREFIX}/lib \
                   6897:             -version-info major:minor
                   6898: 
                   6899:     Note that the library is changed to have a .la extension, and the objects
                   6900:     are changed to have a .lo extension. Change OBJS as necessary. This
                   6901:     automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
                   6902:     necessary) in the build directory. Be sure to include "-version-info",
                   6903:     especially when major and minor are zero, as libtool will otherwise strip
                   6904:     off the shared library version.
                   6905: 
                   6906:     From the libtool manual:
                   6907: 
                   6908:     So, libtool library versions are described by three integers:
                   6909: 
                   6910:     CURRENT
                   6911:     The most recent interface number that this library implements.
                   6912: 
                   6913:     REVISION
                   6914:     The implementation number of the CURRENT interface.
                   6915: 
                   6916:     AGE
                   6917:     The difference between the newest and oldest interfaces that
                   6918:     this library implements.  In other words, the library implements
                   6919:     all the interface numbers in the range from number `CURRENT -
                   6920:     AGE' to `CURRENT'.
                   6921: 
                   6922:     If two libraries have identical CURRENT and AGE numbers, then the
                   6923:     dynamic linker chooses the library with the greater REVISION number.
                   6924: 
                   6925:     The "-release" option will produce different results for a.out and ELF
1.25      wiz      6926:     (excluding symlinks) in only one case. An ELF library of the form "
                   6927:     libfoo-release.so.x.y" will have a symlink of "libfoo.so.x.y" on an a.out
1.1       dsieger  6928:     platform. This is handled automatically.
                   6929: 
                   6930:     The "-rpath argument" is the install directory of the library being built.
                   6931: 
                   6932:     In the PLIST, include only the .la file, the other files will be added
                   6933:     automatically.
                   6934: 
                   6935:  4. When linking shared object (.so) files, i.e. files that are loaded via
                   6936:     dlopen(3), NOT shared libraries, use "-module -avoid-version" to prevent
                   6937:     them getting version tacked on.
                   6938: 
                   6939:     The PLIST file gets the foo.so entry.
                   6940: 
                   6941:  5. When linking programs that depend on these libraries before they are
                   6942:     installed, preface the cc(1) or ld(1) line with "${LIBTOOL} --mode=link",
                   6943:     and it will find the correct libraries (static or shared), but please be
                   6944:     aware that libtool will not allow you to specify a relative path in -L
                   6945:     (such as "-L../somelib"), because it expects you to change that argument to
                   6946:     be the .la file. e.g.
                   6947: 
                   6948:     ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
                   6949: 
                   6950:     should be changed to:
                   6951: 
                   6952:     ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
                   6953: 
                   6954:     and it will do the right thing with the libraries.
                   6955: 
                   6956:  6. When installing libraries, preface the install(1) or cp(1) command with "$
                   6957:     {LIBTOOL} --mode=install", and change the library name to .la. e.g.
                   6958: 
1.23      jakllsch 6959:     ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1       dsieger  6960: 
                   6961:     This will install the static .a, shared library, any needed symlinks, and
                   6962:     run ldconfig(8).
                   6963: 
                   6964:  7. In your PLIST, include only the .la file (this is a change from previous
                   6965:     behaviour).
                   6966: 
1.154     rillig   6967: 21.3.2. Using libtool on GNU packages that already support libtool
1.1       dsieger  6968: 
                   6969: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
                   6970: own libtool in most cases. For older libtool using packages, libtool is made by
                   6971: ltconfig script during the do-configure step; you can check the libtool script
                   6972: location by doing make configure; find work*/ -name libtool.
                   6973: 
                   6974: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
                   6975: override. By default, it is set to "libtool */libtool */*/libtool". If this
                   6976: does not match the location of the package's libtool script(s), set it as
                   6977: appropriate.
                   6978: 
                   6979: If you do not need *.a static libraries built and installed, then use
                   6980: SHLIBTOOL_OVERRIDE instead.
                   6981: 
                   6982: If your package makes use of the platform-independent library for loading
                   6983: dynamic shared objects, that comes with libtool (libltdl), you should include
                   6984: devel/libltdl/buildlink3.mk.
                   6985: 
                   6986: Some packages use libtool incorrectly so that the package may not work or build
                   6987: in some circumstances. Some of the more common errors are:
                   6988: 
                   6989:   * The inclusion of a shared object (-module) as a dependent library in an
                   6990:     executable or library. This in itself isn't a problem if one of two things
                   6991:     has been done:
                   6992: 
                   6993:      1. The shared object is named correctly, i.e. libfoo.la, not foo.la
                   6994: 
                   6995:      2. The -dlopen option is used when linking an executable.
                   6996: 
                   6997:   * The use of libltdl without the correct calls to initialisation routines.
                   6998:     The function lt_dlinit() should be called and the macro
                   6999:     LTDL_SET_PRELOADED_SYMBOLS included in executables.
                   7000: 
1.154     rillig   7001: 21.3.3. GNU Autoconf/Automake
1.1       dsieger  7002: 
                   7003: If a package needs GNU autoconf or automake to be executed to regenerate the
                   7004: configure script and Makefile.in makefile templates, then they should be
                   7005: executed in a pre-configure target.
                   7006: 
                   7007: For packages that need only autoconf:
                   7008: 
                   7009: AUTOCONF_REQD=  2.50            # if default version is not good enough
                   7010: USE_TOOLS+=     autoconf        # use "autoconf213" for autoconf-2.13
                   7011: ...
                   7012: 
                   7013: pre-configure:
                   7014:         cd ${WRKSRC} && autoconf
                   7015: 
                   7016: ...
                   7017: 
                   7018: and for packages that need automake and autoconf:
                   7019: 
                   7020: AUTOMAKE_REQD=  1.7.1           # if default version is not good enough
                   7021: USE_TOOLS+=     automake        # use "automake14" for automake-1.4
                   7022: ...
                   7023: 
                   7024: pre-configure:
                   7025:         set -e; cd ${WRKSRC}; \
                   7026:         aclocal; autoheader; automake -a --foreign -i; autoconf
                   7027: 
                   7028: ...
                   7029: 
                   7030: Packages which use GNU Automake will almost certainly require GNU Make.
                   7031: 
                   7032: There are times when the configure process makes additional changes to the
                   7033: generated files, which then causes the build process to try to re-execute the
                   7034: automake sequence. This is prevented by touching various files in the configure
                   7035: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
                   7036: NO in the package Makefile.
                   7037: 
1.154     rillig   7038: 21.4. Programming languages
1.1       dsieger  7039: 
1.154     rillig   7040: 21.4.1. C, C++, and Fortran
1.1       dsieger  7041: 
                   7042: Compilers for the C, C++, and Fortran languages comes with the NetBSD base
                   7043: system. By default, pkgsrc assumes that a package is written in C and will hide
1.184     rillig   7044: all other compilers (via the wrapper framework, see Chapter 18, Buildlink
1.1       dsieger  7045: methodology).
                   7046: 
                   7047: To declare which language's compiler a package needs, set the USE_LANGUAGES
                   7048: variable. Allowed values currently are "c", "c++", and "fortran" (and any
                   7049: combination). The default is "c". Packages using GNU configure scripts, even if
                   7050: written in C++, usually need a C compiler for the configure phase.
                   7051: 
1.154     rillig   7052: 21.4.2. Java
1.1       dsieger  7053: 
                   7054: If a program is written in Java, use the Java framework in pkgsrc. The package
                   7055: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
                   7056: variables:
                   7057: 
                   7058:   * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
                   7059:     set to "run", then there is only a runtime dependency on the JDK. The
                   7060:     default is "yes", which also adds a build dependency on the JDK.
                   7061: 
                   7062:   * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
                   7063:     supported values are "yes", "1.4", and "1.5". "yes" accepts any Java2
                   7064:     implementation, "1.4" insists on versions 1.4 or above, and "1.5" only
                   7065:     accepts versions 1.5 or above. This variable is not set by default.
                   7066: 
1.25      wiz      7067:   * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
                   7068:     implementation dependency. It may be used to set JAVA_HOME to a good value
                   7069:     if the program needs this variable to be defined.
                   7070: 
1.205     wiz      7071: 21.4.3. Go
                   7072: 
                   7073: If a program is written in Go and has any dependencies on other Go modules,
                   7074: have the package include ../../lang/go/go-module.mk.
                   7075: 
                   7076:  1. Generate a list of those dependencies with make clean && make patch && make
                   7077:     show-go-modules > go-modules.mk.
                   7078: 
                   7079:  2. Prepend
                   7080: 
                   7081:     .include
                   7082:           "go-modules.mk"
                   7083: 
                   7084:     to any other
                   7085: 
                   7086:     .include
                   7087: 
                   7088:     s.
                   7089: 
                   7090:  3. Incorporate these modules in distinfo with make makesum.
                   7091: 
                   7092: 21.4.4. Packages containing Perl scripts
1.1       dsieger  7093: 
1.203     nia      7094: If your package contains interpreted Perl scripts, add "perl" to the USE_TOOLS
1.1       dsieger  7095: variable and set REPLACE_PERL to ensure that the proper interpreter path is
                   7096: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
1.74      wiz      7097: you want adjusted. Every occurrence of */bin/perl in a she-bang line will be
1.210     gutterid 7098: replaced with the full path to the Perl executable.
1.1       dsieger  7099: 
1.210     gutterid 7100: If a particular version of Perl is needed, set the PERL5_REQD variable to the
1.1       dsieger  7101: version number. The default is "5.0".
                   7102: 
1.203     nia      7103: See Section 21.6.6, "Packages installing Perl modules" for information about
1.210     gutterid 7104: handling Perl modules.
                   7105: 
                   7106: There is also the REPLACE_PERL6 variable for the language now known as Raku.
1.1       dsieger  7107: 
1.205     wiz      7108: 21.4.5. Packages containing shell scripts
1.41      wiz      7109: 
                   7110: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
1.195     gutterid 7111: shell hash bangs in files. Please use the appropriate one, preferring
                   7112: REPLACE_SH in case this shell is sufficient. Each should contain a list of
                   7113: scripts, relative to WRKSRC, that you want adjusted. Every occurrence of the
                   7114: matching shell in a she-bang line will be replaced with the full path to the
                   7115: shell executable. When using REPLACE_BASH, don't forget to add bash to
                   7116: USE_TOOLS.
1.41      wiz      7117: 
1.205     wiz      7118: 21.4.6. Other programming languages
1.1       dsieger  7119: 
1.210     gutterid 7120: There are further similar REPLACE variables available, e.g., REPLACE_AWK for
                   7121: packages containing awk scripts, and REPLACE_R for R. These two, like the
1.211   ! gutterid 7122: others noted above, have their actions defined centrally in mk/configure/
        !          7123: replace-interpreter.mk. Other languages define the actions of these variables
        !          7124: within their own dedicated part of the tree, e.g., REPLACE_PHP is actioned in
        !          7125: lang/php/phpversion.mk, and REPLACE_PYTHON is actioned in lang/python/
        !          7126: application.mk. For other languages, consult the mk files found within their
        !          7127: specific directories (the naming convention varies).
1.210     gutterid 7128: 
                   7129: Currently, special handling for other languages varies in pkgsrc. If a compiler
                   7130: package provides a buildlink3.mk file, include that, otherwise just add a
                   7131: (build) dependency on the appropriate compiler package.
1.1       dsieger  7132: 
1.154     rillig   7133: 21.5. The build phase
1.1       dsieger  7134: 
                   7135: The most common failures when building a package are that some platforms do not
                   7136: provide certain header files, functions or libraries, or they provide the
                   7137: functions in a library that the original package author didn't know. To work
                   7138: around this, you can rewrite the source code in most cases so that it does not
                   7139: use the missing functions or provides a replacement function.
                   7140: 
1.154     rillig   7141: 21.5.1. Compiling C and C++ code conditionally
1.1       dsieger  7142: 
                   7143: If a package already comes with a GNU configure script, the preferred way to
                   7144: fix the build failure is to change the configure script, not the code. In the
                   7145: other cases, you can utilize the C preprocessor, which defines certain macros
                   7146: depending on the operating system and hardware architecture it compiles for.
                   7147: These macros can be queried using for example #if defined(__i386). Almost every
                   7148: operating system, hardware architecture and compiler has its own macro. For
                   7149: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
                   7150: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
                   7151: GCC.
                   7152: 
                   7153: The list of the following macros for hardware and operating system depends on
                   7154: the compiler that is used. For example, if you want to conditionally compile
                   7155: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
                   7156: Use __sun instead.
                   7157: 
1.154     rillig   7158: 21.5.1.1. C preprocessor macros to identify the operating system
1.1       dsieger  7159: 
                   7160: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
                   7161: should use the following code.
                   7162: 
                   7163: #include <sys/param.h>
                   7164: #if (defined(BSD) && BSD >= 199306)
                   7165: /* BSD-specific code goes here */
                   7166: #else
                   7167: /* non-BSD-specific code goes here */
                   7168: #endif
                   7169: 
                   7170: If this distinction is not fine enough, you can also test for the following
                   7171: macros.
                   7172: 
1.46      obache   7173: Cygwin      __CYGWIN__
                   7174: DragonFly   __DragonFly__
1.1       dsieger  7175: FreeBSD     __FreeBSD__
1.46      obache   7176: Haiku       __HAIKU__
1.1       dsieger  7177: Interix     __INTERIX
                   7178: IRIX        __sgi (TODO: get a definite source for this)
                   7179: Linux       linux, __linux, __linux__
1.83      dholland 7180: Mac OS X    __APPLE__
1.46      obache   7181: MirBSD      __MirBSD__ (__OpenBSD__ is also defined)
                   7182: Minix3      __minix
1.1       dsieger  7183: NetBSD      __NetBSD__
                   7184: OpenBSD     __OpenBSD__
                   7185: Solaris     sun, __sun
                   7186: 
1.154     rillig   7187: 21.5.1.2. C preprocessor macros to identify the hardware architecture
1.1       dsieger  7188: 
                   7189: i386        i386, __i386, __i386__
                   7190: MIPS        __mips
                   7191: SPARC       sparc, __sparc
                   7192: 
1.154     rillig   7193: 21.5.1.3. C preprocessor macros to identify the compiler
1.1       dsieger  7194: 
                   7195: GCC         __GNUC__ (major version), __GNUC_MINOR__
                   7196: MIPSpro     _COMPILER_VERSION (0x741 for MIPSpro 7.41)
                   7197: SunPro      __SUNPRO_C (0x570 for Sun C 5.7)
                   7198: SunPro C++  __SUNPRO_CC (0x580 for Sun C++ 5.8)
                   7199: 
1.154     rillig   7200: 21.5.2. How to handle compiler bugs
1.1       dsieger  7201: 
                   7202: Some source files trigger bugs in the compiler, based on combinations of
                   7203: compiler version and architecture and almost always relation to optimisation
                   7204: being enabled. Common symptoms are gcc internal errors or never finishing
                   7205: compiling a file.
                   7206: 
                   7207: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
1.87      tnn      7208: disabling optimisation for that combination of file, MACHINE_ARCH and compiler.
                   7209: 
                   7210: This used to be a big problem in the past, but is rarely needed now as compiler
                   7211: technology has matured. If you still need to add a compiler specific
                   7212: workaround, please do so in the file hacks.mk and describe the symptom and
                   7213: compiler version as detailed as possible.
1.1       dsieger  7214: 
1.172     rillig   7215: 21.5.3. No such file or directory
                   7216: 
                   7217: Compilation sometimes fails with an error message like this:
                   7218: 
                   7219: .../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10:
                   7220:     fatal error: pango/pango.h: No such file or directory
                   7221: 
                   7222: The proper way to fix this problem depends on the type of the header, which is
                   7223: described in the following sections.
                   7224: 
                   7225: 21.5.3.1. Headers from other packages
                   7226: 
                   7227: If the header name looks like it comes from a different package, that other
                   7228: package should be included via the buildlink3 framework.
                   7229: 
                   7230: First, look whether the header is somewhere in the buildlink3 directory below
                   7231: WRKDIR. In the above case of the missing Pango header:
                   7232: 
                   7233: $ find work/.buildlink/ -print | grep -F pango/pango.h
                   7234: 
                   7235: In the case of Pango, the output is:
                   7236: 
                   7237: work/.buildlink/include/pango-1.0/pango/pango.h
                   7238: 
                   7239: If the pango/pango.h file were placed directly in the .buildlink directory, it
                   7240: would have been found automatically. There is an extra pango-1.0 path component
                   7241: though, which means that the compiler command line must contain an option of
                   7242: the form -I${BUILDLINK3_PREFIX.pango}/include/pango-1.0. In most cases this
                   7243: option is generated by the configure script, which can be examined using:
                   7244: 
                   7245: $ $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile
                   7246: -I/usr/pkg/include/pango-1.0
                   7247: -I/usr/pkg/include/pango-1.0
                   7248: -I/usr/pkg/include/pango-1.0
                   7249: -I/usr/pkg/include/pango-1.0
                   7250: -I/usr/pkg/include/pango-1.0
                   7251: 
                   7252: This looks good. These options are transformed by the buildlink wrapper to
                   7253: refer to the correct path inside work/.buildlink.
                   7254: 
                   7255: Since the compilation fails though, examine the compiler command lines in work
                   7256: /.work.log to see whether the -I option is included in the particular command
                   7257: line.
                   7258: 
                   7259: To further analyze the situation, run bmake build-env, which sets up an
                   7260: interactive, realistic environment including all the pkgsrc wrapper commands
                   7261: and environment variables. From there, try to compile some simple example
                   7262: programs that use the header.
                   7263: 
                   7264: 21.5.3.2. Headers generated during the build
                   7265: 
                   7266: If the name of the header seems to come from the package itself, and if the
                   7267: build is run with parallel jobs, the package may have some undeclared
                   7268: dependencies between the .c and the .h files, and a C file is compiled before
                   7269: its required header is generated.
                   7270: 
                   7271: To see whether the build runs with parallel jobs, run bmake show-all-build |
                   7272: grep JOBS. Its output looks like this:
                   7273: 
                   7274:   usr   MAKE_JOBS=              7
                   7275:   pkg   MAKE_JOBS_SAFE          # undefined
                   7276:   def   _MAKE_JOBS_N=           7
                   7277: 
                   7278: In this case the pkgsrc user has asked pkgsrc to build packages with 7 jobs in
                   7279: parallel (MAKE_JOBS). The package could have disabled parallel builds by
                   7280: setting MAKE_JOBS_SAFE to no, but in this case it hasn't.
                   7281: 
                   7282: To see whether the build failure is caused by parallel builds, first save the
                   7283: exact error message and a bit of context, maybe you need it later for reporting
                   7284: a bug. Next, run:
                   7285: 
                   7286: MAKE_JOBS_SAFE=no bmake clean build
                   7287: 
                   7288: If that succeeds, file a bug report against the pkgsrc package, including the
                   7289: exact error message and the contents of your mk.conf file.
                   7290: 
1.173     rillig   7291: 21.5.3.3. Symlinks
                   7292: 
                   7293: Pkgsrc does not work reliably if any of LOCALBASE, VARBASE or WRKDIR contains a
                   7294: symlink. Since 2019Q2, the pkgsrc bootstrap program prevents installing pkgsrc
                   7295: in symlink-based directories. Existing pkgsrc installations are not checked for
                   7296: symlinks though.
                   7297: 
                   7298: The "No such file or directory" error messages are a typical symptom of
                   7299: symlinks, and it's quite difficult to find out that this is the actual cause.
                   7300: 
                   7301: 21.5.3.4. Stale working directories
                   7302: 
                   7303: When building a hierarchy of packages, it may happen that one package is built
                   7304: and then pkgsrc is updated. This situation can provoke various hard to diagnose
                   7305: build errors. To clean up the situation:
                   7306: 
                   7307: $ (cd ../../ && test -f mk/bsd.pkg.mk && rm -rf */*/work)
                   7308: 
                   7309: (The test for bsd.pkg.mk just prevents running this command in the wrong
                   7310: directory.)
                   7311: 
                   7312: If you have set WRKOBJDIR in mk.conf, remove that directory as well.
                   7313: 
                   7314: 21.5.3.5. Other possible reasons
                   7315: 
                   7316: On platforms other than BSD, third-party packages are installed in /usr/
                   7317: include, together with the base system. This means that pkgsrc cannot
                   7318: distinguish between headers provided by the base system (which it needs) and
                   7319: headers from third-party packages (which are often included in pkgsrc as well).
                   7320: This can lead to subtle version mismatches.
                   7321: 
                   7322: In pkgsrc installations that have been active for several years, it may happen
                   7323: that some files are manually deleted. To exclude this unlikely reason, run 
                   7324: pkg_admin check.
                   7325: 
                   7326: It may help to run pkg_admin rebuild-tree to check/fix dependencies.
                   7327: 
                   7328: If all of the above doesn't help, see Chapter 2, Getting help for contact
                   7329: information. Be prepared to describe what you have tried so far and what any
                   7330: error messages were.
                   7331: 
1.172     rillig   7332: 21.5.4. Undefined reference to "..."
1.1       dsieger  7333: 
                   7334: This error message often means that a package did not link to a shared library
                   7335: it needs. The following functions are known to cause this error message over
                   7336: and over.
                   7337: 
                   7338: +-----------------------------------------------------+
                   7339: |        Function         |Library |Affected platforms|
                   7340: |-------------------------+--------+------------------|
                   7341: |accept, bind, connect    |-lsocket|Solaris           |
                   7342: |-------------------------+--------+------------------|
                   7343: |crypt                    |-lcrypt |DragonFly, NetBSD |
                   7344: |-------------------------+--------+------------------|
                   7345: |dlopen, dlsym            |-ldl    |Linux             |
                   7346: |-------------------------+--------+------------------|
                   7347: |gethost*                 |-lnsl   |Solaris           |
                   7348: |-------------------------+--------+------------------|
                   7349: |inet_aton                |-lresolv|Solaris           |
                   7350: |-------------------------+--------+------------------|
                   7351: |nanosleep, sem_*, timer_*|-lrt    |Solaris           |
                   7352: |-------------------------+--------+------------------|
                   7353: |openpty                  |-lutil  |Linux             |
                   7354: +-----------------------------------------------------+
                   7355: 
                   7356: To fix these linker errors, it is often sufficient to say LIBS.OperatingSystem+
                   7357: = -lfoo to the package Makefile and then say bmake clean; bmake.
                   7358: 
1.172     rillig   7359: 21.5.4.1. Special issue: The SunPro compiler
1.1       dsieger  7360: 
                   7361: When you are using the SunPro compiler, there is another possibility. That
                   7362: compiler cannot handle the following code:
                   7363: 
                   7364: extern int extern_func(int);
                   7365: 
                   7366: static inline int
                   7367: inline_func(int x)
                   7368: {
                   7369:         return extern_func(x);
                   7370: }
                   7371: 
                   7372: int main(void)
                   7373: {
                   7374:         return 0;
                   7375: }
                   7376: 
                   7377: It generates the code for inline_func even if that function is never used. This
                   7378: code then refers to extern_func, which can usually not be resolved. To solve
                   7379: this problem you can try to tell the package to disable inlining of functions.
                   7380: 
1.172     rillig   7381: 21.5.5. Running out of memory
1.1       dsieger  7382: 
                   7383: Sometimes packages fail to build because the compiler runs into an operating
                   7384: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
1.94      wiz      7385: told to unlimit the resources. Currently, the allowed values are any
                   7386: combination of "cputime", "datasize", "memorysize", and "stacksize". Setting
                   7387: this variable is similar to running the shell builtin ulimit command to raise
                   7388: the maximum data segment size or maximum stack size of a process, respectively,
                   7389: to their hard limits.
1.1       dsieger  7390: 
1.154     rillig   7391: 21.6. The install phase
1.1       dsieger  7392: 
1.154     rillig   7393: 21.6.1. Creating needed directories
1.1       dsieger  7394: 
                   7395: The BSD-compatible install supplied with some operating systems cannot create
                   7396: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
                   7397: like this:
                   7398: 
                   7399: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
                   7400: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
                   7401: 
                   7402: You can also just append "dir1 dir2" to the INSTALLATION_DIRS variable, which
                   7403: will automatically do the right thing.
                   7404: 
1.154     rillig   7405: 21.6.2. Where to install documentation
1.1       dsieger  7406: 
                   7407: In general, documentation should be installed into ${PREFIX}/share/doc/$
                   7408: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME} (the latter includes the version
                   7409: number of the package).
                   7410: 
                   7411: Many modern packages using GNU autoconf allow to set the directory where HTML
                   7412: documentation is installed with the "--with-html-dir" option. Sometimes using
                   7413: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
                   7414: share/doc/html or other places.
                   7415: 
                   7416: An exception to the above is that library API documentation generated with the
                   7417: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
                   7418: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
                   7419: can be recognized from files ending in .devhelp or .devhelp2. (It is also
                   7420: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
                   7421: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
                   7422: then, no additional subdirectory level is allowed in this case. This is usually
                   7423: achieved by using "--with-html-dir=${PREFIX}/share/doc". ${PREFIX}/share/
                   7424: gtk-doc is preferred though.)
                   7425: 
1.154     rillig   7426: 21.6.3. Installing highscore files
1.1       dsieger  7427: 
                   7428: Certain packages, most of them in the games category, install a score file that
                   7429: allows all users on the system to record their highscores. In order for this to
                   7430: work, the binaries need to be installed setgid and the score files owned by the
1.36      wiz      7431: appropriate group and/or owner (traditionally the "games" user/group). Set
                   7432: USE_GAMESGROUP to yes to support this. The following variables, documented in
                   7433: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
1.100     leot     7434: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER. Other useful variables are:
                   7435: GAMEDIR_PERMS, GAMEDATA_PERMS and SETGID_GAMES_PERMS.
                   7436: 
                   7437: An example that illustrates some of the variables described above is games/
                   7438: moon-buggy. OWN_DIRS_PERMS is used to properly set directory permissions of the
                   7439: directory where the scorefile is saved, REQD_FILES_PERMS is used to create a
                   7440: dummy scorefile (mbscore) with the proper permissions and SPECIAL_PERMS is used
                   7441: to install setgid the game binary:
                   7442: 
                   7443: USE_GAMESGROUP=         yes
                   7444: 
                   7445: BUILD_DEFS+=            VARBASE
                   7446: 
                   7447: OWN_DIRS_PERMS+=        ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
                   7448: REQD_FILES_PERMS+=      /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
                   7449: SPECIAL_PERMS+=         ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
                   7450: 
                   7451: Various INSTALL_* variables are also available: INSTALL_GAME to install setgid
                   7452: game binaries, INSTALL_GAME_DIR to install game directories that are needed to
                   7453: be accessed by setgid games and INSTALL_GAME_DATA to install scorefiles.
1.1       dsieger  7454: 
1.14      jmcneill 7455: A package should therefore never hard code file ownership or access permissions
1.100     leot     7456: but rely on *_PERMS as described above or alternatively on INSTALL_GAME,
                   7457: INSTALL_GAME_DATA and INSTALL_GAME_DIR to set these correctly.
1.1       dsieger  7458: 
1.154     rillig   7459: 21.6.4. Adding DESTDIR support to packages
1.4       rillig   7460: 
1.14      jmcneill 7461: DESTDIR support means that a package installs into a staging directory, not the
                   7462: final location of the files. Then a binary package is created which can be used
                   7463: for installation as usual. There are two ways: Either the package must install
1.25      wiz      7464: as root ("destdir") or the package can install as non-root user ("user-destdir"
                   7465: ).
1.14      jmcneill 7466: 
1.113     leot     7467:   * PKG_DESTDIR_SUPPORT has to be set to "destdir" or "user-destdir". By
                   7468:     default PKG_DESTDIR_SUPPORT is set to "user-destdir" to help catching more
                   7469:     potential packaging problems. If bsd.prefs.mk is included in the Makefile,
                   7470:     PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14      jmcneill 7471: 
1.4       rillig   7472:   * All installation operations have to be prefixed with ${DESTDIR}.
                   7473: 
                   7474:   * automake gets this DESTDIR mostly right automatically. Many manual rules
                   7475:     and pre/post-install often are incorrect; fix them.
                   7476: 
1.17      imil     7477:   * If files are installed with special owner/group use SPECIAL_PERMS.
1.4       rillig   7478: 
                   7479:   * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
                   7480: 
1.154     rillig   7481: 21.6.5. Packages with hardcoded paths to other interpreters
1.1       dsieger  7482: 
                   7483: Your package may also contain scripts with hardcoded paths to other
1.203     nia      7484: interpreters besides (or as well as) Perl. To correct the full pathname to the
1.1       dsieger  7485: script interpreter, you need to set the following definitions in your Makefile
                   7486: (we shall use tclsh in this example):
                   7487: 
                   7488: REPLACE_INTERPRETER+=   tcl
                   7489: REPLACE.tcl.old=        .*/bin/tclsh
                   7490: REPLACE.tcl.new=        ${PREFIX}/bin/tclsh
                   7491: REPLACE_FILES.tcl=      # list of tcl scripts which need to be fixed,
                   7492: # relative to ${WRKSRC}, just as in REPLACE_PERL
                   7493: 
                   7494: Note
                   7495: 
                   7496: Before March 2006, these variables were called _REPLACE.* and _REPLACE_FILES.*.
                   7497: 
1.203     nia      7498: 21.6.6. Packages installing Perl modules
1.1       dsieger  7499: 
                   7500: Makefiles of packages providing perl5 modules should include the Makefile
                   7501: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
                   7502: standard perl configuration for such modules as well as various hooks to tune
                   7503: this configuration. See comments in this file for details.
                   7504: 
                   7505: Perl5 modules will install into different places depending on the version of
                   7506: perl used during the build process. To address this, pkgsrc will append lines
                   7507: to the PLIST corresponding to the files listed in the installed .packlist file
                   7508: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48      wiz      7509: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
                   7510: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1       dsieger  7511: 
1.48      wiz      7512: PERL5_PACKLIST= auto/Pg/.packlist
1.1       dsieger  7513: 
1.48      wiz      7514: The perl5 config variables installarchlib, installscript, installvendorbin,
                   7515: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
                   7516: and installvendorman3dir represent those locations in which components of perl5
                   7517: modules may be installed, provided as variable with uppercase and prefixed with
                   7518: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
                   7519: have a packlist. These variables are also substituted for in the PLIST as
                   7520: uppercase prefixed with PERL5_SUB_.
1.1       dsieger  7521: 
1.154     rillig   7522: 21.6.7. Packages installing info files
1.1       dsieger  7523: 
                   7524: Some packages install info files or use the "makeinfo" or "install-info"
                   7525: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
                   7526: and DEINSTALL scripts will be generated to handle registration of the info
                   7527: files in the Info directory file. The "install-info" command used for the info
                   7528: files registration is either provided by the system, or by a special purpose
                   7529: package automatically added as dependency if needed.
                   7530: 
                   7531: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
                   7532: located. PKGINFODIR defaults to "info" and can be overridden by the user.
                   7533: 
                   7534: The info files for the package should be listed in the package PLIST; however
                   7535: any split info files need not be listed.
                   7536: 
                   7537: A package which needs the "makeinfo" command at build time must add "makeinfo"
                   7538: to USE_TOOLS in its Makefile. If a minimum version of the "makeinfo" command is
                   7539: needed it should be noted with the TEXINFO_REQD variable in the package
                   7540: Makefile. By default, a minimum version of 3.12 is required. If the system does
                   7541: not provide a makeinfo command or if it does not match the required minimum, a
                   7542: build dependency on the devel/gtexinfo package will be added automatically.
                   7543: 
                   7544: The build and installation process of the software provided by the package
                   7545: should not use the install-info command as the registration of info files is
1.25      wiz      7546: the task of the package INSTALL script, and it must use the appropriate 
1.1       dsieger  7547: makeinfo command.
                   7548: 
                   7549: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
                   7550: the install-info and makeinfo commands in a directory listed early in PATH.
                   7551: 
                   7552: The script overriding install-info has no effect except the logging of a
                   7553: message. The script overriding makeinfo logs a message and according to the
                   7554: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
                   7555: error.
                   7556: 
1.154     rillig   7557: 21.6.8. Packages installing man pages
1.1       dsieger  7558: 
                   7559: All packages that install manual pages should install them into the same
                   7560: directory, so that there is one common place to look for them. In pkgsrc, this
                   7561: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.25      wiz      7562: packages. The default for PKGMANDIR is "man". Another often-used value is "
                   7563: share/man".
1.1       dsieger  7564: 
                   7565: Note
                   7566: 
                   7567: The support for a custom PKGMANDIR is far from complete.
                   7568: 
                   7569: The PLIST files can just use man/ as the top level directory for the man page
                   7570: file entries, and the pkgsrc framework will convert as needed. In all other
                   7571: places, the correct PKGMANDIR must be used.
                   7572: 
                   7573: Packages that are configured with GNU_CONFIGURE set as "yes", by default will
                   7574: use the ./configure --mandir switch to set where the man pages should be
                   7575: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
                   7576: {PKGMANDIR}.
                   7577: 
                   7578: Packages that use GNU_CONFIGURE but do not use --mandir, can set
                   7579: CONFIGURE_HAS_MANDIR to "no". Or if the ./configure script uses a non-standard
                   7580: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
                   7581: 
1.184     rillig   7582: See Section 19.5, "Man page compression" for information on installation of
1.1       dsieger  7583: compressed manual pages.
                   7584: 
1.203     nia      7585: 21.6.9. Packages installing X11 fonts
1.1       dsieger  7586: 
                   7587: If a package installs font files, you will need to rebuild the fonts database
                   7588: in the directory where they get installed at installation and deinstallation
                   7589: time. This can be automatically done by using the pkginstall framework.
                   7590: 
                   7591: You can list the directories where fonts are installed in the FONTS_DIRS.type
                   7592: variables, where type can be one of "ttf", "type1" or "x11". Also make sure
                   7593: that the database file fonts.dir is not listed in the PLIST.
                   7594: 
                   7595: Note that you should not create new directories for fonts; instead use the
                   7596: standard ones to avoid that the user needs to manually configure his X server
                   7597: to find them.
                   7598: 
1.203     nia      7599: 21.6.10. Packages installing SGML or XML data
1.1       dsieger  7600: 
                   7601: If a package installs SGML or XML data files that need to be registered in
                   7602: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
                   7603: extra steps:
                   7604: 
                   7605:  1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
                   7606:     care of registering those files in system-wide catalogs at installation and
                   7607:     deinstallation time.
                   7608: 
                   7609:  2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
                   7610:     package.
                   7611: 
                   7612:  3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
                   7613:     package.
                   7614: 
                   7615:  4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
                   7616:     These come in groups of three strings; see xmlcatmgr(1) for more
                   7617:     information (specifically, arguments recognized by the 'add' action). Note
                   7618:     that you will normally not use this variable.
                   7619: 
                   7620:  5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
                   7621:     come in groups of three strings; see xmlcatmgr(1) for more information
                   7622:     (specifically, arguments recognized by the 'add' action). Note that you
                   7623:     will normally not use this variable.
                   7624: 
1.203     nia      7625: 21.6.11. Packages installing extensions to the MIME database
1.1       dsieger  7626: 
                   7627: If a package provides extensions to the MIME database by installing .xml files
                   7628: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
                   7629: ensure that the database is kept consistent with respect to these new files:
                   7630: 
                   7631:  1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
                   7632:     buildlink3.mk file from this same directory, which is reserved for
                   7633:     inclusion from other buildlink3.mk files). It takes care of rebuilding the
                   7634:     MIME database at installation and deinstallation time, and disallows any
                   7635:     access to it directly from the package.
                   7636: 
1.25      wiz      7637:  2. Check the PLIST and remove any entries under the share/mime directory, 
1.1       dsieger  7638:     except for files saved under share/mime/packages. The former are handled
                   7639:     automatically by the update-mime-database program, but the latter are
                   7640:     package-dependent and must be removed by the package that installed them in
                   7641:     the first place.
                   7642: 
                   7643:  3. Remove any share/mime/* directories from the PLIST. They will be handled by
                   7644:     the shared-mime-info package.
                   7645: 
1.203     nia      7646: 21.6.12. Packages using intltool
1.1       dsieger  7647: 
                   7648: If a package uses intltool during its build, add intltool to the USE_TOOLS,
                   7649: which forces it to use the intltool package provided by pkgsrc, instead of the
                   7650: one bundled with the distribution file.
                   7651: 
                   7652: This tracks intltool's build-time dependencies and uses the latest available
                   7653: version; this way, the package benefits of any bug fixes that may have appeared
                   7654: since it was released.
                   7655: 
1.203     nia      7656: 21.6.13. Packages installing startup scripts
1.1       dsieger  7657: 
                   7658: If a package contains a rc.d script, it won't be copied into the startup
                   7659: directory by default, but you can enable it, by adding the option
1.4       rillig   7660: PKG_RCD_SCRIPTS=YES in mk.conf. This option will copy the scripts into /etc/
                   7661: rc.d when a package is installed, and it will automatically remove the scripts
                   7662: when the package is deinstalled.
1.1       dsieger  7663: 
1.203     nia      7664: 21.6.14. Packages installing TeX modules
1.1       dsieger  7665: 
                   7666: If a package installs TeX packages into the texmf tree, the ls-R database of
                   7667: the tree needs to be updated.
                   7668: 
                   7669: Note
                   7670: 
1.23      jakllsch 7671: Except the main TeX packages such as kpathsea, packages should install files
                   7672: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1       dsieger  7673: 
1.23      jakllsch 7674:  1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
                   7675:     ls-R database at installation and deinstallation time.
1.1       dsieger  7676: 
1.23      jakllsch 7677:  2. If your package installs files into a texmf tree other than the one at $
                   7678:     {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
                   7679:     trees that need database update.
1.1       dsieger  7680: 
                   7681:     If your package also installs font map files that need to be registered
1.30      dholland 7682:     using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
                   7683:     and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then 
                   7684:     updmap will be run automatically at installation/deinstallation to enable/
                   7685:     disable font map files for TeX output drivers.
1.1       dsieger  7686: 
                   7687:  3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30      dholland 7688:     be removed only by the kpathsea package.
1.1       dsieger  7689: 
1.203     nia      7690: 21.6.15. Packages supporting running binaries in emulation
1.1       dsieger  7691: 
                   7692: There are some packages that provide libraries and executables for running
                   7693: binaries from a one operating system on a different one (if the latter supports
                   7694: it). One example is running Linux binaries on NetBSD.
                   7695: 
                   7696: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
                   7697: 
                   7698: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
                   7699: if all libraries for each installed executable can be found by the dynamic
                   7700: linker. Since the standard dynamic linker is run, this fails for emulation
                   7701: packages, because the libraries used by the emulation are not in the standard
                   7702: directories.
                   7703: 
1.203     nia      7704: 21.6.16. Packages installing hicolor icons
1.1       dsieger  7705: 
                   7706: If a package installs images under the share/icons/hicolor and/or updates the
                   7707: share/icons/hicolor/icon-theme.cache database, you need to take some extra
                   7708: steps to make sure that the shared theme directory is handled appropriately and
                   7709: that the cache database is rebuilt:
                   7710: 
                   7711:  1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
                   7712: 
                   7713:  2. Check the PLIST and remove the entry that refers to the theme cache.
                   7714: 
                   7715:  3. Ensure that the PLIST does not remove the shared icon directories from the
                   7716:     share/icons/hicolor hierarchy because they will be handled automatically.
                   7717: 
                   7718: The best way to verify that the PLIST is correct with respect to the last two
                   7719: points is to regenerate it using make print-PLIST.
                   7720: 
1.203     nia      7721: 21.6.17. Packages installing desktop files
1.1       dsieger  7722: 
                   7723: If a package installs .desktop files under share/applications and these include
1.54      rodent   7724: MIME information (MimeType key), you need to take extra steps to ensure that
                   7725: they are registered into the MIME database:
1.1       dsieger  7726: 
                   7727:  1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
                   7728: 
                   7729:  2. Check the PLIST and remove the entry that refers to the share/applications/
                   7730:     mimeinfo.cache file. It will be handled automatically.
                   7731: 
                   7732: The best way to verify that the PLIST is correct with respect to the last point
                   7733: is to regenerate it using make print-PLIST.
                   7734: 
1.154     rillig   7735: 21.7. Marking packages as having problems
1.1       dsieger  7736: 
1.23      jakllsch 7737: In some cases one does not have the time to solve a problem immediately. In
                   7738: this case, one can plainly mark a package as broken. For this, one just sets
                   7739: the variable BROKEN to the reason why the package is broken (similar to the
1.162     rillig   7740: PKG_FAIL_REASON variable). A user trying to build the package will immediately
                   7741: be shown this message, and the build will not be even tried.
1.1       dsieger  7742: 
1.23      jakllsch 7743: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1       dsieger  7744: 
1.184     rillig   7745: Chapter 22. GNOME packaging and porting
                   7746: 
                   7747: Table of Contents
                   7748: 
                   7749: 22.1. Meta packages
                   7750: 22.2. Packaging a GNOME application
                   7751: 22.3. Updating GNOME to a newer version
                   7752: 22.4. Patching guidelines
                   7753: 
                   7754: Quoting GNOME's web site:
                   7755: 
                   7756:     The GNOME project provides two things: The GNOME desktop environment, an
                   7757:     intuitive and attractive desktop for users, and the GNOME development
                   7758:     platform, an extensive framework for building applications that integrate
                   7759:     into the rest of the desktop.
                   7760: 
                   7761: pkgsrc provides a seamless way to automatically build and install a complete
                   7762: GNOME environment under many different platforms. We can say with confidence
                   7763: that pkgsrc is one of the most advanced build and packaging systems for GNOME
                   7764: due to its included technologies buildlink3, the wrappers and tools framework
                   7765: and automatic configuration file management. Lots of efforts are put into
                   7766: achieving a completely clean deinstallation of installed software components.
                   7767: 
                   7768: Given that pkgsrc is NetBSD's official packaging system, the above also means
                   7769: that great efforts are put into making GNOME work under this operating system.
                   7770: 
                   7771: This chapter is aimed at pkgsrc developers and other people interested in
                   7772: helping our GNOME porting and packaging efforts. It provides instructions on
                   7773: how to manage the existing packages and some important information regarding
                   7774: their internals.
                   7775: 
                   7776: We need your help!
                   7777: 
                   7778: Should you have some spare cycles to devote to NetBSD, pkgsrc and GNOME and are
                   7779: willing to learn new exciting stuff, please jump straight to the pending work
                   7780: list! There is still a long way to go to get a fully-functional GNOME desktop
                   7781: under NetBSD and we need your help to achieve it!
                   7782: 
                   7783: 22.1. Meta packages
                   7784: 
                   7785: pkgsrc includes three GNOME-related meta packages:
                   7786: 
                   7787:   * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
                   7788:     includes the necessary bits to get it to boot correctly, although it may
                   7789:     lack important functionality for daily operation. The idea behind this
                   7790:     package is to let end users build their own configurations on top of this
                   7791:     one, first installing this meta package to achieve a functional setup and
                   7792:     then adding individual applications.
                   7793: 
                   7794:   * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
                   7795:     desktop as defined by the GNOME project; this is based on the components
                   7796:     distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
                   7797:     directories of the official FTP server. Developer-only tools found in those
                   7798:     directories are not installed unless required by some other component to
                   7799:     work properly. Similarly, packages from the bindings set (bindings/x.y/
                   7800:     x.y.z/sources) are not pulled in unless required as a dependency for an
                   7801:     end-user component. This package "extends" meta-pkgs/gnome-base.
                   7802: 
                   7803:   * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
                   7804:     component when fetched from the CVS repository. These are required to let
                   7805:     the autogen.sh scripts work appropriately.
                   7806: 
                   7807: In all these packages, the DEPENDS lines are sorted in a way that eases
                   7808: updates: a package may depend on other packages listed before it but not on any
                   7809: listed after it. It is very important to keep this order to ease updates so... 
                   7810: do not change it to alphabetical sorting!
                   7811: 
                   7812: 22.2. Packaging a GNOME application
                   7813: 
                   7814: Almost all GNOME applications are written in C and use a common set of tools as
                   7815: their build system. Things get different with the new bindings to other
                   7816: languages (such as Python), but the following will give you a general idea on
                   7817: the minimum required tools:
                   7818: 
                   7819:   * Almost all GNOME applications use the GNU Autotools as their build system.
                   7820:     As a general rule you will need to tell this to your package:
                   7821: 
                   7822:     GNU_CONFIGURE=yes
                   7823:     USE_LIBTOOL=yes
                   7824:     USE_TOOLS+=gmake
                   7825: 
                   7826:   * If the package uses pkg-config to detect dependencies, add this tool to the
                   7827:     list of required utilities:
                   7828: 
                   7829:     USE_TOOLS+=pkg-config
                   7830: 
                   7831:     Also use pkgtools/verifypc at the end of the build process to ensure that
                   7832:     you did not miss to specify any dependency in your package and that the
                   7833:     version requirements are all correct.
                   7834: 
                   7835:   * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
                   7836:     handle dependencies and to force the package to use the latest available
                   7837:     version.
                   7838: 
                   7839:   * If the package uses gtk-doc (a documentation generation utility), do not
                   7840:     add a dependency on it. The tool is rather big and the distfile should come
                   7841:     with pregenerated documentation anyway; if it does not, it is a bug that
                   7842:     you ought to report. For such packages you should disable gtk-doc (unless
                   7843:     it is the default):
                   7844: 
                   7845:     CONFIGURE_ARGS+=--disable-gtk-doc
                   7846: 
                   7847:     The default location of installed HTML files (share/gtk-doc/<package-name>)
                   7848:     is correct and should not be changed unless the package insists on
                   7849:     installing them somewhere else. Otherwise programs as devhelp will not be
                   7850:     able to open them. You can do that with an entry similar to:
1.1       dsieger  7851: 
1.184     rillig   7852:     CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...
1.1       dsieger  7853: 
1.184     rillig   7854: GNOME uses multiple shared directories and files under the installation prefix
                   7855: to maintain databases. In this context, shared means that those exact same
                   7856: directories and files are used among several different packages, leading to
                   7857: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
                   7858: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
                   7859: your file lists and omitting shared files from them. If you find yourself doing
                   7860: those, your package is most likely incorrect.
1.1       dsieger  7861: 
1.184     rillig   7862: The following table lists the common situations that result in using shared
                   7863: directories or files. For each of them, the appropriate solution is given.
                   7864: After applying the solution be sure to regenerate the package's file list with 
                   7865: make print-PLIST and ensure it is correct.
1.1       dsieger  7866: 
1.184     rillig   7867: Table 22.1. PLIST handling for GNOME packages
1.1       dsieger  7868: 
1.184     rillig   7869: +-----------------------------------------------------------------------------+
                   7870: |             If the package...             |             Then...             |
                   7871: |-------------------------------------------+---------------------------------|
1.203     nia      7872: |Installs icons under the share/icons/      |See Section 21.6.16, "Packages   |
                   7873: |hicolor hierarchy or updates share/icons/  |installing hicolor icons".       |
1.184     rillig   7874: |hicolor/icon-theme.cache.                  |                                 |
                   7875: |-------------------------------------------+---------------------------------|
1.203     nia      7876: |                                           |See Section 21.6.11, "Packages   |
1.184     rillig   7877: |Installs files under share/mime/packages.  |installing extensions to the MIME|
                   7878: |                                           |database".                       |
                   7879: |-------------------------------------------+---------------------------------|
1.203     nia      7880: |Installs .desktop files under share/       |See Section 21.6.17, "Packages   |
1.184     rillig   7881: |applications and these include MIME        |installing desktop files".       |
                   7882: |information.                               |                                 |
                   7883: +-----------------------------------------------------------------------------+
1.1       dsieger  7884: 
                   7885: 
1.184     rillig   7886: 22.3. Updating GNOME to a newer version
1.1       dsieger  7887: 
1.184     rillig   7888: When seeing GNOME as a whole, there are two kinds of updates:
1.1       dsieger  7889: 
1.184     rillig   7890: Major update
1.1       dsieger  7891: 
1.184     rillig   7892:     Given that there is still a very long way for GNOME 3 (if it ever appears),
                   7893:     we consider a major update one that goes from a 2.X version to a 2.Y one,
                   7894:     where Y is even and greater than X. These are hard to achieve because they
                   7895:     introduce lots of changes in the components' code and almost all GNOME
                   7896:     distfiles are updated to newer versions. Some of them can even break API
                   7897:     and ABI compatibility with the previous major version series. As a result,
                   7898:     the update needs to be done all at once to minimize breakage.
1.1       dsieger  7899: 
1.184     rillig   7900:     A major update typically consists of around 80 package updates and the
                   7901:     addition of some new ones.
1.1       dsieger  7902: 
1.184     rillig   7903: Minor update
1.1       dsieger  7904: 
1.184     rillig   7905:     We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
                   7906:     one where Y is greater than X. These are easy to achieve because they do
                   7907:     not update all GNOME components, can be done in an incremental way and do
                   7908:     not break API nor ABI compatibility.
1.1       dsieger  7909: 
1.184     rillig   7910:     A minor update typically consists of around 50 package updates, although
                   7911:     the numbers here may vary a lot.
1.1       dsieger  7912: 
1.184     rillig   7913: In order to update the GNOME components in pkgsrc to a new stable release
                   7914: (either major or minor), the following steps should be followed:
1.1       dsieger  7915: 
1.184     rillig   7916:  1. Get a list of all the tarballs that form the new release by using the
                   7917:     following commands. These will leave the full list of the components'
                   7918:     distfiles into the list.txt file:
1.1       dsieger  7919: 
1.184     rillig   7920:     % echo ls "*.tar.bz2" | \
                   7921:         ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
                   7922:         awk '{ print $9 }' >list.txt
                   7923:     % echo ls "*.tar.bz2" | \
                   7924:         ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
                   7925:         awk '{ print $9 }' >>list.txt
1.1       dsieger  7926: 
1.184     rillig   7927:  2. Open each meta package's Makefile and bump their version to the release you
                   7928:     are updating them to. The three meta packages should be always consistent
                   7929:     with versioning. Obviously remove any PKGREVISIONs that might be in them.
1.1       dsieger  7930: 
1.184     rillig   7931:  3. For each meta package, update all its DEPENDS lines to match the latest
                   7932:     versions as shown by the above commands. Do not list any newer version
                   7933:     (even if found in the FTP) because the meta packages are supposed to list
                   7934:     the exact versions that form a specific GNOME release. Exceptions are
                   7935:     permitted here if a newer version solves a serious issue in the overall
                   7936:     desktop experience; these typically come in the form of a revision bump in
                   7937:     pkgsrc, not in newer versions from the developers.
1.1       dsieger  7938: 
1.184     rillig   7939:     Packages not listed in the list.txt file should be updated to the latest
                   7940:     version available (if found in pkgsrc). This is the case, for example, of
                   7941:     the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
                   7942:     package.
1.1       dsieger  7943: 
1.184     rillig   7944:  4. Generate a patch from the modified meta packages and extract the list of
                   7945:     "new" lines. This will provide you an outline on what packages need to be
                   7946:     updated in pkgsrc and in what order:
1.1       dsieger  7947: 
1.184     rillig   7948:     % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
1.1       dsieger  7949: 
1.184     rillig   7950:  5. For major desktop updates it is recommended to zap all your installed
                   7951:     packages and start over from scratch at this point.
1.1       dsieger  7952: 
1.184     rillig   7953:  6. Now comes the longest step by far: iterate over the contents of todo.txt
                   7954:     and update the packages listed in it in order. For major desktop updates
                   7955:     none of these should be committed until the entire set is completed because
                   7956:     there are chances of breaking not-yet-updated packages.
1.1       dsieger  7957: 
1.184     rillig   7958:  7. Once the packages are up to date and working, commit them to the tree one
                   7959:     by one with appropriate log messages. At the end, commit the three meta
                   7960:     package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
                   7961:     and pkgsrc/doc/TODO files.
1.1       dsieger  7962: 
1.184     rillig   7963: 22.4. Patching guidelines
1.1       dsieger  7964: 
1.184     rillig   7965: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
                   7966: it is very important that you always, always, always feed back any portability
                   7967: fixes you do to a GNOME package to the mainstream developers (see
                   7968: Section 12.3.5, "Feedback to the author"). This is the only way to get their
                   7969: attention on portability issues and to ensure that future versions can be built
                   7970: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
                   7971: updates are. Those developers in charge of issuing major GNOME updates will be
                   7972: grateful if you do that.
1.1       dsieger  7973: 
1.200     cirnatda 7974: The most common places to report bugs are the GNOME's GitLab and the
                   7975: freedesktop.org's GitLab. Not all components use these to track bugs, but most
                   7976: of them do. Do not be short on your reports: always provide detailed
1.184     rillig   7977: explanations of the current failure, how it can be improved to achieve maximum
1.200     cirnatda 7978: portability and, if at all possible, provide a patch against the main Git
                   7979: branch. The more verbose you are, the higher chances of your patch being
                   7980: accepted.
1.1       dsieger  7981: 
1.184     rillig   7982: Also, please avoid using preprocessor magic to fix portability issues. While
                   7983: the FreeBSD GNOME people are doing a great job in porting GNOME to their
                   7984: operating system, the official GNOME sources are now plagued by conditionals
                   7985: that check for __FreeBSD__ and similar macros. This hurts portability. Please
                   7986: see our patching guidelines (Section 12.3.4, "Patching guidelines") for more
                   7987: details.
1.1       dsieger  7988: 
1.154     rillig   7989: Chapter 23. Submitting and Committing
1.1       dsieger  7990: 
                   7991: Table of Contents
                   7992: 
1.154     rillig   7993: 23.1. Submitting binary packages
                   7994: 23.2. Submitting source packages (for non-NetBSD-developers)
                   7995: 23.3. General notes when adding, updating, or removing packages
                   7996: 23.4. Commit Messages
                   7997: 23.5. Committing: Adding a package to CVS
                   7998: 23.6. Updating a package to a newer version
                   7999: 23.7. Renaming a package in pkgsrc
                   8000: 23.8. Moving a package in pkgsrc
1.1       dsieger  8001: 
1.154     rillig   8002: 23.1. Submitting binary packages
1.1       dsieger  8003: 
                   8004: Our policy is that we accept binaries only from pkgsrc developers to guarantee
                   8005: that the packages don't contain any trojan horses etc. This is not to annoy
                   8006: anyone but rather to protect our users! You're still free to put up your
                   8007: home-made binary packages and tell the world where to get them. NetBSD
1.154     rillig   8008: developers doing bulk builds and wanting to upload them please see Chapter 8, 
1.66      asau     8009: Creating binary packages for everything in pkgsrc (bulk builds).
1.1       dsieger  8010: 
1.154     rillig   8011: 23.2. Submitting source packages (for non-NetBSD-developers)
1.1       dsieger  8012: 
                   8013: First, check that your package is complete, compiles and runs well; see
1.184     rillig   8014: Chapter 14, Creating a new pkgsrc package from scratch and the rest of this
                   8015: document. Next, generate an uuencoded gzipped tar(1) archive that contains all
                   8016: files that make up the package. Finally, send this package to the pkgsrc bug
                   8017: tracking system, either with the send-pr(1) command, or if you don't have that,
                   8018: go to the web page https://www.NetBSD.org/support/send-pr.html, which contains
                   8019: some instructions and a link to a form where you can submit packages. The
                   8020: sysutils/gtk-send-pr package is also available as a substitute for either of
                   8021: the above two tools.
1.1       dsieger  8022: 
                   8023: In the form of the problem report, the category should be "pkg", the synopsis
                   8024: should include the package name and version number, and the description field
                   8025: should contain a short description of your package (contents of the COMMENT
1.25      wiz      8026: variable or DESCR file are OK). The uuencoded package data should go into the "
                   8027: fix" field.
1.1       dsieger  8028: 
                   8029: If you want to submit several packages, please send a separate PR for each one,
                   8030: it's easier for us to track things that way.
                   8031: 
                   8032: Alternatively, you can also import new packages into pkgsrc-wip ("pkgsrc
1.174     leot     8033: work-in-progress"); see the homepage at https://pkgsrc.org/wip/ for details.
1.1       dsieger  8034: 
1.154     rillig   8035: 23.3. General notes when adding, updating, or removing packages
1.1       dsieger  8036: 
                   8037: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
                   8038: CHANGES-YYYY. It's very important to keep this file up to date and conforming
                   8039: to the existing format, because it will be used by scripts to automatically
                   8040: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
                   8041: doc/TODO file and remove the entry for the package you updated or removed, in
                   8042: case it was mentioned there.
                   8043: 
                   8044: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
                   8045: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
                   8046: that result from a dependency being updated should not be mentioned. In all
                   8047: other cases it's the developer's decision.
                   8048: 
                   8049: There is a make target that helps in creating proper CHANGES-YYYY entries: make
                   8050: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
                   8051: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
                   8052: (to avoid having to resolve conflicts later-on) and then to cd to the package
                   8053: directory. For package updates, make changes-entry is enough. For new packages,
                   8054: or package moves or removals, set the CTYPE variable on the command line to
1.4       rillig   8055: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23      jakllsch 8056: your local login name is not the same as your NetBSD login name. The target
                   8057: also automatically removes possibly existing entries for the package in the
                   8058: TODO file. Don't forget to commit the changes, e.g. by using make
1.66      asau     8059: commit-changes-entry! If you are not using a checkout directly from
1.23      jakllsch 8060: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
                   8061: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1       dsieger  8062: 
1.154     rillig   8063: 23.4. Commit Messages
1.130     wiz      8064: 
                   8065: For several years, there have been mirrors of pkgsrc in fossil, git, and hg.
                   8066: Standard practise when using these tools is to make the first line of a commit
                   8067: message function as a summary that can be read without the rest, such as is
                   8068: commonly done with "git log --oneline". For this reason, we have the following
                   8069: guidelines for pkgsrc commit messages:
                   8070: 
1.131     wiz      8071:   * Start the commit message with a line that explains the big picture in 65
1.130     wiz      8072:     characters or less. When a commit is for one package, include the name of
                   8073:     the package. For updates, include the version to which it is updated.
                   8074: 
                   8075:   * Leave the next line empty.
                   8076: 
                   8077:   * Then come the details for the commit (changes in that package, reason for a
                   8078:     change) and any relevant PRs. Wrap this section.
                   8079: 
                   8080: Here is an example:
                   8081: 
                   8082:   libxslt: update to 1.0.30
                   8083: 
                   8084:   Changes since 1.0.29:
                   8085:   ...
                   8086: 
                   8087: 
                   8088: Here is another example:
                   8089: 
                   8090:   mk/bsd.pkg.mk: enable SSP by default on NetBSD
                   8091: 
                   8092:   (rationale)
                   8093: 
                   8094: 
                   8095: Commit messages are final: no "cvs admin" is allowed on the pkgsrc repository
                   8096: to change commit messages.
                   8097: 
1.154     rillig   8098: 23.5. Committing: Adding a package to CVS
1.1       dsieger  8099: 
                   8100: This section is only of interest for pkgsrc developers with write access to the
1.34      wiz      8101: pkgsrc repository.
                   8102: 
                   8103: When the package is finished, "cvs add" the files. Start by adding the
                   8104: directory and then files in the directory. Don't forget to add the new package
                   8105: to the category's Makefile. Make sure you don't forget any files; you can check
                   8106: by running "cvs status". An example:
                   8107: 
                   8108: $ cd .../pkgsrc/category
                   8109: $ cvs add pkgname
                   8110: $ cd pkgname
                   8111: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
                   8112: $ cvs add patches/p*
                   8113: $ cvs status | less
1.35      wiz      8114: $ cvs commit
1.34      wiz      8115: $ cd ..
                   8116: $ vi Makefile # add SUBDIRS+=pkgname line
1.35      wiz      8117: $ cvs commit Makefile
1.66      asau     8118: $ cd pkgname
1.73      jnemeth  8119: $ make CTYPE=Added commit-changes-entry
1.1       dsieger  8120: 
                   8121: The commit message of the initial import should include part of the DESCR file,
                   8122: so people reading the mailing lists know what the package is/does.
                   8123: 
1.34      wiz      8124: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
                   8125: 
                   8126: Previously, "cvs import" was suggested, but it was much easier to get wrong
                   8127: than "cvs add".
1.1       dsieger  8128: 
1.154     rillig   8129: 23.6. Updating a package to a newer version
1.1       dsieger  8130: 
                   8131: Please always put a concise, appropriate and relevant summary of the changes
                   8132: between old and new versions into the commit log when updating a package. There
                   8133: are various reasons for this:
                   8134: 
                   8135:   * A URL is volatile, and can change over time. It may go away completely or
                   8136:     its information may be overwritten by newer information.
                   8137: 
                   8138:   * Having the change information between old and new versions in our CVS
                   8139:     repository is very useful for people who use either cvs or anoncvs.
                   8140: 
                   8141:   * Having the change information between old and new versions in our CVS
                   8142:     repository is very useful for people who read the pkgsrc-changes mailing
                   8143:     list, so that they can make tactical decisions about when to upgrade the
                   8144:     package.
                   8145: 
                   8146: Please also recognize that, just because a new version of a package has been
                   8147: released, it should not automatically be upgraded in the CVS repository. We
                   8148: prefer to be conservative in the packages that are included in pkgsrc -
                   8149: development or beta packages are not really the best thing for most places in
                   8150: which pkgsrc is used. Please use your judgement about what should go into
                   8151: pkgsrc, and bear in mind that stability is to be preferred above new and
                   8152: possibly untested features.
                   8153: 
1.154     rillig   8154: 23.7. Renaming a package in pkgsrc
1.21      snj      8155: 
                   8156: Renaming packages is not recommended.
                   8157: 
1.175     gutterid 8158: When renaming packages, be sure to fix any references to the old name in other
1.21      snj      8159: Makefiles, options, buildlink files, etc.
                   8160: 
1.175     gutterid 8161: Also, when renaming a package, please add the package name and version pattern
1.167     leot     8162: (s) of the previous package to SUPERSEDES. This may be repeated for multiple
                   8163: renames. The new package would be an exact replacement. Example:
                   8164: 
                   8165: SUPERSEDES+=    p5-IO-Compress-Zlib<2.017
                   8166: SUPERSEDES+=    optcomp-[0-9]*
1.21      snj      8167: 
                   8168: Note that "successor" in the CHANGES-YYYY file doesn't necessarily mean that it
                   8169: supersedes, as that successor may not be an exact replacement but is a
                   8170: suggestion for the replaced functionality.
                   8171: 
1.154     rillig   8172: 23.8. Moving a package in pkgsrc
1.21      snj      8173: 
                   8174: It is preferred that packages are not renamed or moved, but if needed please
                   8175: follow these steps.
1.1       dsieger  8176: 
                   8177:  1. Make a copy of the directory somewhere else.
                   8178: 
                   8179:  2. Remove all CVS dirs.
                   8180: 
                   8181:     Alternatively to the first two steps you can also do:
                   8182: 
                   8183:     % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
                   8184: 
                   8185:     and use that for further work.
                   8186: 
1.25      wiz      8187:  3. Fix CATEGORIES and any DEPENDS paths that just did "../package" instead of 
1.1       dsieger  8188:     "../../category/package".
                   8189: 
1.21      snj      8190:  4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
                   8191:     previous category/package pathname. The PREV_PKGPATH can be used by tools
                   8192:     for doing an update using pkgsrc building; for example, it can search the
                   8193:     pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
                   8194:     the corresponding new PKGPATH for that moved package. Note that it may have
                   8195:     multiple matches, so the tool should also check on the PKGBASE too. The
                   8196:     PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
                   8197:     PKGBASE stays the same.
                   8198: 
                   8199:  5. cvs import the modified package in the new place.
1.1       dsieger  8200: 
1.21      snj      8201:  6. Check if any package depends on it:
1.1       dsieger  8202: 
                   8203:     % cd /usr/pkgsrc
                   8204:     % grep /package */*/Makefile* */*/buildlink*
                   8205: 
1.21      snj      8206:  7. Fix paths in packages from step 5 to point to new location.
1.1       dsieger  8207: 
1.21      snj      8208:  8. cvs rm (-f) the package at the old location.
1.1       dsieger  8209: 
1.21      snj      8210:  9. Remove from oldcategory/Makefile.
1.1       dsieger  8211: 
1.21      snj      8212: 10. Add to newcategory/Makefile.
1.1       dsieger  8213: 
1.21      snj      8214: 11. Commit the changed and removed files:
1.1       dsieger  8215: 
                   8216:     % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
                   8217: 
                   8218:     (and any packages from step 5, of course).
                   8219: 
1.154     rillig   8220: Chapter 24. Frequently Asked Questions
1.1       dsieger  8221: 
                   8222: This section contains the answers to questions that may arise when you are
                   8223: writing a package. If you don't find your question answered here, first have a
                   8224: look in the other chapters, and if you still don't have the answer, ask on the
                   8225: pkgsrc-users mailing list.
                   8226: 
1.154     rillig   8227: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
                   8228: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
                   8229: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
                   8230: 24.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1       dsieger  8231:     BUILDLINK_LIBS?
1.154     rillig   8232: 24.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
                   8233: 24.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1       dsieger  8234:     the := inside it.
1.154     rillig   8235: 24.7. Which mailing lists are there for package developers?
                   8236: 24.8. Where is the pkgsrc documentation?
                   8237: 24.9. I have a little time to kill. What shall I do?
1.1       dsieger  8238: 
1.154     rillig   8239: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1       dsieger  8240: 
                   8241:       MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
                   8242:       (1), while MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM
                   8243:       when building the package. [FIXME: What is .MAKEFLAGS for?]
                   8244: 
1.154     rillig   8245: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1       dsieger  8246: 
                   8247:       MAKE is the path to the make(1) program that is used in the pkgsrc
                   8248:       infrastructure. GMAKE is the path to GNU Make, but you need to say
                   8249:       USE_TOOLS+=gmake to use that. MAKE_PROGRAM is the path to the Make
                   8250:       program that is used for building the package.
                   8251: 
1.154     rillig   8252: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1       dsieger  8253: 
                   8254:       CC is the path to the real C compiler, which can be configured by the
                   8255:       pkgsrc user. PKG_CC is the path to the compiler wrapper. PKGSRC_COMPILER
                   8256:       is not a path to a compiler, but the type of compiler that should be
                   8257:       used. See mk/compiler.mk for more information about the latter variable.
                   8258: 
1.154     rillig   8259: 24.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1       dsieger  8260:       BUILDLINK_LIBS?
                   8261: 
                   8262:       [FIXME]
                   8263: 
1.154     rillig   8264: 24.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1       dsieger  8265: 
1.25      wiz      8266:       For optimization reasons, some variables are only available in the "
                   8267:       wrapper" phase and later. To "simulate" the wrapper phase, append 
1.1       dsieger  8268:       PKG_PHASE=wrapper to the above command.
                   8269: 
1.154     rillig   8270: 24.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1       dsieger  8271:       the := inside it.
                   8272: 
1.108     rillig   8273:       The := is not really an assignment operator, although it looks like it.
                   8274:       Instead, it is a degenerate form of ${LIST:old_string=new_string}, which
                   8275:       is documented in the make(1) man page and which is commonly used in the
                   8276:       form ${SRCS:.c=.o}. In the case of MASTER_SITE_*, old_string is the empty
                   8277:       string and new_string is package/. That's where the : and the = fall
                   8278:       together.
1.1       dsieger  8279: 
1.154     rillig   8280: 24.7. Which mailing lists are there for package developers?
1.1       dsieger  8281: 
                   8282:       tech-pkg
                   8283: 
                   8284:           This is a list for technical discussions related to pkgsrc
                   8285:           development, e.g. soliciting feedback for changes to pkgsrc
                   8286:           infrastructure, proposed new features, questions related to porting
                   8287:           pkgsrc to a new platform, advice for maintaining a package, patches
                   8288:           that affect many packages, help requests moved from pkgsrc-users when
                   8289:           an infrastructure bug is found, etc.
                   8290: 
                   8291:       pkgsrc-bugs
                   8292: 
                   8293:           All bug reports in category "pkg" sent with send-pr(1) appear here.
                   8294:           Please do not report your bugs here directly; use one of the other
                   8295:           mailing lists.
                   8296: 
1.154     rillig   8297: 24.8. Where is the pkgsrc documentation?
1.1       dsieger  8298: 
                   8299:       There are many places where you can find documentation about pkgsrc:
                   8300: 
                   8301:         * The pkgsrc guide (this document) is a collection of chapters that
                   8302:           explain large parts of pkgsrc, but some chapters tend to be outdated.
                   8303:           Which ones they are is hard to say.
                   8304: 
1.174     leot     8305:         * On the mailing list archives (see https://mail-index.NetBSD.org/),
                   8306:           you can find discussions about certain features, announcements of new
1.1       dsieger  8307:           parts of the pkgsrc infrastructure and sometimes even announcements
                   8308:           that a certain feature has been marked as obsolete. The benefit here
                   8309:           is that each message has a date appended to it.
                   8310: 
                   8311:         * Many of the files in the mk/ directory start with a comment that
                   8312:           describes the purpose of the file and how it can be used by the
                   8313:           pkgsrc user and package authors. An easy way to find this
                   8314:           documentation is to run bmake help.
                   8315: 
                   8316:         * The CVS log messages are a rich source of information, but they tend
                   8317:           to be highly abbreviated, especially for actions that occur often.
                   8318:           Some contain a detailed description of what has changed, but they are
                   8319:           geared towards the other pkgsrc developers, not towards an average
                   8320:           pkgsrc user. They also only document changes, so if you don't know
                   8321:           what has been before, these messages may not be worth too much to
                   8322:           you.
                   8323: 
                   8324:         * Some parts of pkgsrc are only "implicitly documented", that is the
                   8325:           documentation exists only in the mind of the developer who wrote the
                   8326:           code. To get this information, use the cvs annotate command to see
                   8327:           who has written it and ask on the tech-pkg mailing list, so that
                   8328:           others can find your questions later (see above). To be sure that the
                   8329:           developer in charge reads the mail, you may CC him or her.
                   8330: 
1.154     rillig   8331: 24.9. I have a little time to kill. What shall I do?
1.1       dsieger  8332: 
                   8333:       This is not really an FAQ yet, but here's the answer anyway.
                   8334: 
                   8335:         * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
                   8336:           about newer versions of installed packages that are available, but
                   8337:           not yet updated in pkgsrc.
                   8338: 
1.198     leot     8339:         * Browse pkgsrc/doc/TODO -- it contains a list of suggested new
                   8340:           packages and a list of cleanups and enhancements for pkgsrc that
                   8341:           would be nice to have.
1.1       dsieger  8342: 
1.71      wiz      8343:         * Review packages for which review was requested on the tech-pkg
                   8344:           mailing list.
1.1       dsieger  8345: 
                   8346: Part III. The pkgsrc infrastructure internals
                   8347: 
                   8348: This part of the guide deals with everything from the infrastructure that is
                   8349: behind the interfaces described in the developer's guide. A casual package
                   8350: maintainer should not need anything from this part.
                   8351: 
                   8352: Table of Contents
                   8353: 
1.184     rillig   8354: 25. Design of the pkgsrc infrastructure
1.1       dsieger  8355: 
1.184     rillig   8356:     25.1. The meaning of variable definitions
                   8357:     25.2. Avoiding problems before they arise
                   8358:     25.3. Variable evaluation
1.1       dsieger  8359: 
1.184     rillig   8360:         25.3.1. At load time
                   8361:         25.3.2. At runtime
1.1       dsieger  8362: 
1.184     rillig   8363:     25.4. How can variables be specified?
                   8364:     25.5. Designing interfaces for Makefile fragments
1.1       dsieger  8365: 
1.184     rillig   8366:         25.5.1. Procedures with parameters
                   8367:         25.5.2. Actions taken on behalf of parameters
1.1       dsieger  8368: 
1.184     rillig   8369:     25.6. The order in which files are loaded
1.1       dsieger  8370: 
1.184     rillig   8371:         25.6.1. The order in bsd.prefs.mk
                   8372:         25.6.2. The order in bsd.pkg.mk
1.1       dsieger  8373: 
1.184     rillig   8374: 26. Regression tests
1.1       dsieger  8375: 
1.184     rillig   8376:     26.1. Running the regression tests
                   8377:     26.2. Adding a new regression test
1.1       dsieger  8378: 
1.184     rillig   8379:         26.2.1. Overridable functions
                   8380:         26.2.2. Helper functions
1.1       dsieger  8381: 
1.184     rillig   8382: 27. Porting pkgsrc
1.1       dsieger  8383: 
1.184     rillig   8384:     27.1. Porting pkgsrc to a new operating system
1.1       dsieger  8385: 
1.184     rillig   8386: Chapter 25. Design of the pkgsrc infrastructure
1.1       dsieger  8387: 
                   8388: Table of Contents
                   8389: 
1.184     rillig   8390: 25.1. The meaning of variable definitions
                   8391: 25.2. Avoiding problems before they arise
                   8392: 25.3. Variable evaluation
1.1       dsieger  8393: 
1.184     rillig   8394:     25.3.1. At load time
                   8395:     25.3.2. At runtime
1.1       dsieger  8396: 
1.184     rillig   8397: 25.4. How can variables be specified?
                   8398: 25.5. Designing interfaces for Makefile fragments
1.1       dsieger  8399: 
1.184     rillig   8400:     25.5.1. Procedures with parameters
                   8401:     25.5.2. Actions taken on behalf of parameters
1.1       dsieger  8402: 
1.184     rillig   8403: 25.6. The order in which files are loaded
1.1       dsieger  8404: 
1.184     rillig   8405:     25.6.1. The order in bsd.prefs.mk
                   8406:     25.6.2. The order in bsd.pkg.mk
1.1       dsieger  8407: 
                   8408: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
                   8409: fragment needs a properly specified interface. This chapter explains how such
                   8410: an interface looks like.
                   8411: 
1.184     rillig   8412: 25.1. The meaning of variable definitions
1.1       dsieger  8413: 
                   8414: Whenever a variable is defined in the pkgsrc infrastructure, the location and
                   8415: the way of definition provide much information about the intended use of that
                   8416: variable. Additionally, more documentation may be found in a header comment or
                   8417: in this pkgsrc guide.
                   8418: 
                   8419: A special file is mk/defaults/mk.conf, which lists all variables that are
                   8420: intended to be user-defined. They are either defined using the ?= operator or
                   8421: they are left undefined because defining them to anything would effectively
                   8422: mean "yes". All these variables may be overridden by the pkgsrc user in the
                   8423: MAKECONF file.
                   8424: 
                   8425: Outside this file, the following conventions apply: Variables that are defined
                   8426: using the ?= operator may be overridden by a package.
                   8427: 
                   8428: Variables that are defined using the = operator may be used read-only at
                   8429: run-time.
                   8430: 
                   8431: Variables whose name starts with an underscore must not be accessed outside the
                   8432: pkgsrc infrastructure at all. They may change without further notice.
                   8433: 
                   8434: Note
                   8435: 
                   8436: These conventions are currently not applied consistently to the complete pkgsrc
                   8437: infrastructure.
                   8438: 
1.184     rillig   8439: 25.2. Avoiding problems before they arise
1.1       dsieger  8440: 
                   8441: All variables that contain lists of things should default to being empty. Two
                   8442: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
                   8443: variables cannot simply be modified using the += operator in package Makefiles
                   8444: (or other files included by them), since there is no guarantee whether the
                   8445: variable is already set or not, and what its value is. In the case of
                   8446: DISTFILES, the packages "know" the default value and just define it as in the
                   8447: following example.
                   8448: 
                   8449: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   8450: 
                   8451: Because of the selection of this default value, the same value appears in many
                   8452: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
                   8453: value ("c") is so short that it doesn't stand out. Nevertheless it is mentioned
                   8454: in many files.
                   8455: 
1.184     rillig   8456: 25.3. Variable evaluation
1.1       dsieger  8457: 
1.184     rillig   8458: 25.3.1. At load time
1.1       dsieger  8459: 
                   8460: Variable evaluation takes place either at load time or at runtime, depending on
                   8461: the context in which they occur. The contexts where variables are evaluated at
                   8462: load time are:
                   8463: 
                   8464:   * The right hand side of the := and != operators,
                   8465: 
                   8466:   * Make directives like .if or .for,
                   8467: 
                   8468:   * Dependency lines.
                   8469: 
                   8470: A special exception are references to the iteration variables of .for loops,
                   8471: which are expanded inline, no matter in which context they appear.
                   8472: 
                   8473: As the values of variables may change during load time, care must be taken not
                   8474: to evaluate them by accident. Typical examples for variables that should not be
                   8475: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
                   8476: clear, here is an example:
                   8477: 
                   8478: CONFIGURE_ARGS=         # none
                   8479: CFLAGS=                 -O
                   8480: CONFIGURE_ARGS+=        CFLAGS=${CFLAGS:Q}
                   8481: 
                   8482: CONFIGURE_ARGS:=        ${CONFIGURE_ARGS}
                   8483: 
                   8484: CFLAGS+=                -Wall
                   8485: 
                   8486: This code shows how the use of the := operator can quickly lead to unexpected
                   8487: results. The first paragraph is fairly common code. The second paragraph
                   8488: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
                   8489: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
                   8490: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
                   8491: typically occur in completely unrelated files.
                   8492: 
1.184     rillig   8493: 25.3.2. At runtime
1.1       dsieger  8494: 
                   8495: After all the files have been loaded, the values of the variables cannot be
                   8496: changed anymore. Variables that are used in the shell commands are expanded at
                   8497: this point.
                   8498: 
1.184     rillig   8499: 25.4. How can variables be specified?
1.1       dsieger  8500: 
                   8501: There are many ways in which the definition and use of a variable can be
                   8502: restricted in order to detect bugs and violations of the (mostly unwritten)
1.108     rillig   8503: policies. A package can be checked with pkglint -Wall to see whether it meets
                   8504: these rules.
1.1       dsieger  8505: 
1.184     rillig   8506: 25.5. Designing interfaces for Makefile fragments
1.1       dsieger  8507: 
                   8508: Most of the .mk files fall into one of the following classes. Cases where a
                   8509: file falls into more than one class should be avoided as it often leads to
                   8510: subtle bugs.
                   8511: 
1.184     rillig   8512: 25.5.1. Procedures with parameters
1.1       dsieger  8513: 
                   8514: In a traditional imperative programming language some of the .mk files could be
1.198     leot     8515: described as procedures. They take some input parameters and--after
                   8516: inclusion--provide a result in output parameters. Since all variables in
1.23      jakllsch 8517: Makefiles have global scope care must be taken not to use parameter names that
                   8518: have already another meaning. For example, PKGNAME is a bad choice for a
                   8519: parameter name.
1.1       dsieger  8520: 
                   8521: Procedures are completely evaluated at preprocessing time. That is, when
                   8522: calling a procedure all input parameters must be completely resolvable. For
                   8523: example, CONFIGURE_ARGS should never be an input parameter since it is very
                   8524: likely that further text will be added after calling the procedure, which would
                   8525: effectively apply the procedure to only a part of the variable. Also,
1.108     rillig   8526: references to other variables will be modified after calling the procedure.
1.1       dsieger  8527: 
                   8528: A procedure can declare its output parameters either as suitable for use in
                   8529: preprocessing directives or as only available at runtime. The latter
                   8530: alternative is for variables that contain references to other runtime
                   8531: variables.
                   8532: 
                   8533: Procedures shall be written such that it is possible to call the procedure more
                   8534: than once. That is, the file must not contain multiple-inclusion guards.
                   8535: 
                   8536: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
                   8537: To express that the parameters are evaluated at load time, they should be
                   8538: assigned using the := operator, which should be used only for this purpose.
                   8539: 
1.184     rillig   8540: 25.5.2. Actions taken on behalf of parameters
1.1       dsieger  8541: 
                   8542: Action files take some input parameters and may define runtime variables. They
                   8543: shall not define loadtime variables. There are action files that are included
                   8544: implicitly by the pkgsrc infrastructure, while other must be included
                   8545: explicitly.
                   8546: 
                   8547: An example for action files is mk/subst.mk.
                   8548: 
1.184     rillig   8549: 25.6. The order in which files are loaded
1.1       dsieger  8550: 
                   8551: Package Makefiles usually consist of a set of variable definitions, and include
                   8552: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
                   8553: include various other *.mk files if they need to query the availability of
                   8554: certain features like the type of compiler or the X11 implementation. Due to
                   8555: the heavy use of preprocessor directives like .if and .for, the order in which
                   8556: the files are loaded matters.
                   8557: 
                   8558: This section describes at which point the various files are loaded and gives
                   8559: reasons for that order.
                   8560: 
1.184     rillig   8561: 25.6.1. The order in bsd.prefs.mk
1.1       dsieger  8562: 
                   8563: The very first action in bsd.prefs.mk is to define some essential variables
                   8564: like OPSYS, OS_VERSION and MACHINE_ARCH.
                   8565: 
1.4       rillig   8566: Then, the user settings are loaded from the file specified in MAKECONF, which
                   8567: is usually mk.conf. After that, those variables that have not been overridden
                   8568: by the user are loaded from mk/defaults/mk.conf.
1.1       dsieger  8569: 
                   8570: After the user settings, the system settings and platform settings are loaded,
                   8571: which may override the user settings.
                   8572: 
                   8573: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
                   8574: This only happens when building a package, so the proper variables must be used
                   8575: instead of the direct tool names.
                   8576: 
                   8577: As the last steps, some essential variables from the wrapper and the package
                   8578: system flavor are loaded, as well as the variables that have been cached in
                   8579: earlier phases of a package build.
                   8580: 
1.184     rillig   8581: 25.6.2. The order in bsd.pkg.mk
1.1       dsieger  8582: 
                   8583: First, bsd.prefs.mk is loaded.
                   8584: 
                   8585: Then, the various *-vars.mk files are loaded, which fill default values for
                   8586: those variables that have not been defined by the package. These variables may
                   8587: later be used even in unrelated files.
                   8588: 
                   8589: Then, the file bsd.pkg.error.mk provides the target error-check that is added
                   8590: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
                   8591: DELAYED_WARNING_MSG.
                   8592: 
                   8593: Then, the package-specific hacks from hacks.mk are included.
                   8594: 
                   8595: Then, various other files follow. Most of them don't have any dependencies on
                   8596: what they need to have included before or after them, though some do.
                   8597: 
                   8598: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
                   8599: restricts the use of these variables to all the files that have been included
                   8600: before. Appearances in later files will be silently ignored.
                   8601: 
                   8602: Then, the files for the main targets are included, in the order of later
                   8603: execution, though the actual order should not matter.
                   8604: 
                   8605: At last, some more files are included that don't set any interesting variables
                   8606: but rather just define make targets to be executed.
                   8607: 
1.184     rillig   8608: Chapter 26. Regression tests
1.1       dsieger  8609: 
                   8610: Table of Contents
                   8611: 
1.184     rillig   8612: 26.1. Running the regression tests
                   8613: 26.2. Adding a new regression test
1.1       dsieger  8614: 
1.184     rillig   8615:     26.2.1. Overridable functions
                   8616:     26.2.2. Helper functions
1.1       dsieger  8617: 
                   8618: The pkgsrc infrastructure consists of a large codebase, and there are many
                   8619: corners where every little bit of a file is well thought out, making pkgsrc
                   8620: likely to fail as soon as anything is changed near those parts. To prevent most
                   8621: changes from breaking anything, a suite of regression tests should go along
                   8622: with every important part of the pkgsrc infrastructure. This chapter describes
                   8623: how regression tests work in pkgsrc and how you can add new tests.
                   8624: 
1.184     rillig   8625: 26.1. Running the regression tests
1.1       dsieger  8626: 
1.25      wiz      8627: You first need to install the pkgtools/pkg_regress package, which provides the 
1.1       dsieger  8628: pkg_regress command. Then you can simply run that command, which will run all
1.168     rillig   8629: tests in the regress/ directory.
1.1       dsieger  8630: 
1.184     rillig   8631: 26.2. Adding a new regression test
1.1       dsieger  8632: 
1.168     rillig   8633: Every directory in the regress/ directory that contains a file called spec is
1.1       dsieger  8634: considered a regression test. This file is a shell program that is included by
                   8635: the pkg_regress command. The following functions can be overridden to suit your
                   8636: needs.
                   8637: 
1.184     rillig   8638: 26.2.1. Overridable functions
1.1       dsieger  8639: 
1.108     rillig   8640: These functions do not take any parameters. Although they are called in "set -e
1.168     rillig   8641: " mode, they don't stop at the first failing command. See this Stack Overflow
1.108     rillig   8642: question for details.
1.1       dsieger  8643: 
1.108     rillig   8644: do_setup
1.1       dsieger  8645: 
                   8646:     This function prepares the environment for the test. By default it does
                   8647:     nothing.
                   8648: 
1.108     rillig   8649: do_test
1.1       dsieger  8650: 
                   8651:     This function runs the actual test. By default, it calls TEST_MAKE with the
                   8652:     arguments MAKEARGS_TEST and writes its output including error messages into
                   8653:     the file TEST_OUTFILE.
                   8654: 
1.108     rillig   8655:     When defining this function, make sure that all output that needs to be
                   8656:     checked is written to the correct output file. Example:
                   8657: 
                   8658:     do_test() {
                   8659:             echo "Example output"
                   8660:     } 1>$TEST_OUTFILE 2>&1
                   8661: 
                   8662: check_result
1.1       dsieger  8663: 
                   8664:     This function is run after the test and is typically used to compare the
                   8665:     actual output from the one that is expected. It can make use of the various
1.108     rillig   8666:     helper functions from the next section. Example:
                   8667: 
                   8668:     check_result() {
                   8669:             exit_status 0
                   8670:             output_require "Example"
                   8671:             output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
                   8672:             output_prohibit "no such file or directory"
1.169     rillig   8673:             regress_fail "expected $expected but got $actual for input $input"
1.108     rillig   8674:     }
1.1       dsieger  8675: 
1.108     rillig   8676: do_cleanup
1.1       dsieger  8677: 
                   8678:     This function cleans everything up after the test has been run. By default
                   8679:     it does nothing.
                   8680: 
1.184     rillig   8681: 26.2.2. Helper functions
1.1       dsieger  8682: 
1.168     rillig   8683: regress_fail message...
                   8684: 
                   8685:     This function makes the test fail with the given error message.
                   8686: 
1.108     rillig   8687: exit_status expected
1.1       dsieger  8688: 
1.108     rillig   8689:     This function compares the exitcode of the do_test function with its first
                   8690:     parameter. If they differ, the test will fail.
1.1       dsieger  8691: 
1.108     rillig   8692: output_require regex...
1.1       dsieger  8693: 
                   8694:     This function checks for each of its parameters if the output from do_test
1.108     rillig   8695:     matches the extended regular expression. If it does not, the test will
                   8696:     fail. Example:
                   8697: 
                   8698:     output_require "looks fine"
                   8699:     output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
1.1       dsieger  8700: 
1.177     leot     8701: output_prohibit regex...
1.1       dsieger  8702: 
                   8703:     This function checks for each of its parameters if the output from do_test
                   8704:     () does not match the extended regular expression. If any of the regular
                   8705:     expressions matches, the test will fail.
                   8706: 
1.184     rillig   8707: Chapter 27. Porting pkgsrc
1.1       dsieger  8708: 
                   8709: Table of Contents
                   8710: 
1.184     rillig   8711: 27.1. Porting pkgsrc to a new operating system
1.1       dsieger  8712: 
                   8713: The pkgsrc system has already been ported to many operating systems, hardware
                   8714: architectures and compilers. This chapter explains the necessary steps to make
                   8715: pkgsrc even more portable.
                   8716: 
1.184     rillig   8717: 27.1. Porting pkgsrc to a new operating system
1.1       dsieger  8718: 
                   8719: To port pkgsrc to a new operating system (called MyOS in this example), you
                   8720: need to touch the following files:
                   8721: 
                   8722: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
                   8723: 
                   8724:     This file contains some basic definitions, for example the name of the C
                   8725:     compiler.
                   8726: 
                   8727: mk/bsd.prefs.mk
                   8728: 
                   8729:     Insert code that defines the variables OPSYS, OS_VERSION, LOWER_OS_VERSION,
                   8730:     LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
                   8731:     that appear in this file.
                   8732: 
                   8733: mk/platform/MyOS.mk
                   8734: 
                   8735:     This file contains the platform-specific definitions that are used by
                   8736:     pkgsrc. Start by copying one of the other files and edit it to your needs.
                   8737: 
                   8738: mk/tools/tools.MyOS.mk
                   8739: 
                   8740:     This file defines the paths to all the tools that are needed by one or the
                   8741:     other package in pkgsrc, as well as by pkgsrc itself. Find out where these
                   8742:     tools are on your platform and add them.
                   8743: 
                   8744: Now, you should be able to build some basic packages, like lang/perl5, shells/
                   8745: bash.
                   8746: 
                   8747: Appendix A. A simple example package: bison
                   8748: 
                   8749: Table of Contents
                   8750: 
                   8751: A.1. files
                   8752: 
                   8753:     A.1.1. Makefile
                   8754:     A.1.2. DESCR
                   8755:     A.1.3. PLIST
                   8756:     A.1.4. Checking a package with pkglint
                   8757: 
                   8758: A.2. Steps for building, installing, packaging
                   8759: 
                   8760: We checked to find a piece of software that wasn't in the packages collection,
1.25      wiz      8761: and picked GNU bison. Quite why someone would want to have bison when Berkeley 
1.1       dsieger  8762: yacc is already present in the tree is beyond us, but it's useful for the
                   8763: purposes of this exercise.
                   8764: 
                   8765: A.1. files
                   8766: 
                   8767: A.1.1. Makefile
                   8768: 
1.2       rillig   8769: # $NetBSD$
1.1       dsieger  8770: #
                   8771: 
                   8772: DISTNAME=       bison-1.25
                   8773: CATEGORIES=     devel
1.171     rillig   8774: MASTER_SITES=   ${MASTER_SITE_GNU:=bison/}
1.1       dsieger  8775: 
1.30      dholland 8776: MAINTAINER=     pkgsrc-users@NetBSD.org
1.174     leot     8777: HOMEPAGE=       https://www.gnu.org/software/bison/bison.html
1.1       dsieger  8778: COMMENT=        GNU yacc clone
                   8779: 
                   8780: GNU_CONFIGURE=  yes
1.47      wiz      8781: INFO_FILES=     yes
1.1       dsieger  8782: 
                   8783: .include "../../mk/bsd.pkg.mk"
                   8784: 
                   8785: A.1.2. DESCR
                   8786: 
                   8787: GNU version of yacc.  Can make re-entrant parsers, and numerous other
                   8788: improvements.  Why you would want this when Berkeley yacc(1) is part
                   8789: of the NetBSD source tree is beyond me.
                   8790: 
                   8791: A.1.3. PLIST
                   8792: 
1.2       rillig   8793: @comment $NetBSD$
1.1       dsieger  8794: bin/bison
                   8795: man/man1/bison.1.gz
                   8796: share/bison.simple
                   8797: share/bison.hairy
                   8798: 
                   8799: A.1.4. Checking a package with pkglint
                   8800: 
                   8801: The NetBSD package system comes with pkgtools/pkglint which helps to check the
                   8802: contents of these files. After installation it is quite easy to use, just
1.171     rillig   8803: change to the directory of the package you wish to examine and run pkglint:
1.1       dsieger  8804: 
                   8805: $ pkglint
1.171     rillig   8806: ERROR: Makefile: Each package must define its LICENSE.
                   8807: WARN: Makefile:9: HOMEPAGE should migrate from http to https.
                   8808: NOTE: PLIST:3: The .gz extension is unnecessary for manual pages.
                   8809: WARN: PLIST:5: "share/bison.hairy" should be sorted before "share/bison.simple".
                   8810: 1 error, 2 warnings and 1 note found.
                   8811: (Run "pkglint -e" to show explanations.)
                   8812: (Run "pkglint -fs" to show what can be fixed automatically.)
1.172     rillig   8813: (Run "pkglint -F" to automatically fix some issues.)
1.1       dsieger  8814: 
                   8815: Depending on the supplied command line arguments (see pkglint(1)), more checks
1.170     rillig   8816: will be performed. Use e.g. pkglint -Wall for a very thorough check.
1.1       dsieger  8817: 
                   8818: A.2. Steps for building, installing, packaging
                   8819: 
                   8820: Create the directory where the package lives, plus any auxiliary directories:
                   8821: 
                   8822: # cd /usr/pkgsrc/lang
                   8823: # mkdir bison
                   8824: # cd bison
                   8825: # mkdir patches
                   8826: 
1.184     rillig   8827: Create Makefile, DESCR and PLIST (see Chapter 12, Package components - files,
1.1       dsieger  8828: directories and contents) then continue with fetching the distfile:
                   8829: 
                   8830: # make fetch
                   8831: >> bison-1.25.tar.gz doesn't seem to exist on this system.
                   8832: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
                   8833: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8834: ftp: Error retrieving file: 500 Internal error
                   8835: 
                   8836: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
                   8837: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8838: ftp: Error retrieving file: 500 Internal error
                   8839: 
                   8840: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
                   8841: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8842: Successfully retrieved file.
                   8843: 
                   8844: Generate the checksum of the distfile into distinfo:
                   8845: 
                   8846: # make makedistinfo
                   8847: 
                   8848: Now compile:
                   8849: 
                   8850: # make
                   8851: >> Checksum OK for bison-1.25.tar.gz.
                   8852: ===>  Extracting for bison-1.25
                   8853: ===>  Patching for bison-1.25
                   8854: ===>   Ignoring empty patch directory
                   8855: ===>  Configuring for bison-1.25
                   8856: creating cache ./config.cache
                   8857: checking for gcc... cc
                   8858: checking whether we are using GNU C... yes
                   8859: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
                   8860: checking how to run the C preprocessor... cc -E
                   8861: checking for minix/config.h... no
                   8862: checking for POSIXized ISC... no
                   8863: checking whether cross-compiling... no
                   8864: checking for ANSI C header files... yes
                   8865: checking for string.h... yes
                   8866: checking for stdlib.h... yes
                   8867: checking for memory.h... yes
                   8868: checking for working const... yes
                   8869: checking for working alloca.h... no
                   8870: checking for alloca... yes
                   8871: checking for strerror... yes
                   8872: updating cache ./config.cache
                   8873: creating ./config.status
                   8874: creating Makefile
                   8875: ===>  Building for bison-1.25
                   8876: 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
                   8877: 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
                   8878: 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
                   8879: 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
                   8880: 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
                   8881: 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
                   8882: 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
                   8883: 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
                   8884: 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
                   8885: 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
                   8886: 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
                   8887: 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
                   8888: 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
                   8889: 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
                   8890: 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
                   8891: 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
                   8892: 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
                   8893: 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
                   8894: 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
                   8895: 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
                   8896: 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
                   8897: 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
                   8898: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
                   8899: rm -f bison.s1
                   8900: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
                   8901: 
                   8902: Everything seems OK, so install the files:
                   8903: 
                   8904: # make install
                   8905: >> Checksum OK for bison-1.25.tar.gz.
                   8906: ===>  Installing for bison-1.25
                   8907: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
                   8908: rm -f /usr/pkg/bin/bison
                   8909: cd /usr/pkg/share; rm -f bison.simple bison.hairy
                   8910: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
                   8911: install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
                   8912: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
                   8913: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
                   8914: cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
                   8915: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
                   8916: ===>  Registering installation for bison-1.25
                   8917: 
                   8918: You can now use bison, and also - if you decide so - remove it with pkg_delete
                   8919: bison. Should you decide that you want a binary package, do this now:
                   8920: 
                   8921: # make package
                   8922: >> Checksum OK for bison-1.25.tar.gz.
                   8923: ===>  Building package for bison-1.25
                   8924: Creating package bison-1.25.tgz
                   8925: Registering depends:.
                   8926: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
                   8927: 
                   8928: Now that you don't need the source and object files any more, clean up:
                   8929: 
                   8930: # make clean
                   8931: ===>  Cleaning for bison-1.25
                   8932: 
1.207     leot     8933: Appendix B. Security hardening
                   8934: 
                   8935: Table of Contents
                   8936: 
                   8937: B.1. Mechanisms
                   8938: 
                   8939:     B.1.1. Enabled by default
                   8940:     B.1.2. Not enabled by default
                   8941: 
                   8942: B.2. Caveats
                   8943: 
                   8944:     B.2.1. Problems with PKGSRC_MKPIE
                   8945:     B.2.2. Problems with PKGSRC_USE_FORTIFY
                   8946:     B.2.3. Problems with PKGSRC_USE_RELRO
                   8947:     B.2.4. Problems with PKGSRC_USE_SSP
                   8948: 
                   8949: B.3. Auditing the system
                   8950: 
                   8951:     B.3.1. Checking for PIE
                   8952:     B.3.2. Checking for partial RELRO
                   8953:     B.3.3. Checking for full RELRO
                   8954:     B.3.4. Checking for SSP
                   8955: 
                   8956: A number of mechanisms are available in pkgsrc to improve the security of the
                   8957: resulting system. This page describes the mechanisms, and gives hints about
                   8958: detecting and fixing problems.
                   8959: 
                   8960: Mechanisms can be enabled individually in mk.conf, and are individually
                   8961: described below.
                   8962: 
                   8963: Typically, a feature will cause some programs to fail to build or work when
                   8964: first enabled. This can be due to latent problems in the program, and can be
                   8965: due to other reasons. After enough testing to have confidence that user
                   8966: problems will be quite rare, individual mechanisms will be enabled by default.
                   8967: 
                   8968: For each mechanism, see the Caveats section below for an explanation of what
                   8969: might go wrong at compile time and at run time, and how to notice and address
                   8970: these problems.
                   8971: 
                   8972: B.1. Mechanisms
                   8973: 
                   8974: B.1.1. Enabled by default
                   8975: 
                   8976: B.1.1.1. PKGSRC_USE_FORTIFY
                   8977: 
                   8978: This allows substitute wrappers to be used for some commonly used library
                   8979: functions that do not have built-in bounds checking - but could in some cases.
                   8980: 
                   8981: Two mitigation levels are available:
                   8982: 
                   8983:   * "weak" only enables checks at compile-time.
                   8984: 
                   8985:   * "strong" enables checks at compile-time and runtime.
                   8986: 
                   8987: "strong" has been enabled by default since pkgsrc-2017Q3.
                   8988: 
                   8989: B.1.1.2. PKGSRC_USE_SSP
                   8990: 
                   8991: This enables a stack-smashing protection mitigation. It is done by adding a
                   8992: guard variable to functions with vulnerable objects. The guards are initialized
                   8993: when a function is entered and then checked when the function exits. The guard
                   8994: check will fail and the program forcibly exited if the variable was modified in
                   8995: the meantime. This can happen in case of buffer overflows or memory corruption,
                   8996: and therefore exposing these bugs.
                   8997: 
                   8998: Different mitigation levels are available:
                   8999: 
                   9000:   * "yes", which will only protect functions considered vulnerable by the
                   9001:     compiler;
                   9002: 
                   9003:   * "all", which will protect every function;
                   9004: 
                   9005:   * "strong", the default, which will apply a better balance between the two
                   9006:     settings above.
                   9007: 
                   9008: This mitigation is supported by both GCC and clang. It may be supported in
                   9009: additional compilers, possibly under a different name. It is particularly
                   9010: useful for unsafe programming languages, such as C/C++.
                   9011: 
                   9012:   * "yes" is enabled by default where known supported since pkgsrc-2017Q3.
                   9013: 
                   9014:   * "strong" is enabled by default where known supported since pkgsrc-2021Q4.
                   9015: 
                   9016: More details can be found here:
                   9017: 
                   9018:   * Buffer overflow protection on Wikipedia
                   9019: 
                   9020: B.1.1.3. PKGSRC_MKPIE
                   9021: 
                   9022: This requests the creation of PIE (Position Independent Executables) for all
                   9023: executables. The PIE mechanism is normally used for shared libraries, so that
                   9024: they can be loaded at differing addresses at runtime. PIE itself does not have
                   9025: useful security properties; however, it is necessary to fully leverage some,
                   9026: such as ASLR. Some operating systems support Address Space Layout Randomization
                   9027: (ASLR), which causes different addresses to be used each time a program is run.
                   9028: This makes it more difficult for an attacker to guess addresses and thus makes
                   9029: exploits harder to construct. With PIE, ASLR can really be applied to the
                   9030: entire program, instead of the stack and heap only.
                   9031: 
                   9032: PIE executables will only be built for toolchains that are known to support
                   9033: PIE. Currently, this means NetBSD on x86, ARM, SPARC64, m68k, and MIPS.
                   9034: 
                   9035: PKGSRC_MKPIE was enabled by default after the pkgsrc-2021Q3 branch.
                   9036: 
1.210     gutterid 9037: B.1.2. Not enabled by default
                   9038: 
                   9039: B.1.2.1. PKGSRC_MKREPRO
                   9040: 
                   9041: With this option, pkgsrc will try to build packages reproducibly. This allows
                   9042: packages built from the same tree and with the same options, to produce
                   9043: identical results bit by bit. This option should be combined with ASLR and
                   9044: PKGSRC_MKPIE to avoid predictable address offsets for attackers attempting to
                   9045: exploit security vulnerabilities.
                   9046: 
                   9047: More details can be found here:
                   9048: 
                   9049:   * Reproducible Builds - a set of software development practices that create
                   9050:     an independently-verifiable path from source to binary code
                   9051: 
                   9052: More work likely needs to be done before pkgsrc is fully reproducible.
                   9053: 
                   9054: B.1.2.2. PKGSRC_USE_RELRO
1.207     leot     9055: 
                   9056: This also makes the exploitation of some security vulnerabilities more
                   9057: difficult in some cases.
                   9058: 
                   9059: Two different mitigation levels are available:
                   9060: 
                   9061:   * partial: the ELF sections are reordered so that internal data sections
                   9062:     precede the program's own data sections, and non-PLT GOT is read-only;
                   9063: 
                   9064:   * full: in addition to partial RELRO, every relocation is performed
                   9065:     immediately when starting the program (with a slight performance impact),
                   9066:     allowing the entire GOT to be read-only.
                   9067: 
                   9068: This is currently supported by GCC. Many software distributions now enable this
1.210     gutterid 9069: feature by default, at the "partial" level. However, it cannot yet be enforced
                   9070: globally in pkgsrc through cwrappers.
1.207     leot     9071: 
                   9072: More details can be found here:
                   9073: 
                   9074:   * Hardening ELF binaries using Relocation Read-Only (RELRO)
                   9075: 
1.210     gutterid 9076: B.1.2.3. PKGSRC_USE_STACK_CHECK
1.207     leot     9077: 
                   9078: This uses -fstack-check with GCC for another stack protection mitigation.
                   9079: 
                   9080: It asks the compiler to generate code verifying that it does not corrupt the
                   9081: stack. According to GCC's manual page, this is really only useful for
                   9082: multi-threaded programs.
                   9083: 
                   9084: B.2. Caveats
                   9085: 
                   9086: B.2.1. Problems with PKGSRC_MKPIE
                   9087: 
                   9088: B.2.1.1. Packages failing to build
                   9089: 
                   9090: A number of packages may fail to build with this option enabled. The failures
                   9091: are often related to the absence of the -fPIC compilation flag when building
                   9092: libraries or executables (or ideally -fPIE in the latter case). This flag is
                   9093: added to the CFLAGS already, but requires the package to actually support it.
                   9094: 
                   9095: B.2.1.1.1. How to fix
                   9096: 
                   9097: These instructions are meant as a reference only; they likely need to be
                   9098: adapted for many packages individually.
                   9099: 
                   9100: For packages using Makefiles:
                   9101: 
                   9102: MAKE_FLAGS+=    CFLAGS=${CFLAGS:Q}
                   9103: MAKE_FLAGS+=    LDFLAGS=${LDFLAGS:Q}
                   9104: 
                   9105: For packages using Imakefiles:
                   9106: 
                   9107: MAKE_FLAGS+=    CCOPTIONS=${CFLAGS:Q}
                   9108: MAKE_FLAGS+=    LOCAL_LDFLAGS=${LDFLAGS:Q}
                   9109: 
                   9110: B.2.1.2. Run-time crashes
                   9111: 
                   9112: Some programs may fail to run, or crash at random times once built as PIE. Two
                   9113: scenarios are essentially possible. This is nearly always due to a bug in the
                   9114: program being exposed due to ASLR.
                   9115: 
                   9116: B.2.1.3. Disabling PKGSRC_MKPIE on a per-package basis
                   9117: 
                   9118: Ideally, packages should be fixed for compatibility with MKPIE. However, in
                   9119: some cases this is very difficult, due to complex build systems, packages using
                   9120: non-standard toolchains, or programming languages with odd bootstrapping
                   9121: mechanisms.
                   9122: 
                   9123: To disable PKGSRC_MKPIE on a per-package basis, set MKPIE_SUPPORTED= no in the
                   9124: package's Makefile before bsd.prefs.mk is included.
                   9125: 
                   9126: B.2.2. Problems with PKGSRC_USE_FORTIFY
                   9127: 
                   9128: B.2.2.1. Packages failing to build
                   9129: 
                   9130: This feature makes use of pre-processing directives to look for hardened,
                   9131: alternative implementations of essential library calls. Some programs may fail
                   9132: to build as a result; this usually happens for those trying too hard to be
                   9133: portable, or otherwise abusing definitions in the standard library.
                   9134: 
                   9135: B.2.2.2. Run-time crashes
                   9136: 
                   9137: This feature may cause some programs to crash, usually indicating an actual bug
                   9138: in the program. The fix will typically involve patching the original program's
                   9139: source code.
                   9140: 
                   9141: B.2.2.3. Optimization is required
                   9142: 
                   9143: At least in the case of GCC, FORTIFY will only be applied if optimization is
                   9144: applied while compiling. This means that the CFLAGS should also contain -O, -O2
                   9145: or another optimization level. This cannot easily be applied globally, as some
                   9146: packages may require specific optimization levels.
                   9147: 
                   9148: B.2.2.4. Disabling FORTIFY on a per-package basis
                   9149: 
                   9150: Note
                   9151: 
                   9152: FORTIFY should not be disabled to work around runtime crashes in the program!
                   9153: This is a very bad idea and will expose you to security vulnerabilities.
                   9154: 
                   9155: To disable FORTIFY on a per-package basis, set the following in the package's
                   9156: Makefile before bsd.prefs.mk is included:
                   9157: 
                   9158: FORTIFY_SUPPORTED=      no
                   9159: 
                   9160: B.2.3. Problems with PKGSRC_USE_RELRO
                   9161: 
                   9162: B.2.3.1. Performance impact
                   9163: 
                   9164: For better protection, full RELRO requires every symbol to be resolved when the
                   9165: program starts, rather than simply when required at run-time. This will have
                   9166: more impact on programs using a lot of symbols, or linked to libraries exposing
                   9167: a lot of symbols. Therefore, daemons or programs otherwise running in
                   9168: background are affected only when started. Programs loading plug-ins at
                   9169: run-time are affected when loading the plug-ins.
                   9170: 
                   9171: The impact is not expected to be noticeable on modern hardware, except in some
                   9172: cases for big programs.
                   9173: 
                   9174: B.2.3.2. Run-time crashes
                   9175: 
                   9176: Some programs handle plug-ins and dependencies in a way that conflicts with
                   9177: RELRO: for instance, with an initialization routine listing any other plug-in
                   9178: required. With full RELRO, the missing symbols are resolved before the
                   9179: initialization routine can run, and the dynamic loader will not be able to find
                   9180: them directly and abort as a result. Unfortunately, this is how Xorg loads its
                   9181: drivers. Partial RELRO can be applied instead in this case.
                   9182: 
                   9183: B.2.3.3. Disabling RELRO on a per-package basis
                   9184: 
                   9185: To disable RELRO on a per-package basis, set the following in the package's
                   9186: Makefile before bsd.prefs.mk is included:
                   9187: 
                   9188: RELRO_SUPPORTED=        no
                   9189: 
1.209     nia      9190: It is also possible to at most enable partial RELRO, by setting RELRO_SUPPORTED
                   9191: to partial.
                   9192: 
1.207     leot     9193: B.2.4. Problems with PKGSRC_USE_SSP
                   9194: 
                   9195: B.2.4.1. Packages failing to build
                   9196: 
                   9197: The stack-smashing protection provided by this option does not work for some
                   9198: programs. The most common situation in which this happens is when the program
                   9199: allocates variables on the stack, with the size determined at run-time.
                   9200: 
                   9201: B.2.4.2. Run-time crashes
                   9202: 
                   9203: Again, this feature may cause some programs to crash via a SIGABRT, usually
                   9204: indicating an actual bug in the program.
                   9205: 
                   9206: On NetBSD LOG_CRIT level syslog messages are sent and - by default - appended
                   9207: to /var/log/messages, e.g.:
                   9208: 
                   9209: Jan  6 15:42:51 hostname -: hostname program - - - buffer overflow detected; terminated
                   9210: 
                   9211: (where hostname is the hostname(1) and program is the basename(1) of the
                   9212: program crashed).
                   9213: 
                   9214: Patching the original program is then required.
                   9215: 
                   9216: Rebuilding the package via:
                   9217: 
                   9218: % env CFLAGS=-g INSTALL_UNSTRIPPED=yes make replace
                   9219: 
                   9220: and inspecting the backtrace of the coredump via the debugger should point out
                   9221: the problematic call by inspecting the frame calling the _chk() (SSP) function.
                   9222: 
                   9223: B.2.4.3. Performance impact
                   9224: 
                   9225: The compiler emits extra code when using this feature: a check for buffer
                   9226: overflows is performed when entering and exiting functions, requiring an extra
                   9227: variable on the stack. The level of protection can otherwise be adjusted to
                   9228: affect only those functions considered more sensitive by the compiler (with
                   9229: -fstack-protector instead of -fstack-protector-all).
                   9230: 
                   9231: The impact is not expected to be noticeable on modern hardware. However,
                   9232: programs with a hard requirement to run at the fastest possible speed should
                   9233: avoid using this feature, or using libraries built with this feature.
                   9234: 
                   9235: B.2.4.4. Disabling SSP on a per-package basis
                   9236: 
                   9237: Note
                   9238: 
                   9239: SSP should not be disabled to work around runtime crashes in the program! This
                   9240: is a very bad idea and will expose you to security vulnerabilities.
                   9241: 
                   9242: To disable SSP on a per-package basis, set the following in the package's
                   9243: Makefile before bsd.prefs.mk is included:
                   9244: 
                   9245: SSP_SUPPORTED=  no
                   9246: 
                   9247: B.3. Auditing the system
                   9248: 
                   9249: The illusion of security is worse than having no security at all. This section
                   9250: lists a number of ways to ensure the security features requested are actually
                   9251: effective.
                   9252: 
                   9253: These instructions were obtained and tested on a system derived from NetBSD 7
                   9254: (amd64). YMMV.
                   9255: 
                   9256: B.3.1. Checking for PIE
                   9257: 
                   9258: The ELF executable type in use changes for binaries built as PIE; without:
                   9259: 
                   9260: $ file /path/to/bin/ary
                   9261: /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
                   9262: 
                   9263: as opposed to the following binary, built as PIE:
                   9264: 
                   9265: $ file /path/to/pie/bin/ary
                   9266: /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
                   9267: 
                   9268: The latter result is then what is expected.
                   9269: 
                   9270: B.3.2. Checking for partial RELRO
                   9271: 
                   9272: The following command should list a section called RELRO:
                   9273: 
                   9274: $ objdump -p /path/to/bin/ary
                   9275: 
                   9276: /path/to/bin/ary:     file format elf64-x86-64
                   9277: 
                   9278: Program Header:
                   9279: [...]
                   9280:    RELRO off    0x0000000000000d78 vaddr 0x0000000000600d78 paddr 0x0000000000600d78 align 2**0
                   9281: 
                   9282: This check is now performed automatically if PKG_DEVELOPER is set and RELRO is
                   9283: enabled.
                   9284: 
                   9285: B.3.3. Checking for full RELRO
                   9286: 
                   9287: The dynamic loader will apply RELRO immediately when detecting the presence of
                   9288: the BIND_NOW flag:
                   9289: 
                   9290: $ objdump -x /path/to/bin/ary
                   9291: 
                   9292: /path/to/bin/ary:     file format elf64-x86-64
                   9293: 
                   9294: Dynamic Section:
                   9295: [...]
                   9296:   BIND_NOW             0x0000000000000000
                   9297: 
                   9298: This has to be combined with partial RELRO (see above) to be fully efficient.
                   9299: 
                   9300: This check is now performed automatically (where supported) if PKG_DEVELOPER is
                   9301: set.
                   9302: 
                   9303: B.3.4. Checking for SSP
                   9304: 
1.208     nia      9305: Note
                   9306: 
                   9307: Checking for SSP using this method only works where the operating system uses
                   9308: libssp. libssp is not used on recent NetBSD/FreeBSD/Linux versions.
                   9309: 
1.207     leot     9310: Building objects, binaries and libraries with SSP will affect the presence of
                   9311: additional symbols in the resulting file:
                   9312: 
                   9313: $ nm /path/to/bin/ary
                   9314: [...]
                   9315:                  U __stack_chk_fail
                   9316: 0000000000600ea0 B __stack_chk_guard
                   9317: 
                   9318: This is an indicator that the program was indeed built with support for SSP.
                   9319: 
                   9320: This check is now performed automatically (where supported) if PKG_DEVELOPER is
                   9321: set and SSP is enabled.
                   9322: 
                   9323: Appendix C. Build logs
1.1       dsieger  9324: 
                   9325: Table of Contents
                   9326: 
1.207     leot     9327: C.1. Building figlet
                   9328: C.2. Packaging figlet
1.1       dsieger  9329: 
1.207     leot     9330: C.1. Building figlet
1.1       dsieger  9331: 
                   9332: # make
                   9333: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   9334: => figlet221.tar.gz doesn't seem to exist on this system.
                   9335: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
                   9336: => [172219 bytes]
                   9337: Connected to ftp.plig.net.
                   9338: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
                   9339: 331 Guest login ok, send your complete e-mail address as password.
                   9340: 230-You are user #5 of 500 simultaneous users allowed.
                   9341: 230-
                   9342: 230-  ___ _             _ _
                   9343: 230- |  _| |_ ___   ___| |_|___   ___ ___ ___
                   9344: 230- |  _|  _| . |_| . | | | . |_| . |  _| . |
                   9345: 230- |_| |_| |  _|_|  _|_|_|_  |_|___|_| |_  |
                   9346: 230-         |_|   |_|     |___|         |___|
                   9347: 230-
                   9348: 230-** Welcome to ftp.plig.org **
                   9349: 230-
                   9350: 230-Please note that all transfers from this FTP site are logged. If you
                   9351: 230-do not like this, please disconnect now.
                   9352: 230-
1.19      snj      9353: 230-This archive is available via
1.1       dsieger  9354: 230-
                   9355: 230-HTTP:  http://ftp.plig.org/
                   9356: 230-FTP:   ftp://ftp.plig.org/     (max 500 connections)
                   9357: 230-RSYNC: rsync://ftp.plig.org/   (max  30 connections)
                   9358: 230-
                   9359: 230-Please email comments, bug reports and requests for packages to be
                   9360: 230-mirrored to ftp-admin@plig.org.
                   9361: 230-
                   9362: 230-
                   9363: 230 Logged in anonymously.
                   9364: Remote system type is UNIX.
                   9365: Using binary mode to transfer files.
                   9366: 200 Type okay.
                   9367: 250 "/pub" is new cwd.
                   9368: 250-"/pub/figlet" is new cwd.
                   9369: 250-
                   9370: 250-Welcome to the figlet archive at ftp.figlet.org
                   9371: 250-
                   9372: 250-    ftp://ftp.figlet.org/pub/figlet/
                   9373: 250-
                   9374: 250-The official FIGlet web page is:
                   9375: 250-    http://www.figlet.org/
                   9376: 250-
                   9377: 250-If you have questions, please mailto:info@figlet.org. If you want to
                   9378: 250-contribute a font or something else, you can email us.
                   9379: 250
                   9380: 250 "/pub/figlet/program" is new cwd.
                   9381: 250 "/pub/figlet/program/unix" is new cwd.
                   9382: local: figlet221.tar.gz remote: figlet221.tar.gz
                   9383: 502 Unimplemented command.
                   9384: 227 Entering Passive Mode (195,40,6,41,246,104)
                   9385: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
                   9386: 38% |**************                       | 65800      64.16 KB/s    00:01 ETA
                   9387: 226 Transfer completed.
                   9388: 172219 bytes received in 00:02 (75.99 KB/s)
                   9389: 221 Goodbye.
                   9390: => Checksum OK for figlet221.tar.gz.
                   9391: ===> Extracting for figlet-2.2.1nb2
                   9392: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
                   9393: ===> Patching for figlet-2.2.1nb2
                   9394: ===> Applying pkgsrc patches for figlet-2.2.1nb2
                   9395: ===> Overriding tools for figlet-2.2.1nb2
                   9396: ===> Creating toolchain wrappers for figlet-2.2.1nb2
                   9397: ===> Configuring for figlet-2.2.1nb2
                   9398: ===> Building for figlet-2.2.1nb2
                   9399: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\"  -DDEFAULTFONTFILE=\"standard.flf\"  figlet.c zipio.c crc.c inflate.c -o figlet
                   9400: chmod a+x figlet
                   9401: gcc -O2 -o chkfont chkfont.c
                   9402: => Unwrapping files-to-be-installed.
                   9403: #
                   9404: # make install
                   9405: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   9406: ===> Installing for figlet-2.2.1nb2
                   9407: install -d -o root -g wheel -m 755 /usr/pkg/bin
                   9408: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
                   9409: mkdir -p /usr/pkg/share/figlet
                   9410: cp figlet /usr/pkg/bin
                   9411: cp chkfont /usr/pkg/bin
                   9412: chmod 555 figlist showfigfonts
                   9413: cp figlist /usr/pkg/bin
                   9414: cp showfigfonts /usr/pkg/bin
                   9415: cp fonts/*.flf /usr/pkg/share/figlet
                   9416: cp fonts/*.flc /usr/pkg/share/figlet
                   9417: cp figlet.6 /usr/pkg/man/man6
                   9418: ===> Registering installation for figlet-2.2.1nb2
                   9419: #
                   9420: 
1.207     leot     9421: C.2. Packaging figlet
1.1       dsieger  9422: 
                   9423: # make package
                   9424: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   9425: ===> Packaging figlet-2.2.1nb2
                   9426: ===> Building binary package for figlet-2.2.1nb2
                   9427: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
                   9428: Using SrcDir value of /usr/pkg
                   9429: Registering depends:.
                   9430: #
                   9431: 
1.207     leot     9432: Appendix D. Directory layout of the pkgsrc FTP server
1.1       dsieger  9433: 
                   9434: Table of Contents
                   9435: 
1.207     leot     9436: D.1. distfiles: The distributed source files
                   9437: D.2. misc: Miscellaneous things
                   9438: D.3. packages: Binary packages
                   9439: D.4. reports: Bulk build reports
                   9440: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  9441: 
                   9442: As in other big projects, the directory layout of pkgsrc is quite complex for
                   9443: newbies. This chapter explains where you find things on the FTP server. The
                   9444: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
                   9445: different, but inside this directory, everything should look the same, no
                   9446: matter on which server you are. This directory contains some subdirectories,
                   9447: which are explained below.
                   9448: 
1.207     leot     9449: D.1. distfiles: The distributed source files
1.1       dsieger  9450: 
                   9451: The directory distfiles contains lots of archive files from all pkgsrc
                   9452: packages, which are mirrored here. The subdirectories are called after their
                   9453: package names and are used when the distributed files have names that don't
                   9454: explicitly contain a version number or are otherwise too generic (for example
                   9455: release.tar.gz).
                   9456: 
1.207     leot     9457: D.2. misc: Miscellaneous things
1.1       dsieger  9458: 
                   9459: This directory contains things that individual pkgsrc developers find worth
                   9460: publishing.
                   9461: 
1.207     leot     9462: D.3. packages: Binary packages
1.1       dsieger  9463: 
1.3       rillig   9464: This directory contains binary packages for the various platforms that are
                   9465: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
                   9466: The meaning of these variables is:
                   9467: 
                   9468:   * OPSYS is the name of the operating system for which the packages have been
1.9       rillig   9469:     built. The name is taken from the output of the uname command, so it may
                   9470:     differ from the one you are used to hear.
1.3       rillig   9471: 
1.8       rillig   9472:   * ARCH is the hardware architecture of the platform for which the packages
1.10      hubertf  9473:     have been built. It also includes the ABI (Application Binary Interface)
                   9474:     for platforms that have several of them.
1.3       rillig   9475: 
1.8       rillig   9476:   * OSVERSION is the version of the operating system. For version numbers that
                   9477:     change often (for example NetBSD-current), the often-changing part should
                   9478:     be replaced with an x, for example 4.99.x.
1.3       rillig   9479: 
1.23      jakllsch 9480:   * TAG is either 20xxQy for a stable branch, or head for packages built from
1.8       rillig   9481:     the HEAD branch. The latter should only be used when the packages are
                   9482:     updated on a regular basis. Otherwise the date from checking out pkgsrc
                   9483:     should be appended, for example head_20071015.
1.3       rillig   9484: 
                   9485: The rationale for exactly this scheme is that the pkgsrc users looking for
                   9486: binary packages can quickly click through the directories on the server and
                   9487: find the best binary packages for their machines. Since they usually know the
                   9488: operating system and the hardware architecture, OPSYS and ARCH are placed
                   9489: first. After these choices, they can select the best combination of OSVERSION
                   9490: and TAG together, since it is usually the case that packages stay compatible
                   9491: between different version of the operating system.
                   9492: 
                   9493: In each of these directories, there is a whole binary packages collection for a
                   9494: specific platform. It has a directory called All which contains all binary
                   9495: packages. Besides that, there are various category directories that contain
                   9496: symbolic links to the real binary packages.
1.1       dsieger  9497: 
1.207     leot     9498: D.4. reports: Bulk build reports
1.8       rillig   9499: 
                   9500: Here are the reports from bulk builds, for those who want to fix packages that
                   9501: didn't build on some of the platforms. The structure of subdirectories should
1.207     leot     9502: look like the one in Section D.3, "packages: Binary packages".
1.8       rillig   9503: 
1.207     leot     9504: D.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  9505: 
                   9506: These directories contain the "real" pkgsrc, that is the files that define how
                   9507: to create binary packages from source archives.
                   9508: 
1.149     leot     9509: Each of the current, stable and pkgsrc-20xxQy directories share the same
                   9510: structure. They each contain a pkgsrc directory and pkgsrc.tar.{bz,gz,xz} file.
                   9511: 
1.1       dsieger  9512: The directory pkgsrc contains a snapshot of the CVS repository, which is
1.149     leot     9513: updated regularly. The file pkgsrc.tar.{bz,gz,xz} contains the same as the
                   9514: directory, ready to be downloaded as a whole.
1.1       dsieger  9515: 
1.149     leot     9516: The current directory contains files related to the HEAD branch of the CVS
                   9517: repository. In this directory there is an additional file called
                   9518: pkgsrc-readmes.tar.{bz,gz,xz} that contains all pkgsrc READMEs with information
                   9519: about categories and packages.
                   9520: 
                   9521: The stable directory is a symlink to the latest pkgsrc-20xxQy.
                   9522: 
                   9523: The pkgsrc-20xxQy. directories contain files related to the -20xxQy stable
                   9524: branch of the CVS repository. In these directories there is an additional file
                   9525: called pkgsrc-20xxQy.tar.{bz,gz,xz}, which contains the state of pkgsrc when it
                   9526: was branched.
1.148     leot     9527: 
1.207     leot     9528: Appendix E. Help topics
1.154     rillig   9529: 
                   9530: The following list contains all help topics that are available when running 
                   9531: bmake help topic=:index.
                   9532: 
1.210     gutterid 9533: #!                               -lintl
                   9534: 32bit                            64bit
                   9535: ABI                              ACCEPTABLE_LICENSES
                   9536: ACROREAD_FONTPATH                ADDITIONAL
                   9537: AFAIK                            AIX
                   9538: ALLOW_VULNERABLE_PACKAGES        ALL_ENV
                   9539: ALTERNATIVES_SRC                 AMANDA_TMP
                   9540: AMANDA_USER                      AMANDA_VAR
                   9541: APACHE_GROUP                     APACHE_MODULE_NAME
                   9542: APACHE_MODULE_SRC                APACHE_MODULE_SRCDIR
                   9543: APACHE_PKG_PREFIX                APACHE_SUEXEC_CONFIGURE_ARGS
                   9544: APACHE_SUEXEC_DOCROOT            APACHE_USER
                   9545: APPEND_ABI                       APPEND_ELF
                   9546: ARLA_CACHE                       AUDIT_PACKAGES_FLAGS
                   9547: AUTOCONF_REQD                    AUTOMAKE_OVERRIDE
                   9548: AUTOMAKE_REQD                    AUTO_MKDIRS
                   9549: BDB185_DEFAULT                   BDBBASE
                   9550: BDB_ACCEPTED                     BDB_DEFAULT
                   9551: BDB_LIBS                         BDB_TYPE
                   9552: BINCIMAP_GROUP                   BINCIMAP_USER
                   9553: BIND_DIR                         BIND_GROUP
                   9554: BIND_USER                        BINOWN
                   9555: BINPKG_SITES                     BIN_INSTALL_FLAGS
                   9556: BISON_PKGDATADIR                 BLAS
                   9557: BLAS_ACCEPTED                    BLAS_C_INTERFACE
                   9558: BLAS_INCLUDES                    BLAS_INDEX64
                   9559: BLAS_LIBS                        BLAS_TYPE
                   9560: BOOTSTRAP_DEPENDS                BOOTSTRAP_SETUPTOOLS
                   9561: BROKEN                           BROKEN_EXCEPT_ON_PLATFORM
                   9562: BROKEN_ON_PLATFORM               BSDSRCDIR
                   9563: BSDXSRCDIR                       BSD_MAKE_ENV
                   9564: BUILDLINK_AUTO_DIRS              BUILDLINK_AUTO_VARS
                   9565: BUILDLINK_CFLAGS                 BUILDLINK_CONTENTS_FILTER
                   9566: BUILDLINK_CPPFLAGS               BUILDLINK_FILES
                   9567: BUILDLINK_FILES_CMD              BUILDLINK_FNAME_TRANSFORM
                   9568: BUILDLINK_LDFLAGS                BUILDLINK_LIBS
                   9569: BUILDLINK_OPSYS_SUPPORT_PTHREAD  BUILDLINK_PKGNAME
                   9570: BUILDLINK_PREFIX                 BUILDLINK_RPATHDIRS
                   9571: BUILDLINK_TREE                   BUILD_DEFS
                   9572: BUILD_DEFS_EFFECTS               BUILD_DEPENDS
                   9573: BUILD_DIRS                       BUILD_ENV_SHELL
                   9574: BUILD_MAKE_CMD                   BUILD_MAKE_FLAGS
                   9575: BUILD_TARGET                     BUILTIN_FIND_FILES
                   9576: BUILTIN_FIND_FILES_VAR           BUILTIN_FIND_GREP
                   9577: BUILTIN_FIND_HEADERS             BUILTIN_FIND_HEADERS_VAR
                   9578: BUILTIN_FIND_PKGCONFIG           BUILTIN_FIND_PKGCONFIG_VAR
                   9579: BUILTIN_PKG                      BUILTIN_TEST_CURSES_DEFINES
                   9580: BUILTIN_TEST_CURSES_FUNCS        BUILTIN_VERSION_SCRIPT
                   9581: BUILTIN_X11_TYPE                 BUILTIN_X11_VERSION
                   9582: CACTI_GROUP                      CACTI_USER
                   9583: CANNA_GROUP                      CANNA_USER
                   9584: CAT                              CBLAS_LIBS
                   9585: CCACHE_BASE                      CCACHE_DIR
                   9586: CCACHE_LOGFILE                   CC_VERSION
                   9587: CC_VERSION_STRING                CDRECORD_CONF
                   9588: CDROM_PKG_URL_DIR                CDROM_PKG_URL_HOST
                   9589: CHECK_COMPILER                   CHECK_FAKEHOME
                   9590: CHECK_FILES                      CHECK_FILES_SKIP
                   9591: CHECK_FILES_STRICT               CHECK_HEADERS
                   9592: CHECK_HEADERS_SKIP               CHECK_INTERPRETER
                   9593: CHECK_INTERPRETER_SKIP           CHECK_PERMS
                   9594: CHECK_PERMS_AUTOFIX              CHECK_PERMS_SKIP
                   9595: CHECK_PORTABILITY                CHECK_PORTABILITY_EXPERIMENTAL
                   9596: CHECK_PORTABILITY_SKIP           CHECK_RELRO
                   9597: CHECK_RELRO_SKIP                 CHECK_RELRO_SUPPORTED
                   9598: CHECK_SHLIBS                     CHECK_SHLIBS_SKIP
                   9599: CHECK_SHLIBS_SUPPORTED           CHECK_SHLIBS_TOXIC
                   9600: CHECK_SSP                        CHECK_SSP_SKIP
                   9601: CHECK_SSP_SUPPORTED              CHECK_STRIPPED
                   9602: CHECK_STRIPPED_SKIP              CHECK_WRKREF
                   9603: CHECK_WRKREF_EXTRA_DIRS          CHECK_WRKREF_SKIP
                   9604: CLAMAV_DBDIR                     CLAMAV_GROUP
                   9605: CLAMAV_USER                      CLANGBASE
                   9606: CLEANDEPENDS                     CMAKE_DEPENDENCIES_REWRITE
                   9607: CMAKE_INSTALL_NAME_DIR           CMAKE_INSTALL_PREFIX
                   9608: CMAKE_MODULE_PATH_OVERRIDE       CMAKE_PKGSRC_BUILD_FLAGS
                   9609: CMAKE_PREFIX_PATH                CMAKE_USE_GNU_INSTALL_DIRS
                   9610: COMPILER_RPATH_FLAG              COMPILER_USE_SYMLINKS
                   9611: CONFIGURE_ARGS                   CONFIGURE_DIRS
                   9612: CONFIGURE_ENV                    CONFIGURE_ENV_SHELL
                   9613: CONFIGURE_HAS_INFODIR            CONFIGURE_HAS_MANDIR
                   9614: CONFIGURE_SCRIPT                 CONFIG_SHELL
                   9615: CONFIG_SHELL_FLAGS               CONF_FILES
                   9616: CONF_FILES_MODE                  CONF_FILES_PERMS
                   9617: CONSERVER_DEFAULTHOST            CONSERVER_DEFAULTPORT
                   9618: CP                               CPP
                   9619: CPP_PRECOMP_FLAGS                CREATE_WRKDIR_SYMLINK
                   9620: CROSSBASE                        CTFCONVERT
                   9621: CTF_FILES_SKIP                   CTF_SUPPORTED
                   9622: CTYPE                            CUPS_GROUP
                   9623: CUPS_SYSTEM_GROUPS               CUPS_USER
                   9624: CURSES_DEFAULT                   CURSES_TYPE
                   9625: CXX                              CYRUS_GROUP
                   9626: CYRUS_IDLE                       CYRUS_USER
                   9627: DAEMONTOOLS_GROUP                DAEMONTOOLS_LOG_USER
                   9628: DARWIN_NO_SYSTEM_LIBS            DARWIN_REQUIRES_FILTER
                   9629: DBUS_GROUP                       DBUS_USER
                   9630: DEFANG_GROUP                     DEFANG_USER
                   9631: DEFAULT_ACCEPTABLE_LICENSES      DEFAULT_DISTFILES
                   9632: DEFAULT_IRC_SERVER               DEFAULT_SERIAL_DEVICE
                   9633: DEF_UMASK                        DEINSTALLDEPENDS
                   9634: DEINSTALL_SRC                    DEINSTALL_TEMPLATES
                   9635: DELAYED_ERROR_MSG                DELAYED_WARNING_MSG
                   9636: DEPENDS                          DEPENDS_TARGET
                   9637: DEPENDS_TYPE                     DESTDIR
                   9638: DESTDIR_VARNAME                  DIALER_GROUP
                   9639: DIGEST_REQD                      DISTDIR
                   9640: DISTFILES                        DISTINFO_FILE
                   9641: DISTNAME                         DIST_PATH
                   9642: DIST_SUBDIR                      DJBDNS_AXFR_USER
                   9643: DJBDNS_CACHE_USER                DJBDNS_DJBDNS_GROUP
                   9644: DJBDNS_LOG_USER                  DJBDNS_RBL_USER
                   9645: DJBDNS_TINY_USER                 DLOPEN_REQUIRE_PTHREADS
                   9646: DL_AUTO_VARS                     DL_CFLAGS
                   9647: DL_LDFLAGS                       DL_LIBS
                   9648: DNS                              DOCOWN
                   9649: DOWNLOADED_DISTFILE              DT_LAYOUT
                   9650: DYNAMIC_SITES_CMD                DYNAMIC_SITES_SCRIPT
                   9651: ECHO                             ECHO_N
                   9652: ELK_GUI                          EMACS_TYPE
                   9653: EMULDIR                          EMULSUBDIR
                   9654: EMULSUBDIRSLASH                  EMUL_ARCH
                   9655: EMUL_DISTRO                      EMUL_EXEC_FMT
                   9656: EMUL_IS_NATIVE                   EMUL_MODULES
                   9657: EMUL_OPSYS                       EMUL_PKG_FMT
                   9658: EMUL_PLATFORM                    EMUL_PLATFORMS
                   9659: EMUL_PREFER                      EMUL_REQD
                   9660: EMUL_TYPE                        ERROR_MSG
                   9661: EXIM_GROUP                       EXIM_USER
                   9662: EXPORT_SYMBOLS_LDFLAGS           EXTRACTOR
                   9663: EXTRACT_CMD                      EXTRACT_CMD_DEFAULT
                   9664: EXTRACT_DIR                      EXTRACT_ELEMENTS
                   9665: EXTRACT_ENV                      EXTRACT_ONLY
                   9666: EXTRACT_OPTS                     EXTRACT_SUFX
                   9667: EXTRACT_USING                    FAIL
                   9668: FAILOVER_FETCH                   FAIL_MSG
                   9669: FAKE_NCURSES                     FAM
                   9670: FAM_ACCEPTED                     FAM_DEFAULT
                   9671: FAM_SERVER                       FCPATH
                   9672: FEATURE_CPPFLAGS                 FEATURE_LDFLAGS
                   9673: FEATURE_LIBS                     FETCH_AFTER_ARGS
                   9674: FETCH_BEFORE_ARGS                FETCH_CMD
                   9675: FETCH_OUTPUT_ARGS                FETCH_PROXY
                   9676: FETCH_RESUME_ARGS                FETCH_TIMEOUT
                   9677: FETCH_USE_IPV4_ONLY              FETCH_USING
                   9678: FILES_SUBST                      FILES_SUBST_SED
                   9679: FIX_SYSTEM_HEADERS               FLUXBOX_USE_GNOME
                   9680: FLUXBOX_USE_KDE                  FLUXBOX_USE_XFT
                   9681: FLUXBOX_USE_XINERAMA             FONTS_DIRS
                   9682: FONTS_VERBOSE                    FOO_HACKS_MK
                   9683: FOX_USE_XUNICODE                 FREEWNN_GROUP
                   9684: FREEWNN_USER                     FTP_PKG_URL_DIR
                   9685: FTP_PKG_URL_HOST                 GAMEDATAMODE
                   9686: GAMEDATA_PERMS                   GAMEDIRMODE
                   9687: GAMEDIR_PERMS                    GAMEGRP
                   9688: GAMEMODE                         GAMEOWN
                   9689: GAMES_GROUP                      GAMES_USER
                   9690: GCC                              GCCBASE
                   9691: GCC_REQD                         GCC_VERSION_SUFFIX
                   9692: GEM_BUILD                        GEM_CLEANBUILD
                   9693: GEM_CLEANBUILD_EXTENSIONS        GEM_DOCDIR
                   9694: GEM_EXTSDIR                      GEM_HOME
                   9695: GEM_KEEPBUILD                    GEM_LIBDIR
                   9696: GEM_NAME                         GEM_PATH
                   9697: GEM_PLUGINSDIR                   GEM_SPECFILE
                   9698: GENERATE_PLIST                   GHC
                   9699: GHOSTSCRIPT_REQD                 GITHUB_PROJECT
                   9700: GITHUB_RELEASE                   GITHUB_SUBMODULES
                   9701: GITHUB_TAG                       GITHUB_TYPE
                   9702: GNU                              GNU_CONFIGURE
                   9703: GNU_CONFIGURE_INFODIR            GNU_CONFIGURE_MANDIR
                   9704: GNU_CONFIGURE_QUIET              GNU_CONFIGURE_STRICT
                   9705: GODEP_REDIRECTS                  GO_BUILD_PATTERN
                   9706: GO_DEPS                          GO_DIST_BASE
                   9707: GO_EXTRA_MOD_DIRS                GO_MODULE_FILES
                   9708: GO_SRCPATH                       GO_VERSION_DEFAULT
                   9709: GROUP_SPECIFIC_PKGS              GRUB_NETWORK_CARDS
                   9710: GRUB_PRESET_COMMAND              GRUB_SCAN_ARGS
                   9711: GZIP                             HASKELL_ENABLE_HADDOCK_DOCUMENTATION
                   9712: HASKELL_ENABLE_LIBRARY_PROFILING HASKELL_ENABLE_SHARED_LIBRARY
                   9713: HASKELL_OPTIMIZATION_LEVEL       HAS_CONFIGURE
                   9714: HEADER_TEMPLATES                 HOMEPAGE
                   9715: HOST_PKGTOOLS_ARGS               HOST_SPECIFIC_PKGS
                   9716: HOWL_GROUP                       HOWL_USER
                   9717: ICCBASE                          ICECAST_CHROOTDIR
                   9718: ICON_THEMES                      IDOBASE
                   9719: IGNORE_CCACHE                    IGNORE_INFO_DIRS
                   9720: IGNORE_INTERACTIVE_FETCH         IMAKE
                   9721: IMAKEOPTS                        IMAKE_MAKE
                   9722: IMAKE_MANINSTALL                 IMAP_UW_CCLIENT_MBOX_FMT
                   9723: IMDICTDIR                        INCOMPAT_CURSES
                   9724: INFO_DIR                         INFO_FILES
                   9725: INFO_FILES_VERBOSE               INFO_MSG
                   9726: INIT_SYSTEM                      INN_DATA_DIR
                   9727: INN_GROUP                        INN_USER
                   9728: INSTALLATION_DIRS                INSTALLATION_DIRS_FROM_PLIST
                   9729: INSTALL_ENV                      INSTALL_SH_OVERRIDE
                   9730: INSTALL_SRC                      INSTALL_TEMPLATES
                   9731: INSTALL_UNSTRIPPED               IRCD_HYBRID_IRC_GROUP
                   9732: IRCD_HYBRID_IRC_USER             IRCD_HYBRID_MAXCONN
                   9733: IRCD_HYBRID_NICLEN               IRCD_HYBRID_SYSLOG_EVENTS
                   9734: IRCD_HYBRID_SYSLOG_FACILITY      IRCD_HYBRID_TOPICLEN
                   9735: IRIX                             IRRD_USE_PGP
                   9736: JABBERD_GROUP                    JABBERD_LOGDIR
                   9737: JABBERD_PIDDIR                   JABBERD_SPOOLDIR
                   9738: JABBERD_USER                     JAKARTA_HOME
                   9739: JAVA_BINPREFIX                   JAVA_CLASSPATH
                   9740: JAVA_HOME                        JAVA_LD_LIBRARY_PATH
                   9741: JAVA_NAME                        JAVA_UNLIMIT
                   9742: JAVA_WRAPPERS                    JPEG_ACCEPTED
                   9743: JPEG_DEFAULT                     KERBEROS
                   9744: KERMIT_SUID_UUCP                 KJS_USE_PCRE
                   9745: KNEWS_DOMAIN_FILE                KNEWS_DOMAIN_NAME
                   9746: KRB5_ACCEPTED                    KRB5_DEFAULT
                   9747: LANGUAGES                        LAPACKE_LIBS
                   9748: LAPACK_LIBS                      LATEX2HTML_ICONPATH
                   9749: LDCONFIG_ADD_CMD                 LDCONFIG_REMOVE_CMD
                   9750: LEAFNODE_DATA_DIR                LEAFNODE_GROUP
                   9751: LEAFNODE_USER                    LIBDVDCSS_HOMEPAGE
                   9752: LIBDVDCSS_MASTER_SITES           LIBRSVG_TYPE
                   9753: LIBTOOL                          LIBTOOLIZE_PLIST
                   9754: LIBTOOL_M4_OVERRIDE              LIBUSB_TYPE
                   9755: LICENSE                          LINKER_RPATH_FLAG
                   9756: LINK_RPATH_FLAG                  LINUX_LOCALES
                   9757: LOCALBASE                        LOCALBASE_LOCKTYPE
                   9758: LOCALPATCHES                     LOVE_DATA
                   9759: LOVE_GAME                        LOVE_VERSION
                   9760: LP32PLATFORMS                    LP64PLATFORMS
                   9761: MACHINE_PLATFORM                 MAILAGENT_DOMAIN
                   9762: MAILAGENT_EMAIL                  MAILAGENT_FQDN
                   9763: MAILAGENT_ORGANIZATION           MAJORDOMO_HOMEDIR
                   9764: MAKEINFO_ARGS                    MAKE_DIRS
                   9765: MAKE_DIRS_PERMS                  MAKE_ENV
                   9766: MAKE_FILE                        MAKE_FLAGS
                   9767: MAKE_JOBS                        MAKE_JOBS_SAFE
                   9768: MAKE_PROGRAM                     MANCOMPRESSED_IF_MANZ
                   9769: MANINSTALL                       MANZ
                   9770: MASTER_SITES                     MASTER_SITE_BACKUP
                   9771: MASTER_SITE_LOCAL                MASTER_SITE_MOZILLA
                   9772: MASTER_SITE_OVERRIDE             MASTER_SITE_PERL_CPAN
                   9773: MASTER_SORT                      MASTER_SORT_RANDOM
                   9774: MASTER_SORT_REGEX                MECAB_CHARSET
                   9775: MEDIATOMB_GROUP                  MEDIATOMB_USER
                   9776: MIPSPROBASE                      MIREDO_GROUP
                   9777: MIREDO_USER                      MISSING_FEATURES
                   9778: MKDIR                            MKPIE_SUPPORTED
                   9779: MLDONKEY_GROUP                   MLDONKEY_HOME
                   9780: MLDONKEY_USER                    MONOTONE_GROUP
                   9781: MONOTONE_USER                    MOTIFBASE
                   9782: MOTIF_TYPE                       MOTIF_TYPE_DEFAULT
                   9783: MPI_TYPE                         MSGFMT_STRIP_MSGCTXT
                   9784: MSGFMT_STRIP_MSGID_PLURAL        MTOOLS_ENABLE_FLOPPYD
                   9785: MV                               MYSQL_CHARSET
                   9786: MYSQL_DATADIR                    MYSQL_EXTRA_CHARSET
                   9787: MYSQL_GROUP                      MYSQL_USER
                   9788: MYSQL_VERSION                    MYSQL_VERSIONS_ACCEPTED
                   9789: MYSQL_VERSIONS_ALL               MYSQL_VERSION_DEFAULT
                   9790: NAGIOSCMD_GROUP                  NAGIOSDIR
                   9791: NAGIOS_GROUP                     NAGIOS_USER
                   9792: NATIVE_APPEND_ABI                NATIVE_APPEND_ELF
                   9793: NATIVE_EXEC_FMT                  NATIVE_MACHINE_PLATFORM
                   9794: NATIVE_OBJECT_FMT                NBPAX_PROGRAM_PREFIX
                   9795: NETBSD_LOGIN_NAME                NMH_EDITOR
                   9796: NMH_MTA                          NMH_PAGER
                   9797: NOLOGIN                          NOTE
                   9798: NOT_FOR_PLATFORM                 NOT_PAX_ASLR_SAFE
                   9799: NOT_PAX_MPROTECT_SAFE            NO_BUILD
                   9800: NO_CHECKSUM                      NO_CONFIGURE
                   9801: NO_SKIP                          NS_PREFERRED
                   9802: NULLMAILER_GROUP                 NULLMAILER_USER
                   9803: OASIS                            OASIS_BUILD_ARGS
                   9804: OBJHOSTNAME                      OBJMACHINE
                   9805: OCAML_FINDLIB_DIRS               OCAML_FINDLIB_REGISTER
                   9806: OCAML_FINDLIB_REGISTER_VERBOSE   OCAML_SITELIBDIR
                   9807: OCAML_TOPKG_DOCDIR               OCAML_USE_DUNE
                   9808: OCAML_USE_FINDLIB                OCAML_USE_JBUILDER
                   9809: OCAML_USE_OASIS                  OCAML_USE_OASIS_DYNRUN
                   9810: OCAML_USE_OPAM                   OCAML_USE_OPT_COMPILER
                   9811: OCAML_USE_TOPKG                  OMF
                   9812: ONLY_FOR_COMPILER                ONLY_FOR_PLATFORM
                   9813: OPENSSH_CHROOT                   OPENSSH_GROUP
                   9814: OPENSSH_USER                     OPSYS
                   9815: OPSYS_EMULDIR                    OS
                   9816: OSS_TYPE                         OSX
                   9817: OSX_TOLERATE_SDK_SKEW            OS_VARIANT
                   9818: OS_VERSION                       OTF_FONTS_DIR
                   9819: OVERRIDE_DIRDEPTH                OVERRIDE_GEMSPEC
                   9820: OVERRIDE_GNU_CONFIG_SCRIPTS      OWN_DIRS
                   9821: OWN_DIRS_PERMS                   P4GROUP
                   9822: P4PORT                           P4ROOT
                   9823: P4USER                           PACKAGES
                   9824: PALMOS_DEFAULT_SDK               PAMBASE
                   9825: PAM_DEFAULT                      PAPERSIZE
                   9826: PASSIVE_FETCH                    PATCHDIR
                   9827: PATCHFILES                       PATCH_ARGS
                   9828: PATCH_DEBUG                      PATCH_DIST_ARGS
                   9829: PATCH_DIST_CAT                   PATCH_DIST_STRIP
                   9830: PATCH_FUZZ_FACTOR                PATCH_STRIP
                   9831: PATH                             PCCBASE
                   9832: PEAR_CMD                         PEAR_LIB
                   9833: PEAR_PACKAGE_XML                 PERL5
                   9834: PERL5_CONFIGURE                  PERL5_CONFIGURE_DIRS
                   9835: PERL5_LDFLAGS                    PERL5_LICENSE
                   9836: PERL5_MODULE_TYPE                PERL5_PACKLIST
                   9837: PERL5_PACKLIST_DIR               PERL5_PERLBASE
                   9838: PERL5_SITEBASE                   PERL5_USE_PACKLIST
                   9839: PERL5_VENDORBASE                 PFCTL
                   9840: PFVAR_H                          PF_VERSION
                   9841: PGGROUP                          PGHOME
                   9842: PGPKGSRCDIR                      PGSQL_TYPE
                   9843: PGSQL_VERSION                    PGSQL_VERSIONS_ACCEPTED
                   9844: PGSQL_VERSION_DEFAULT            PGUSER
                   9845: PG_LIB_EXT                       PHP
                   9846: PHPCOMMON_MK                     PHPPKGSRCDIR
                   9847: PHP_BASE_VERS                    PHP_CHECK_INSTALLED
                   9848: PHP_EXTENSION_DIR                PHP_INITIAL_TEENY
                   9849: PHP_PKG_PREFIX                   PHP_VERSION
                   9850: PHP_VERSIONS_ACCEPTED            PHP_VERSIONS_INCOMPATIBLE
                   9851: PHP_VERSION_DEFAULT              PHP_VERSION_REQD
                   9852: PILRC_USE_GTK                    PKGCONFIG_BASE
                   9853: PKGCONFIG_FILE                   PKGCONFIG_OVERRIDE
                   9854: PKGCONFIG_OVERRIDE_STAGE         PKGDIR
                   9855: PKGGNUDIR                        PKGINFODIR
                   9856: PKGLOCALEDIR                     PKGMANDIR
                   9857: PKGNAME                          PKGNAME_REQD
                   9858: PKGPATH                          PKGREVISION
                   9859: PKGSRC_BLAS_TYPES                PKGSRC_CHANGES
                   9860: PKGSRC_COMPILER                  PKGSRC_KEEP_BIN_PKGS
                   9861: PKGSRC_LOCKTYPE                  PKGSRC_MAKE_ENV
                   9862: PKGSRC_MESSAGE_RECIPIENTS        PKGSRC_MKPIE
                   9863: PKGSRC_MKREPRO                   PKGSRC_RUN_TEST
                   9864: PKGSRC_SETENV                    PKGSRC_SLEEPSECS
                   9865: PKGSRC_TODO                      PKGSRC_USE_CTF
                   9866: PKGSRC_USE_FORTIFY               PKGSRC_USE_RELRO
                   9867: PKGSRC_USE_SSP                   PKGSRC_USE_STACK_CHECK
                   9868: PKGTASKS_DATAFILE                PKGTOOLS_ARGS
                   9869: PKGTOOLS_ENV                     PKG_ALTERNATIVES
                   9870: PKG_APACHE                       PKG_APACHE_ACCEPTED
                   9871: PKG_APACHE_DEFAULT               PKG_BEST_EXISTS
                   9872: PKG_BUILD_OPTIONS                PKG_COMPRESSION
                   9873: PKG_CONFIG                       PKG_CONFIG_PERMS
                   9874: PKG_CREATE_USERGROUP             PKG_DB_TMPDIR
                   9875: PKG_DEBUG_LEVEL                  PKG_DEFAULT_OPTIONS
                   9876: PKG_DESTDIR_SUPPORT              PKG_DEVELOPER
                   9877: PKG_DISABLED_OPTIONS             PKG_FATAL_ERRORS
                   9878: PKG_FC                           PKG_FILELIST_CMD
                   9879: PKG_GECOS                        PKG_GID
                   9880: PKG_GROUPS                       PKG_GROUPS_VARS
                   9881: PKG_HOME                         PKG_INIT_SCRIPTS
                   9882: PKG_JAVA_HOME                    PKG_JVM
                   9883: PKG_JVMS_ACCEPTED                PKG_JVM_DEFAULT
                   9884: PKG_LEGACY_OPTIONS               PKG_LIBTOOL
                   9885: PKG_OPTIONS                      PKG_OPTIONS_DEPRECATED_WARNINGS
                   9886: PKG_OPTIONS_LEGACY_OPTS          PKG_OPTIONS_LEGACY_VARS
                   9887: PKG_OPTIONS_NONEMPTY_SETS        PKG_OPTIONS_OPTIONAL_GROUPS
                   9888: PKG_OPTIONS_REQUIRED_GROUPS      PKG_OPTIONS_VAR
                   9889: PKG_PHP                          PKG_PHP_MAJOR_VERS
                   9890: PKG_PHP_VERSION                  PKG_RCD_SCRIPTS
                   9891: PKG_REFCOUNT_DBDIR               PKG_REGISTER_SHELLS
                   9892: PKG_RESUME_TRANSFERS             PKG_SHELL
                   9893: PKG_SUGGESTED_OPTIONS            PKG_SUPPORTED_OPTIONS
                   9894: PKG_SYSCONFBASE                  PKG_SYSCONFBASEDIR
                   9895: PKG_SYSCONFDIR                   PKG_SYSCONFDIR_PERMS
                   9896: PKG_SYSCONFSUBDIR                PKG_SYSCONFVAR
                   9897: PKG_TOOLS_BIN                    PKG_UID
                   9898: PKG_UPDATE_FONTS_DB              PKG_USERS
                   9899: PKG_USERS_VARS                   PKG_VERBOSE
                   9900: PLEASE                           PLIST
                   9901: PLIST_AWK                        PLIST_AWK_ENV
                   9902: PLIST_SRC                        PLIST_SUBST
                   9903: PLIST_TYPE                       PLIST_VARS
                   9904: POPTOP_USE_MPPE                  POSSIBLE_GFORTRAN_VERSION
                   9905: POST_FETCH_HOOK                  PREFER
                   9906: PREFER_NATIVE                    PREFER_NATIVE_PTHREADS
                   9907: PREFER_PKGSRC                    PREFIX
                   9908: PREPEND_PATH                     PRE_ROOT_CMD
                   9909: PRIVILEGED_STAGES                PS
                   9910: PTHREAD_AUTO_VARS                PTHREAD_CFLAGS
                   9911: PTHREAD_LDFLAGS                  PTHREAD_LIBS
                   9912: PTHREAD_OPTS                     PTHREAD_TYPE
                   9913: PVM_SSH                          PYPKGPREFIX
                   9914: PYTHON_FOR_BUILD_ONLY            PYTHON_SELF_CONFLICT
                   9915: PYTHON_VERSIONED_DEPENDENCIES    PYTHON_VERSIONS_ACCEPTED
                   9916: PYTHON_VERSIONS_INCOMPATIBLE     PYTHON_VERSION_DEFAULT
                   9917: PYTHON_VERSION_REQD              PYVERSSUFFIX
                   9918: PY_NO_EGG                        QMAILDIR
                   9919: QMAIL_ALIAS_USER                 QMAIL_DAEMON_USER
                   9920: QMAIL_LOG_USER                   QMAIL_NOFILES_GROUP
                   9921: QMAIL_PASSWD_USER                QMAIL_QMAIL_GROUP
                   9922: QMAIL_QUEUE_DIR                  QMAIL_QUEUE_EXTRA
                   9923: QMAIL_QUEUE_USER                 QMAIL_REMOTE_USER
                   9924: QMAIL_ROOT_USER                  QMAIL_SEND_USER
                   9925: QPOPPER_FAC                      QPOPPER_SPOOL_DIR
                   9926: QPOPPER_USER                     RAKE_NAME
                   9927: RASMOL_DEPTH                     RCD_SCRIPTS
                   9928: RCD_SCRIPTS_DIR                  RCD_SCRIPTS_EXAMPLEDIR
                   9929: RCD_SCRIPTS_MODE                 RCD_SCRIPTS_SHELL
                   9930: RCD_SCRIPT_SRC                   RDOC
                   9931: READLINE_DEFAULT                 READLINE_TYPE
                   9932: REAL_ROOT_GROUP                  REAL_ROOT_USER
                   9933: RECURSIVE_MAKE                   RELAY_CTRL_DIR
                   9934: RELRO_SUPPORTED                  REPLACE_AWK
                   9935: REPLACE_BASH                     REPLACE_CSH
                   9936: REPLACE_KSH                      REPLACE_PERL
                   9937: REPLACE_PERL6                    REPLACE_PHP
                   9938: REPLACE_PYTHON                   REPLACE_R
                   9939: REPLACE_RUBY                     REPLACE_RUBY_DIRS
                   9940: REPLACE_RUBY_PAT                 REPLACE_SH
                   9941: REPLACE_TEXLUA                   REQD_DIRS
                   9942: REQD_DIRS_PERMS                  REQD_FILES
                   9943: REQD_FILES_MODE                  REQD_FILES_PERMS
                   9944: RESOLV_AUTO_VARS                 RESOLV_LDFLAGS
                   9945: RESOLV_LIBS                      RM
                   9946: ROOT_CMD                         ROOT_GROUP
                   9947: ROOT_USER                        RPCGEN
                   9948: RPM                              RPM2PKG_PLIST
                   9949: RPM2PKG_PREFIX                   RPM2PKG_STAGE
                   9950: RPM2PKG_STRIP                    RPM2PKG_SUBPREFIX
                   9951: RPMFILES                         RPMIGNOREPATH
                   9952: RPM_DB_PREFIX                    RSSH_CVS_PATH
                   9953: RSSH_RDIST_PATH                  RSSH_RSYNC_PATH
                   9954: RSSH_SCP_PATH                    RSSH_SFTP_SERVER_PATH
                   9955: RUBY                             RUBYGEM
                   9956: RUBYGEM_NAME                     RUBYGEM_OPTIONS
                   9957: RUBYGEM_VERBOSE                  RUBY_ABI_VERSION
                   9958: RUBY_ARCH                        RUBY_ARCHINC
                   9959: RUBY_ARCHLIB                     RUBY_BASE
                   9960: RUBY_BASERIDIR                   RUBY_BUILD_DOCUMENT
                   9961: RUBY_DLEXT                       RUBY_DOC
                   9962: RUBY_DYNAMIC_DIRS                RUBY_EG
                   9963: RUBY_ENCODING_ARG                RUBY_EXTCONF
                   9964: RUBY_EXTCONF_CHECK               RUBY_EXTCONF_DEBUG
                   9965: RUBY_EXTCONF_MAKEFILE            RUBY_GEM_BASE
                   9966: RUBY_INC                         RUBY_LIB
                   9967: RUBY_LIB_BASE                    RUBY_NAME
                   9968: RUBY_NOVERSION                   RUBY_PKGPREFIX
                   9969: RUBY_RAILS                       RUBY_RAILS52_VERSION
                   9970: RUBY_RAILS60_VERSION             RUBY_RAILS61_VERSION
                   9971: RUBY_RAILS_ACCEPTED              RUBY_RAILS_DEFAULT
                   9972: RUBY_RAILS_REQD                  RUBY_RAILS_STRICT_DEP
                   9973: RUBY_RIDIR                       RUBY_SETUP
                   9974: RUBY_SHLIB                       RUBY_SHLIBALIAS
                   9975: RUBY_SHLIBVER                    RUBY_SIMPLE_INSTALL
                   9976: RUBY_SITEARCHLIB                 RUBY_SITELIB
                   9977: RUBY_SITELIB_BASE                RUBY_SITERIDIR
                   9978: RUBY_SLEXT                       RUBY_SRCDIR
                   9979: RUBY_STATICLIB                   RUBY_SUFFIX
                   9980: RUBY_SYSRIDIR                    RUBY_USE_PTHREAD
                   9981: RUBY_VENDORARCHLIB               RUBY_VENDORLIB
                   9982: RUBY_VENDORLIB_BASE              RUBY_VER
                   9983: RUBY_VERSION                     RUBY_VERSIONS_ACCEPTED
                   9984: RUBY_VERSIONS_INCOMPATIBLE       RUBY_VERSION_DEFAULT
                   9985: RUBY_VERSION_REQD                RUBY_VER_DIR
                   9986: RUN                              RUN_LDCONFIG
                   9987: SAWFISH_THEMES                   SCO
                   9988: SCREWS_GROUP                     SCREWS_USER
                   9989: SCRIPTS_ENV                      SCROLLKEEPER_DATADIR
                   9990: SCROLLKEEPER_REBUILDDB           SCROLLKEEPER_UPDATEDB
                   9991: SDIST_PAWD                       SERIAL_DEVICES
                   9992: SETGIDGAME                       SETGID_GAMES_PERMS
                   9993: SETUID_ROOT_PERMS                SH
                   9994: SHLIB                            SIGN_PACKAGES
                   9995: SILC_CLIENT_WITH_PERL            SITE_SPECIFIC_PKGS
                   9996: SKIP_DEPENDS                     SMF_INSTANCES
                   9997: SMF_MANIFEST                     SMF_METHODS
                   9998: SMF_METHOD_SHELL                 SMF_METHOD_SRC
                   9999: SMF_NAME                         SMF_PREFIX
                   10000: SMF_SRCDIR                       SNIPROXY_GROUP
                   10001: SNIPROXY_USER                    SOURCE_BUFFSIZE
                   10002: SPECIAL_PERMS                    SPECIFIC_PKGS
                   10003: SSH_SUID                         SSP_SUPPORTED
                   10004: SSYNC_PAWD                       STEP_MSG
                   10005: STRIP                            STRIP_DBG
                   10006: STRIP_DEBUG                      STRIP_DEBUG_SUPPORTED
                   10007: STRIP_FILES_SKIP                 SU
                   10008: SUBDIR                           SUBST
                   10009: SUBST_CLASSES                    SUBST_FILES
                   10010: SUBST_FILTER_CMD                 SUBST_MESSAGE
                   10011: SUBST_NOOP_OK                    SUBST_SED
                   10012: SUBST_SHOW_DIFF                  SUBST_SKIP_TEXT_CHECK
                   10013: SUBST_STAGE                      SUBST_VARS
                   10014: SUNWSPROBASE                     SUSE_PREFER
                   10015: SU_CMD                           SYSCONFBASE
                   10016: TBL                              TERMCAP_TYPE
                   10017: TERMINFO_DEFAULT                 TERMINFO_TYPE
                   10018: TEST                             TEST_DEPENDS
                   10019: TEST_DIRS                        TEST_ENV
                   10020: TEST_ENV_SHELL                   TEST_MAKE_CMD
                   10021: TEST_MAKE_FLAGS                  TEST_TARGET
                   10022: TEXLIVE_IGNORE_PATTERNS          TEXLIVE_REV
                   10023: TEXLIVE_UNVERSIONED              TEXMFSITE
                   10024: TEX_FORMATS                      TEX_HYPHEN_DAT
                   10025: TEX_HYPHEN_DEF                   TEX_TEXMF_DIRS
                   10026: THTTPD_LOG_FACILITY              TINYDYN_USER
                   10027: TO                               TOOLS_ALIASES
                   10028: TOOLS_ALWAYS_WRAP                TOOLS_ARGS
                   10029: TOOLS_BROKEN                     TOOLS_CMD
                   10030: TOOLS_CMDLINE_SED                TOOLS_CREATE
                   10031: TOOLS_DIR                        TOOLS_FAIL
                   10032: TOOLS_GNU_MISSING                TOOLS_LDCONFIG
                   10033: TOOLS_NOOP                       TOOLS_PATH
                   10034: TOOLS_SCRIPT                     TOOL_DEPENDS
                   10035: TTF_FONTS_DIR                    TYPE
                   10036: UAC_REQD_EXECS                   UCSPI_SSL_GROUP
                   10037: UCSPI_SSL_USER                   UNLIMIT_RESOURCES
                   10038: UNPRIVILEGED                     UNPRIVILEGED_GROUP
                   10039: UNPRIVILEGED_GROUPS              UNPRIVILEGED_USER
                   10040: UNWRAP_FILES                     UNWRAP_PATTERNS
                   10041: UPDATE_GEMSPEC                   UPDATE_TARGET
                   10042: URI                              USERGROUP_PHASE
                   10043: USERPPP_GROUP                    USER_SPECIFIC_PKGS
                   10044: USE_ABI_DEPENDS                  USE_APR
                   10045: USE_BSD_MAKEFILE                 USE_BUILTIN
                   10046: USE_CROSS_COMPILE                USE_CURSES
                   10047: USE_CWRAPPERS                    USE_DB185
                   10048: USE_FEATURES                     USE_GAMESGROUP
                   10049: USE_GCC_RUNTIME                  USE_IMAKE
                   10050: USE_JAVA                         USE_JAVA2
                   10051: USE_LANGUAGES                    USE_LIBTOOL
                   10052: USE_NATIVE_GCC                   USE_NETBSD_REPO
                   10053: USE_PKGSRC_GCC                   USE_PKGSRC_GCC_RUNTIME
                   10054: USE_PKGTASKS                     USE_PKG_ADMIN_DIGEST
                   10055: USE_RUBY_EXTCONF                 USE_RUBY_INSTALL
                   10056: USE_RUBY_SETUP                   USE_RUBY_SETUP_PKG
                   10057: USE_TOOLS                        UUCP_GROUP
                   10058: UUCP_USER                        VARBASE
                   10059: VARNAME                          VIM_EXTRA_OPTS
                   10060: WARNING_MSG                      WCALC_CGIDIR
                   10061: WCALC_CGIPATH                    WCALC_HTMLDIR
                   10062: WCALC_HTMLPATH                   WDM_MANAGERS
                   10063: WRAPPER_CC                       WRAPPER_REORDER_CMDS
                   10064: WRKDIR                           WRKDIR_BASENAME
                   10065: WRKDIR_LOCKTYPE                  WRKLOG
                   10066: WRKOBJDIR                        WRKSRC
                   10067: X10_PORT                         X11
                   10068: X11BASE                          X11_PKGSRCDIR
                   10069: X11_TYPE                         X509_CERTIFICATE
                   10070: X509_KEY                         XAW_TYPE
                   10071: XLOCK_DEFAULT_MODE               XMKMF
                   10072: XMKMF_FLAGS                      XXX
                   10073: YES                              ZSH_STATIC
                   10074: __stdc__                         _vargroups
                   10075: accept                           acquire-localbase-lock
                   10076: acquire-lock                     add
                   10077: administrator                    alloca
                   10078: alternatives                     aslr
                   10079: asprintf                         atlas
                   10080: autoconf                         automake
                   10081: autoreconf                       awk
                   10082: bash                             big-endian
                   10083: bin-install                      bind
                   10084: binpkg-list                      blas
                   10085: bootstrap-depends                broken
                   10086: broken_on_platform               bsd
                   10087: bsd.prog.mk                      build
                   10088: build-env                        buildlink-directories
                   10089: buildlink-oss-soundcard-h        c
                   10090: c++                              ccache
                   10091: cce                              cdefs
                   10092: ceil                             changes
                   10093: changes-entry                    changes-entry-noupdate
                   10094: check                            check-clean
                   10095: check-files                      check-files-clean
                   10096: check-vulnerable                 checksum
                   10097: checksum-phase                   clean
                   10098: clean-depends                    cleandir
                   10099: commit                           commit-changes-entry
                   10100: compact                          compiler
                   10101: conf                             config.guess
                   10102: config.sub                       configuration
                   10103: configure                        configure-env
                   10104: configure-help                   configure_args
                   10105: connect                          cos
                   10106: cputime                          create-usergroup
                   10107: csh                              ctf
                   10108: debug                            declaration
                   10109: declare                          defined
                   10110: depend                           dependencies
                   10111: depends                          depends-checksum
                   10112: depends-fetch                    deps
                   10113: describe                         destdir
                   10114: disable                          distclean
                   10115: distinfo                         dl
                   10116: dlopen                           do-build
                   10117: do-buildlink                     do-clean
                   10118: do-configure                     do-configure-post-hook
                   10119: do-extract                       do-fetch
                   10120: emul                             emul-distinfo
                   10121: emul-fetch                       emulation
                   10122: emulator                         enable
                   10123: endian                           enomem
                   10124: err                              errx
                   10125: etc                              exp
                   10126: extract-rpm                      fabs
                   10127: feature                          features
                   10128: fetch                            fetch-list
                   10129: follows                          forbids
                   10130: form                             format
                   10131: fortify                          fortify_source
                   10132: friend                           fts
                   10133: fts_close                        fts_open
                   10134: fts_read                         fts_set
                   10135: gcc                              gethostbyaddr
                   10136: gethostbyname                    gethostbyname2
                   10137: getopt_long                      getprogname
                   10138: getservbyname                    getservbyport
                   10139: getservent                       gettext
                   10140: github                           glob
                   10141: gnu                              gnu_configure_strict
                   10142: go                               go-deps
                   10143: golang                           guess-license
                   10144: hashbang                         heimdal
                   10145: help                             imake
                   10146: increment                        inet_aton
                   10147: interp                           interpreter
                   10148: intl                             ip4
                   10149: ip6                              ipv4
                   10150: ipv6                             iso
                   10151: kerberos                         krb
                   10152: krb5                             ksh
                   10153: lapack                           latex
                   10154: libintl_bindtextdomain           libintl_gettext
                   10155: libintl_textdomain               libnbcompat
                   10156: libs                             libtool
                   10157: licence                          license
                   10158: lintl                            little-endian
                   10159: lock                             locking
                   10160: lvalue                           make
                   10161: makesum                          memory
                   10162: meta                             meta-package
                   10163: meta_package                     mit-krb5
                   10164: mk.conf                          mkl
                   10165: mount                            mprotect
                   10166: mremap                           nb
                   10167: nbcompat                         netlib
                   10168: obstack                          obstack_ptr_grow
                   10169: occurs                           only
                   10170: openblas                         options
                   10171: options.mk                       order
                   10172: override                         override-intltool
                   10173: override-message-intltool        package
                   10174: parallel                         path
                   10175: pax                              paxctl
                   10176: pbulk-index                      pc
                   10177: perl                             perl5
                   10178: perms                            php
                   10179: pkg-build-options                pkg-config
                   10180: pkg_build_options                platform
                   10181: plist                            post-extract
                   10182: post-fetch                       post-wrapper
                   10183: pre-build-checks-hook            pre-configure
                   10184: pre-configure-checks-hook        pre-extract
                   10185: pre-fetch                        print-go-deps
                   10186: print-plist                      print-summary-data
                   10187: privileged-install-hook          pypi
1.211   ! gutterid 10188: python                           r
        !          10189: readme-all                       recv
        !          10190: recvfrom                         regcomp
        !          10191: release-localbase-lock           release-lock
        !          10192: relro                            rename
        !          10193: reorder                          replace
        !          10194: replace_interpreter              reproducible
        !          10195: resolv                           root
        !          10196: ruby                             send
        !          10197: sendfile                         sendto
        !          10198: setenv                           setgid
        !          10199: setprogname                      setuid
        !          10200: sh                               shebang
        !          10201: show                             show-all
        !          10202: show-build-defs                  show-depends
        !          10203: show-deps                        show-distfiles
        !          10204: show-downlevel                   show-subdir-var
        !          10205: show-tools                       show-var
        !          10206: show-vars                        snprintf
        !          10207: socket                           ssp
        !          10208: st_mode                          stage-install
        !          10209: strcasestr                       strict
        !          10210: strip                            strndup
        !          10211: strnlen                          strsep
        !          10212: subst                            substitutions
        !          10213: sun                              sunpro
        !          10214: sunwspro                         symlink
        !          10215: test                             test-env
        !          10216: tex                              texlive
        !          10217: tmp                              tool
        !          10218: tools                            tools-libtool-m4-override
        !          10219: type                             ulimit
        !          10220: undefined                        undo-replace
        !          10221: unlimit                          unprivileged
        !          10222: unprivileged-install-hook        unstripped
        !          10223: update                           upload
        !          10224: upload-distfiles                 use_tools
        !          10225: user                             utimes
        !          10226: vasprintf                        verbose
        !          10227: vsnprintf                        warn
        !          10228: warning                          warnings
        !          10229: warnx                            wattr_off
        !          10230: wattr_on                         work
        !          10231: wrapper                          wrkdir
1.154     rillig   10232: 
1.207     leot     10233: Appendix F. Editing guidelines for the pkgsrc guide
1.1       dsieger  10234: 
                   10235: Table of Contents
                   10236: 
1.207     leot     10237: F.1. Make targets
                   10238: F.2. Procedure
1.1       dsieger  10239: 
                   10240: This section contains information on editing the pkgsrc guide itself.
                   10241: 
1.207     leot     10242: F.1. Make targets
1.1       dsieger  10243: 
                   10244: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
                   10245: files are created from it:
                   10246: 
                   10247:   * pkgsrc/doc/pkgsrc.txt
                   10248: 
                   10249:   * pkgsrc/doc/pkgsrc.html
                   10250: 
1.174     leot     10251:   * https://www.NetBSD.org/docs/pkgsrc/
1.1       dsieger  10252: 
1.174     leot     10253:   * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the
                   10254:     pkgsrc guide.
1.1       dsieger  10255: 
1.174     leot     10256:   * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
1.2       rillig   10257:     pkgsrc guide.
1.1       dsieger  10258: 
1.207     leot     10259: F.2. Procedure
1.1       dsieger  10260: 
                   10261: The procedure to edit the pkgsrc guide is:
                   10262: 
1.190     bacon    10263:  1. Make sure you have checked out the htdocs repository into a sibling
                   10264:     directory of your pkgsrc directory. You will need the ability to commit
                   10265:     from both pkgsrc and htdocs.
                   10266: 
                   10267:  2. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46      obache   10268:     other XML-based NetBSD documentation) installed. These are automatically
                   10269:     installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1       dsieger  10270: 
1.190     bacon    10271:  3. Run cd doc/guide to get to the right directory. All further steps will take
1.1       dsieger  10272:     place here.
                   10273: 
1.190     bacon    10274:  4. Edit the XML file(s) in files/.
1.1       dsieger  10275: 
1.190     bacon    10276:  5. Run bmake to check the pkgsrc guide for valid XML and to build the final
1.1       dsieger  10277:     output files. If you get any errors at this stage, you can just edit the
                   10278:     files, as there are only symbolic links in the working directory, pointing
                   10279:     to the files in files/.
                   10280: 
1.190     bacon    10281:  6. (cd files && cvs commit)
1.1       dsieger  10282: 
1.190     bacon    10283:  7. Run bmake clean && bmake to regenerate the output files with the proper RCS
1.1       dsieger  10284:     Ids.
                   10285: 
1.190     bacon    10286:  8. Run bmake regen to install and commit the files in both pkgsrc/doc and
1.1       dsieger  10287:     htdocs.
                   10288: 
                   10289:     Note
                   10290: 
                   10291:     If you have added, removed or renamed some chapters, you need to
                   10292:     synchronize them using cvs add or cvs delete in the htdocs directory.
                   10293: 

CVSweb <webmaster@jp.NetBSD.org>