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

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.166     leot       15: Copyright   1994-2020 The NetBSD Foundation, Inc
1.1       dsieger    16: 
1.166     leot       17: $NetBSD: pkgsrc.xml,v 1.36 2020/01/03 15:55:24 leot 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
                     70:             5.1.3. Deinstalling packages
                     71:             5.1.4. Getting information about installed packages
                     72:             5.1.5. Checking for security vulnerabilities in installed packages
                     73:             5.1.6. Finding if newer versions of your installed packages are in
1.1       dsieger    74:                 pkgsrc
1.154     rillig     75:             5.1.7. Other administrative functions
1.1       dsieger    76: 
1.154     rillig     77:         5.2. Building packages from source
1.1       dsieger    78: 
1.154     rillig     79:             5.2.1. Requirements
                     80:             5.2.2. Fetching distfiles
                     81:             5.2.3. How to build and install
1.1       dsieger    82: 
1.154     rillig     83:     6. Configuring pkgsrc
1.1       dsieger    84: 
1.154     rillig     85:         6.1. General configuration
                     86:         6.2. Variables affecting the build process
                     87:         6.3. Variables affecting the installation process
                     88:         6.4. Selecting and configuring the compiler
1.1       dsieger    89: 
1.154     rillig     90:             6.4.1. Selecting the compiler
                     91:             6.4.2. Additional flags to the compiler (CFLAGS)
                     92:             6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger    93: 
1.154     rillig     94:         6.5. Developer/advanced settings
                     95:         6.6. Selecting Build Options
1.1       dsieger    96: 
1.154     rillig     97:     7. Creating binary packages
1.1       dsieger    98: 
1.154     rillig     99:         7.1. Building a single binary package
                    100:         7.2. Settings for creation of binary packages
1.1       dsieger   101: 
1.154     rillig    102:     8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig    103: 
1.154     rillig    104:         8.1. Preparations
1.180     rillig    105:         8.2. Running a bulk build
1.6       rillig    106: 
1.154     rillig    107:             8.2.1. Configuration
1.6       rillig    108: 
1.154     rillig    109:         8.3. Requirements of a full bulk build
1.178     rillig    110:         8.4. Bulk build variants
1.6       rillig    111: 
1.179     rillig    112:             8.4.1. Detect unknown configure options
                    113:             8.4.2. Detect classes of bugs by forcing compiler warnings
1.181   ! rillig    114:             8.4.3. Force compiler options only in the build phase
        !           115:             8.4.4. Use custom directories
        !           116:             8.4.5. Turn warnings into errors
        !           117:             8.4.6. Reject packages for which pkglint reports errors
        !           118:             8.4.7. Reject packages that contain forbidden strings
        !           119:             8.4.8. Reject packages whose self-test fails
        !           120:             8.4.9. Reject packages that use undefined shell variables
        !           121:             8.4.10. Turn off verbose logging
1.178     rillig    122: 
                    123:         8.5. Creating a multiple CD-ROM packages collection
                    124: 
                    125:             8.5.1. Example of cdpack
1.6       rillig    126: 
1.154     rillig    127:     9. Directory layout of the installed files
1.6       rillig    128: 
1.154     rillig    129:         9.1. File system layout in ${LOCALBASE}
                    130:         9.2. File system layout in ${VARBASE}
1.6       rillig    131: 
1.154     rillig    132:     10. Frequently Asked Questions
1.6       rillig    133: 
1.154     rillig    134:         10.1. Are there any mailing lists for pkg-related discussion?
                    135:         10.2. Utilities for package management (pkgtools)
                    136:         10.3. How to use pkgsrc as non-root
                    137:         10.4. How to resume transfers when fetching distfiles?
                    138:         10.5. How can I install/use modular X.org from pkgsrc?
                    139:         10.6. How to fetch files from behind a firewall
                    140:         10.7. How to fetch files from HTTPS sites
                    141:         10.8. How do I tell make fetch to do passive FTP?
                    142:         10.9. How to fetch all distfiles at once
                    143:         10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc"
1.24      wiz       144:             mean?
1.154     rillig    145:         10.11. What does "Could not find bsd.own.mk" mean?
                    146:         10.12. Using 'sudo' with pkgsrc
                    147:         10.13. How do I change the location of configuration files?
                    148:         10.14. Automated security checks
                    149:         10.15. Why do some packages ignore my CFLAGS?
                    150:         10.16. A package does not build. What shall I do?
                    151:         10.17. What does "Makefile appears to contain unresolved cvs/rcs/???
1.24      wiz       152:             merge conflicts" mean?
1.1       dsieger   153: 
                    154: II. The pkgsrc developer's guide
                    155: 
1.154     rillig    156:     11. Getting help
                    157:     12. Creating a new pkgsrc package from scratch
1.1       dsieger   158: 
1.154     rillig    159:         12.1. Common types of packages
1.1       dsieger   160: 
1.154     rillig    161:             12.1.1. Perl modules
                    162:             12.1.2. Python modules and programs
1.160     brook     163:             12.1.3. R packages
                    164:             12.1.4. TeXlive packages
1.1       dsieger   165: 
1.154     rillig    166:         12.2. Examples
1.1       dsieger   167: 
1.154     rillig    168:             12.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger   169: 
1.154     rillig    170:     13. Package components - files, directories and contents
1.1       dsieger   171: 
1.154     rillig    172:         13.1. Makefile
                    173:         13.2. distinfo
                    174:         13.3. patches/*
1.1       dsieger   175: 
1.154     rillig    176:             13.3.1. Structure of a single patch file
                    177:             13.3.2. Creating patch files
                    178:             13.3.3. Sources where the patch files come from
                    179:             13.3.4. Patching guidelines
                    180:             13.3.5. Feedback to the author
1.1       dsieger   181: 
1.154     rillig    182:         13.4. Other mandatory files
                    183:         13.5. Optional files
1.1       dsieger   184: 
1.154     rillig    185:             13.5.1. Files affecting the binary package
                    186:             13.5.2. Files affecting the build process
                    187:             13.5.3. Files affecting nothing at all
1.1       dsieger   188: 
1.154     rillig    189:         13.6. work*
                    190:         13.7. files/*
1.1       dsieger   191: 
1.154     rillig    192:     14. Programming in Makefiles
1.1       dsieger   193: 
1.154     rillig    194:         14.1. Caveats
                    195:         14.2. Makefile variables
1.1       dsieger   196: 
1.154     rillig    197:             14.2.1. Naming conventions
1.1       dsieger   198: 
1.154     rillig    199:         14.3. Code snippets
1.1       dsieger   200: 
1.154     rillig    201:             14.3.1. Adding things to a list
                    202:             14.3.2. Echoing a string exactly as-is
                    203:             14.3.3. Passing CFLAGS to GNU configure scripts
                    204:             14.3.4. Handling possibly empty variables
1.1       dsieger   205: 
1.154     rillig    206:     15. PLIST issues
1.1       dsieger   207: 
1.154     rillig    208:         15.1. RCS ID
                    209:         15.2. Semi-automatic PLIST generation
                    210:         15.3. Tweaking output of make print-PLIST
                    211:         15.4. Variable substitution in PLIST
                    212:         15.5. Man page compression
                    213:         15.6. Changing PLIST source with PLIST_SRC
                    214:         15.7. Platform-specific and differing PLISTs
                    215:         15.8. Build-specific PLISTs
                    216:         15.9. Sharing directories between packages
1.1       dsieger   217: 
1.154     rillig    218:     16. Buildlink methodology
1.1       dsieger   219: 
1.154     rillig    220:         16.1. Converting packages to use buildlink3
                    221:         16.2. Writing buildlink3.mk files
1.1       dsieger   222: 
1.154     rillig    223:             16.2.1. Anatomy of a buildlink3.mk file
                    224:             16.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
1.27      wiz       225:                 BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
1.1       dsieger   226: 
1.154     rillig    227:         16.3. Writing builtin.mk files
1.1       dsieger   228: 
1.154     rillig    229:             16.3.1. Anatomy of a builtin.mk file
                    230:             16.3.2. Global preferences for native or pkgsrc software
1.1       dsieger   231: 
1.154     rillig    232:     17. The pkginstall framework
1.1       dsieger   233: 
1.154     rillig    234:         17.1. Files and directories outside the installation prefix
1.1       dsieger   235: 
1.154     rillig    236:             17.1.1. Directory manipulation
                    237:             17.1.2. File manipulation
1.1       dsieger   238: 
1.154     rillig    239:         17.2. Configuration files
1.1       dsieger   240: 
1.154     rillig    241:             17.2.1. How PKG_SYSCONFDIR is set
                    242:             17.2.2. Telling the software where configuration files are
                    243:             17.2.3. Patching installations
                    244:             17.2.4. Disabling handling of configuration files
1.1       dsieger   245: 
1.154     rillig    246:         17.3. System startup scripts
1.1       dsieger   247: 
1.154     rillig    248:             17.3.1. Disabling handling of system startup scripts
1.1       dsieger   249: 
1.154     rillig    250:         17.4. System users and groups
                    251:         17.5. System shells
1.1       dsieger   252: 
1.154     rillig    253:             17.5.1. Disabling shell registration
1.1       dsieger   254: 
1.154     rillig    255:         17.6. Fonts
1.1       dsieger   256: 
1.154     rillig    257:             17.6.1. Disabling automatic update of the fonts databases
1.1       dsieger   258: 
1.154     rillig    259:     18. Options handling
1.1       dsieger   260: 
1.154     rillig    261:         18.1. Global default options
                    262:         18.2. Converting packages to use bsd.options.mk
                    263:         18.3. Option Names
                    264:         18.4. Determining the options of dependencies
1.1       dsieger   265: 
1.154     rillig    266:     19. The build process
1.1       dsieger   267: 
1.154     rillig    268:         19.1. Introduction
                    269:         19.2. Program location
                    270:         19.3. Directories used during the build process
                    271:         19.4. Running a phase
                    272:         19.5. The fetch phase
1.1       dsieger   273: 
1.154     rillig    274:             19.5.1. What to fetch and where to get it from
                    275:             19.5.2. How are the files fetched?
1.1       dsieger   276: 
1.154     rillig    277:         19.6. The checksum phase
                    278:         19.7. The extract phase
                    279:         19.8. The patch phase
                    280:         19.9. The tools phase
                    281:         19.10. The wrapper phase
                    282:         19.11. The configure phase
                    283:         19.12. The build phase
                    284:         19.13. The test phase
                    285:         19.14. The install phase
                    286:         19.15. The package phase
                    287:         19.16. Cleaning up
                    288:         19.17. Other helpful targets
1.1       dsieger   289: 
1.154     rillig    290:     20. Tools needed for building or running
1.1       dsieger   291: 
1.154     rillig    292:         20.1. Tools for pkgsrc builds
                    293:         20.2. Tools needed by packages
                    294:         20.3. Tools provided by platforms
1.1       dsieger   295: 
1.154     rillig    296:     21. Making your package work
1.1       dsieger   297: 
1.154     rillig    298:         21.1. General operation
1.1       dsieger   299: 
1.154     rillig    300:             21.1.1. How to pull in user-settable variables from mk.conf
                    301:             21.1.2. User interaction
                    302:             21.1.3. Handling licenses
                    303:             21.1.4. Restricted packages
                    304:             21.1.5. Handling dependencies
                    305:             21.1.6. Handling conflicts with other packages
                    306:             21.1.7. Packages that cannot or should not be built
                    307:             21.1.8. Packages which should not be deleted, once installed
                    308:             21.1.9. Handling packages with security problems
                    309:             21.1.10. How to handle incrementing versions when fixing an
1.1       dsieger   310:                 existing package
1.154     rillig    311:             21.1.11. Substituting variable text in the package files (the SUBST
1.1       dsieger   312:                 framework)
                    313: 
1.154     rillig    314:         21.2. The fetch phase
1.1       dsieger   315: 
1.154     rillig    316:             21.2.1. Packages whose distfiles aren't available for plain
1.1       dsieger   317:                 downloading
1.154     rillig    318:             21.2.2. How to handle modified distfiles with the 'old' name
                    319:             21.2.3. Packages hosted on github.com
1.1       dsieger   320: 
1.154     rillig    321:         21.3. The configure phase
1.1       dsieger   322: 
1.154     rillig    323:             21.3.1. Shared libraries - libtool
                    324:             21.3.2. Using libtool on GNU packages that already support libtool
                    325:             21.3.3. GNU Autoconf/Automake
                    326: 
                    327:         21.4. Programming languages
                    328: 
                    329:             21.4.1. C, C++, and Fortran
                    330:             21.4.2. Java
                    331:             21.4.3. Packages containing perl scripts
                    332:             21.4.4. Packages containing shell scripts
                    333:             21.4.5. Other programming languages
                    334: 
                    335:         21.5. The build phase
                    336: 
                    337:             21.5.1. Compiling C and C++ code conditionally
                    338:             21.5.2. How to handle compiler bugs
1.172     rillig    339:             21.5.3. No such file or directory
                    340:             21.5.4. Undefined reference to "..."
                    341:             21.5.5. Running out of memory
1.154     rillig    342: 
                    343:         21.6. The install phase
                    344: 
                    345:             21.6.1. Creating needed directories
                    346:             21.6.2. Where to install documentation
                    347:             21.6.3. Installing highscore files
                    348:             21.6.4. Adding DESTDIR support to packages
                    349:             21.6.5. Packages with hardcoded paths to other interpreters
                    350:             21.6.6. Packages installing perl modules
                    351:             21.6.7. Packages installing info files
                    352:             21.6.8. Packages installing man pages
                    353:             21.6.9. Packages installing GConf data files
                    354:             21.6.10. Packages installing scrollkeeper/rarian data files
                    355:             21.6.11. Packages installing X11 fonts
                    356:             21.6.12. Packages installing GTK2 modules
                    357:             21.6.13. Packages installing SGML or XML data
                    358:             21.6.14. Packages installing extensions to the MIME database
                    359:             21.6.15. Packages using intltool
                    360:             21.6.16. Packages installing startup scripts
                    361:             21.6.17. Packages installing TeX modules
                    362:             21.6.18. Packages supporting running binaries in emulation
                    363:             21.6.19. Packages installing hicolor theme icons
                    364:             21.6.20. Packages installing desktop files
                    365: 
                    366:         21.7. Marking packages as having problems
                    367: 
                    368:     22. Debugging
                    369:     23. Submitting and Committing
                    370: 
                    371:         23.1. Submitting binary packages
                    372:         23.2. Submitting source packages (for non-NetBSD-developers)
                    373:         23.3. General notes when adding, updating, or removing packages
                    374:         23.4. Commit Messages
                    375:         23.5. Committing: Adding a package to CVS
                    376:         23.6. Updating a package to a newer version
                    377:         23.7. Renaming a package in pkgsrc
                    378:         23.8. Moving a package in pkgsrc
                    379: 
                    380:     24. Frequently Asked Questions
                    381:     25. GNOME packaging and porting
                    382: 
                    383:         25.1. Meta packages
                    384:         25.2. Packaging a GNOME application
                    385:         25.3. Updating GNOME to a newer version
                    386:         25.4. Patching guidelines
1.1       dsieger   387: 
                    388: III. The pkgsrc infrastructure internals
                    389: 
1.154     rillig    390:     26. Design of the pkgsrc infrastructure
1.1       dsieger   391: 
1.154     rillig    392:         26.1. The meaning of variable definitions
                    393:         26.2. Avoiding problems before they arise
                    394:         26.3. Variable evaluation
1.1       dsieger   395: 
1.154     rillig    396:             26.3.1. At load time
                    397:             26.3.2. At runtime
1.1       dsieger   398: 
1.154     rillig    399:         26.4. How can variables be specified?
                    400:         26.5. Designing interfaces for Makefile fragments
1.1       dsieger   401: 
1.154     rillig    402:             26.5.1. Procedures with parameters
                    403:             26.5.2. Actions taken on behalf of parameters
1.1       dsieger   404: 
1.154     rillig    405:         26.6. The order in which files are loaded
1.1       dsieger   406: 
1.154     rillig    407:             26.6.1. The order in bsd.prefs.mk
                    408:             26.6.2. The order in bsd.pkg.mk
1.1       dsieger   409: 
1.154     rillig    410:     27. Regression tests
1.1       dsieger   411: 
1.154     rillig    412:         27.1. Running the regression tests
                    413:         27.2. Adding a new regression test
1.1       dsieger   414: 
1.154     rillig    415:             27.2.1. Overridable functions
                    416:             27.2.2. Helper functions
1.1       dsieger   417: 
1.154     rillig    418:     28. Porting pkgsrc
1.1       dsieger   419: 
1.154     rillig    420:         28.1. Porting pkgsrc to a new operating system
1.1       dsieger   421: 
                    422: A. A simple example package: bison
                    423: 
                    424:     A.1. files
                    425: 
                    426:         A.1.1. Makefile
                    427:         A.1.2. DESCR
                    428:         A.1.3. PLIST
                    429:         A.1.4. Checking a package with pkglint
                    430: 
                    431:     A.2. Steps for building, installing, packaging
                    432: 
                    433: B. Build logs
                    434: 
                    435:     B.1. Building figlet
                    436:     B.2. Packaging figlet
                    437: 
                    438: C. Directory layout of the pkgsrc FTP server
                    439: 
1.23      jakllsch  440:     C.1. distfiles: The distributed source files
                    441:     C.2. misc: Miscellaneous things
                    442:     C.3. packages: Binary packages
                    443:     C.4. reports: Bulk build reports
1.148     leot      444:     C.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger   445: 
1.154     rillig    446: D. Help topics
                    447: E. Editing guidelines for the pkgsrc guide
1.1       dsieger   448: 
1.154     rillig    449:     E.1. Make targets
                    450:     E.2. Procedure
1.1       dsieger   451: 
                    452: List of Tables
                    453: 
                    454: 1.1. Platforms supported by pkgsrc
1.154     rillig    455: 13.1. Patching examples
                    456: 25.1. PLIST handling for GNOME packages
1.1       dsieger   457: 
                    458: Chapter 1. What is pkgsrc?
                    459: 
                    460: Table of Contents
                    461: 
                    462: 1.1. Introduction
                    463: 
                    464:     1.1.1. Why pkgsrc?
                    465:     1.1.2. Supported platforms
                    466: 
                    467: 1.2. Overview
                    468: 1.3. Terminology
                    469: 
                    470:     1.3.1. Roles involved in pkgsrc
                    471: 
                    472: 1.4. Typography
                    473: 
                    474: 1.1. Introduction
                    475: 
                    476: There is a lot of software freely available for Unix-based systems, which is
                    477: usually available in form of the source code. Before such software can be used,
                    478: it needs to be configured to the local system, compiled and installed, and this
                    479: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
                    480: some basic commands to handle binary packages, so that not every user has to
                    481: build the packages for himself, which is a time-costly task.
                    482: 
                    483: pkgsrc currently contains several thousand packages, including:
                    484: 
1.104     sevan     485:   * www/apache24 - The Apache web server
1.1       dsieger   486: 
                    487:   * www/firefox - The Firefox web browser
                    488: 
                    489:   * meta-pkgs/gnome - The GNOME Desktop Environment
                    490: 
1.102     ryoon     491:   * meta-pkgs/kde4 - The K Desktop Environment
1.1       dsieger   492: 
1.108     rillig    493: ? just to name a few.
1.1       dsieger   494: 
                    495: pkgsrc has built-in support for handling varying dependencies, such as pthreads
                    496: and X11, and extended features such as IPv6 support on a range of platforms.
                    497: 
                    498: 1.1.1. Why pkgsrc?
                    499: 
                    500: pkgsrc provides the following key features:
                    501: 
                    502:   * Easy building of software from source as well as the creation and
                    503:     installation of binary packages. The source and latest patches are
                    504:     retrieved from a master or mirror download site, checksum verified, then
                    505:     built on your system. Support for binary-only distributions is available
                    506:     for both native platforms and NetBSD emulated platforms.
                    507: 
                    508:   * All packages are installed in a consistent directory tree, including
                    509:     binaries, libraries, man pages and other documentation.
                    510: 
1.104     sevan     511:   * Tracking of package dependencies automatically, including when performing
                    512:     updates, to ensure required packages are installed. The configuration files
                    513:     of various packages are handled automatically during updates, so local
                    514:     changes are preserved.
1.1       dsieger   515: 
                    516:   * Like NetBSD, pkgsrc is designed with portability in mind and consists of
                    517:     highly portable code. This allows the greatest speed of development when
1.26      spz       518:     porting to a new platform. This portability also ensures that pkgsrc is 
1.1       dsieger   519:     consistent across all platforms.
                    520: 
                    521:   * The installation prefix, acceptable software licenses, international
                    522:     encryption requirements and build-time options for a large number of
                    523:     packages are all set in a simple, central configuration file.
                    524: 
                    525:   * The entire source (not including the distribution files) is freely
                    526:     available under a BSD license, so you may extend and adapt pkgsrc to your
                    527:     needs. Support for local packages and patches is available right out of the
                    528:     box, so you can configure it specifically for your environment.
                    529: 
                    530: The following principles are basic to pkgsrc:
                    531: 
                    532:   * "It should only work if it's right." ? That means, if a package contains
                    533:     bugs, it's better to find them and to complain about them rather than to
                    534:     just install the package and hope that it works. There are numerous checks
1.175     gutterid  535:     in pkgsrc that try to find such bugs: static analysis tools (pkgtools/
1.1       dsieger   536:     pkglint), build-time checks (portability of shell scripts), and
                    537:     post-installation checks (installed files, references to shared libraries,
                    538:     script interpreters).
                    539: 
                    540:   * "If it works, it should work everywhere" ? Like NetBSD has been ported to
                    541:     many hardware architectures, pkgsrc has been ported to many operating
                    542:     systems. Care is taken that packages behave the same on all platforms.
                    543: 
                    544: 1.1.2. Supported platforms
                    545: 
                    546: pkgsrc consists of both a source distribution and a binary distribution for
                    547: these operating systems. After retrieving the required source or binaries, you
                    548: can be up and running with pkgsrc in just minutes!
                    549: 
                    550: pkgsrc was derived from FreeBSD's ports system, and initially developed for
                    551: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
                    552: platforms:
                    553: 
                    554: Table 1.1. Platforms supported by pkgsrc
                    555: 
1.92      sevan     556: +-----------------------------------------------------------------------------+
                    557: |               Platform               | Date Support  |        Notes         |
                    558: |                                      |     Added     |                      |
                    559: |--------------------------------------+---------------+----------------------|
                    560: |NetBSD                                |   Aug 1997    |                      |
                    561: |--------------------------------------+---------------+----------------------|
                    562: |Solaris                               |   Mar 1999    |README.Solaris        |
                    563: |--------------------------------------+---------------+----------------------|
                    564: |Linux                                 |   Jun 1999    |README.Linux          |
                    565: |--------------------------------------+---------------+----------------------|
1.118     sevan     566: |Darwin / Mac OS X / OS X / macOS      |   Oct 2001    |README.MacOSX         |
1.92      sevan     567: |--------------------------------------+---------------+----------------------|
                    568: |FreeBSD                               |   Nov 2002    |README.FreeBSD        |
                    569: |--------------------------------------+---------------+----------------------|
                    570: |OpenBSD                               |   Nov 2002    |README.OpenBSD        |
                    571: |--------------------------------------+---------------+----------------------|
                    572: |IRIX                                  |   Dec 2002    |README.IRIX           |
                    573: |                                      |               |README.IRIX5.3        |
                    574: |--------------------------------------+---------------+----------------------|
                    575: |BSD/OS                                |   Dec 2003    |                      |
                    576: |--------------------------------------+---------------+----------------------|
                    577: |AIX                                   |   Dec 2003    |README.AIX            |
                    578: |--------------------------------------+---------------+----------------------|
                    579: |Interix (Microsoft Windows Services   |   Mar 2004    |README.Interix        |
                    580: |for Unix)                             |               |                      |
                    581: |--------------------------------------+---------------+----------------------|
                    582: |DragonFlyBSD                          |   Oct 2004    |                      |
                    583: |--------------------------------------+---------------+----------------------|
                    584: |OSF/1                                 |   Nov 2004    |README.OSF1           |
                    585: |--------------------------------------+---------------+----------------------|
                    586: |HP-UX                                 |   Apr 2007    |README.HPUX           |
                    587: |--------------------------------------+---------------+----------------------|
                    588: |Haiku                                 |   Sep 2010    |README.Haiku          |
                    589: |--------------------------------------+---------------+----------------------|
                    590: |MirBSD                                |   Jan 2011    |                      |
                    591: |--------------------------------------+---------------+----------------------|
                    592: |Minix3                                |   Nov 2011    |README.Minix3         |
                    593: |--------------------------------------+---------------+----------------------|
                    594: |Cygwin                                |   Mar 2013    |README.Cygwin         |
                    595: |--------------------------------------+---------------+----------------------|
                    596: |GNU/kFreeBSD                          |   Jul 2013    |README.GNUkFreeBSD    |
1.104     sevan     597: |--------------------------------------+---------------+----------------------|
                    598: |Bitrig                                |   Jun 2014    |README.Bitrig         |
1.92      sevan     599: +-----------------------------------------------------------------------------+
1.1       dsieger   600: 
                    601: 
                    602: 1.2. Overview
                    603: 
                    604: This document is divided into three parts. The first, The pkgsrc user's guide,
                    605: describes how one can use one of the packages in the Package Collection, either
                    606: by installing a precompiled binary package, or by building one's own copy using
                    607: the NetBSD package system. The second part, The pkgsrc developer's guide,
                    608: explains how to prepare a package so it can be easily built by other NetBSD
                    609: users without knowing about the package's building details. The third part, The
                    610: pkgsrc infrastructure internals is intended for those who want to understand
                    611: how pkgsrc is implemented.
                    612: 
                    613: This document is available in various formats: HTML, PDF, PS, TXT.
                    614: 
                    615: 1.3. Terminology
                    616: 
                    617: There has been a lot of talk about "ports", "packages", etc. so far. Here is a
                    618: description of all the terminology used within this document.
                    619: 
                    620: Package
                    621: 
                    622:     A set of files and building instructions that describe what's necessary to
                    623:     build a certain piece of software using pkgsrc. Packages are traditionally
1.123     wiz       624:     stored under /usr/pkgsrc, but may be stored in any location, referred to as
                    625:     PKGSRCDIR.
1.1       dsieger   626: 
                    627: The NetBSD package system
                    628: 
                    629:     This is the former name of "pkgsrc". It is part of the NetBSD operating
                    630:     system and can be bootstrapped to run on non-NetBSD operating systems as
                    631:     well. It handles building (compiling), installing, and removing of
                    632:     packages.
                    633: 
                    634: Distfile
                    635: 
                    636:     This term describes the file or files that are provided by the author of
                    637:     the piece of software to distribute his work. All the changes necessary to
                    638:     build on NetBSD are reflected in the corresponding package. Usually the
                    639:     distfile is in the form of a compressed tar-archive, but other types are
                    640:     possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
                    641: 
                    642: Port
                    643: 
                    644:     This is the term used by FreeBSD and OpenBSD people for what we call a
                    645:     package. In NetBSD terminology, "port" refers to a different architecture.
                    646: 
                    647: Precompiled/binary package
                    648: 
                    649:     A set of binaries built with pkgsrc from a distfile and stuffed together in
                    650:     a single .tgz file so it can be installed on machines of the same machine
                    651:     architecture without the need to recompile. Packages are usually generated
                    652:     in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
                    653: 
                    654:     Sometimes, this is referred to by the term "package" too, especially in the
                    655:     context of precompiled packages.
                    656: 
                    657: Program
                    658: 
                    659:     The piece of software to be installed which will be constructed from all
                    660:     the files in the distfile by the actions defined in the corresponding
                    661:     package.
                    662: 
                    663: 1.3.1. Roles involved in pkgsrc
                    664: 
                    665: pkgsrc users
                    666: 
                    667:     The pkgsrc users are people who use the packages provided by pkgsrc.
                    668:     Typically they are system administrators. The people using the software
                    669:     that is inside the packages (maybe called "end users") are not covered by
                    670:     the pkgsrc guide.
                    671: 
                    672:     There are two kinds of pkgsrc users: Some only want to install pre-built
                    673:     binary packages. Others build the pkgsrc packages from source, either for
                    674:     installing them directly or for building binary packages themselves. For
                    675:     pkgsrc users Part I, "The pkgsrc user's guide" should provide all necessary
                    676:     documentation.
                    677: 
                    678: package maintainers
                    679: 
                    680:     A package maintainer creates packages as described in Part II, "The pkgsrc
                    681:     developer's guide".
                    682: 
                    683: infrastructure developers
                    684: 
                    685:     These people are involved in all those files that live in the mk/ directory
                    686:     and below. Only these people should need to read through Part III, "The
                    687:     pkgsrc infrastructure internals", though others might be curious, too.
                    688: 
                    689: 1.4. Typography
                    690: 
                    691: When giving examples for commands, shell prompts are used to show if the
                    692: command should/can be issued as root, or if "normal" user privileges are
1.115     sevan     693: sufficient. We use a # for root's shell prompt, a % for users' shell prompt,
                    694: assuming they use the C-shell or tcsh and a $ for bourne shell and derivatives.
1.1       dsieger   695: 
                    696: Part I. The pkgsrc user's guide
                    697: 
                    698: Table of Contents
                    699: 
1.154     rillig    700: 2. Getting help
                    701: 3. Where to get pkgsrc and how to keep it up-to-date
1.1       dsieger   702: 
1.154     rillig    703:     3.1. Getting pkgsrc for the first time
1.1       dsieger   704: 
1.154     rillig    705:         3.1.1. As tar archive
                    706:         3.1.2. Via anonymous CVS
1.1       dsieger   707: 
1.154     rillig    708:     3.2. Keeping pkgsrc up-to-date
1.1       dsieger   709: 
1.154     rillig    710:         3.2.1. Via tar files
                    711:         3.2.2. Via CVS
1.1       dsieger   712: 
1.154     rillig    713: 4. Using pkgsrc on systems other than NetBSD
1.1       dsieger   714: 
1.154     rillig    715:     4.1. Binary distribution
                    716:     4.2. Bootstrapping pkgsrc
1.1       dsieger   717: 
1.154     rillig    718: 5. Using pkgsrc
1.1       dsieger   719: 
1.154     rillig    720:     5.1. Using binary packages
1.1       dsieger   721: 
1.154     rillig    722:         5.1.1. Finding binary packages
                    723:         5.1.2. Installing binary packages
                    724:         5.1.3. Deinstalling packages
                    725:         5.1.4. Getting information about installed packages
                    726:         5.1.5. Checking for security vulnerabilities in installed packages
                    727:         5.1.6. Finding if newer versions of your installed packages are in
1.1       dsieger   728:             pkgsrc
1.154     rillig    729:         5.1.7. Other administrative functions
1.1       dsieger   730: 
1.154     rillig    731:     5.2. Building packages from source
1.1       dsieger   732: 
1.154     rillig    733:         5.2.1. Requirements
                    734:         5.2.2. Fetching distfiles
                    735:         5.2.3. How to build and install
1.1       dsieger   736: 
1.154     rillig    737: 6. Configuring pkgsrc
1.1       dsieger   738: 
1.154     rillig    739:     6.1. General configuration
                    740:     6.2. Variables affecting the build process
                    741:     6.3. Variables affecting the installation process
                    742:     6.4. Selecting and configuring the compiler
1.1       dsieger   743: 
1.154     rillig    744:         6.4.1. Selecting the compiler
                    745:         6.4.2. Additional flags to the compiler (CFLAGS)
                    746:         6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger   747: 
1.154     rillig    748:     6.5. Developer/advanced settings
                    749:     6.6. Selecting Build Options
1.1       dsieger   750: 
1.154     rillig    751: 7. Creating binary packages
1.1       dsieger   752: 
1.154     rillig    753:     7.1. Building a single binary package
                    754:     7.2. Settings for creation of binary packages
1.1       dsieger   755: 
1.154     rillig    756: 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig    757: 
1.154     rillig    758:     8.1. Preparations
1.180     rillig    759:     8.2. Running a bulk build
1.6       rillig    760: 
1.154     rillig    761:         8.2.1. Configuration
1.6       rillig    762: 
1.154     rillig    763:     8.3. Requirements of a full bulk build
1.178     rillig    764:     8.4. Bulk build variants
                    765: 
1.179     rillig    766:         8.4.1. Detect unknown configure options
                    767:         8.4.2. Detect classes of bugs by forcing compiler warnings
1.181   ! rillig    768:         8.4.3. Force compiler options only in the build phase
        !           769:         8.4.4. Use custom directories
        !           770:         8.4.5. Turn warnings into errors
        !           771:         8.4.6. Reject packages for which pkglint reports errors
        !           772:         8.4.7. Reject packages that contain forbidden strings
        !           773:         8.4.8. Reject packages whose self-test fails
        !           774:         8.4.9. Reject packages that use undefined shell variables
        !           775:         8.4.10. Turn off verbose logging
1.6       rillig    776: 
1.178     rillig    777:     8.5. Creating a multiple CD-ROM packages collection
                    778: 
                    779:         8.5.1. Example of cdpack
1.6       rillig    780: 
1.154     rillig    781: 9. Directory layout of the installed files
1.6       rillig    782: 
1.154     rillig    783:     9.1. File system layout in ${LOCALBASE}
                    784:     9.2. File system layout in ${VARBASE}
1.6       rillig    785: 
1.154     rillig    786: 10. Frequently Asked Questions
1.6       rillig    787: 
1.154     rillig    788:     10.1. Are there any mailing lists for pkg-related discussion?
                    789:     10.2. Utilities for package management (pkgtools)
                    790:     10.3. How to use pkgsrc as non-root
                    791:     10.4. How to resume transfers when fetching distfiles?
                    792:     10.5. How can I install/use modular X.org from pkgsrc?
                    793:     10.6. How to fetch files from behind a firewall
                    794:     10.7. How to fetch files from HTTPS sites
                    795:     10.8. How do I tell make fetch to do passive FTP?
                    796:     10.9. How to fetch all distfiles at once
                    797:     10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
                    798:     10.11. What does "Could not find bsd.own.mk" mean?
                    799:     10.12. Using 'sudo' with pkgsrc
                    800:     10.13. How do I change the location of configuration files?
                    801:     10.14. Automated security checks
                    802:     10.15. Why do some packages ignore my CFLAGS?
                    803:     10.16. A package does not build. What shall I do?
                    804:     10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24      wiz       805:         conflicts" mean?
1.1       dsieger   806: 
1.154     rillig    807: Chapter 2. Getting help
                    808: 
                    809: To get help when using pkgsrc, the definitive source is this document, the
                    810: pkgsrc guide. If you don't find anything here, there are alternatives:
                    811: 
                    812:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
                    813:     Run bmake help topic=? to get help for any topic, such as a variable name
                    814:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                    815:     like strcasecmp or any other topic.
                    816: 
                    817:     The available help topics are listed in Appendix D, Help topics.
                    818: 
1.163     rillig    819:   * To see the value of a single variable, run bmake show-var VARNAME=X.
                    820: 
                    821:   * To see the values of the most common variables, run bmake show-all. These
                    822:     variables are grouped by topic. To see the variables for a single topic,
                    823:     run bmake show-all-topic, for example bmake show-all-fetch.
                    824: 
1.154     rillig    825:   * The pkgsrc-users mailing list, to which you can subscribe and then ask your
                    826:     questions.
                    827: 
                    828:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                    829:     a specialized chat program such as XChat. Pick any user name and join the
                    830:     channel #pkgsrc.
                    831: 
                    832: Chapter 3. Where to get pkgsrc and how to keep it up-to-date
1.1       dsieger   833: 
                    834: Table of Contents
                    835: 
1.154     rillig    836: 3.1. Getting pkgsrc for the first time
1.1       dsieger   837: 
1.154     rillig    838:     3.1.1. As tar archive
                    839:     3.1.2. Via anonymous CVS
1.1       dsieger   840: 
1.154     rillig    841: 3.2. Keeping pkgsrc up-to-date
1.1       dsieger   842: 
1.154     rillig    843:     3.2.1. Via tar files
                    844:     3.2.2. Via CVS
1.1       dsieger   845: 
                    846: Before you download and extract the files, you need to decide where you want to
                    847: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
                    848: usr/pkgsrc. You are though free to install the sources and binary packages
                    849: wherever you want in your filesystem, provided that the pathname does not
                    850: contain white-space or other characters that are interpreted specially by the
                    851: shell and some other programs. A safe bet is to use only letters, digits,
                    852: underscores and dashes.
                    853: 
1.154     rillig    854: 3.1. Getting pkgsrc for the first time
1.1       dsieger   855: 
1.25      wiz       856: Before you download any pkgsrc files, you should decide whether you want the 
1.1       dsieger   857: current branch or the stable branch. The latter is forked on a quarterly basis
                    858: from the current branch and only gets modified for security updates. The names
                    859: of the stable branches are built from the year and the quarter, for example
1.174     leot      860: 2020Q1.
1.1       dsieger   861: 
                    862: The second step is to decide how you want to download pkgsrc. You can get it as
1.24      wiz       863: a tar file or via CVS. Both ways are described here.
1.1       dsieger   864: 
1.52      asau      865: Note that tar archive contains CVS working copy. Thus you can switch to using
                    866: CVS at any later time.
1.1       dsieger   867: 
1.154     rillig    868: 3.1.1. As tar archive
1.52      asau      869: 
1.151     sevan     870: The primary download location for all pkgsrc files is https://cdn.NetBSD.org/
                    871: pub/pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same
                    872: location). There are a number of subdirectories for different purposes, which
                    873: are described in detail in Appendix C, Directory layout of the pkgsrc FTP
                    874: server.
1.1       dsieger   875: 
1.52      asau      876: The tar archive for the current branch is in the directory current and is
1.118     sevan     877: called pkgsrc.tar.gz. It is autogenerated weekly.
1.52      asau      878: 
                    879: To save download time we provide bzip2- and xz-compressed archives which are
                    880: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
                    881: 
                    882: You can fetch the same files using FTP.
1.1       dsieger   883: 
1.174     leot      884: The tar file for the stable branch 2020Q1 is in the directory pkgsrc-2020Q1 and
1.59      jnemeth   885: is also called pkgsrc.tar.gz.
1.1       dsieger   886: 
1.136     leot      887: To download the latest pkgsrc stable tarball, run:
1.12      weinem    888: 
1.174     leot      889: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2020Q1/pkgsrc.tar.gz
1.12      weinem    890: 
1.78      snj       891: If you prefer, you can also fetch it using "wget", "curl", or your web browser.
1.52      asau      892: 
1.12      weinem    893: Then, extract it with:
                    894: 
1.78      snj       895: $ tar -xzf pkgsrc.tar.gz -C /usr
1.12      weinem    896: 
                    897: This will create the directory pkgsrc/ in /usr/ and all the package source will
                    898: be stored under /usr/pkgsrc/.
                    899: 
                    900: To download pkgsrc-current, run:
                    901: 
                    902: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1       dsieger   903: 
1.154     rillig    904: 3.1.2. Via anonymous CVS
1.1       dsieger   905: 
1.24      wiz       906: To fetch a specific pkgsrc stable branch, run:
1.1       dsieger   907: 
1.174     leot      908: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2020Q1 -P pkgsrc
1.13      weinem    909: 
1.24      wiz       910: This will create the directory pkgsrc/ in your /usr/ directory and all the
                    911: package source will be stored under /usr/pkgsrc/.
                    912: 
                    913: To fetch the pkgsrc current branch, run:
1.1       dsieger   914: 
1.40      wiz       915: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   916: 
1.30      dholland  917: Refer to the list of available mirrors to choose a faster CVS mirror, if
                    918: needed.
1.1       dsieger   919: 
1.24      wiz       920: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1       dsieger   921: 
1.40      wiz       922: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   923: 
1.24      wiz       924: Refer to documentation on your command shell how to set CVS_RSH=ssh
                    925: permanently. For Bourne shells, you can set it in your .profile or better
                    926: globally in /etc/profile:
                    927: 
                    928: # set CVS remote shell command
                    929: CVS_RSH=ssh
                    930: export CVS_RSH
1.12      weinem    931: 
1.13      weinem    932: By default, CVS doesn't do things like most people would expect it to do. But
                    933: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12      weinem    934: directory and saving the following lines to it. This file will save you lots of
                    935: headache and some bug reports, so we strongly recommend it. You can find an
                    936: explanation of this file in the CVS documentation.
1.2       rillig    937: 
                    938: # recommended CVS configuration file from the pkgsrc guide
1.155     sevan     939: cvs -q
1.2       rillig    940: checkout -P
1.4       rillig    941: update -dP
                    942: diff -upN
1.2       rillig    943: rdiff -u
1.24      wiz       944: release -d
1.1       dsieger   945: 
1.154     rillig    946: 3.2. Keeping pkgsrc up-to-date
1.1       dsieger   947: 
                    948: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
                    949: have first installed it via a tar file). It saves bandwidth and hard disk
                    950: activity, compared to downloading the tar file again.
                    951: 
1.154     rillig    952: 3.2.1. Via tar files
1.1       dsieger   953: 
                    954: Warning
                    955: 
                    956: When updating from a tar file, you first need to completely remove the old
                    957: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
                    958: the mean time will not be removed on your local disk, resulting in
                    959: inconsistencies. When removing the old files, any changes that you have done to
                    960: the pkgsrc files will be lost after updating. Therefore updating via CVS is
                    961: strongly recommended.
                    962: 
                    963: Note that by default the distfiles and the binary packages are saved in the
                    964: pkgsrc tree, so don't forget to rescue them before updating. You can also
1.78      snj       965: configure pkgsrc to store distfiles and packages in directories outside the
1.154     rillig    966: pkgsrc tree by setting the DISTDIR and PACKAGES variables. See Chapter 6, 
1.78      snj       967: Configuring pkgsrc for the details.
1.1       dsieger   968: 
                    969: To update pkgsrc from a tar file, download the tar file as explained above.
                    970: Then, make sure that you have not made any changes to the files in the pkgsrc
                    971: directory. Remove the pkgsrc directory and extract the new tar file. Done.
                    972: 
1.154     rillig    973: 3.2.2. Via CVS
1.1       dsieger   974: 
1.26      spz       975: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12      weinem    976: 
1.26      spz       977: $ cd /usr/pkgsrc && cvs update -dP
                    978: 
                    979: If you get error messages from rsh, you need to set CVS_RSH variable as
                    980: described above. E.g.:
                    981: 
                    982: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1       dsieger   983: 
1.154     rillig    984: 3.2.2.1. Switching between different pkgsrc branches
1.1       dsieger   985: 
                    986: When updating pkgsrc, the CVS program keeps track of the branch you selected.
                    987: But if you, for whatever reason, want to switch from the stable branch to the
                    988: current one, you can do it by adding the option "-A" after the "update"
1.25      wiz       989: keyword. To switch from the current branch back to the stable branch, add the "
1.174     leot      990: -rpkgsrc-2020Q1" option.
1.1       dsieger   991: 
1.154     rillig    992: 3.2.2.2. What happens to my changes when updating?
1.1       dsieger   993: 
                    994: When you update pkgsrc, the CVS program will only touch those files that are
                    995: registered in the CVS repository. That means that any packages that you created
                    996: on your own will stay unmodified. If you change files that are managed by CVS,
                    997: later updates will try to merge your changes with those that have been done by
                    998: others. See the CVS manual, chapter "update" for details.
                    999: 
1.154     rillig   1000: Chapter 4. Using pkgsrc on systems other than NetBSD
1.1       dsieger  1001: 
                   1002: Table of Contents
                   1003: 
1.154     rillig   1004: 4.1. Binary distribution
                   1005: 4.2. Bootstrapping pkgsrc
1.1       dsieger  1006: 
1.154     rillig   1007: 4.1. Binary distribution
1.1       dsieger  1008: 
1.154     rillig   1009: See Section 5.1, "Using binary packages".
1.1       dsieger  1010: 
1.154     rillig   1011: 4.2. Bootstrapping pkgsrc
1.1       dsieger  1012: 
1.44      asau     1013: pkgsrc can be bootstrapped for use in two different modes: privileged and
                   1014: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45      asau     1015: programs are installed under one particular user and cannot utilise privileged
1.44      asau     1016: operations (packages don't create special users and all special file
                   1017: permissions like setuid are ignored).
                   1018: 
1.1       dsieger  1019: Installing the bootstrap kit from source should be as simple as:
                   1020: 
1.60      asau     1021: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger  1022: # cd pkgsrc/bootstrap
                   1023: # ./bootstrap
                   1024: 
                   1025: 
1.44      asau     1026: To bootstrap in unprivileged mode pass "--unprivileged" flag to bootstrap
                   1027: 
                   1028: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
1.118     sevan    1029: will be installed in, and /usr/pkg/pkgdb for the package database directory
                   1030: where pkgsrc will do its internal bookkeeping, /var is used as varbase, where
1.44      asau     1031: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
1.118     sevan    1032: for prefix, ~/pkg/pkgdb for the package database, and ~/pkg/var for varbase.
1.44      asau     1033: 
                   1034: You can change default layout using command-line arguments. Run "./bootstrap
                   1035: --help" to get details.
1.1       dsieger  1036: 
                   1037: Note
                   1038: 
                   1039: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
                   1040: For examples in this guide, use bmake instead of "make".
                   1041: 
1.44      asau     1042: Note
                   1043: 
                   1044: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
                   1045: directories. Use bmake corresponding to the installation you're working with to
                   1046: build and install packages.
                   1047: 
1.154     rillig   1048: Chapter 5. Using pkgsrc
1.1       dsieger  1049: 
                   1050: Table of Contents
                   1051: 
1.154     rillig   1052: 5.1. Using binary packages
1.1       dsieger  1053: 
1.154     rillig   1054:     5.1.1. Finding binary packages
                   1055:     5.1.2. Installing binary packages
                   1056:     5.1.3. Deinstalling packages
                   1057:     5.1.4. Getting information about installed packages
                   1058:     5.1.5. Checking for security vulnerabilities in installed packages
                   1059:     5.1.6. Finding if newer versions of your installed packages are in pkgsrc
                   1060:     5.1.7. Other administrative functions
                   1061: 
                   1062: 5.2. Building packages from source
                   1063: 
                   1064:     5.2.1. Requirements
                   1065:     5.2.2. Fetching distfiles
                   1066:     5.2.3. How to build and install
1.1       dsieger  1067: 
                   1068: Basically, there are two ways of using pkgsrc. The first is to only install the
                   1069: package tools and to use binary packages that someone else has prepared. This
                   1070: is the "pkg" in pkgsrc. The second way is to install the "src" of pkgsrc, too.
                   1071: Then you are able to build your own packages, and you can still use binary
                   1072: packages from someone else.
                   1073: 
1.154     rillig   1074: 5.1. Using binary packages
1.1       dsieger  1075: 
1.151     sevan    1076: On the cdn.NetBSD.org site and mirrors, there are collections of binary
1.9       rillig   1077: packages, ready to be installed. These binary packages have been built using
                   1078: the default settings for the directories, that is:
                   1079: 
                   1080:   * /usr/pkg for LOCALBASE, where most of the files are installed,
                   1081: 
                   1082:   * /usr/pkg/etc for configuration files,
                   1083: 
                   1084:   * /var for VARBASE, where those files are installed that may change after
                   1085:     installation.
                   1086: 
                   1087: If you cannot use these directories for whatever reasons (maybe because you're
                   1088: not root), you cannot use these binary packages, but have to build the packages
1.154     rillig   1089: yourself, which is explained in Section 4.2, "Bootstrapping pkgsrc".
1.1       dsieger  1090: 
1.154     rillig   1091: 5.1.1. Finding binary packages
1.1       dsieger  1092: 
1.5       weinem   1093: To install binary packages, you first need to know from where to get them. The
                   1094: first place where you should look is on the main pkgsrc FTP server in the
                   1095: directory /pub/pkgsrc/packages.
                   1096: 
                   1097: This directory contains binary packages for multiple platforms. First, select
                   1098: your operating system. (Ignore the directories with version numbers attached to
                   1099: it, they just exist for legacy reasons.) Then, select your hardware
                   1100: architecture, and in the third step, the OS version and the "version" of
1.9       rillig   1101: pkgsrc.
                   1102: 
                   1103: In this directory, you often find a file called bootstrap.tar.gz which contains
                   1104: the package management tools. If the file is missing, it is likely that your
                   1105: operating system already provides those tools. Download the file and extract it
                   1106: in the / directory. It will create the directories /usr/pkg (containing the
1.118     sevan    1107: tools for managing binary packages and the database of installed packages).
1.1       dsieger  1108: 
1.154     rillig   1109: 5.1.2. Installing binary packages
1.1       dsieger  1110: 
1.85      wiz      1111: In the directory from the last section, there is a subdirectory called All/,
1.9       rillig   1112: which contains all the binary packages that are available for the platform,
                   1113: excluding those that may not be distributed via FTP or CDROM (depending on
1.24      wiz      1114: which medium you are using).
1.9       rillig   1115: 
                   1116: To install packages directly from an FTP or HTTP server, run the following
                   1117: commands in a Bourne-compatible shell (be sure to su to root first):
                   1118: 
                   1119: # PATH="/usr/pkg/sbin:$PATH"
1.179     rillig   1120: 
                   1121: # PKG_PATH="http://cdn.NetBSD.org/pub/pkgsrc/packages"
1.169     rillig   1122: # PKG_PATH="$PKG_PATH/OPSYS/ARCH/VERSIONS/All/"
1.9       rillig   1123: # export PATH PKG_PATH
                   1124: 
                   1125: Instead of URLs, you can also use local paths, for example if you are
                   1126: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
                   1127: to install packages from multiple sources, you can separate them by a semicolon
                   1128: in PKG_PATH.
                   1129: 
                   1130: After these preparations, installing a package is very easy:
                   1131: 
1.118     sevan    1132: # pkg_add libreoffice
                   1133: # pkg_add ap24-php71-*
1.1       dsieger  1134: 
                   1135: Note that any prerequisite packages needed to run the package in question will
                   1136: be installed, too, assuming they are present where you install from.
                   1137: 
1.25      wiz      1138: Adding packages might install vulnerable packages. Thus you should run 
1.24      wiz      1139: pkg_admin audit regularly, especially after installing new packages, and verify
                   1140: that the vulnerabilities are acceptable for your configuration.
1.1       dsieger  1141: 
                   1142: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
                   1143: in your PATH so you can actually start the just installed program.
                   1144: 
1.154     rillig   1145: 5.1.3. Deinstalling packages
1.1       dsieger  1146: 
                   1147: To deinstall a package, it does not matter whether it was installed from source
                   1148: code or from a binary package. The pkg_delete command does not know it anyway.
                   1149: To delete a package, you can just run pkg_delete package-name. The package name
                   1150: can be given with or without version number. Wildcards can also be used to
                   1151: deinstall a set of packages, for example *emacs*. Be sure to include them in
                   1152: quotes, so that the shell does not expand them before pkg_delete sees them.
                   1153: 
                   1154: The -r option is very powerful: it removes all the packages that require the
                   1155: package in question and then removes the package itself. For example:
                   1156: 
                   1157: # pkg_delete -r jpeg
                   1158: 
                   1159: 
                   1160: will remove jpeg and all the packages that used it; this allows upgrading the
                   1161: jpeg package.
                   1162: 
1.154     rillig   1163: 5.1.4. Getting information about installed packages
1.1       dsieger  1164: 
                   1165: The pkg_info shows information about installed packages or binary package
                   1166: files.
                   1167: 
1.154     rillig   1168: 5.1.5. Checking for security vulnerabilities in installed packages
1.1       dsieger  1169: 
1.164     leot     1170: The pkgsrc Security Team and Packages Groups maintain a list of known security
                   1171: vulnerabilities to packages which are (or have been) included in pkgsrc. The
1.179     rillig   1172: list is available from the NetBSD FTP site at http://ftp.NetBSD.org/pub/NetBSD/
                   1173: packages/vulns/pkg-vulnerabilities.
1.1       dsieger  1174: 
1.23      jakllsch 1175: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
                   1176: automatically, and a security audit of all packages installed on a system can
                   1177: take place.
                   1178: 
                   1179: There are two components to auditing. The first step, pkg_admin
                   1180: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
                   1181: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
                   1182: your installed packages are vulnerable. If a package is vulnerable, you will
                   1183: see output similar to the following:
1.1       dsieger  1184: 
                   1185: Package samba-2.0.9 has a local-root-shell vulnerability, see
1.174     leot     1186:     https://www.samba.org/samba/whatsnew/macroexploit.html
1.1       dsieger  1187: 
1.23      jakllsch 1188: You may wish to have the vulnerabilities file downloaded daily so that it
                   1189: remains current. This may be done by adding an appropriate entry to the root
                   1190: users crontab(5) entry. For example the entry
                   1191: 
1.121     sevan    1192: # Download vulnerabilities file
1.118     sevan    1193: 0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1.121     sevan    1194: # Audit the installed packages and email results to root
                   1195: 9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
                   1196:             root >/dev/null 2>&1
1.118     sevan    1197: 
                   1198: 
                   1199: will update the vulnerability list every day at 3AM, followed by an audit at
                   1200: 3:09AM. The result of the audit are then emailed to root. On NetBSD this may be
                   1201: accomplished instead by adding the following line to /etc/daily.conf:
                   1202: 
                   1203: fetch_pkg_vulnerabilities=YES
                   1204: 
1.23      jakllsch 1205: 
1.118     sevan    1206: to fetch the vulnerability list from the daily security script. The system is
                   1207: set to audit the packages by default but can be set explicitly, if desired (not
1.123     wiz      1208: required), by adding the following line to /etc/security.conf:
1.23      jakllsch 1209: 
1.118     sevan    1210: check_pkg_vulnerabilities=YES
1.23      jakllsch 1211: 
                   1212: 
1.118     sevan    1213: see daily.conf(5) and security.conf(5) for more details.
1.1       dsieger  1214: 
1.154     rillig   1215: 5.1.6. Finding if newer versions of your installed packages are in pkgsrc
1.1       dsieger  1216: 
1.12      weinem   1217: Install pkgtools/lintpkgsrc and run lintpkgsrc with the "-i" argument to check
                   1218: if your packages are up-to-date, e.g.
1.1       dsieger  1219: 
                   1220: % lintpkgsrc -i
                   1221: ...
                   1222: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
                   1223: 
                   1224: 
                   1225: You can then use make update to update the package on your system and rebuild
                   1226: any dependencies.
                   1227: 
1.154     rillig   1228: 5.1.7. Other administrative functions
1.1       dsieger  1229: 
                   1230: The pkg_admin executes various administrative functions on the package system.
                   1231: 
1.154     rillig   1232: 5.2. Building packages from source
1.1       dsieger  1233: 
                   1234: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25      wiz      1235: organized into categories. You can browse the online index of packages, or run 
1.1       dsieger  1236: make readme from the pkgsrc directory to build local README.html files for all
                   1237: packages, viewable with any web browser such as www/lynx or www/firefox.
                   1238: 
                   1239: The default prefix for installed packages is /usr/pkg. If you wish to change
                   1240: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
                   1241: use multiple different LOCALBASE definitions on the same system (inside a
                   1242: chroot is an exception).
                   1243: 
                   1244: The rest of this chapter assumes that the package is already in pkgsrc. If it
                   1245: is not, see Part II, "The pkgsrc developer's guide" for instructions how to
                   1246: create your own packages.
                   1247: 
1.154     rillig   1248: 5.2.1. Requirements
1.1       dsieger  1249: 
                   1250: To build packages from source, you need a working C compiler. On NetBSD, you
                   1251: need to install the "comp" and the "text" distribution sets. If you want to
                   1252: build X11-related packages, the "xbase" and "xcomp" distribution sets are
                   1253: required, too.
                   1254: 
1.154     rillig   1255: 5.2.2. Fetching distfiles
1.1       dsieger  1256: 
                   1257: The first step for building a package is downloading the distfiles (i.e. the
                   1258: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
                   1259: them automatically.
                   1260: 
                   1261: If you have all files that you need in the distfiles directory, you don't need
                   1262: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
                   1263: and add:
                   1264: 
                   1265: DISTDIR=/cdrom/pkgsrc/distfiles
                   1266: 
                   1267: to your mk.conf.
                   1268: 
                   1269: By default a list of distribution sites will be randomly intermixed to prevent
                   1270: huge load on servers which holding popular packages (for example,
                   1271: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
                   1272: distfile all the mirrors will be tried in new (random) order. You can turn this
                   1273: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
                   1274: disabled).
                   1275: 
                   1276: You can overwrite some of the major distribution sites to fit to sites that are
                   1277: close to your own. By setting one or two variables you can modify the order in
                   1278: which the master sites are accessed. MASTER_SORT contains a whitespace
                   1279: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
                   1280: contains a whitespace delimited list of regular expressions. It has higher
                   1281: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
                   1282: some examples. This may save some of your bandwidth and time.
                   1283: 
                   1284: You can change these settings either in your shell's environment, or, if you
1.4       rillig   1285: want to keep the settings, by editing the mk.conf file, and adding the
1.1       dsieger  1286: definitions there.
                   1287: 
1.132     wiz      1288: If a package depends on many other packages (such as meta-pkgs/kde4), the build
1.1       dsieger  1289: process may alternate between periods of downloading source, and compiling. To
                   1290: ensure you have all the source downloaded initially you can run the command:
                   1291: 
                   1292: % make fetch-list | sh
                   1293: 
                   1294: which will output and run a set of shell commands to fetch the necessary files
                   1295: into the distfiles directory. You can also choose to download the files
                   1296: manually.
                   1297: 
1.154     rillig   1298: 5.2.3. How to build and install
1.1       dsieger  1299: 
                   1300: Once the software has downloaded, any patches will be applied, then it will be
                   1301: compiled for you. This may take some time depending on your computer, and how
                   1302: many other packages the software depends on and their compile time.
                   1303: 
                   1304: Note
                   1305: 
                   1306: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
                   1307: command instead of "make" in the examples in this guide.
                   1308: 
                   1309: For example, type
                   1310: 
                   1311: % cd misc/figlet
                   1312: % make
                   1313: 
                   1314: 
                   1315: at the shell prompt to build the various components of the package.
                   1316: 
                   1317: The next stage is to actually install the newly compiled program onto your
                   1318: system. Do this by entering:
                   1319: 
                   1320: % make install
                   1321: 
                   1322: 
                   1323: while you are still in the directory for whatever package you are installing.
                   1324: 
                   1325: Installing the package on your system may require you to be root. However,
                   1326: pkgsrc has a just-in-time-su feature, which allows you to only become root for
                   1327: the actual installation step.
                   1328: 
                   1329: That's it, the software should now be installed and setup for use. You can now
                   1330: enter:
                   1331: 
                   1332: % make clean
                   1333: 
                   1334: 
                   1335: to remove the compiled files in the work directory, as you shouldn't need them
                   1336: any more. If other packages were also added to your system (dependencies) to
                   1337: allow your program to compile, you can tidy these up also with the command:
                   1338: 
                   1339: % make clean-depends
                   1340: 
                   1341: 
                   1342: Taking the figlet utility as an example, we can install it on our system by
                   1343: building as shown in Appendix B, Build logs.
                   1344: 
                   1345: The program is installed under the default root of the packages tree - /usr/
                   1346: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
                   1347: environment, and it will use that value as the root of your packages tree. So,
                   1348: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
                   1349: that you should use a directory which is dedicated to packages and not shared
                   1350: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
                   1351: not try to add any of your own files or directories (such as src/, obj/, or
                   1352: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
                   1353: between programs and other files installed by the package system and whatever
                   1354: else may have been installed there.
                   1355: 
1.4       rillig   1356: Some packages look in mk.conf to alter some configuration options at build
1.1       dsieger  1357: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
                   1358: be set there by default. Environment variables such as LOCALBASE can be set in
1.4       rillig   1359: mk.conf to save having to remember to set them each time you want to use
1.1       dsieger  1360: pkgsrc.
                   1361: 
                   1362: Occasionally, people want to "look under the covers" to see what is going on
                   1363: when a package is building or being installed. This may be for debugging
                   1364: purposes, or out of simple curiosity. A number of utility values have been
                   1365: added to help with this.
                   1366: 
                   1367:  1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
                   1368:     amount of information will be displayed. For example,
                   1369: 
                   1370:     make patch PKG_DEBUG_LEVEL=2
                   1371: 
1.25      wiz      1372:     will show all the commands that are invoked, up to and including the "patch
                   1373:     " stage.
1.1       dsieger  1374: 
                   1375:  2. If you want to know the value of a certain make(1) definition, then the
                   1376:     VARNAME definition should be used, in conjunction with the show-var target.
                   1377:     e.g. to show the expansion of the make(1) variable LOCALBASE:
                   1378: 
                   1379:     % make show-var VARNAME=LOCALBASE
                   1380:     /usr/pkg
                   1381:     %
                   1382: 
                   1383: 
                   1384: If you want to install a binary package that you've either created yourself
                   1385: (see next section), that you put into pkgsrc/packages manually or that is
                   1386: located on a remote FTP server, you can use the "bin-install" target. This
                   1387: target will install a binary package - if available - via pkg_add(1), else do a
                   1388: make package. The list of remote FTP sites searched is kept in the variable
                   1389: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
                   1390: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
                   1391: for more details.
                   1392: 
                   1393: A final word of warning: If you set up a system that has a non-standard setting
                   1394: for LOCALBASE, be sure to set that before any packages are installed, as you
                   1395: cannot use several directories for the same purpose. Doing so will result in
                   1396: pkgsrc not being able to properly detect your installed packages, and fail
                   1397: miserably. Note also that precompiled binary packages are usually built with
                   1398: the default LOCALBASE of /usr/pkg, and that you should not install any if you
                   1399: use a non-standard LOCALBASE.
                   1400: 
1.154     rillig   1401: Chapter 6. Configuring pkgsrc
1.1       dsieger  1402: 
                   1403: Table of Contents
                   1404: 
1.154     rillig   1405: 6.1. General configuration
                   1406: 6.2. Variables affecting the build process
                   1407: 6.3. Variables affecting the installation process
                   1408: 6.4. Selecting and configuring the compiler
                   1409: 
                   1410:     6.4.1. Selecting the compiler
                   1411:     6.4.2. Additional flags to the compiler (CFLAGS)
                   1412:     6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger  1413: 
1.154     rillig   1414: 6.5. Developer/advanced settings
                   1415: 6.6. Selecting Build Options
1.1       dsieger  1416: 
                   1417: The whole pkgsrc system is configured in a single file, usually called mk.conf.
                   1418: In which directory pkgsrc looks for that file depends on the installation. On
                   1419: NetBSD, when you use make(1) from the base system, it is in the directory /etc
                   1420: /. In all other cases the default location is ${PREFIX}/etc/, depending on
                   1421: where you told the bootstrap program to install the binary packages.
                   1422: 
                   1423: The format of the configuration file is that of the usual BSD-style Makefiles.
                   1424: The whole pkgsrc configuration is done by setting variables in this file. Note
                   1425: that you can define all kinds of variables, and no special error checking (for
1.112     rillig   1426: example for spelling mistakes) takes place.
1.1       dsieger  1427: 
1.154     rillig   1428: 6.1. General configuration
1.1       dsieger  1429: 
1.112     rillig   1430: The following variables apply to all pkgsrc packages. A complete list of the
                   1431: variables that can be configured by the user is available in mk/defaults/
                   1432: mk.conf, together with some comments that describe each variable's intent.
1.1       dsieger  1433: 
                   1434:   * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
                   1435:     not mix binary packages with different LOCALBASEs!
                   1436: 
                   1437:   * CROSSBASE: Where "cross" category packages will be installed. The default
                   1438:     is ${LOCALBASE}/cross.
                   1439: 
1.84      wiz      1440:   * X11BASE: Where X11 is installed on the system. The default is /usr/X11R7.
1.1       dsieger  1441: 
                   1442:   * DISTDIR: Where to store the downloaded copies of the original source
                   1443:     distributions used for building pkgsrc packages. The default is $
                   1444:     {PKGSRCDIR}/distfiles.
                   1445: 
                   1446:   * PKG_DBDIR: Where the database about installed packages is stored. The
1.118     sevan    1447:     default is /usr/pkg/pkgdb.
1.1       dsieger  1448: 
                   1449:   * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
                   1450:     value.
                   1451: 
                   1452:   * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
                   1453:     files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.118     sevan    1454:     respectively. The defaults is ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1.1       dsieger  1455:     {DIST_SUBDIR}/.
                   1456: 
                   1457:   * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
                   1458:     with OS release ("2.0", etc.) and architecture ("mipsel", etc.).
                   1459: 
1.23      jakllsch 1460:   * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
                   1461:     case-sensitive. Whenever you try to build a package whose license is not in
                   1462:     this list, you will get an error message. If the license condition is
                   1463:     simple enough, the error message will include specific instructions on how
                   1464:     to change this variable.
1.1       dsieger  1465: 
1.154     rillig   1466: 6.2. Variables affecting the build process
1.1       dsieger  1467: 
                   1468:   * PACKAGES: The top level directory for the binary packages. The default is $
                   1469:     {PKGSRCDIR}/packages.
                   1470: 
                   1471:   * WRKOBJDIR: The top level directory where, if defined, the separate working
                   1472:     directories will get created, and symbolically linked to from ${WRKDIR}
                   1473:     (see below). This is useful for building packages on several architectures,
                   1474:     then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
                   1475:     architecture. (It should be noted that PKGSRCDIR should not be set by the
                   1476:     user ? it is an internal definition which refers to the root of the pkgsrc
                   1477:     tree. It is possible to have many pkgsrc tree instances.)
                   1478: 
                   1479:   * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.154     rillig   1480:     Section 13.3, "patches/*" for more information.
1.1       dsieger  1481: 
                   1482:   * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
                   1483:     Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
                   1484:     up settings used by builds in /usr/src.
                   1485: 
1.154     rillig   1486: 6.3. Variables affecting the installation process
1.1       dsieger  1487: 
1.143     maya     1488:   * PKGSRC_KEEP_BIN_PKGSRC: By default, binary packages of built packages are
1.150     leot     1489:     preserved in ${PACKAGES}/All. Setting this variable to "no" prevents this.
1.1       dsieger  1490: 
1.107     jnemeth  1491: Packages have to support installation into a subdirectory of WRKDIR. This
                   1492: allows a package to be built, before the actual filesystem is touched. DESTDIR
                   1493: support exists in two variations:
1.4       rillig   1494: 
                   1495:   * Basic DESTDIR support means that the package installation and packaging is
                   1496:     still run as root.
                   1497: 
                   1498:   * Full DESTDIR support can run the complete build, installation and packaging
                   1499:     as normal user. Root privileges are only needed to add packages.
                   1500: 
                   1501: With basic DESTDIR support, make clean needs to be run as root.
                   1502: 
1.17      imil     1503: Considering the foo/bar package, DESTDIR full support can be tested using the
                   1504: following commands
                   1505: 
                   1506: $ id
                   1507: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
                   1508: $ mkdir $HOME/packages
                   1509: $ cd $PKGSRCDIR/foo/bar
                   1510: 
                   1511: Verify DESTDIR full support, no root privileges should be needed
                   1512: 
1.66      asau     1513: $ make stage-install
1.17      imil     1514: 
                   1515: Create a package without root privileges
                   1516: 
1.66      asau     1517: $ make PACKAGES=$HOME/packages package
1.17      imil     1518: 
                   1519: For the following command, you must be able to gain root privileges using su(1)
                   1520: 
1.66      asau     1521: $ make PACKAGES=$HOME/packages install
1.17      imil     1522: 
                   1523: Then, as a simple user
                   1524: 
                   1525: $ make clean
                   1526: 
1.154     rillig   1527: 6.4. Selecting and configuring the compiler
1.4       rillig   1528: 
1.154     rillig   1529: 6.4.1. Selecting the compiler
1.1       dsieger  1530: 
                   1531: By default, pkgsrc will use GCC to build packages. This may be overridden by
                   1532: setting the following variables in /etc/mk.conf:
                   1533: 
                   1534: PKGSRC_COMPILER:
                   1535: 
                   1536:     This is a list of values specifying the chain of compilers to invoke when
                   1537:     building packages. Valid values are:
                   1538: 
1.66      asau     1539:       + ccc: Compaq C Compilers (Tru64)
                   1540: 
                   1541:       + ccache: compiler cache (chainable)
                   1542: 
                   1543:       + clang: Clang C and Objective-C compiler
                   1544: 
1.42      asau     1545:       + distcc: distributed C/C++ (chainable)
1.1       dsieger  1546: 
1.66      asau     1547:       + f2c: Fortran 77 to C compiler (chainable)
                   1548: 
                   1549:       + icc: Intel C++ Compiler (Linux)
                   1550: 
                   1551:       + ido: SGI IRIS Development Option cc (IRIX 5)
1.1       dsieger  1552: 
1.42      asau     1553:       + gcc: GNU C/C++ Compiler
1.1       dsieger  1554: 
1.66      asau     1555:       + hp: HP-UX C/aC++ compilers
                   1556: 
1.42      asau     1557:       + mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1       dsieger  1558: 
1.66      asau     1559:       + mipspro-ucode: Silicon Graphics, Inc. MIPSpro (o32)
1.1       dsieger  1560: 
1.42      asau     1561:       + sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1       dsieger  1562: 
1.118     sevan    1563:       + xlc: IBM's XL C/C++ compiler suite
1.66      asau     1564: 
1.1       dsieger  1565:     The default is "gcc". You can use ccache and/or distcc with an appropriate
                   1566:     PKGSRC_COMPILER setting, e.g. "ccache gcc". This variable should always be
                   1567:     terminated with a value for a real compiler. Note that only one real
                   1568:     compiler should be listed (e.g. "sunpro gcc" is not allowed).
                   1569: 
                   1570: GCC_REQD:
                   1571: 
                   1572:     This specifies the minimum version of GCC to use when building packages. If
                   1573:     the system GCC doesn't satisfy this requirement, then pkgsrc will build and
                   1574:     install one of the GCC packages to use instead.
                   1575: 
1.153     leot     1576: PYTHON_VERSION_DEFAULT:
1.114     maya     1577: 
                   1578:     Specifies which version of python to use when several options are
                   1579:     available.
                   1580: 
                   1581: PKGSRC_FORTRAN:
                   1582: 
1.176     gutterid 1583:     Specifies the Fortran compiler to use. The default is gfortran.
1.114     maya     1584: 
                   1585: GFORTRAN_VERSION:
                   1586: 
                   1587:     If PKGSRC_FORTRAN= gfortran is used, this option specifies which version to
                   1588:     use.
                   1589: 
1.154     rillig   1590: 6.4.2. Additional flags to the compiler (CFLAGS)
1.1       dsieger  1591: 
                   1592: If you wish to set the CFLAGS variable, please make sure to use the += operator
                   1593: instead of the = operator:
                   1594: 
                   1595: CFLAGS+=        -your -flags
                   1596: 
                   1597: Using CFLAGS= (i.e. without the "+") may lead to problems with packages that
1.16      jnemeth  1598: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24      wiz      1599: package if you're interested in optimization specifically for the current CPU.
1.1       dsieger  1600: 
1.154     rillig   1601: 6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger  1602: 
                   1603: If you want to pass flags to the linker, both in the configure step and the
                   1604: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
                   1605: difference between the two is that LIBS will be appended to the command line,
                   1606: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
                   1607: machines depending on the setting of USE_IMAKE or the inclusion of mk/
                   1608: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
                   1609: settings, use the += operator:
                   1610: 
                   1611: LDFLAGS+=        -your -linkerflags
                   1612: 
1.154     rillig   1613: 6.5. Developer/advanced settings
1.1       dsieger  1614: 
                   1615:   * PKG_DEVELOPER: Run some sanity checks that package developers want:
                   1616: 
1.42      asau     1617:       + make sure patches apply with zero fuzz
1.1       dsieger  1618: 
1.42      asau     1619:       + run check-shlibs to see that all binaries will find their shared libs.
1.1       dsieger  1620: 
                   1621:   * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
                   1622:     making and installing the package. The default value for this is 0, which
                   1623:     will not display the commands as they are executed (normal, default, quiet
                   1624:     operation); the value 1 will display all shell commands before their
                   1625:     invocation, and the value 2 will display both the shell commands before
1.112     rillig   1626:     their invocation, as well as their actual execution progress with set -x.
1.1       dsieger  1627: 
1.154     rillig   1628: 6.6. Selecting Build Options
1.1       dsieger  1629: 
                   1630: Some packages have build time options, usually to select between different
                   1631: dependencies, enable optional support for big dependencies or enable
                   1632: experimental features.
                   1633: 
                   1634: To see which options, if any, a package supports, and which options are
                   1635: mutually exclusive, run make show-options, for example:
                   1636: 
                   1637:     The following options are supported by this package:
                   1638:         ssl      Enable SSL support.
                   1639:     Exactly one of the following gecko options is required:
                   1640:         firefox  Use firefox as gecko rendering engine.
                   1641:         mozilla  Use mozilla as gecko rendering engine.
                   1642:     At most one of the following database options may be selected:
                   1643:         mysql    Enable support for MySQL database.
                   1644:         pgsql    Enable support for PostgreSQL database.
                   1645: 
                   1646:     These options are enabled by default: firefox
                   1647:     These options are currently enabled: mozilla ssl
                   1648: 
1.4       rillig   1649: The following variables can be defined in mk.conf to select which options to
                   1650: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1       dsieger  1651: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
                   1652: which can be used to select or disable options specifically for package pkgbase
                   1653: . Options listed in these variables are selected, options preceded by "-" are
                   1654: disabled. A few examples:
                   1655: 
1.4       rillig   1656: $ grep "PKG.*OPTION" mk.conf
1.1       dsieger  1657: PKG_DEFAULT_OPTIONS=    -arts -dvdread -esound
                   1658: PKG_OPTIONS.kdebase=    debug -sasl
                   1659: PKG_OPTIONS.apache=     suexec
                   1660: 
1.11      rillig   1661: It is important to note that options that were specifically suggested by the
1.19      snj      1662: package maintainer must be explicitly removed if you do not wish to include the
                   1663: option. If you are unsure you can view the current state with make show-options
                   1664: .
1.11      rillig   1665: 
1.1       dsieger  1666: The following settings are consulted in the order given, and the last setting
                   1667: that selects or disables an option is used:
                   1668: 
                   1669:  1. the default options as suggested by the package maintainer
                   1670: 
                   1671:  2. the options implied by the settings of legacy variables (see below)
                   1672: 
                   1673:  3. PKG_DEFAULT_OPTIONS
                   1674: 
                   1675:  4. PKG_OPTIONS.pkgbase
                   1676: 
                   1677: For groups of mutually exclusive options, the last option selected is used, all
                   1678: others are automatically disabled. If an option of the group is explicitly
                   1679: disabled, the previously selected option, if any, is used. It is an error if no
                   1680: option from a required group of options is selected, and building the package
                   1681: will fail.
                   1682: 
                   1683: Before the options framework was introduced, build options were selected by
1.4       rillig   1684: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
                   1685: transition to the options framework for the user, these legacy variables are
                   1686: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
                   1687: automatically. A warning is issued to prompt the user to update mk.conf to use
                   1688: the options framework directly. Support for the legacy variables will be
1.1       dsieger  1689: removed eventually.
                   1690: 
1.154     rillig   1691: Chapter 7. Creating binary packages
1.1       dsieger  1692: 
                   1693: Table of Contents
                   1694: 
1.154     rillig   1695: 7.1. Building a single binary package
                   1696: 7.2. Settings for creation of binary packages
1.1       dsieger  1697: 
1.154     rillig   1698: 7.1. Building a single binary package
1.1       dsieger  1699: 
                   1700: Once you have built and installed a package, you can create a binary package
                   1701: which can be installed on another system with pkg_add(1). This saves having to
                   1702: build the same package on a group of hosts and wasting CPU time. It also
                   1703: provides a simple means for others to install your package, should you
                   1704: distribute it.
                   1705: 
                   1706: To create a binary package, change into the appropriate directory in pkgsrc,
                   1707: and run make package:
                   1708: 
1.112     rillig   1709: $ cd misc/figlet
                   1710: $ make package
1.1       dsieger  1711: 
                   1712: This will build and install your package (if not already done), and then build
                   1713: a binary package from what was installed. You can then use the pkg_* tools to
                   1714: manipulate it. Binary packages are created by default in /usr/pkgsrc/packages,
                   1715: in the form of a gzipped tar file. See Section B.2, "Packaging figlet" for a
                   1716: continuation of the above misc/figlet example.
                   1717: 
1.154     rillig   1718: See Chapter 23, Submitting and Committing for information on how to submit such
1.1       dsieger  1719: a binary package.
                   1720: 
1.154     rillig   1721: 7.2. Settings for creation of binary packages
1.1       dsieger  1722: 
1.154     rillig   1723: See Section 19.17, "Other helpful targets".
1.6       rillig   1724: 
1.154     rillig   1725: Chapter 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig   1726: 
                   1727: Table of Contents
                   1728: 
1.154     rillig   1729: 8.1. Preparations
1.180     rillig   1730: 8.2. Running a bulk build
1.6       rillig   1731: 
1.154     rillig   1732:     8.2.1. Configuration
1.6       rillig   1733: 
1.154     rillig   1734: 8.3. Requirements of a full bulk build
1.178     rillig   1735: 8.4. Bulk build variants
                   1736: 
1.179     rillig   1737:     8.4.1. Detect unknown configure options
                   1738:     8.4.2. Detect classes of bugs by forcing compiler warnings
1.181   ! rillig   1739:     8.4.3. Force compiler options only in the build phase
        !          1740:     8.4.4. Use custom directories
        !          1741:     8.4.5. Turn warnings into errors
        !          1742:     8.4.6. Reject packages for which pkglint reports errors
        !          1743:     8.4.7. Reject packages that contain forbidden strings
        !          1744:     8.4.8. Reject packages whose self-test fails
        !          1745:     8.4.9. Reject packages that use undefined shell variables
        !          1746:     8.4.10. Turn off verbose logging
1.6       rillig   1747: 
1.178     rillig   1748: 8.5. Creating a multiple CD-ROM packages collection
                   1749: 
                   1750:     8.5.1. Example of cdpack
1.6       rillig   1751: 
1.175     gutterid 1752: For a number of reasons, you may want to build binary packages for a large
                   1753: selected set of packages in pkgsrc, or even for all pkgsrc packages. For
1.71      wiz      1754: instance, when you have multiple machines that should run the same software, it
                   1755: is wasted time if they all build their packages themselves from source. Or you
                   1756: may want to build a list of packages you want and check them before deploying
1.175     gutterid 1757: onto production systems. There is a way of getting a set of binary packages:
                   1758: the bulk build system, or pbulk ("p" stands for "parallel"). This chapter
                   1759: describes how to set it up.
1.71      wiz      1760: 
1.154     rillig   1761: 8.1. Preparations
1.71      wiz      1762: 
                   1763: First of all, you have to decide whether you build all packages or a limited
                   1764: set of them. Full bulk builds usually consume a lot more resources, both space
1.175     gutterid 1765: and time, than builds for some practical sets of packages. A number of
                   1766: particularly heavy packages exist that are not actually interesting to a wide
                   1767: audience. (The approximate resource consumption for a full bulk build is given
                   1768: in section Section 8.3, "Requirements of a full bulk build".) For limited bulk
                   1769: builds you need to make a list of packages you want to build. Note that all
                   1770: their dependencies will be built, so you don't need to track them manually.
1.71      wiz      1771: 
                   1772: During bulk builds various packages are installed and deinstalled in /usr/pkg
                   1773: (or whatever LOCALBASE is), so make sure that you don't need any package during
1.112     rillig   1774: the builds. Essentially, you should provide a fresh system, either a chroot
1.71      wiz      1775: environment or something even more restrictive, depending on what the operating
                   1776: system provides, or dedicate the whole physical machine. As a useful side
                   1777: effect this makes sure that bulk builds cannot break anything in your system.
                   1778: There have been numerous cases where certain packages tried to install files
                   1779: outside the LOCALBASE or wanted to edit some files in /etc.
1.6       rillig   1780: 
1.180     rillig   1781: 8.2. Running a bulk build
1.6       rillig   1782: 
1.180     rillig   1783: Running a bulk build works roughly as follows:
1.15      rillig   1784: 
                   1785:   * First, build the pbulk infrastructure in a fresh pkgsrc location.
                   1786: 
                   1787:   * Then, build each of the packages from a clean installation directory using
                   1788:     the infrastructure.
                   1789: 
1.154     rillig   1790: 8.2.1. Configuration
1.6       rillig   1791: 
1.112     rillig   1792: To simplify configuration, we provide the helper script mk/pbulk/pbulk.sh.
1.6       rillig   1793: 
1.68      asau     1794: In order to use it, prepare a clear system (real one, chroot environment, jail,
                   1795: zone, virtual machine). Configure network access to fetch distribution files.
1.112     rillig   1796: Create a user with name "pbulk".
1.68      asau     1797: 
                   1798: Fetch and extract pkgsrc. Use a command like one of these:
                   1799: 
1.151     sevan    1800: # (cd /usr && ftp -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
                   1801: # (cd /usr && fetch -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1.72      wiz      1802: # (cd /usr && cvs -Q -z3 -d anoncvs@anoncvs.NetBSD.org:/cvsroot get -P pkgsrc)
1.68      asau     1803: 
                   1804: Or any other way that fits (e.g., curl, wget).
                   1805: 
                   1806: Deploy and configure pbulk tools, e.g.:
                   1807: 
1.118     sevan    1808: # sh pbulk.sh -n # use native make, no bootstrap kit needed (for use on NetBSD)
1.68      asau     1809: # sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment
                   1810: # sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build
                   1811: 
                   1812: Note
                   1813: 
                   1814: mk.conf.frag is a fragment of mk.conf that contains settings you want to apply
                   1815: to packages you build. For instance,
                   1816: 
1.112     rillig   1817: PKG_DEVELOPER=          yes     # perform more checks
                   1818: X11_TYPE=               modular # use pkgsrc X11
                   1819: SKIP_LICENSE_CHECK=     yes     # accept all licences (useful
                   1820:                                 # when building all packages)
1.68      asau     1821: 
                   1822: If configured for limited list, replace the list in /usr/pbulk/etc/pbulk.list
1.112     rillig   1823: with your list of packages, one per line without empty lines or comments. E.g.:
1.68      asau     1824: 
                   1825: www/firefox
                   1826: mail/thunderbird
                   1827: misc/libreoffice4
                   1828: 
1.69      asau     1829: At this point you can also review configuration in /usr/pbulk/etc and make
                   1830: final amendments, if wanted.
                   1831: 
1.68      asau     1832: Start it:
                   1833: 
                   1834: # /usr/pbulk/bin/bulkbuild
                   1835: 
                   1836: After it finishes, you'll have /mnt filled with distribution files, binary
                   1837: packages, and reports, plain text summary in /mnt/bulklog/meta/report.txt
                   1838: 
                   1839: Note
                   1840: 
                   1841: The pbulk.sh script does not cover all possible use cases. While being ready to
                   1842: run, it serves as a good starting point to understand and build more complex
                   1843: setups. The script is kept small enough for better understanding.
                   1844: 
                   1845: Note
                   1846: 
                   1847: The pbulk.sh script supports running unprivileged bulk build and helps
                   1848: configuring distributed bulk builds.
1.15      rillig   1849: 
1.154     rillig   1850: 8.3. Requirements of a full bulk build
1.71      wiz      1851: 
                   1852: A complete bulk build requires lots of disk space. Some of the disk space can
                   1853: be read-only, some other must be writable. Some can be on remote filesystems
                   1854: (such as NFS) and some should be local. Some can be temporary filesystems,
                   1855: others must survive a sudden reboot.
                   1856: 
                   1857:   * 40 GB for the distfiles (read-write, remote, temporary)
                   1858: 
                   1859:   * 30 GB for the binary packages (read-write, remote, permanent)
                   1860: 
                   1861:   * 1 GB for the pkgsrc tree (read-only, remote, permanent)
                   1862: 
                   1863:   * 5 GB for LOCALBASE (read-write, local, temporary)
                   1864: 
                   1865:   * 10 GB for the log files (read-write, remote, permanent)
                   1866: 
                   1867:   * 5 GB for temporary files (read-write, local, temporary)
                   1868: 
1.178     rillig   1869: 8.4. Bulk build variants
                   1870: 
                   1871: To ensure that pkgsrc packages work in different configurations, it makes sense
                   1872: to run non-default bulk builds from time to time. This section lists some ideas
                   1873: for bulk builds that intentionally let packages fail if they don't follow the
                   1874: pkgsrc style.
                   1875: 
1.179     rillig   1876: 8.4.1. Detect unknown configure options
1.178     rillig   1877: 
                   1878: Add the following line to mk.conf.
                   1879: 
                   1880: GNU_CONFIGURE_STRICT=   yes
                   1881: 
                   1882: When a package fails this additional check, the most common cause is that the
                   1883: configure option was valid for an older version of the package but does not
                   1884: apply anymore. In that case, just remove it.
                   1885: 
1.179     rillig   1886: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.178     rillig   1887: 
                   1888: The job of a compiler is not restricted to producing executable code, most
1.179     rillig   1889: compilers also detect typical programming mistakes. The pkgsrc compiler
                   1890: wrappers make it easy to force compiler options when the package is built. This
                   1891: can be used to find typical bugs across all packages that are in pkgsrc. By
                   1892: reporting these bugs upstream, the packages will be more reliable with the next
                   1893: updates.
1.178     rillig   1894: 
1.179     rillig   1895: Add some of the following lines to mk.conf:
1.178     rillig   1896: 
                   1897: CFLAGS+=        -Werror=char-subscripts
1.179     rillig   1898: CFLAGS+=        -Werror=implicit-function-declaration
1.178     rillig   1899: 
1.179     rillig   1900: When a package fails to build using these stricter compiler options, document
                   1901: the circumstances in which the compiler produced the error message. This
                   1902: includes:
1.178     rillig   1903: 
                   1904:   * The platform (MACHINE_PLATFORM)
                   1905: 
                   1906:   * The source file
                   1907: 
                   1908:   * An excerpt of the code. GCC and Clang already do this as part of the
                   1909:     diagnostic.
                   1910: 
1.179     rillig   1911:   * The exact error message from the compiler.
1.178     rillig   1912: 
1.179     rillig   1913: If a package produces these error messages, but the package is fine, record
                   1914: this in your local mk.conf, like this, to skip this check in the next builds:
1.178     rillig   1915: 
1.179     rillig   1916: .if ${PKGPATH} == category/package
1.178     rillig   1917: # Version ${VERSION} failed on ${MACHINE_PLATFORM}:
                   1918: # error message
                   1919: # code
1.179     rillig   1920: # Reason why the code does not need to be fixed.
1.178     rillig   1921: BUILDLINK_TRANSFORM+=   rm:-Werror=char-subscripts
1.179     rillig   1922: .endif
1.178     rillig   1923: 
                   1924: If the error messages from the compiler are valid and the code needs to be
1.179     rillig   1925: fixed, prepare a local patch (see LOCALPATCHES) and report the bug to the
                   1926: upstream authors of the package, providing them with the information you
                   1927: collected above.
1.178     rillig   1928: 
1.179     rillig   1929: Patches that are not essential for the package to work should only be reported
                   1930: upstream but not committed to pkgsrc, to make future updates easier.
                   1931: 
1.181   ! rillig   1932: 8.4.3. Force compiler options only in the build phase
        !          1933: 
        !          1934: When adding custom compiler flags via CFLAGS, these apply to all phases of the
        !          1935: package build process. Especially in the configure phase, adding -Werror leads
        !          1936: to wrong decisions. The GNU configure scripts feed many small test programs to
        !          1937: the C compiler to see whether certain headers are available, functions are
        !          1938: defined in a library and programs can be run. In many cases these programs
        !          1939: would not survive a strict compiler run with -Wall -Wextra -Werror.
        !          1940: 
        !          1941: The pkgsrc infrastructure is flexible enough to support compiler options being
        !          1942: added between the configure and build phases. It's a little more complicated
        !          1943: than the other examples in this section but still easy enough.
        !          1944: 
        !          1945: The basic idea is to use the pkgsrc compiler wrapper to inject the desired
        !          1946: compiler options. The compiler wrapper's original task is to hide unwanted
        !          1947: directories of include files and to normalize compiler options. It does this by
        !          1948: wrapping the compiler command and rewriting the command line. To see this in
        !          1949: action, run bmake patch in a package directory and examine the work/.cwrappers/
        !          1950: config directory. It contains individual configurations for the C compiler and
        !          1951: the related tools. The plan is to find a hook between the configure and build
        !          1952: phases, and to modify these configuration files at that point.
        !          1953: 
        !          1954: To find this hook, have a look at mk/build/build.mk, which contains among
        !          1955: others the pre-build-checks-hook. The word checks doesn't quite fit, but the
        !          1956: pre-build-hook sounds good enough.
        !          1957: 
        !          1958: The code to be included in mk.conf is:
        !          1959: 
        !          1960: # Just a few example options.
        !          1961: BUILD_ONLY_CFLAGS=      -Wall -Werror -O2 -DTEMPDIR='"/tmp"'
        !          1962: 
        !          1963: .if ${BUILD_ONLY_CFLAGS:U:M*}
        !          1964: pre-build-checks-hook: add-build-only-cflags
        !          1965: 
        !          1966: add-build-only-cflags: .PHONY
        !          1967:         ${RUN} cd ${CWRAPPERS_CONFIG_DIR};      \
        !          1968:         ${TEST} ! -f ${.TARGET} || exit 0;      \
        !          1969:         for flag in ${BUILD_ONLY_CFLAGS}; do    \
        !          1970:                 ${ECHO} "append=$$flag" >> cc;  \
        !          1971:         done;                                   \
        !          1972:         > ${.TARGET}
        !          1973: .endif
        !          1974: 
        !          1975: (When editing the mk.conf, make sure that the commands of the
        !          1976: add-build-only-cflags target are indented with a tab, not with spaces.)
        !          1977: 
        !          1978: The condition in the .if statement contains the :U modifier to prevent parse
        !          1979: errors if the variable should be undefined, possibly because it is only defined
        !          1980: for a subset of the packages. The :M* modifier ensures that there is at least
        !          1981: one compiler option, to prevent a syntax error in the shell parser.
        !          1982: 
        !          1983: The code around the ${.TARGET} variable ensures that the additional compiler
        !          1984: options are only appended once, even if bmake build is run multiple times. To
        !          1985: do this, it creates a marker file.
        !          1986: 
        !          1987: To verify that this setup works, run bmake configure in a package directory. Up
        !          1988: to now, everything works as usual. Examine the directory work/.cwrappers/config
        !          1989: to see that the compiler options from BUILD_ONLY_CFLAGS are not yet added to
        !          1990: the file cc. Examine the tail of the work/.work.log file to see that the normal
        !          1991: compiler options are used.
        !          1992: 
        !          1993: Now run bmake build. This will append the options to the file cc and will
        !          1994: create the marker file in the same directory. After that, the build starts as
        !          1995: usual, but with the added compiler options. Examine the tail of the file work
        !          1996: /.work.log to see that the lines starting with [*] don't contain the compiler
        !          1997: options, but the corresponding lines starting with <.> do end with these
        !          1998: options.
        !          1999: 
        !          2000: Building packages using this setup variant and fixing the resulting bugs is the
        !          2001: same as in Section 8.4.2, "Detect classes of bugs by forcing compiler warnings"
        !          2002: .
        !          2003: 
        !          2004: 8.4.4. Use custom directories
1.178     rillig   2005: 
                   2006: Some directories like PREFIX, VARBASE, PKG_SYSCONFDIR, PKGMANDIR, PKG_INFODIR
                   2007: can be configured in pkgsrc. Set these to arbitrary paths during bootstrap or
                   2008: afterwards in mk.conf.
                   2009: 
                   2010: PREFIX=         /a-random-uuid
                   2011: PKG_SYSCONFDIR= /a-random-uuid
                   2012: VARBASE=        /a-random-uuid
                   2013: PKGMANDIR=      a-random-uuid
                   2014: PKG_INFODIR=    a-random-uuid
                   2015: 
1.181   ! rillig   2016: 8.4.5. Turn warnings into errors
1.178     rillig   2017: 
                   2018: When building a package, warnings are typically ignored since they just flow by
                   2019: and do not cause the build to fail immediately. To find these warnings,
                   2020: redefine them to errors in mk.conf.
                   2021: 
                   2022: DELAYED_WARNING_MSG=    ${DELAYED_ERROR_MSG} "(was warning)"
                   2023: WARNING_MSG=            ${FAIL_MSG} "(was warning)"
                   2024: 
                   2025: (There are many more classes of warnings in pkgsrc, and most of them can be
                   2026: redefined with a simple definition like above.
                   2027: 
1.179     rillig   2028: If a package suggests to add USE_TOOLS+=perl to the package Makefile, research
1.178     rillig   2029: whether the package actually needs Perl. If it does, add USE_TOOLS+=perl to the
                   2030: package Makefile, and if it doesn't, add TOOLS_BROKEN+=perl.
                   2031: 
1.181   ! rillig   2032: 8.4.6. Reject packages for which pkglint reports errors
1.178     rillig   2033: 
                   2034: Using pkglint as part of the regular build process is mostly a waste of time.
                   2035: If you want to fix some of the warnings, just run pkglint recursively on the
                   2036: whole pkgsrc tree. This will take a few minutes (up to 10), which is much
                   2037: faster than a complete bulk build.
                   2038: 
1.181   ! rillig   2039: 8.4.7. Reject packages that contain forbidden strings
1.178     rillig   2040: 
                   2041: To ensure that the binary packages don't contain references to the build
                   2042: directory, there is already CHECK_WRKREF. If that variable includes the item
                   2043: extra, it is possible to define additional patterns that must not appear in any
                   2044: installed file. This is specified in mk.conf.
                   2045: 
                   2046: CHECK_WRKREF=                   extra
                   2047: CHECK_WRKREF_EXTRA_DIRS+=       /usr/local
                   2048: CHECK_WRKREF_EXTRA_DIRS+=       /usr/pkg
                   2049: CHECK_WRKREF_EXTRA_DIRS+=       @[A-Z][A-Z]*@
                   2050: 
                   2051: The above patterns will probably generate many false positives, therefore the
                   2052: results need to be taken with a grain of salt.
                   2053: 
1.181   ! rillig   2054: 8.4.8. Reject packages whose self-test fails
1.178     rillig   2055: 
                   2056: To run the test suites that come with each package, add this line to mk.conf.
                   2057: 
                   2058: PKGSRC_RUN_TEST=        yes
                   2059: 
                   2060: Be prepared that even the most basic packages fail this test. When doing a bulk
                   2061: build with this, it will often abort in the early phase where the packages are
                   2062: scanned for their dependencies since there are cyclic dependencies. There is
                   2063: still a lot to do in this area.
                   2064: 
1.181   ! rillig   2065: 8.4.9. Reject packages that use undefined shell variables
1.178     rillig   2066: 
                   2067: To catch typos in the shell snippets from the Makefile fragments, add the -u
                   2068: flag to most of the commands by adding this line to mk.conf.
                   2069: 
                   2070: RUN=    @set -eu;
                   2071: 
1.181   ! rillig   2072: After that, ensure that none of the bulk build log files (even those for
        !          2073: successfully built packages) contains the string parameter not set or whatever
        !          2074: error message the command sh -ceu '$undefined' outputs.
        !          2075: 
1.178     rillig   2076: See mk/misc/common.mk for the existing definition.
                   2077: 
1.181   ! rillig   2078: 8.4.10. Turn off verbose logging
1.178     rillig   2079: 
                   2080: The build logs of a package are often quite long. This allows error messages or
                   2081: other interesting details to hide between the noise. To make the actual error
                   2082: message stand out more, add these lines to mk.conf.
                   2083: 
                   2084: GNU_CONFIGURE_QUIET=    yes
                   2085: MAKE_FLAGS+=            -s
                   2086: 
                   2087: The -s option works for both GNU Make and BSD Make. On exotic platforms with
                   2088: their own make, it may be a little different.
                   2089: 
                   2090: 8.5. Creating a multiple CD-ROM packages collection
1.1       dsieger  2091: 
                   2092: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
                   2093: of the resulting binary packages to assist in installing packages on other
                   2094: machines. The pkgtools/cdpack package provides a simple tool for creating the
                   2095: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
                   2096: keeps all the dependencies for a given package on the same CD as that package.
                   2097: 
1.178     rillig   2098: 8.5.1. Example of cdpack
1.1       dsieger  2099: 
                   2100: Complete documentation for cdpack is found in the cdpack(1) man page. The
                   2101: following short example assumes that the binary packages are left in /usr/
                   2102: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
                   2103: ISO 9660 images.
                   2104: 
                   2105: # mkdir /u2/images
                   2106: # pkg_add /usr/pkgsrc/packages/All/cdpack
                   2107: # cdpack /usr/pkgsrc/packages/All /u2/images
                   2108: 
                   2109: 
                   2110: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
                   2111: CD in the collection, then you need to create a directory which contains these
1.175     gutterid 2112: files, e.g.:
1.1       dsieger  2113: 
                   2114: # mkdir /tmp/common
                   2115: # echo "This is a README" > /tmp/common/README
                   2116: # echo "Another file" > /tmp/common/COPYING
                   2117: # mkdir /tmp/common/bin
                   2118: # echo "#!/bin/sh" > /tmp/common/bin/myscript
                   2119: # echo "echo Hello world" >> /tmp/common/bin/myscript
                   2120: # chmod 755 /tmp/common/bin/myscript
                   2121: 
                   2122: 
                   2123: Now create the images:
                   2124: 
                   2125: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
                   2126: 
                   2127: Each image will contain README, COPYING, and bin/myscript in their root
                   2128: directories.
                   2129: 
1.154     rillig   2130: Chapter 9. Directory layout of the installed files
1.1       dsieger  2131: 
                   2132: Table of Contents
                   2133: 
1.154     rillig   2134: 9.1. File system layout in ${LOCALBASE}
                   2135: 9.2. File system layout in ${VARBASE}
1.1       dsieger  2136: 
                   2137: The files that are installed by pkgsrc are organized in a way that is similar
                   2138: to what you find in the /usr directory of the base system. But some details are
                   2139: different. This is because pkgsrc initially came from FreeBSD and had adopted
                   2140: its file system hierarchy. Later it was largely influenced by NetBSD. But no
                   2141: matter which operating system you are using pkgsrc with, you can expect the
                   2142: same layout for pkgsrc.
                   2143: 
                   2144: There are mainly four root directories for pkgsrc, which are all configurable
                   2145: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
                   2146: default locations are:
                   2147: 
                   2148: LOCALBASE=              /usr/pkg
                   2149: PKG_SYSCONFBASE=        /usr/pkg/etc
                   2150: VARBASE=                /var
1.119     sevan    2151: PKG_DBDIR=              /usr/pkg/pkgdb
1.1       dsieger  2152: 
                   2153: In unprivileged mode (when pkgsrc has been installed as any other user), the
                   2154: default locations are:
                   2155: 
                   2156: LOCALBASE=              ${HOME}/pkg
                   2157: PKG_SYSCONFBASE=        ${HOME}/pkg/etc
                   2158: VARBASE=                ${HOME}/pkg/var
1.119     sevan    2159: PKG_DBDIR=              ${HOME}/pkg/pkgdb
1.1       dsieger  2160: 
                   2161: What these four directories are for, and what they look like is explained
                   2162: below.
                   2163: 
1.25      wiz      2164:   * LOCALBASE corresponds to the /usr directory in the base system. It is the "
                   2165:     main" directory where the files are installed and contains the well-known
1.1       dsieger  2166:     subdirectories like bin, include, lib, share and sbin.
                   2167: 
                   2168:   * VARBASE corresponds to /var in the base system. Some programs (especially
                   2169:     games, network daemons) need write access to it during normal operation.
                   2170: 
                   2171:   * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
                   2172:     configuration files of the packages, as well as pkgsrc's mk.conf itself.
                   2173: 
1.154     rillig   2174: 9.1. File system layout in ${LOCALBASE}
1.1       dsieger  2175: 
                   2176: The following directories exist in a typical pkgsrc installation in $
                   2177: {LOCALBASE}.
                   2178: 
                   2179: bin
                   2180: 
                   2181:     Contains executable programs that are intended to be directly used by the
                   2182:     end user.
                   2183: 
                   2184: emul
                   2185: 
                   2186:     Contains files for the emulation layers of various other operating systems,
                   2187:     especially for NetBSD.
                   2188: 
                   2189: etc (the usual location of ${PKG_SYSCONFDIR})
                   2190: 
                   2191:     Contains the configuration files.
                   2192: 
                   2193: include
                   2194: 
                   2195:     Contains headers for the C and C++ programming languages.
                   2196: 
                   2197: info
                   2198: 
                   2199:     Contains GNU info files of various packages.
                   2200: 
                   2201: lib
                   2202: 
                   2203:     Contains shared and static libraries.
                   2204: 
                   2205: libdata
                   2206: 
                   2207:     Contains data files that don't change after installation. Other data files
                   2208:     belong into ${VARBASE}.
                   2209: 
                   2210: libexec
                   2211: 
                   2212:     Contains programs that are not intended to be used by end users, such as
                   2213:     helper programs or network daemons.
                   2214: 
                   2215: libexec/cgi-bin
                   2216: 
                   2217:     Contains programs that are intended to be executed as CGI scripts by a web
                   2218:     server.
                   2219: 
                   2220: man (the usual value of ${PKGMANDIR})
                   2221: 
                   2222:     Contains brief documentation in form of manual pages.
                   2223: 
                   2224: sbin
                   2225: 
                   2226:     Contains programs that are intended to be used only by the super-user.
                   2227: 
                   2228: share
                   2229: 
                   2230:     Contains platform-independent data files that don't change after
                   2231:     installation.
                   2232: 
                   2233: share/doc
                   2234: 
                   2235:     Contains documentation files provided by the packages.
                   2236: 
                   2237: share/examples
                   2238: 
                   2239:     Contains example files provided by the packages. Among others, the original
                   2240:     configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
                   2241:     installation.
                   2242: 
                   2243: share/examples/rc.d
                   2244: 
                   2245:     Contains the original files for rc.d scripts.
                   2246: 
                   2247: var (the usual location of ${VARBASE})
                   2248: 
                   2249:     Contains files that may be modified after installation.
                   2250: 
1.154     rillig   2251: 9.2. File system layout in ${VARBASE}
1.1       dsieger  2252: 
                   2253: db/pkg (the usual location of ${PKG_DBDIR})
                   2254: 
                   2255:     Contains information about the currently installed packages.
                   2256: 
                   2257: games
                   2258: 
                   2259:     Contains highscore files.
                   2260: 
                   2261: log
                   2262: 
                   2263:     Contains log files.
                   2264: 
                   2265: run
                   2266: 
                   2267:     Contains informational files about daemons that are currently running.
                   2268: 
1.154     rillig   2269: Chapter 10. Frequently Asked Questions
1.1       dsieger  2270: 
                   2271: Table of Contents
                   2272: 
1.154     rillig   2273: 10.1. Are there any mailing lists for pkg-related discussion?
                   2274: 10.2. Utilities for package management (pkgtools)
                   2275: 10.3. How to use pkgsrc as non-root
                   2276: 10.4. How to resume transfers when fetching distfiles?
                   2277: 10.5. How can I install/use modular X.org from pkgsrc?
                   2278: 10.6. How to fetch files from behind a firewall
                   2279: 10.7. How to fetch files from HTTPS sites
                   2280: 10.8. How do I tell make fetch to do passive FTP?
                   2281: 10.9. How to fetch all distfiles at once
                   2282: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
                   2283: 10.11. What does "Could not find bsd.own.mk" mean?
                   2284: 10.12. Using 'sudo' with pkgsrc
                   2285: 10.13. How do I change the location of configuration files?
                   2286: 10.14. Automated security checks
                   2287: 10.15. Why do some packages ignore my CFLAGS?
                   2288: 10.16. A package does not build. What shall I do?
                   2289: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24      wiz      2290:     conflicts" mean?
1.1       dsieger  2291: 
                   2292: This section contains hints, tips & tricks on special things in pkgsrc that we
                   2293: didn't find a better place for in the previous chapters, and it contains items
                   2294: for both pkgsrc users and developers.
                   2295: 
1.154     rillig   2296: 10.1. Are there any mailing lists for pkg-related discussion?
1.1       dsieger  2297: 
                   2298: The following mailing lists may be of interest to pkgsrc users:
                   2299: 
                   2300:   * pkgsrc-users: This is a general purpose list for most issues regarding
                   2301:     pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
                   2302:     configuration, unexpected build failures, using particular packages,
                   2303:     upgrading pkgsrc installations, questions regarding the pkgsrc release
                   2304:     branches, etc. General announcements or proposals for changes that impact
                   2305:     the pkgsrc user community, e.g. major infrastructure changes, new features,
                   2306:     package removals, etc., may also be posted.
                   2307: 
                   2308:   * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
                   2309:     discussed.
                   2310: 
                   2311:   * pkgsrc-changes: This list is for those who are interested in getting a
                   2312:     commit message for every change committed to pkgsrc. It is also available
                   2313:     in digest form, meaning one daily message containing all commit messages
                   2314:     for changes to the package source tree in that 24 hour period.
                   2315: 
                   2316: To subscribe, do:
                   2317: 
                   2318: % echo subscribe listname | mail majordomo@NetBSD.org
                   2319: 
1.174     leot     2320: Archives for all these mailing lists are available from https://
1.1       dsieger  2321: mail-index.NetBSD.org/.
                   2322: 
1.154     rillig   2323: 10.2. Utilities for package management (pkgtools)
1.1       dsieger  2324: 
                   2325: The directory pkgsrc/pkgtools contains a number of useful utilities for both
                   2326: users and developers of pkgsrc. This section attempts only to make the reader
1.121     sevan    2327: aware of some of the utilities and when they might be useful, and not to
                   2328: duplicate the documentation that comes with each package.
1.1       dsieger  2329: 
                   2330: Utilities used by pkgsrc (automatically installed when needed):
                   2331: 
                   2332:   * pkgtools/x11-links: Symlinks for use by buildlink.
                   2333: 
                   2334: OS tool augmentation (automatically installed when needed):
                   2335: 
1.121     sevan    2336:   * pkgtools/digest: Calculates various kinds of checksums (including SHA3).
1.1       dsieger  2337: 
                   2338:   * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
                   2339: 
                   2340:   * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
                   2341: 
                   2342:   * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
                   2343:     for use on operating systems where pkg_install is not present.
                   2344: 
                   2345: Utilities used by pkgsrc (not automatically installed):
                   2346: 
                   2347:   * pkgtools/pkg_tarup: Create a binary package from an already-installed
                   2348:     package. Used by make replace to save the old package.
                   2349: 
                   2350:   * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
                   2351:     distfiles from multiple locations. It currently supports the following
                   2352:     methods: multiple CD-ROMs and network FTP/HTTP connections.
                   2353: 
                   2354:   * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24      wiz      2355:     current CPU and compiler.
1.1       dsieger  2356: 
                   2357: Utilities for keeping track of installed packages, being up to date, etc:
                   2358: 
1.65      wiz      2359:   * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
                   2360:     and upgrade binary packages easily.
                   2361: 
1.1       dsieger  2362:   * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
                   2363:     the latest pkgsrc entries.
                   2364: 
                   2365:   * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
                   2366:     strategy for updating.
                   2367: 
                   2368:   * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
                   2369:     graphviz).
                   2370: 
1.12      weinem   2371:   * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
                   2372: 
                   2373:   * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
                   2374:     complete pkgsrc system.
1.1       dsieger  2375: 
                   2376:   * pkgtools/pkgsurvey: Report what packages you have installed.
                   2377: 
                   2378: Utilities for people maintaining or creating individual packages:
                   2379: 
                   2380:   * pkgtools/pkgdiff: Automate making and maintaining patches for a package
                   2381:     (includes pkgdiff, pkgvi, mkpatches, etc.).
                   2382: 
1.65      wiz      2383:   * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1       dsieger  2384: 
                   2385: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
                   2386: 
                   2387:   * pkgtools/pkg_comp: Build packages in a chrooted area.
                   2388: 
                   2389:   * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
                   2390: 
1.154     rillig   2391: 10.3. How to use pkgsrc as non-root
1.1       dsieger  2392: 
1.108     rillig   2393: To install packages from source as a non-root user, download pkgsrc as
1.154     rillig   2394: described in Chapter 3, Where to get pkgsrc and how to keep it up-to-date, cd
1.108     rillig   2395: into that directory and run the command ./bootstrap/bootstrap --unprivileged.
                   2396: 
                   2397: This will install the binary part of pkgsrc to ~/pkg and put the pkgsrc
                   2398: configuration mk.conf into ~/pkg/etc.
                   2399: 
                   2400: For more details, see mk/unprivileged.mk.
1.1       dsieger  2401: 
1.154     rillig   2402: 10.4. How to resume transfers when fetching distfiles?
1.1       dsieger  2403: 
                   2404: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4       rillig   2405: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
                   2406: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1       dsieger  2407: 
1.61      wiz      2408: You can also use a different program than the platform default program by
                   2409: changing the FETCH_USING variable. You can specify the program by using of ftp,
                   2410: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
                   2411: manual. A value of custom disables the system defaults and dependency tracking
                   2412: for the fetch program. In that case you have to provide FETCH_CMD,
                   2413: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1       dsieger  2414: 
1.16      jnemeth  2415: For example, if you want to use wget to download, you'll have to use something
                   2416: like:
1.1       dsieger  2417: 
1.16      jnemeth  2418: FETCH_USING=    wget
1.1       dsieger  2419: 
1.154     rillig   2420: 10.5. How can I install/use modular X.org from pkgsrc?
1.1       dsieger  2421: 
1.4       rillig   2422: If you want to use modular X.org from pkgsrc instead of your system's own X11
                   2423: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1       dsieger  2424: mk.conf:
                   2425: 
1.4       rillig   2426: X11_TYPE=modular
1.1       dsieger  2427: 
1.154     rillig   2428: 10.6. How to fetch files from behind a firewall
1.1       dsieger  2429: 
                   2430: If you are sitting behind a firewall which does not allow direct connections to
                   2431: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
                   2432: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
                   2433: machine "orpheus.amdahl.com" is one of the firewalls, and it uses port 80 as
                   2434: the proxy port number. So the proxy environment variables are:
                   2435: 
                   2436: ftp_proxy=ftp://orpheus.amdahl.com:80/
                   2437: http_proxy=http://orpheus.amdahl.com:80/
                   2438: 
1.154     rillig   2439: 10.7. How to fetch files from HTTPS sites
1.65      wiz      2440: 
                   2441: Some fetch tools are not prepared to support HTTPS by default (for example, the
                   2442: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
                   2443: openssl dependency that low in the dependency graph).
                   2444: 
                   2445: Usually you won't notice, because distribution files are mirrored weekly to "
                   2446: ftp.NetBSD.org", but that might not be often enough if you are following
                   2447: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to "curl" or
                   2448: "wget", which are both compiled with HTTPS support by default. Of course, these
                   2449: tools need to be installed before you can use them this way.
                   2450: 
1.154     rillig   2451: 10.8. How do I tell make fetch to do passive FTP?
1.1       dsieger  2452: 
                   2453: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
                   2454: FETCH_CMD is assigned the first available command from the following list:
                   2455: 
                   2456:   * ${LOCALBASE}/bin/ftp
                   2457: 
                   2458:   * /usr/bin/ftp
                   2459: 
                   2460: On a default NetBSD installation, this will be /usr/bin/ftp, which
                   2461: automatically tries passive connections first, and falls back to active
                   2462: connections if the server refuses to do passive. For the other tools, add the
1.4       rillig   2463: following to your mk.conf file: PASSIVE_FETCH=1.
1.1       dsieger  2464: 
                   2465: Having that option present will prevent /usr/bin/ftp from falling back to
                   2466: active transfers.
                   2467: 
1.154     rillig   2468: 10.9. How to fetch all distfiles at once
1.1       dsieger  2469: 
                   2470: You would like to download all the distfiles in a single batch from work or
                   2471: university, where you can't run a make fetch. There is an archive of distfiles
                   2472: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
                   2473: 
                   2474: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
                   2475: subdirectories, carry the resulting list to your machine at work/school and use
                   2476: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
                   2477: don't forget to set FETCH_CMD to something that fetches a URL:
                   2478: 
                   2479: At home:
                   2480: 
                   2481: % cd /usr/pkgsrc
                   2482: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
                   2483: % scp /tmp/fetch.sh work:/tmp
                   2484: 
                   2485: At work:
                   2486: 
                   2487: % sh /tmp/fetch.sh
                   2488: 
                   2489: then tar up /tmp/distfiles and take it home.
                   2490: 
                   2491: If you have a machine running NetBSD, and you want to get all distfiles (even
                   2492: ones that aren't for your machine architecture), you can do so by using the
                   2493: above-mentioned make fetch-list approach, or fetch the distfiles directly by
                   2494: running:
                   2495: 
                   2496: % make mirror-distfiles
                   2497: 
                   2498: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
                   2499: everything by running:
                   2500: 
                   2501: % make fetch NO_SKIP=yes
                   2502: 
1.154     rillig   2503: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
1.1       dsieger  2504: 
                   2505: When compiling the pkgtools/pkg_install package, you get the error from make
                   2506: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
                   2507: that you don't have installed the "text" set (nroff, ...) from the NetBSD base
                   2508: distribution on your machine. It is recommended to do that to format man pages.
                   2509: 
                   2510: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4       rillig   2511: NOMAN=YES either in the environment or in mk.conf.
1.1       dsieger  2512: 
1.154     rillig   2513: 10.11. What does "Could not find bsd.own.mk" mean?
1.1       dsieger  2514: 
                   2515: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
                   2516: machine. Please get and install it, by extracting it in /:
                   2517: 
                   2518: # cd /
                   2519: # tar --unlink -zxvpf .../comp.tgz
                   2520: 
                   2521: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
                   2522: release (determine via uname -r).
                   2523: 
1.154     rillig   2524: 10.12. Using 'sudo' with pkgsrc
1.1       dsieger  2525: 
                   2526: When installing packages as non-root user and using the just-in-time su(1)
                   2527: feature of pkgsrc, it can become annoying to type in the root password for each
                   2528: required package installed. To avoid this, the sudo package can be used, which
                   2529: does password caching over a limited time. To use it, install sudo (either as
1.4       rillig   2530: binary package or from security/sudo) and then put the following into your
                   2531: mk.conf, somewhere after the definition of the LOCALBASE variable:
1.1       dsieger  2532: 
                   2533: .if exists(${LOCALBASE}/bin/sudo)
                   2534: SU_CMD=        ${LOCALBASE}/bin/sudo /bin/sh -c
                   2535: .endif
                   2536: 
1.154     rillig   2537: 10.13. How do I change the location of configuration files?
1.1       dsieger  2538: 
                   2539: As the system administrator, you can choose where configuration files are
                   2540: installed. The default settings make all these files go into ${PREFIX}/etc or
                   2541: some of its subdirectories; this may be suboptimal depending on your
                   2542: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
                   2543: configuration of the provided packages).
                   2544: 
                   2545: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4       rillig   2546: (in mk.conf) to point to your preferred configuration directory; some common
                   2547: examples include /etc or /etc/pkg.
1.1       dsieger  2548: 
                   2549: Furthermore, you can change this value on a per-package basis by setting the
                   2550: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
                   2551: matches the name of the package you would like to modify, that is, the contents
                   2552: of PKGBASE.
                   2553: 
                   2554: Note that after changing these settings, you must rebuild and reinstall any
                   2555: affected packages.
                   2556: 
1.154     rillig   2557: 10.14. Automated security checks
1.1       dsieger  2558: 
                   2559: Please be aware that there can often be bugs in third-party software, and some
                   2560: of these bugs can leave a machine vulnerable to exploitation by attackers. In
                   2561: an effort to lessen the exposure, the NetBSD packages team maintains a database
                   2562: of known-exploits to packages which have at one time been included in pkgsrc.
                   2563: The database can be downloaded automatically, and a security audit of all
1.14      jmcneill 2564: packages installed on a system can take place. To do this, refer to the
                   2565: following two tools (installed as part of the pkgtools/pkg_install package):
1.1       dsieger  2566: 
1.21      snj      2567:  1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
                   2568:     security vulnerabilities information. This list is kept up to date by the
1.26      spz      2569:     pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1       dsieger  2570: 
1.177     leot     2571:     https://ftp.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities
1.1       dsieger  2572: 
1.21      snj      2573:  2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24      wiz      2574:     known vulnerability. If a vulnerable package is installed, it will be shown
                   2575:     by output to stdout, including a description of the type of vulnerability,
                   2576:     and a URL containing more information.
1.1       dsieger  2577: 
1.154     rillig   2578: Use of these tools is strongly recommended! See Section 5.1.5, "Checking for
1.121     sevan    2579: security vulnerabilities in installed packages" for instructions on how to
                   2580: automate checking and reporting.
                   2581: 
                   2582: If this database is installed, pkgsrc builds will use it to perform a security
                   2583: check before building any package.
1.1       dsieger  2584: 
1.154     rillig   2585: 10.15. Why do some packages ignore my CFLAGS?
1.1       dsieger  2586: 
                   2587: When you add your own preferences to the CFLAGS variable in your mk.conf, these
                   2588: flags are passed in environment variables to the ./configure scripts and to
                   2589: make(1). Some package authors ignore the CFLAGS from the environment variable
                   2590: by overriding them in the Makefiles of their package.
                   2591: 
                   2592: Currently there is no solution to this problem. If you really need the package
                   2593: to use your CFLAGS you should run make patch in the package directory and then
                   2594: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
                   2595: Usually you can remove these lines. But be aware that some "smart" programmers
                   2596: write so bad code that it only works for the specific combination of CFLAGS
                   2597: they have chosen.
                   2598: 
1.172     rillig   2599: To find out where the CFLAGS are ignored, add the following lines to mk.conf:
                   2600: 
                   2601: CPPFLAGS+=              -Dpkgsrc___CPPFLAGS
                   2602: CFLAGS+=                -Dpkgsrc___CFLAGS
                   2603: CXXFLAGS+=              -Dpkgsrc___CXXFLAGS
                   2604: 
                   2605: Then run bmake show-all-configure show-all-build to see whether the above flags
                   2606: are passed to the actual build commands in general.
                   2607: 
                   2608: To find out whether the flags are passed to individual compiler commands, have
                   2609: a look at the file work/.work.log. In most cases, the flags from the original
                   2610: command lines (the lines starting with [*]) are passed unmodified to the actual
                   2611: compiler (the lines starting with <.>). If the flag is missing from the actual
                   2612: compiler command, it must have been removed by the pkgsrc compiler wrappers.
                   2613: 
1.154     rillig   2614: 10.16. A package does not build. What shall I do?
1.1       dsieger  2615: 
                   2616:  1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
                   2617:     is that people only update pkgsrc in parts, because of performance reasons.
                   2618:     Since pkgsrc is one large system, not a collection of many small systems,
                   2619:     there are sometimes changes that only work when the whole pkgsrc tree is
                   2620:     updated.
                   2621: 
1.25      wiz      2622:  2. Make sure that you don't have any CVS conflicts. Search for "<<<<<<" or "
                   2623:     >>>>>>" in all your pkgsrc files.
1.1       dsieger  2624: 
1.25      wiz      2625:  3. Make sure that you don't have old copies of the packages extracted. Run 
1.1       dsieger  2626:     make clean clean-depends to verify this.
                   2627: 
1.108     rillig   2628:  4. If you are a package developer who wants to invest some work, have a look
1.154     rillig   2629:     at Chapter 21, Making your package work.
1.108     rillig   2630: 
                   2631:  5. If the problem still exists, write a mail to the pkgsrc-users mailing list.
1.1       dsieger  2632: 
1.154     rillig   2633: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.1       dsieger  2634: conflicts" mean?
                   2635: 
                   2636: You have modified a file from pkgsrc, and someone else has modified that same
                   2637: file afterwards in the CVS repository. Both changes are in the same region of
                   2638: the file, so when you updated pkgsrc, the cvs command marked the conflicting
                   2639: changes in the file. Because of these markers, the file is no longer a valid
                   2640: Makefile.
                   2641: 
                   2642: Have a look at that file, and if you don't need your local changes anymore, you
                   2643: can remove that file and run cvs -q update -dP in that directory to download
                   2644: the current version.
                   2645: 
                   2646: Part II. The pkgsrc developer's guide
                   2647: 
                   2648: This part of the book deals with creating and modifying packages. It starts
                   2649: with a "HOWTO"-like guide on creating a new package. The remaining chapters are
                   2650: more like a reference manual for pkgsrc.
                   2651: 
                   2652: Table of Contents
                   2653: 
1.154     rillig   2654: 11. Getting help
                   2655: 12. Creating a new pkgsrc package from scratch
1.1       dsieger  2656: 
1.154     rillig   2657:     12.1. Common types of packages
1.1       dsieger  2658: 
1.154     rillig   2659:         12.1.1. Perl modules
                   2660:         12.1.2. Python modules and programs
1.160     brook    2661:         12.1.3. R packages
                   2662:         12.1.4. TeXlive packages
1.1       dsieger  2663: 
1.154     rillig   2664:     12.2. Examples
1.1       dsieger  2665: 
1.154     rillig   2666:         12.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  2667: 
1.154     rillig   2668: 13. Package components - files, directories and contents
1.1       dsieger  2669: 
1.154     rillig   2670:     13.1. Makefile
                   2671:     13.2. distinfo
                   2672:     13.3. patches/*
1.1       dsieger  2673: 
1.154     rillig   2674:         13.3.1. Structure of a single patch file
                   2675:         13.3.2. Creating patch files
                   2676:         13.3.3. Sources where the patch files come from
                   2677:         13.3.4. Patching guidelines
                   2678:         13.3.5. Feedback to the author
1.1       dsieger  2679: 
1.154     rillig   2680:     13.4. Other mandatory files
                   2681:     13.5. Optional files
1.1       dsieger  2682: 
1.154     rillig   2683:         13.5.1. Files affecting the binary package
                   2684:         13.5.2. Files affecting the build process
                   2685:         13.5.3. Files affecting nothing at all
1.1       dsieger  2686: 
1.154     rillig   2687:     13.6. work*
                   2688:     13.7. files/*
1.1       dsieger  2689: 
1.154     rillig   2690: 14. Programming in Makefiles
1.1       dsieger  2691: 
1.154     rillig   2692:     14.1. Caveats
                   2693:     14.2. Makefile variables
1.1       dsieger  2694: 
1.154     rillig   2695:         14.2.1. Naming conventions
1.1       dsieger  2696: 
1.154     rillig   2697:     14.3. Code snippets
1.1       dsieger  2698: 
1.154     rillig   2699:         14.3.1. Adding things to a list
                   2700:         14.3.2. Echoing a string exactly as-is
                   2701:         14.3.3. Passing CFLAGS to GNU configure scripts
                   2702:         14.3.4. Handling possibly empty variables
1.1       dsieger  2703: 
1.154     rillig   2704: 15. PLIST issues
1.1       dsieger  2705: 
1.154     rillig   2706:     15.1. RCS ID
                   2707:     15.2. Semi-automatic PLIST generation
                   2708:     15.3. Tweaking output of make print-PLIST
                   2709:     15.4. Variable substitution in PLIST
                   2710:     15.5. Man page compression
                   2711:     15.6. Changing PLIST source with PLIST_SRC
                   2712:     15.7. Platform-specific and differing PLISTs
                   2713:     15.8. Build-specific PLISTs
                   2714:     15.9. Sharing directories between packages
1.1       dsieger  2715: 
1.154     rillig   2716: 16. Buildlink methodology
1.1       dsieger  2717: 
1.154     rillig   2718:     16.1. Converting packages to use buildlink3
                   2719:     16.2. Writing buildlink3.mk files
1.1       dsieger  2720: 
1.154     rillig   2721:         16.2.1. Anatomy of a buildlink3.mk file
                   2722:         16.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
1.27      wiz      2723:             pkg in buildlink3.mk files
1.1       dsieger  2724: 
1.154     rillig   2725:     16.3. Writing builtin.mk files
1.1       dsieger  2726: 
1.154     rillig   2727:         16.3.1. Anatomy of a builtin.mk file
                   2728:         16.3.2. Global preferences for native or pkgsrc software
1.1       dsieger  2729: 
1.154     rillig   2730: 17. The pkginstall framework
1.1       dsieger  2731: 
1.154     rillig   2732:     17.1. Files and directories outside the installation prefix
1.1       dsieger  2733: 
1.154     rillig   2734:         17.1.1. Directory manipulation
                   2735:         17.1.2. File manipulation
1.1       dsieger  2736: 
1.154     rillig   2737:     17.2. Configuration files
1.1       dsieger  2738: 
1.154     rillig   2739:         17.2.1. How PKG_SYSCONFDIR is set
                   2740:         17.2.2. Telling the software where configuration files are
                   2741:         17.2.3. Patching installations
                   2742:         17.2.4. Disabling handling of configuration files
1.1       dsieger  2743: 
1.154     rillig   2744:     17.3. System startup scripts
1.1       dsieger  2745: 
1.154     rillig   2746:         17.3.1. Disabling handling of system startup scripts
1.1       dsieger  2747: 
1.154     rillig   2748:     17.4. System users and groups
                   2749:     17.5. System shells
1.1       dsieger  2750: 
1.154     rillig   2751:         17.5.1. Disabling shell registration
1.1       dsieger  2752: 
1.154     rillig   2753:     17.6. Fonts
1.1       dsieger  2754: 
1.154     rillig   2755:         17.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  2756: 
1.154     rillig   2757: 18. Options handling
1.1       dsieger  2758: 
1.154     rillig   2759:     18.1. Global default options
                   2760:     18.2. Converting packages to use bsd.options.mk
                   2761:     18.3. Option Names
                   2762:     18.4. Determining the options of dependencies
1.1       dsieger  2763: 
1.154     rillig   2764: 19. The build process
1.1       dsieger  2765: 
1.154     rillig   2766:     19.1. Introduction
                   2767:     19.2. Program location
                   2768:     19.3. Directories used during the build process
                   2769:     19.4. Running a phase
                   2770:     19.5. The fetch phase
1.1       dsieger  2771: 
1.154     rillig   2772:         19.5.1. What to fetch and where to get it from
                   2773:         19.5.2. How are the files fetched?
1.1       dsieger  2774: 
1.154     rillig   2775:     19.6. The checksum phase
                   2776:     19.7. The extract phase
                   2777:     19.8. The patch phase
                   2778:     19.9. The tools phase
                   2779:     19.10. The wrapper phase
                   2780:     19.11. The configure phase
                   2781:     19.12. The build phase
                   2782:     19.13. The test phase
                   2783:     19.14. The install phase
                   2784:     19.15. The package phase
                   2785:     19.16. Cleaning up
                   2786:     19.17. Other helpful targets
1.1       dsieger  2787: 
1.154     rillig   2788: 20. Tools needed for building or running
1.1       dsieger  2789: 
1.154     rillig   2790:     20.1. Tools for pkgsrc builds
                   2791:     20.2. Tools needed by packages
                   2792:     20.3. Tools provided by platforms
1.1       dsieger  2793: 
1.154     rillig   2794: 21. Making your package work
1.1       dsieger  2795: 
1.154     rillig   2796:     21.1. General operation
1.1       dsieger  2797: 
1.154     rillig   2798:         21.1.1. How to pull in user-settable variables from mk.conf
                   2799:         21.1.2. User interaction
                   2800:         21.1.3. Handling licenses
                   2801:         21.1.4. Restricted packages
                   2802:         21.1.5. Handling dependencies
                   2803:         21.1.6. Handling conflicts with other packages
                   2804:         21.1.7. Packages that cannot or should not be built
                   2805:         21.1.8. Packages which should not be deleted, once installed
                   2806:         21.1.9. Handling packages with security problems
                   2807:         21.1.10. How to handle incrementing versions when fixing an existing
1.1       dsieger  2808:             package
1.154     rillig   2809:         21.1.11. Substituting variable text in the package files (the SUBST
1.1       dsieger  2810:             framework)
                   2811: 
1.154     rillig   2812:     21.2. The fetch phase
1.1       dsieger  2813: 
1.154     rillig   2814:         21.2.1. Packages whose distfiles aren't available for plain downloading
                   2815:         21.2.2. How to handle modified distfiles with the 'old' name
                   2816:         21.2.3. Packages hosted on github.com
                   2817: 
                   2818:     21.3. The configure phase
                   2819: 
                   2820:         21.3.1. Shared libraries - libtool
                   2821:         21.3.2. Using libtool on GNU packages that already support libtool
                   2822:         21.3.3. GNU Autoconf/Automake
                   2823: 
                   2824:     21.4. Programming languages
                   2825: 
                   2826:         21.4.1. C, C++, and Fortran
                   2827:         21.4.2. Java
                   2828:         21.4.3. Packages containing perl scripts
                   2829:         21.4.4. Packages containing shell scripts
                   2830:         21.4.5. Other programming languages
                   2831: 
                   2832:     21.5. The build phase
                   2833: 
                   2834:         21.5.1. Compiling C and C++ code conditionally
                   2835:         21.5.2. How to handle compiler bugs
1.172     rillig   2836:         21.5.3. No such file or directory
                   2837:         21.5.4. Undefined reference to "..."
                   2838:         21.5.5. Running out of memory
1.154     rillig   2839: 
                   2840:     21.6. The install phase
                   2841: 
                   2842:         21.6.1. Creating needed directories
                   2843:         21.6.2. Where to install documentation
                   2844:         21.6.3. Installing highscore files
                   2845:         21.6.4. Adding DESTDIR support to packages
                   2846:         21.6.5. Packages with hardcoded paths to other interpreters
                   2847:         21.6.6. Packages installing perl modules
                   2848:         21.6.7. Packages installing info files
                   2849:         21.6.8. Packages installing man pages
                   2850:         21.6.9. Packages installing GConf data files
                   2851:         21.6.10. Packages installing scrollkeeper/rarian data files
                   2852:         21.6.11. Packages installing X11 fonts
                   2853:         21.6.12. Packages installing GTK2 modules
                   2854:         21.6.13. Packages installing SGML or XML data
                   2855:         21.6.14. Packages installing extensions to the MIME database
                   2856:         21.6.15. Packages using intltool
                   2857:         21.6.16. Packages installing startup scripts
                   2858:         21.6.17. Packages installing TeX modules
                   2859:         21.6.18. Packages supporting running binaries in emulation
                   2860:         21.6.19. Packages installing hicolor theme icons
                   2861:         21.6.20. Packages installing desktop files
                   2862: 
                   2863:     21.7. Marking packages as having problems
                   2864: 
                   2865: 22. Debugging
                   2866: 23. Submitting and Committing
                   2867: 
                   2868:     23.1. Submitting binary packages
                   2869:     23.2. Submitting source packages (for non-NetBSD-developers)
                   2870:     23.3. General notes when adding, updating, or removing packages
                   2871:     23.4. Commit Messages
                   2872:     23.5. Committing: Adding a package to CVS
                   2873:     23.6. Updating a package to a newer version
                   2874:     23.7. Renaming a package in pkgsrc
                   2875:     23.8. Moving a package in pkgsrc
                   2876: 
                   2877: 24. Frequently Asked Questions
                   2878: 25. GNOME packaging and porting
                   2879: 
                   2880:     25.1. Meta packages
                   2881:     25.2. Packaging a GNOME application
                   2882:     25.3. Updating GNOME to a newer version
                   2883:     25.4. Patching guidelines
                   2884: 
                   2885: Chapter 11. Getting help
                   2886: 
                   2887: To get help when developing pkgsrc, the definitive source is this document, the
                   2888: pkgsrc guide. If you don't find anything here, there are alternatives:
                   2889: 
                   2890:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
                   2891:     Run bmake help topic=? to get help for any topic, such as a variable name
                   2892:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                   2893:     like strcasecmp or any other topic.
                   2894: 
                   2895:     The available help topics are listed in Appendix D, Help topics.
                   2896: 
1.163     rillig   2897:   * To see the value of a single variable, run bmake show-var VARNAME=X.
                   2898: 
                   2899:   * To see the values of the most common variables, run bmake show-all. These
                   2900:     variables are grouped by topic. To see the variables for a single topic,
                   2901:     run bmake show-all-topic, for example bmake show-all-fetch.
                   2902: 
1.154     rillig   2903:   * The tech-pkg mailing list, to which you can subscribe and then ask your
                   2904:     questions.
                   2905: 
                   2906:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                   2907:     a specialized chat program such as XChat. Pick any user name and join the
                   2908:     channel #pkgsrc.
1.1       dsieger  2909: 
1.154     rillig   2910: Chapter 12. Creating a new pkgsrc package from scratch
1.1       dsieger  2911: 
                   2912: Table of Contents
                   2913: 
1.154     rillig   2914: 12.1. Common types of packages
1.1       dsieger  2915: 
1.154     rillig   2916:     12.1.1. Perl modules
                   2917:     12.1.2. Python modules and programs
1.160     brook    2918:     12.1.3. R packages
                   2919:     12.1.4. TeXlive packages
1.1       dsieger  2920: 
1.154     rillig   2921: 12.2. Examples
1.1       dsieger  2922: 
1.154     rillig   2923:     12.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  2924: 
                   2925: When you find a package that is not yet in pkgsrc, you most likely have a URL
                   2926: from where you can download the source code. Starting with this URL, creating a
                   2927: package involves only a few steps.
                   2928: 
                   2929:  1. First, install the packages pkgtools/url2pkg and pkgtools/pkglint.
                   2930: 
                   2931:  2. Then, choose one of the top-level directories as the category in which you
                   2932:     want to place your package. You can also create a directory of your own
                   2933:     (maybe called local). In that category directory, create another directory
                   2934:     for your package and change into it.
                   2935: 
                   2936:  3. Run the program url2pkg, which will ask you for a URL. Enter the URL of the
                   2937:     distribution file (in most cases a .tar.gz file) and watch how the basic
                   2938:     ingredients of your package are created automatically. The distribution
                   2939:     file is extracted automatically to fill in some details in the Makefile
                   2940:     that would otherwise have to be done manually.
                   2941: 
                   2942:  4. Examine the extracted files to determine the dependencies of your package.
                   2943:     Ideally, this is mentioned in some README file, but things may differ. For
                   2944:     each of these dependencies, look where it exists in pkgsrc, and if there is
                   2945:     a file called buildlink3.mk in that directory, add a line to your package
                   2946:     Makefile which includes that file just before the last line. If the
1.26      spz      2947:     buildlink3.mk file does not exist, it must be created first. The
                   2948:     buildlink3.mk file makes sure that the package's include files and
                   2949:     libraries are provided.
                   2950: 
                   2951:     If you just need binaries from a package, add a DEPENDS line to the
                   2952:     Makefile, which specifies the version of the dependency and where it can be
                   2953:     found in pkgsrc. This line should be placed in the third paragraph. If the
1.1       dsieger  2954:     dependency is only needed for building the package, but not when using it,
1.156     leot     2955:     use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The difference
                   2956:     between TOOL_DEPENDS and BUILD_DEPENDS occurs when cross-compiling:
                   2957:     TOOL_DEPENDS are native packages, i.e. packages for the architecture where
                   2958:     the package is built; BUILD_DEPENDS are target packages, i.e. packages for
1.175     gutterid 2959:     the architecture for which the package is built. There is also
                   2960:     TEST_DEPENDS, which is used to specify a dependency used only for testing
                   2961:     the resulting package built, using the upstream project's included test
                   2962:     suite. Your package may then look like this:
1.1       dsieger  2963: 
                   2964:     [...]
                   2965: 
1.156     leot     2966:     TOOL_DEPENDS+=  libxslt-[0-9]*:../../textproc/libxslt
1.1       dsieger  2967:     DEPENDS+=       screen-[0-9]*:../../misc/screen
                   2968:     DEPENDS+=       screen>=4.0:../../misc/screen
                   2969: 
                   2970:     [...]
                   2971: 
                   2972:     .include "../../category/package/buildlink3.mk"
                   2973:     .include "../../devel/glib2/buildlink3.mk"
                   2974:     .include "../../mk/bsd.pkg.mk"
                   2975: 
                   2976:  5. Run pkglint to see what things still need to be done to make your package a
                   2977:     "good" one. If you don't know what pkglint's warnings want to tell you, try
                   2978:     pkglint --explain or pkglint -e, which outputs additional explanations.
                   2979: 
                   2980:  6. In many cases the package is not yet ready to build. You can find
1.154     rillig   2981:     instructions for the most common cases in the next section, Section 12.1,
1.1       dsieger  2982:     "Common types of packages". After you have followed the instructions over
                   2983:     there, you can hopefully continue here.
                   2984: 
                   2985:  7. Run bmake clean to clean the working directory from the extracted files.
                   2986:     Besides these files, a lot of cache files and other system information has
                   2987:     been saved in the working directory, which may become wrong after you
                   2988:     edited the Makefile.
                   2989: 
                   2990:  8. Now, run bmake to build the package. For the various things that can go
1.154     rillig   2991:     wrong in this phase, consult Chapter 21, Making your package work.
1.1       dsieger  2992: 
1.25      wiz      2993:  9. When the package builds fine, the next step is to install the package. Run 
1.1       dsieger  2994:     bmake install and hope that everything works.
                   2995: 
                   2996: 10. Up to now, the file PLIST, which contains a list of the files that are
                   2997:     installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
                   2998:     generate a probably correct list. Check the file using your preferred text
                   2999:     editor to see if the list of files looks plausible.
                   3000: 
                   3001: 11. Run pkglint again to see if the generated PLIST contains garbage or not.
                   3002: 
                   3003: 12. When you ran bmake install, the package has been registered in the database
                   3004:     of installed files, but with an empty list of files. To fix this, run bmake
                   3005:     deinstall and bmake install again. Now the package is registered with the
                   3006:     list of files from PLIST.
                   3007: 
                   3008: 13. Run bmake package to create a binary package from the set of installed
                   3009:     files.
                   3010: 
1.154     rillig   3011: 12.1. Common types of packages
1.1       dsieger  3012: 
1.154     rillig   3013: 12.1.1. Perl modules
1.1       dsieger  3014: 
                   3015: Simple Perl modules are handled automatically by url2pkg, including
                   3016: dependencies.
                   3017: 
1.154     rillig   3018: 12.1.2. Python modules and programs
1.17      imil     3019: 
                   3020: Python modules and programs packages are easily created using a set of
                   3021: predefined variables.
                   3022: 
1.63      wiz      3023: If some Python versions are not supported by the software, set the
                   3024: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
                   3025: supported, e.g.
1.17      imil     3026: 
1.93      sevan    3027: PYTHON_VERSIONS_INCOMPATIBLE=       27
1.17      imil     3028: 
1.103     wiz      3029: If the packaged software is a Python module, include one of ../../lang/python/
                   3030: egg.mk, ../../lang/python/distutils.mk, or ../../lang/python/extension.mk.
                   3031: 
                   3032: Most Python packages use either "distutils" or easy-setup/setuptools ("eggs").
1.175     gutterid 3033: If the packaged software is using setuptools, you only need to include "../../
1.103     wiz      3034: lang/python/egg.mk". Otherwise, if the software uses "distutils", include "..
1.175     gutterid 3035: /../lang/python/distutils.mk", so pkgsrc will use this framework. "distutils"
                   3036: uses a script called setup.py; if the "distutils" driver is not called
1.103     wiz      3037: setup.py, set the PYSETUP variable to the name of the script.
                   3038: 
                   3039: Either way, the package directory should be called "py-software" and PKGNAME
                   3040: should be set to "${PYPKGPREFIX}-${DISTNAME}", e.g.
1.17      imil     3041: 
                   3042: DISTNAME=   foopymodule-1.2.10
                   3043: PKGNAME=    ${PYPKGPREFIX}-${DISTNAME}
                   3044: 
1.63      wiz      3045: If it is an application, include "../../lang/python/application.mk". In order
                   3046: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
                   3047: variable and set it to the list of files (paths relative to WRKSRC) that must
                   3048: be corrected. For example:
1.17      imil     3049: 
1.63      wiz      3050: REPLACE_PYTHON=   *.py
1.17      imil     3051: 
1.63      wiz      3052: Some Python modules have separate distributions for Python-2.x and Python-3.x
                   3053: support. In pkgsrc this is handled by the versioned_dependencies.mk file. Set
                   3054: PYTHON_VERSIONED_DEPENDENCIES to the list of packages that should be depended
                   3055: upon and include "../../lang/python/versioned_dependencies.mk", then the pkgsrc
                   3056: infrastructure will depend on the appropriate package version. For example:
1.17      imil     3057: 
1.135     wiz      3058: PYTHON_VERSIONED_DEPENDENCIES=dialog
1.63      wiz      3059: 
                   3060: Look inside versioned_dependencies.mk for a list of supported packages.
1.17      imil     3061: 
1.160     brook    3062: 12.1.3. R packages
                   3063: 
                   3064: Simple R packages from CRAN are handled automatically by R2pkg, which is
                   3065: available in pkgtools/R2pkg. Individual packages (and optionally their
                   3066: dependencies) may be created and updated. R packages generally follow the same
                   3067: form, and most of the relevant information needed is contained in a DESCRIPTION
                   3068: file as part of each R package on CRAN. Consequently, R2pkg downloads that
                   3069: information and creates or updates a package in the canonical form. The
                   3070: resulting package should be reviewed for correctness.
                   3071: 
                   3072: 12.1.4. TeXlive packages
                   3073: 
                   3074: TeXlive packages from CTAN are handled automatically by texlive2pkg, which is
                   3075: available in pkgtools/texlive2pkg.
                   3076: 
                   3077: If the TeXlive package name is not known, it may be useful to search CTAN. A "
                   3078: Contained in" field on the package page typically identifies the basename of
                   3079: the package file in the TeXlive archive.
                   3080: 
                   3081: If the TeXlive package name is known, download the files from the TeXlive
                   3082: archive. For package foo, you will need to download foo.tar.xz. Most TeXlive
                   3083: packages also have associated documentation packages, so download
                   3084: foo.doc.tar.xz at the same time. These files should be placed in the
                   3085: appropriate category directory, which is often but not always print. Then run
                   3086: the following command in the category directory.
                   3087: 
                   3088: texlive2pkg foo.tar.xz foo.doc.tar.xz
                   3089: 
                   3090: This will create two packages, tex-foo and tex-foo-doc. Be sure to check that
                   3091: both packages are correct.
                   3092: 
                   3093: Finally, CTAN currently does not include version information in package
                   3094: filenames and changes their contents periodically when updates occur.
                   3095: Consequently, pkgsrc avoids downloading distfiles directly from CTAN and
                   3096: instead relies on the pkgsrc archives. For each new or updated TeXlive package,
                   3097: e.g., the main one and the corresponding documentation, upload the distfiles
                   3098: with the following command in each package directory.
                   3099: 
                   3100: make upload-distfiles
                   3101: 
1.154     rillig   3102: 12.2. Examples
1.1       dsieger  3103: 
1.154     rillig   3104: 12.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  3105: 
1.154     rillig   3106: 12.2.1.1. The initial package
1.1       dsieger  3107: 
                   3108: Looking at the file pkgsrc/doc/TODO, I saw that the "nvu" package has not yet
                   3109: been imported into pkgsrc. As the description says it has to do with the web,
                   3110: the obvious choice for the category is "www".
                   3111: 
                   3112: $ mkdir www/nvu
                   3113: $ cd www/nvu
                   3114: 
                   3115: The web site says that the sources are available as a tar file, so I fed that
                   3116: URL to the url2pkg program:
                   3117: 
                   3118: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
                   3119: 
                   3120: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
                   3121: package name should not have the word "sources" in it. I also filled in the
                   3122: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
                   3123: that:
                   3124: 
1.121     sevan    3125: # $NetBSD $
1.1       dsieger  3126: #
                   3127: 
                   3128: DISTNAME=       nvu-1.0-sources
                   3129: PKGNAME=        nvu-1.0
                   3130: CATEGORIES=     www
                   3131: MASTER_SITES=   http://cvs.nvu.com/download/
                   3132: EXTRACT_SUFX=   .tar.bz2
                   3133: 
                   3134: MAINTAINER=     rillig@NetBSD.org
                   3135: HOMEPAGE=       http://cvs.nvu.com/
                   3136: COMMENT=        Web Authoring System
                   3137: 
                   3138: # url2pkg-marker (please do not remove this line.)
                   3139: .include "../../mk/bsd.pkg.mk"
                   3140: 
1.124     wiz      3141: On the first line of output above, an artificial space has been added between
1.121     sevan    3142: NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
                   3143: the guide.
                   3144: 
1.1       dsieger  3145: Then, I quit the editor and watched pkgsrc downloading a large source archive:
                   3146: 
                   3147: url2pkg> Running "make makesum" ...
                   3148: => Required installed package digest>=20010302: digest-20060826 found
                   3149: => Fetching nvu-1.0-sources.tar.bz2
                   3150: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
                   3151: 100% |*************************************| 28992 KB  150.77 KB/s00:00 ETA
                   3152: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
                   3153: url2pkg> Running "make extract" ...
                   3154: => Required installed package digest>=20010302: digest-20060826 found
                   3155: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   3156: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   3157: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
                   3158: ===> Installing dependencies for nvu-1.0
                   3159: ===> Overriding tools for nvu-1.0
                   3160: ===> Extracting for nvu-1.0
                   3161: url2pkg> Adjusting the Makefile.
                   3162: 
                   3163: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
                   3164: 
                   3165: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
                   3166: 
1.154     rillig   3167: 12.2.1.2. Fixing all kinds of problems to make the package work
1.1       dsieger  3168: 
                   3169: Now that the package has been extracted, let's see what's inside it. The
                   3170: package has a README.txt, but that only says something about mozilla, so it's
                   3171: probably useless for seeing what dependencies this package has. But since there
                   3172: is a GNU configure script in the package, let's hope that it will complain
                   3173: about everything it needs.
                   3174: 
                   3175: $ bmake
                   3176: => Required installed package digest>=20010302: digest-20060826 found
                   3177: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   3178: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   3179: ===> Patching for nvu-1.0
                   3180: ===> Creating toolchain wrappers for nvu-1.0
                   3181: ===> Configuring for nvu-1.0
                   3182: [...]
                   3183: configure: error: Perl 5.004 or higher is required.
                   3184: [...]
                   3185: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
                   3186: [...]
                   3187: 
                   3188: That worked quite well. So I opened the package Makefile in my editor, and
                   3189: since it already has a USE_TOOLS line, I just appended "perl" to it. Since the
                   3190: dependencies of the package have changed now, and since a perl wrapper is
                   3191: automatically installed in the "tools" phase, I need to build the package from
                   3192: scratch.
                   3193: 
                   3194: $ bmake clean
                   3195: ===> Cleaning for nvu-1.0
                   3196: $ bmake
                   3197: [...]
                   3198: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
                   3199: GNU Make.  You will not be able to build Mozilla without GNU Make.
                   3200: [...]
                   3201: 
                   3202: So I added "gmake" to the USE_TOOLS line and tried again (from scratch).
                   3203: 
                   3204: [...]
                   3205: checking for GTK - version >= 1.2.0... no
                   3206: *** Could not run GTK test program, checking why...
                   3207: [...]
                   3208: 
                   3209: Now to the other dependencies. The first question is: Where is the GTK package
                   3210: hidden in pkgsrc?
                   3211: 
                   3212: $ echo ../../*/gtk*
                   3213: [many packages ...]
                   3214: $ echo ../../*/gtk
                   3215: ../../x11/gtk
                   3216: $ echo ../../*/gtk2
                   3217: ../../x11/gtk2
                   3218: $ echo ../../*/gtk2/bui*
                   3219: ../../x11/gtk2/buildlink3.mk
                   3220: 
                   3221: The first try was definitely too broad. The second one had exactly one result,
                   3222: which is very good. But there is one pitfall with GNOME packages. Before GNOME
                   3223: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
                   3224: able to continue to use these packages, the GNOME 2 packages were imported as
                   3225: separate packages, and their names usually have a "2" appended. So I checked
                   3226: whether this was the case here, and indeed it was.
                   3227: 
                   3228: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
                   3229: easy. I just inserted an .include line before the last line of the package
                   3230: Makefile, so that it now looks like this:
                   3231: 
                   3232: [...]
                   3233: .include "../../x11/gtk2/buildlink3.mk"
                   3234: .include "../../mk/bsd.pkg.mk
                   3235: 
                   3236: After another bmake clean && bmake, the answer was:
                   3237: 
                   3238: [...]
                   3239: checking for gtk-config... /home/roland/pkg/bin/gtk-config
                   3240: checking for GTK - version >= 1.2.0... no
                   3241: *** Could not run GTK test program, checking why...
                   3242: *** The test program failed to compile or link. See the file config.log for the
                   3243: *** exact error that occured. This usually means GTK was incorrectly installed
                   3244: *** or that you have moved GTK since it was installed. In the latter case, you
                   3245: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
                   3246: configure: error: Test for GTK failed.
                   3247: [...]
                   3248: 
                   3249: In this particular case, the assumption that "every package prefers GNOME 2"
                   3250: had been wrong. The first of the lines above told me that this package really
                   3251: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
                   3252: it would have looked for pkg-config instead of gtk-config. So I changed the x11
                   3253: /gtk2 to x11/gtk in the package Makefile, and tried again.
                   3254: 
                   3255: [...]
1.59      jnemeth  3256: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\"  [...]
1.1       dsieger  3257: In file included from xpidl.c:42:
                   3258: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
                   3259: In file included from xpidl.c:42:
                   3260: xpidl.h:132: error: parse error before "IDL_ns"
                   3261: [...]
                   3262: 
                   3263: The package still does not find all of its dependencies. Now the question is:
                   3264: Which package provides the libIDL/IDL.h header file?
                   3265: 
                   3266: $ echo ../../*/*idl*
                   3267: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
                   3268: $ echo ../../*/*IDL*
                   3269: ../../net/libIDL
                   3270: 
                   3271: Let's take the one from the second try. So I included the ../../net/libIDL/
                   3272: buildlink3.mk file and tried again. But the error didn't change. After digging
                   3273: through some of the code, I concluded that the build process of the package was
                   3274: broken and couldn't have ever worked, but since the Mozilla source tree is
                   3275: quite large, I didn't want to fix it. So I added the following to the package
                   3276: Makefile and tried again:
                   3277: 
                   3278: CPPFLAGS+=              -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
1.139     leot     3279: BUILDLINK_TRANSFORM+=   l:IDL:IDL-2
1.1       dsieger  3280: 
                   3281: The latter line is needed because the package expects the library libIDL.so,
                   3282: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
                   3283: that on the fly.
                   3284: 
                   3285: The next problem was related to a recent change of the FreeType interface. I
                   3286: looked up in www/seamonkey which patch files were relevant for this issue and
                   3287: copied them to the patches directory. Then I retried, fixed the patches so that
                   3288: they applied cleanly and retried again. This time, everything worked.
                   3289: 
1.154     rillig   3290: 12.2.1.3. Installing the package
1.1       dsieger  3291: 
                   3292: $ bmake CHECK_FILES=no install
                   3293: [...]
                   3294: $ bmake print-PLIST >PLIST
                   3295: $ bmake deinstall
                   3296: $ bmake install
                   3297: 
1.154     rillig   3298: Chapter 13. Package components - files, directories and contents
1.1       dsieger  3299: 
                   3300: Table of Contents
                   3301: 
1.154     rillig   3302: 13.1. Makefile
                   3303: 13.2. distinfo
                   3304: 13.3. patches/*
                   3305: 
                   3306:     13.3.1. Structure of a single patch file
                   3307:     13.3.2. Creating patch files
                   3308:     13.3.3. Sources where the patch files come from
                   3309:     13.3.4. Patching guidelines
                   3310:     13.3.5. Feedback to the author
                   3311: 
                   3312: 13.4. Other mandatory files
                   3313: 13.5. Optional files
                   3314: 
                   3315:     13.5.1. Files affecting the binary package
                   3316:     13.5.2. Files affecting the build process
                   3317:     13.5.3. Files affecting nothing at all
1.1       dsieger  3318: 
1.154     rillig   3319: 13.6. work*
                   3320: 13.7. files/*
1.1       dsieger  3321: 
                   3322: Whenever you're preparing a package, there are a number of files involved which
                   3323: are described in the following sections.
                   3324: 
1.154     rillig   3325: 13.1. Makefile
1.1       dsieger  3326: 
                   3327: Building, installation and creation of a binary package are all controlled by
                   3328: the package's Makefile. The Makefile describes various things about a package,
                   3329: for example from where to get it, how to configure, build, and install it.
                   3330: 
                   3331: A package Makefile contains several sections that describe the package.
                   3332: 
                   3333: In the first section there are the following variables, which should appear
                   3334: exactly in the order given here. The order and grouping of the variables is
                   3335: mostly historical and has no further meaning.
                   3336: 
                   3337:   * DISTNAME is the basename of the distribution file to be downloaded from the
                   3338:     package's website.
                   3339: 
1.66      asau     3340:   * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
                   3341:     it if DISTNAME (which is the default) is not a good name for the package in
                   3342:     pkgsrc or DISTNAME is not provided (no distribution file is required).
                   3343:     Usually it is the pkgsrc directory name together with the version number.
                   3344:     It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
                   3345:     is, it starts with a letter or digit, and contains only letters, digits,
                   3346:     dashes, underscores, dots and plus signs.
1.1       dsieger  3347: 
                   3348:   * CATEGORIES is a list of categories which the package fits in. You can
                   3349:     choose any of the top-level directories of pkgsrc for it.
                   3350: 
                   3351:     Currently the following values are available for CATEGORIES. If more than
                   3352:     one is used, they need to be separated by spaces:
                   3353: 
                   3354:     archivers     cross         geography     meta-pkgs     security
                   3355:     audio         databases     graphics      misc          shells
                   3356:     benchmarks    devel         ham           multimedia    sysutils
                   3357:     biology       editors       inputmethod   net           textproc
                   3358:     cad           emulators     lang          news          time
                   3359:     chat          finance       mail          parallel      wm
                   3360:     comms         fonts         math          pkgtools      www
                   3361:     converters    games         mbone         print         x11
                   3362: 
                   3363:   * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
1.154     rillig   3364:     are discussed in detail in Section 19.5, "The fetch phase".
1.1       dsieger  3365: 
                   3366: The second section contains information about separately downloaded patches, if
                   3367: any.
                   3368: 
                   3369:   * PATCHFILES: Name(s) of additional files that contain distribution patches.
                   3370:     There is no default. pkgsrc will look for them at PATCH_SITES. They will
                   3371:     automatically be uncompressed before patching if the names end with .gz or
                   3372:     .Z.
                   3373: 
                   3374:   * PATCH_SITES: Primary location(s) for distribution patch files (see
1.80      wiz      3375:     PATCHFILES above) if not found locally.
                   3376: 
                   3377:   * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
                   3378:     count to help find the correct files to patch. It defaults to -p0.
1.1       dsieger  3379: 
                   3380: The third section contains the following variables.
                   3381: 
                   3382:   * MAINTAINER is the email address of the person who feels responsible for
                   3383:     this package, and who is most likely to look at problems or questions
                   3384:     regarding this package which have been reported with send-pr(1). Other
1.14      jmcneill 3385:     developers may contact the MAINTAINER before making changes to the package,
                   3386:     but are not required to do so. When packaging a new program, set MAINTAINER
                   3387:     to yourself. If you really can't maintain the package for future updates,
                   3388:     set it to <pkgsrc-users@NetBSD.org>.
                   3389: 
                   3390:   * OWNER should be used instead of MAINTAINER when you do not want other
                   3391:     developers to update or change the package without contacting you first. A
                   3392:     package Makefile should contain one of MAINTAINER or OWNER, but not both.
1.1       dsieger  3393: 
                   3394:   * HOMEPAGE is a URL where users can find more information about the package.
                   3395: 
                   3396:   * COMMENT is a one-line description of the package (should not include the
                   3397:     package name).
                   3398: 
1.122     leot     3399:   * LICENSE indicates the license(s) applicable for the package. See
1.154     rillig   3400:     Section 21.1.3, "Handling licenses" for further details.
1.122     leot     3401: 
1.1       dsieger  3402: Other variables that affect the build:
                   3403: 
                   3404:   * WRKSRC: The directory where the interesting distribution files of the
                   3405:     package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
                   3406:     most packages.
                   3407: 
                   3408:     If a package doesn't create a subdirectory for itself (most GNU software
                   3409:     does, for instance), but extracts itself in the current directory, you
                   3410:     should set WRKSRC=${WRKDIR}.
                   3411: 
                   3412:     If a package doesn't create a subdirectory with the name of DISTNAME but
                   3413:     some different name, set WRKSRC to point to the proper name in ${WRKDIR},
                   3414:     for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
                   3415:     other examples.
                   3416: 
                   3417:     The name of the working directory created by pkgsrc is taken from the
                   3418:     WRKDIR_BASENAME variable. By default, its value is work. If you want to use
                   3419:     the same pkgsrc tree for building different kinds of binary packages, you
                   3420:     can change the variable according to your needs. Two other variables handle
                   3421:     common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
1.4       rillig   3422:     defined in mk.conf, the first component of the host's name is attached to
                   3423:     the directory name. If OBJMACHINE is defined, the platform name is
1.1       dsieger  3424:     attached, which might look like work.i386 or work.sparc.
                   3425: 
                   3426: Please pay attention to the following gotchas:
                   3427: 
                   3428:   * Add MANCOMPRESSED if man pages are installed in compressed form by the
                   3429:     package. For packages using BSD-style makefiles which honor MANZ, there is
                   3430:     MANCOMPRESSED_IF_MANZ.
                   3431: 
                   3432:   * Replace /usr/local with "${PREFIX}" in all files (see patches, below).
                   3433: 
1.154     rillig   3434:   * If the package installs any info files, see Section 21.6.7, "Packages
1.1       dsieger  3435:     installing info files".
                   3436: 
1.154     rillig   3437: 13.2. distinfo
1.1       dsieger  3438: 
                   3439: The distinfo file contains the message digest, or checksum, of each distfile
                   3440: needed for the package. This ensures that the distfiles retrieved from the
                   3441: Internet have not been corrupted during transfer or altered by a malign force
1.108     rillig   3442: to introduce a security hole. To provide maximum security, all distfiles are
                   3443: protected using three different message digest algorithms (SHA1, RMD160,
                   3444: SHA512), as well as the file size.
1.1       dsieger  3445: 
                   3446: The distinfo file also contains the checksums for all the patches found in the
1.154     rillig   3447: patches directory (see Section 13.3, "patches/*"). These checksums ensure that
1.145     leot     3448: patches are only applied intentionally and that they don't accidentally change,
                   3449: e.g. when merging different changes together. They also make sure that new
                   3450: patches are actually added to CVS and old ones are removed. Too see whether the
                   3451: patches and the distinfo file match, run pkglint after changing the patches.
1.1       dsieger  3452: 
1.108     rillig   3453: To regenerate the distinfo file, use the make distinfo command.
1.1       dsieger  3454: 
                   3455: Some packages have different sets of distfiles depending on the platform, for
1.178     rillig   3456: example lang/openjdk8. These are kept in the same distinfo file and care should
1.24      wiz      3457: be taken when upgrading such a package to ensure distfile information is not
                   3458: lost.
1.1       dsieger  3459: 
1.154     rillig   3460: 13.3. patches/*
1.1       dsieger  3461: 
1.108     rillig   3462: Some packages don't work out-of-the box on the various platforms that are
                   3463: supported by pkgsrc. These packages need to be patched to make them work. The
                   3464: patch files can be found in the patches/ directory.
1.1       dsieger  3465: 
                   3466: In the patch phase, these patches are applied to the files in WRKSRC directory
1.25      wiz      3467: after extracting them, in alphabetic order.
1.1       dsieger  3468: 
1.154     rillig   3469: 13.3.1. Structure of a single patch file
1.1       dsieger  3470: 
                   3471: The patch-* files should be in diff -bu format, and apply without a fuzz to
                   3472: avoid problems. (To force patches to apply with fuzz you can set
                   3473: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
                   3474: a single file, and no file should be patched by more than one patch file. This
                   3475: helps to keep future modifications simple.
                   3476: 
                   3477: Each patch file is structured as follows: In the first line, there is the RCS
                   3478: Id of the patch itself. The second line should be empty for aesthetic reasons.
                   3479: After that, there should be a comment for each change that the patch does.
                   3480: There are a number of standard cases:
                   3481: 
                   3482:   * Patches for commonly known vulnerabilities should mention the vulnerability
                   3483:     ID (CAN, CVE).
                   3484: 
                   3485:   * Patches that change source code should mention the platform and other
                   3486:     environment (for example, the compiler) that the patch is needed for.
                   3487: 
1.108     rillig   3488: The patch should be commented so that any developer who knows the code of the
                   3489: application can make some use of the patch. Special care should be taken for
                   3490: the upstream developers, since we generally want that they accept our patches,
                   3491: so we have less work in the future.
1.1       dsieger  3492: 
1.154     rillig   3493: 13.3.2. Creating patch files
1.1       dsieger  3494: 
                   3495: One important thing to mention is to pay attention that no RCS IDs get stored
                   3496: in the patch files, as these will cause problems when later checked into the
                   3497: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
                   3498: avoid these problems.
                   3499: 
                   3500: For even more automation, we recommend using mkpatches from the same package to
                   3501: make a whole set of patches. You just have to backup files before you edit them
1.25      wiz      3502: to filename.orig, e.g. with cp -p filename filename.orig or, easier, by using 
1.1       dsieger  3503: pkgvi again from the same package. If you upgrade a package this way, you can
1.25      wiz      3504: easily compare the new set of patches with the previously existing one with 
                   3505: patchdiff. The files in patches are replaced by new files, so carefully check
                   3506: if you want to take all the changes.
1.1       dsieger  3507: 
                   3508: When you have finished a package, remember to generate the checksums for the
1.154     rillig   3509: patch files by using the make makepatchsum command, see Section 13.2,
1.1       dsieger  3510: "distinfo".
                   3511: 
                   3512: When adding a patch that corrects a problem in the distfile (rather than e.g.
                   3513: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
                   3514: report to the maintainer. This benefits non-pkgsrc users of the package, and
                   3515: usually makes it possible to remove the patch in future version.
                   3516: 
1.25      wiz      3517: The file names of the patch files are usually of the form patch-
                   3518: path_to_file__with__underscores.c. Many packages still use the previous
                   3519: convention patch-[a-z][a-z], but new patches should be of the form containing
                   3520: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
                   3521: automatically.
1.2       rillig   3522: 
1.154     rillig   3523: 13.3.3. Sources where the patch files come from
1.1       dsieger  3524: 
                   3525: If you want to share patches between multiple packages in pkgsrc, e.g. because
                   3526: they use the same distfiles, set PATCHDIR to the path where the patch files can
                   3527: be found, e.g.:
                   3528: 
1.159     rillig   3529: PATCHDIR=       ../../editors/xemacs/patches
1.1       dsieger  3530: 
                   3531: Patch files that are distributed by the author or other maintainers can be
                   3532: listed in PATCHFILES.
                   3533: 
                   3534: If it is desired to store any patches that should not be committed into pkgsrc,
                   3535: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
                   3536: directory tree there is expected to have the same "category/package" structure
                   3537: as pkgsrc, and patches are expected to be stored inside these dirs (also known
                   3538: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
                   3539: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
                   3540: files in the named directory are expected to be patch files, and they are
                   3541: applied after pkgsrc patches are applied.
                   3542: 
1.154     rillig   3543: 13.3.4. Patching guidelines
1.1       dsieger  3544: 
                   3545: When fixing a portability issue in the code do not use preprocessor magic to
                   3546: check for the current operating system nor platform. Doing so hurts portability
                   3547: to other platforms because the OS-specific details are not abstracted
                   3548: appropriately.
                   3549: 
                   3550: The general rule to follow is: instead of checking for the operating system the
                   3551: application is being built on, check for the specific features you need. For
                   3552: example, instead of assuming that kqueue is available under NetBSD and using
                   3553: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
                   3554: kqueue itself ? yes, this generally involves patching the configure script.
                   3555: There is absolutely nothing that prevents some OSes from adopting interfaces
                   3556: from other OSes (e.g. Linux implementing kqueue), something that the above
                   3557: checks cannot take into account.
                   3558: 
                   3559: Of course, checking for features generally involves more work on the
                   3560: developer's side, but the resulting changes are cleaner and there are chances
                   3561: they will work on many other platforms. Not to mention that there are higher
                   3562: chances of being later integrated into the mainstream sources. Remember: It
                   3563: doesn't work unless it is right!
                   3564: 
                   3565: Some typical examples:
                   3566: 
1.154     rillig   3567: Table 13.1. Patching examples
1.1       dsieger  3568: 
                   3569: +-------------------------------------------------------------------------------------------+
                   3570: |  Where  |        Incorrect         |                       Correct                        |
                   3571: |---------+--------------------------+------------------------------------------------------|
                   3572: |         |case ${target_os} in      |                                                      |
                   3573: |configure|netbsd*) have_kvm=yes ;;  |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
                   3574: |script   |*)       have_kvm=no  ;;  |                                                      |
                   3575: |         |esac                      |                                                      |
                   3576: |---------+--------------------------+------------------------------------------------------|
1.2       rillig   3577: |C source |#if defined(__NetBSD__)   |#if defined(HAVE_SYS_EVENT_H)                         |
                   3578: |file     |#  include <sys/event.h>  |#  include <sys/event.h>                              |
                   3579: |         |#endif                    |#endif                                                |
1.1       dsieger  3580: |---------+--------------------------+------------------------------------------------------|
                   3581: |         |int                       |int                                                   |
                   3582: |         |monitor_file(...)         |monitor_file(...)                                     |
                   3583: |         |{                         |{                                                     |
                   3584: |         |#if defined(__NetBSD__)   |#if defined(HAVE_KQUEUE)                              |
                   3585: |C source |        int fd = kqueue();|        int fd = kqueue();                            |
                   3586: |file     |        ...               |        ...                                           |
                   3587: |         |#else                     |#else                                                 |
                   3588: |         |        ...               |        ...                                           |
                   3589: |         |#endif                    |#endif                                                |
                   3590: |         |}                         |}                                                     |
                   3591: +-------------------------------------------------------------------------------------------+
                   3592: 
                   3593: 
1.154     rillig   3594: 13.3.5. Feedback to the author
1.1       dsieger  3595: 
                   3596: Always, always, always feed back any portability fixes or improvements you do
                   3597: to a package to the mainstream developers. This is the only way to get their
                   3598: attention on portability issues and to ensure that future versions can be built
                   3599: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
                   3600: get the fixes straight from the packaged code.
                   3601: 
                   3602: This generally involves cleaning up the patches (because sometimes the patches
1.41      wiz      3603: that are added to pkgsrc are quick hacks), filing bug reports in the
1.1       dsieger  3604: appropriate trackers for the projects and working with the mainstream authors
                   3605: to accept your changes. It is extremely important that you do it so that the
                   3606: packages in pkgsrc are kept simple and thus further changes can be done without
                   3607: much hassle.
                   3608: 
1.25      wiz      3609: When you have done this, please add a URL to the upstream bug report to the
                   3610: patch comment.
                   3611: 
1.1       dsieger  3612: Support the idea of free software!
                   3613: 
1.154     rillig   3614: 13.4. Other mandatory files
1.1       dsieger  3615: 
                   3616: DESCR
                   3617: 
                   3618:     A multi-line description of the piece of software. This should include any
                   3619:     credits where they are due. Please bear in mind that others do not share
                   3620:     your sense of humour (or spelling idiosyncrasies), and that others will
                   3621:     read everything that you write here.
                   3622: 
                   3623: PLIST
                   3624: 
                   3625:     This file governs the files that are installed on your system: all the
                   3626:     binaries, manual pages, etc. There are other directives which may be
                   3627:     entered in this file, to control the creation and deletion of directories,
1.154     rillig   3628:     and the location of inserted files. See Chapter 15, PLIST issues for more
1.1       dsieger  3629:     information.
                   3630: 
1.154     rillig   3631: 13.5. Optional files
1.1       dsieger  3632: 
1.154     rillig   3633: 13.5.1. Files affecting the binary package
1.1       dsieger  3634: 
                   3635: INSTALL
                   3636: 
                   3637:     This shell script is invoked twice by pkg_add(1). First time after package
                   3638:     extraction and before files are moved in place, the second time after the
                   3639:     files to install are moved in place. This can be used to do any custom
                   3640:     procedures not possible with @exec commands in PLIST. See pkg_add(1) and
1.154     rillig   3641:     pkg_create(1) for more information. See also Section 17.1, "Files and
1.29      wiz      3642:     directories outside the installation prefix". Please note that you can
                   3643:     modify variables in it easily by using FILES_SUBST in the package's
                   3644:     Makefile:
                   3645: 
                   3646:     FILES_SUBST+=  SOMEVAR="somevalue"
                   3647: 
                   3648:     replaces "@SOMEVAR@" with "somevalue" in the INSTALL. By default,
                   3649:     substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
                   3650:     few others, type make help topic=FILES_SUBST for a complete list.
1.1       dsieger  3651: 
                   3652: DEINSTALL
                   3653: 
                   3654:     This script is executed before and after any files are removed. It is this
                   3655:     script's responsibility to clean up any additional messy details around the
                   3656:     package's installation, since all pkg_delete knows is how to delete the
                   3657:     files created in the original distribution. See pkg_delete(1) and
1.29      wiz      3658:     pkg_create(1) for more information. The same methods to replace variables
                   3659:     can be used as for the INSTALL file.
1.1       dsieger  3660: 
                   3661: MESSAGE
                   3662: 
                   3663:     This file is displayed after installation of the package. Useful for things
                   3664:     like legal notices on almost-free software and hints for updating config
                   3665:     files after installing modules for apache, PHP etc. Please note that you
                   3666:     can modify variables in it easily by using MESSAGE_SUBST in the package's
                   3667:     Makefile:
                   3668: 
                   3669:     MESSAGE_SUBST+=  SOMEVAR="somevalue"
                   3670: 
                   3671:     replaces "${SOMEVAR}" with "somevalue" in MESSAGE. By default, substitution
1.99      sevan    3672:     is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11BASE,
1.16      jnemeth  3673:     PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1       dsieger  3674: 
                   3675:     You can display a different or additional files by setting the MESSAGE_SRC
                   3676:     variable. Its default is MESSAGE, if the file exists.
                   3677: 
                   3678: ALTERNATIVES
                   3679: 
1.66      asau     3680:     This file is used by the alternatives framework. It creates, configures,
                   3681:     and destroys generic wrappers used to run programs with similar interfaces.
                   3682:     See pkg_alternatives(8) from pkgtools/pkg_alternatives for more
                   3683:     information.
                   3684: 
                   3685:     Each line of the file contains two filenames, first the wrapper and then
                   3686:     the alternative provided by the package. Both paths are relative to PREFIX.
1.1       dsieger  3687: 
1.154     rillig   3688: 13.5.2. Files affecting the build process
1.1       dsieger  3689: 
                   3690: Makefile.common
                   3691: 
                   3692:     This file contains arbitrary things that could also go into a Makefile, but
                   3693:     its purpose is to be used by more than one package. This file should only
                   3694:     be used when the packages that will use the file are known in advance. For
                   3695:     other purposes it is often better to write a *.mk file and give it a good
                   3696:     name that describes what it does.
                   3697: 
                   3698: buildlink3.mk
                   3699: 
                   3700:     This file contains the dependency information for the buildlink3 framework
1.154     rillig   3701:     (see Chapter 16, Buildlink methodology).
1.1       dsieger  3702: 
                   3703: hacks.mk
                   3704: 
                   3705:     This file contains workarounds for compiler bugs and similar things. It is
                   3706:     included automatically by the pkgsrc infrastructure, so you don't need an
                   3707:     extra .include line for it.
                   3708: 
                   3709: options.mk
                   3710: 
                   3711:     This file contains the code for the package-specific options (see
1.154     rillig   3712:     Chapter 18, Options handling) that can be selected by the user. If a
1.1       dsieger  3713:     package has only one or two options, it is equally acceptable to put the
                   3714:     code directly into the Makefile.
                   3715: 
1.154     rillig   3716: 13.5.3. Files affecting nothing at all
1.1       dsieger  3717: 
                   3718: README*
                   3719: 
                   3720:     These files do not take place in the creation of a package and thus are
                   3721:     purely informative to the package developer.
                   3722: 
                   3723: TODO
                   3724: 
                   3725:     This file contains things that need to be done to make the package even
                   3726:     better.
                   3727: 
1.154     rillig   3728: 13.6. work*
1.1       dsieger  3729: 
                   3730: When you type make, the distribution files are unpacked into the directory
                   3731: denoted by WRKDIR. It can be removed by running make clean. Besides the
                   3732: sources, this directory is also used to keep various timestamp files. The
                   3733: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
                   3734: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
                   3735: 
1.154     rillig   3736: 13.7. files/*
1.1       dsieger  3737: 
                   3738: If you have any files that you wish to be placed in the package prior to
1.172     rillig   3739: configuration or building, you can place these files here and use a ${CP}
                   3740: command in the "post-extract" target to achieve this.
1.1       dsieger  3741: 
                   3742: If you want to share files in this way with other packages, set the FILESDIR
                   3743: variable to point to the other package's files directory, e.g.:
                   3744: 
1.159     rillig   3745: FILESDIR=       ../../editors/xemacs/files
1.1       dsieger  3746: 
1.154     rillig   3747: Chapter 14. Programming in Makefiles
1.1       dsieger  3748: 
                   3749: Table of Contents
                   3750: 
1.154     rillig   3751: 14.1. Caveats
                   3752: 14.2. Makefile variables
1.1       dsieger  3753: 
1.154     rillig   3754:     14.2.1. Naming conventions
1.1       dsieger  3755: 
1.154     rillig   3756: 14.3. Code snippets
1.1       dsieger  3757: 
1.154     rillig   3758:     14.3.1. Adding things to a list
                   3759:     14.3.2. Echoing a string exactly as-is
                   3760:     14.3.3. Passing CFLAGS to GNU configure scripts
                   3761:     14.3.4. Handling possibly empty variables
1.1       dsieger  3762: 
                   3763: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
                   3764: part of the pkgsrc system. Using the make(1) system as a programming language
                   3765: for a big system like pkgsrc requires some discipline to keep the code correct
                   3766: and understandable.
                   3767: 
1.154     rillig   3768: The basic ingredients for Makefile programming are variables and shell
                   3769: commands. Among these shell commands may even be more complex ones like awk(1)
                   3770: programs. To make sure that every shell command runs as intended it is
                   3771: necessary to quote all variables correctly when they are used.
1.1       dsieger  3772: 
1.154     rillig   3773: This chapter describes some patterns that appear quite often in Makefiles,
1.1       dsieger  3774: including the pitfalls that come along with them.
                   3775: 
1.154     rillig   3776: 14.1. Caveats
1.1       dsieger  3777: 
                   3778:   * When you are creating a file as a target of a rule, always write the data
                   3779:     to a temporary file first and finally rename that file. Otherwise there
                   3780:     might occur an error in the middle of generating the file, and when the
                   3781:     user runs make(1) for the second time, the file exists and will not be
                   3782:     regenerated properly. Example:
                   3783: 
                   3784:     wrong:
                   3785:             @echo "line 1" > ${.TARGET}
                   3786:             @echo "line 2" >> ${.TARGET}
                   3787:             @false
                   3788: 
                   3789:     correct:
                   3790:             @echo "line 1" > ${.TARGET}.tmp
                   3791:             @echo "line 2" >> ${.TARGET}.tmp
                   3792:             @false
                   3793:             @mv ${.TARGET}.tmp ${.TARGET}
                   3794: 
                   3795:     When you run make wrong twice, the file wrong will exist, although there
                   3796:     was an error message in the first run. On the other hand, running make
                   3797:     correct gives an error message twice, as expected.
                   3798: 
                   3799:     You might remember that make(1) sometimes removes ${.TARGET} in case of
                   3800:     error, but this only happens when it is interrupted, for example by
1.154     rillig   3801:     pressing Ctrl+C. This does not happen when one of the commands fails (like
1.1       dsieger  3802:     false(1) above).
                   3803: 
1.154     rillig   3804: 14.2. Makefile variables
1.1       dsieger  3805: 
                   3806: Makefile variables contain strings that can be processed using the five
1.154     rillig   3807: operators =, +=, ?=, := and !=, which are described in the make(1) man page.
1.1       dsieger  3808: 
1.154     rillig   3809: When a variable's value is parsed from a Makefile, the hash character # and the
                   3810: backslash character \ are handled specially. If a backslash is the last
                   3811: character in a line, that backslash is removed from the line and the line
                   3812: continues with the next line of the file.
                   3813: 
                   3814: The # character starts a comment that reaches until the end of the line. To get
                   3815: an actual # character, such as in a URL, write \# instead.
1.1       dsieger  3816: 
1.108     rillig   3817: The evaluation of variables either happens immediately or lazy. It happens
1.154     rillig   3818: immediately when the variable occurs on the right-hand side of the := or the !=
                   3819: operator, in a .if condition or a .for loop. In the other cases, it is
                   3820: evaluated lazily.
1.1       dsieger  3821: 
                   3822: Some of the modifiers split the string into words and then operate on the
                   3823: words, others operate on the string as a whole. When a string is split into
1.154     rillig   3824: words, double quotes and single quotes are interpreted as delimiters, just like
                   3825: in sh(1).
1.1       dsieger  3826: 
1.154     rillig   3827: 14.2.1. Naming conventions
1.1       dsieger  3828: 
                   3829:   * All variable names starting with an underscore are reserved for use by the
1.154     rillig   3830:     pkgsrc infrastructure. They shall not be used by packages.
1.1       dsieger  3831: 
                   3832:   * In .for loops you should use lowercase variable names for the iteration
                   3833:     variables.
                   3834: 
1.154     rillig   3835:   * All list variables should have a plural name, such as PKG_OPTIONS or
1.1       dsieger  3836:     DISTFILES.
                   3837: 
1.154     rillig   3838: 14.3. Code snippets
1.1       dsieger  3839: 
1.154     rillig   3840: 14.3.1. Adding things to a list
1.108     rillig   3841: 
                   3842: When adding a string that possibly contains whitespace or quotes to a list
                   3843: (example 1), it must be quoted using the :Q modifier.
1.1       dsieger  3844: 
1.108     rillig   3845: When adding another list to a list (example 2), it must not be quoted, since
                   3846: its elements are already quoted.
1.1       dsieger  3847: 
1.108     rillig   3848: STRING=         foo * bar `date`
                   3849: LIST=           # empty
                   3850: ANOTHER_LIST=   a=b c=d
1.1       dsieger  3851: 
1.108     rillig   3852: LIST+=          ${STRING:Q}       # 1
                   3853: LIST+=          ${ANOTHER_LIST}   # 2
1.1       dsieger  3854: 
1.154     rillig   3855: 14.3.2. Echoing a string exactly as-is
1.1       dsieger  3856: 
1.108     rillig   3857: Echoing a string containing special characters needs special work.
1.1       dsieger  3858: 
                   3859: STRING=         foo bar <    > * `date` $$HOME ' "
1.108     rillig   3860: EXAMPLE_ENV=    string=${STRING:Q} x=multiple\ quoted\ words
1.1       dsieger  3861: 
                   3862: all:
                   3863:         echo ${STRING}                  # 1
1.108     rillig   3864:         echo ${STRING:Q}                # 2
                   3865:         printf '%s\n' ${STRING:Q}''     # 3
                   3866:         env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"'   # 4
1.1       dsieger  3867: 
                   3868: Example 1 leads to a syntax error in the shell, as the characters are just
                   3869: copied.
                   3870: 
1.108     rillig   3871: Example 2 quotes the string so that the shell interprets it correctly. But the
                   3872: echo command may additionally interpret strings with a leading dash or those
                   3873: containing backslashes.
                   3874: 
                   3875: Example 3 can handle arbitrary strings, since printf(1) only interprets the
1.139     leot     3876: format string, but not the next argument. The trailing single quotes handle the
                   3877: case when the string is empty. In that case, the :Q modifier would result in an
                   3878: empty string too, which would then be skipped by the shell. For printf(1) this
                   3879: doesn't make a difference, but other programs may care.
1.108     rillig   3880: 
                   3881: In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
                   3882: has already been done when adding elements to the list.
                   3883: 
1.154     rillig   3884: 14.3.3. Passing CFLAGS to GNU configure scripts
1.108     rillig   3885: 
                   3886: When passing CFLAGS or similar variables to a GNU-style configure script
                   3887: (especially those that call other configure scripts), it must not have leading
                   3888: or trailing whitespace, since otherwise the configure script gets confused. To
                   3889: trim leading and trailing whitespace, use the :M modifier, as in the following
                   3890: example:
                   3891: 
                   3892: CPPFLAGS=               # empty
                   3893: CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX}\"
                   3894: CPPFLAGS+=              ${MY_CPPFLAGS}
                   3895: 
                   3896: CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
                   3897: 
                   3898: all:
                   3899:         echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
                   3900:         echo x${CONFIGURE_ARGS:Q}x      # properly trimmed
                   3901: 
                   3902: In this example, CPPFLAGS has both leading and trailing whitespace because the
                   3903: += operator always adds a space.
                   3904: 
1.154     rillig   3905: 14.3.4. Handling possibly empty variables
1.108     rillig   3906: 
                   3907: When a possibly empty variable is used in a shell program, it may lead to a
                   3908: syntax error.
                   3909: 
                   3910: EGFILES=        # empty
                   3911: 
                   3912: install-examples:   # produces a syntax error in the shell
                   3913:         for egfile in ${EGFILES}; do            \
                   3914:                 echo "Installing $$egfile";     \
                   3915:         done
                   3916: 
                   3917: The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
                   3918: with an empty string by make(1). To fix this syntax error, use one of the
                   3919: snippets below.
                   3920: 
                   3921: EMPTY=          # empty
                   3922: 
                   3923: install-examples:
                   3924:         for egfile in ${EGFILES} ""; do         \
                   3925:                 [ -n "$$egfile" ] || continue;  \
                   3926:                 echo "Installing $$egfile";     \
                   3927:         done
                   3928: 
                   3929: In this case, an empty string is appended to the iteration list (to prevent the
                   3930: syntax error) and filtered out later.
1.1       dsieger  3931: 
1.108     rillig   3932: EGFILES=        # empty
1.1       dsieger  3933: 
1.108     rillig   3934: install-examples:
                   3935: .for egfile in ${EGFILES}
                   3936:         echo "Installing ${egfile}"
                   3937: .endfor
                   3938: 
1.154     rillig   3939: If one of the filenames contains special characters, it should be enclosed in
                   3940: single or double quotes.
1.108     rillig   3941: 
                   3942: To have a shell command test whether a make variable is empty, use the
                   3943: following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
1.1       dsieger  3944: 
1.154     rillig   3945: Chapter 15. PLIST issues
1.1       dsieger  3946: 
                   3947: Table of Contents
                   3948: 
1.154     rillig   3949: 15.1. RCS ID
                   3950: 15.2. Semi-automatic PLIST generation
                   3951: 15.3. Tweaking output of make print-PLIST
                   3952: 15.4. Variable substitution in PLIST
                   3953: 15.5. Man page compression
                   3954: 15.6. Changing PLIST source with PLIST_SRC
                   3955: 15.7. Platform-specific and differing PLISTs
                   3956: 15.8. Build-specific PLISTs
                   3957: 15.9. Sharing directories between packages
1.1       dsieger  3958: 
                   3959: The PLIST file contains a package's "packing list", i.e. a list of files that
                   3960: belong to the package (relative to the ${PREFIX} directory it's been installed
                   3961: in) plus some additional statements - see the pkg_create(1) man page for a full
                   3962: list. This chapter addresses some issues that need attention when dealing with
                   3963: the PLIST file (or files, see below!).
                   3964: 
1.154     rillig   3965: 15.1. RCS ID
1.1       dsieger  3966: 
                   3967: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
                   3968: 
1.121     sevan    3969: @comment $NetBSD $
                   3970: 
1.123     wiz      3971: An artificial space has been added between NetBSD and $, this is a workaround
1.121     sevan    3972: here to prevent CVS expanding to the filename of the guide. When adding the RCS
1.125     leot     3973: ID the space should be omitted.
1.1       dsieger  3974: 
1.154     rillig   3975: 15.2. Semi-automatic PLIST generation
1.1       dsieger  3976: 
                   3977: You can use the make print-PLIST command to output a PLIST that matches any new
1.154     rillig   3978: files since the package was extracted. See Section 19.17, "Other helpful
1.1       dsieger  3979: targets" for more information on this target.
                   3980: 
1.154     rillig   3981: 15.3. Tweaking output of make print-PLIST
1.1       dsieger  3982: 
                   3983: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
                   3984: used to filter the output of print-PLIST. You can append any chunk of AWK
                   3985: scripting you like to it, but be careful with quoting.
                   3986: 
                   3987: For example, to get all files inside the libdata/foo directory removed from the
                   3988: resulting PLIST:
                   3989: 
                   3990: PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
                   3991: 
1.154     rillig   3992: 15.4. Variable substitution in PLIST
1.1       dsieger  3993: 
                   3994: A number of variables are substituted automatically in PLISTs when a package is
                   3995: installed on a system. This includes the following variables:
                   3996: 
                   3997: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
                   3998: 
                   3999:     Some packages like emacs and perl embed information about which
                   4000:     architecture they were built on into the pathnames where they install their
                   4001:     files. To handle this case, PLIST will be preprocessed before actually
                   4002:     used, and the symbol "${MACHINE_ARCH}" will be replaced by what uname -p
                   4003:     gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
                   4004:     PLIST somewhere - use this on packages that have GNU autoconf-created
                   4005:     configure scripts.
                   4006: 
                   4007:     Legacy note
                   4008: 
                   4009:     There used to be a symbol "$ARCH" that was replaced by the output of uname
                   4010:     -m, but that's no longer supported and has been removed.
                   4011: 
                   4012: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
                   4013: 
                   4014:     Some packages want to embed the OS name and version into some paths. To do
                   4015:     this, use these variables in the PLIST:
                   4016: 
1.42      asau     4017:       + ${OPSYS} - output of "uname -s"
1.1       dsieger  4018: 
1.42      asau     4019:       + ${LOWER_OPSYS} - lowercase common name (eg. "solaris")
1.1       dsieger  4020: 
1.42      asau     4021:       + ${OS_VERSION} - "uname -r"
1.1       dsieger  4022: 
1.88      tnn      4023: For a list of values which are replaced by default, the output of make help
                   4024: topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
                   4025: PLIST_SUBST should help.
1.1       dsieger  4026: 
                   4027: If you want to change other variables not listed above, you can add variables
                   4028: and their expansions to this variable in the following way, similar to
1.154     rillig   4029: MESSAGE_SUBST (see Section 13.5, "Optional files"):
1.1       dsieger  4030: 
                   4031: PLIST_SUBST+=   SOMEVAR="somevalue"
                   4032: 
                   4033: This replaces all occurrences of "${SOMEVAR}" in the PLIST with "somevalue".
                   4034: 
1.19      snj      4035: The PLIST_VARS variable can be used to simplify the common case of
                   4036: conditionally including some PLIST entries. It can be done by adding
                   4037: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
                   4038: entry should be included. This will substitute "${PLIST.foo}" in the PLIST with
                   4039: either """" or ""@comment "". For example, in Makefile:
1.18      mishka   4040: 
                   4041: PLIST_VARS+=    foo
                   4042: .if condition
                   4043: PLIST.foo=      yes
                   4044: .else
                   4045: 
                   4046: And then in PLIST:
                   4047: 
1.121     sevan    4048: @comment $NetBSD $
1.18      mishka   4049: bin/bar
                   4050: man/man1/bar.1
                   4051: ${PLIST.foo}bin/foo
                   4052: ${PLIST.foo}man/man1/foo.1
                   4053: ${PLIST.foo}share/bar/foo.data
                   4054: 
1.123     wiz      4055: An artificial space has been added between NetBSD and $, this is a workaround
1.121     sevan    4056: here to prevent CVS expanding to the filename of the guide. When adding the RCS
                   4057: ID the space should be ommited.
                   4058: 
1.154     rillig   4059: 15.5. Man page compression
1.1       dsieger  4060: 
                   4061: Man pages should be installed in compressed form if MANZ is set (in
                   4062: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
                   4063: suffix ".gz" is appended/removed automatically for man pages according to MANZ
                   4064: and MANCOMPRESSED being set or not, see above for details. This modification of
                   4065: the PLIST file is done on a copy of it, not PLIST itself.
                   4066: 
1.154     rillig   4067: 15.6. Changing PLIST source with PLIST_SRC
1.1       dsieger  4068: 
                   4069: To use one or more files as source for the PLIST used in generating the binary
                   4070: package, set the variable PLIST_SRC to the names of that file(s). The files are
                   4071: later concatenated using cat(1), and the order of things is important. The
                   4072: default for PLIST_SRC is ${PKGDIR}/PLIST.
                   4073: 
1.154     rillig   4074: 15.7. Platform-specific and differing PLISTs
1.1       dsieger  4075: 
                   4076: Some packages decide to install a different set of files based on the operating
                   4077: system being used. These differences can be automatically handled by using the
                   4078: following files:
                   4079: 
                   4080:   * PLIST.common
                   4081: 
                   4082:   * PLIST.${OPSYS}
                   4083: 
                   4084:   * PLIST.${MACHINE_ARCH}
                   4085: 
                   4086:   * PLIST.${OPSYS}-${MACHINE_ARCH}
                   4087: 
                   4088:   * PLIST.common_end
                   4089: 
1.154     rillig   4090: 15.8. Build-specific PLISTs
1.86      wiz      4091: 
                   4092: Some packages decide to generate hard-to-guess file names during installation
                   4093: that are hard to wire down.
                   4094: 
                   4095: In such cases, you can set the GENERATE_PLIST variable to shell code terminated
                   4096: (with a semicolon) that will output PLIST entries which will be appended to the
                   4097: PLIST
                   4098: 
                   4099: You can find one example in editors/xemacs:
                   4100: 
1.111     sevan    4101: GENERATE_PLIST+=        ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
1.86      wiz      4102: 
                   4103: which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
                   4104: 
1.154     rillig   4105: 15.9. Sharing directories between packages
1.1       dsieger  4106: 
                   4107: A "shared directory" is a directory where multiple (and unrelated) packages
1.23      jakllsch 4108: install files. These directories were problematic because you had to add
1.1       dsieger  4109: special tricks in the PLIST to conditionally remove them, or have some
                   4110: centralized package handle them.
                   4111: 
1.23      jakllsch 4112: In pkgsrc, it is now easy: Each package should create directories and install
                   4113: files as needed; pkg_delete will remove any directories left empty after
                   4114: uninstalling a package.
1.1       dsieger  4115: 
1.23      jakllsch 4116: If a package needs an empty directory to work, create the directory during
                   4117: installation as usual, and also add an entry to the PLIST:
1.1       dsieger  4118: 
1.23      jakllsch 4119: @pkgdir path/to/empty/directory
1.1       dsieger  4120: 
1.86      wiz      4121: or take a look at MAKE_DIRS and OWN_DIRS.
                   4122: 
1.154     rillig   4123: Chapter 16. Buildlink methodology
1.1       dsieger  4124: 
                   4125: Table of Contents
                   4126: 
1.154     rillig   4127: 16.1. Converting packages to use buildlink3
                   4128: 16.2. Writing buildlink3.mk files
1.1       dsieger  4129: 
1.154     rillig   4130:     16.2.1. Anatomy of a buildlink3.mk file
                   4131:     16.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.27      wiz      4132:         buildlink3.mk files
1.1       dsieger  4133: 
1.154     rillig   4134: 16.3. Writing builtin.mk files
1.1       dsieger  4135: 
1.154     rillig   4136:     16.3.1. Anatomy of a builtin.mk file
                   4137:     16.3.2. Global preferences for native or pkgsrc software
1.1       dsieger  4138: 
                   4139: Buildlink is a framework in pkgsrc that controls what headers and libraries are
                   4140: seen by a package's configure and build processes. This is implemented in a two
                   4141: step process:
                   4142: 
                   4143:  1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
                   4144:     default is a subdirectory of WRKDIR.
                   4145: 
                   4146:  2. Create wrapper scripts that are used in place of the normal compiler tools
                   4147:     that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
                   4148:     references to BUILDLINK_DIR. The wrapper scripts also make native compiler
                   4149:     on some operating systems look like GCC, so that packages that expect GCC
                   4150:     won't require modifications to build with those native compilers.
                   4151: 
                   4152: This normalizes the environment in which a package is built so that the package
                   4153: may be built consistently despite what other software may be installed. Please
                   4154: note that the normal system header and library paths, e.g. /usr/include, /usr/
                   4155: lib, etc., are always searched -- buildlink3 is designed to insulate the
                   4156: package build from non-system-supplied software.
                   4157: 
1.154     rillig   4158: 16.1. Converting packages to use buildlink3
1.1       dsieger  4159: 
1.25      wiz      4160: The process of converting packages to use the buildlink3 framework ("bl3ifying"
                   4161: ) is fairly straightforward. The things to keep in mind are:
1.1       dsieger  4162: 
                   4163:  1. Ensure that the build always calls the wrapper scripts instead of the
                   4164:     actual toolchain. Some packages are tricky, and the only way to know for
                   4165:     sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
                   4166:     invoked.
                   4167: 
                   4168:  2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
                   4169:     standalone shells, etc., because the code to symlink files into $
                   4170:     {BUILDLINK_DIR} looks for files relative to "pkg_info -qp pkgname".
                   4171: 
                   4172:  3. Remember that only the buildlink3.mk files that you list in a package's
                   4173:     Makefile are added as dependencies for that package.
                   4174: 
                   4175: If a dependency on a particular package is required for its libraries and
                   4176: headers, then we replace:
                   4177: 
                   4178: DEPENDS+=       foo>=1.1.0:../../category/foo
                   4179: 
                   4180: with
                   4181: 
                   4182: .include "../../category/foo/buildlink3.mk"
                   4183: 
                   4184: The buildlink3.mk files usually define the required dependencies. If you need a
                   4185: newer version of the dependency when using buildlink3.mk files, then you can
                   4186: define it in your Makefile; for example:
                   4187: 
                   4188: BUILDLINK_API_DEPENDS.foo+=   foo>=1.1.0
                   4189: .include "../../category/foo/buildlink3.mk"
                   4190: 
                   4191: There are several buildlink3.mk files in pkgsrc/mk that handle special package
                   4192: issues:
                   4193: 
                   4194:   * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
                   4195:     implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
                   4196: 
                   4197:   * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
                   4198:     this will take care to install the devel/ncurses package.
                   4199: 
                   4200:   * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
                   4201:     a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
                   4202:     implementation.
                   4203: 
                   4204:   * motif.buildlink3.mk checks for a system-provided Motif installation or adds
1.126     leot     4205:     a dependency on x11/lesstif or x11/motif. The user can set MOTIF_TYPE to "
                   4206:     dt", "lesstif" or "motif" to choose which Motif version will be used.
1.1       dsieger  4207: 
1.57      wiz      4208:   * readline.buildlink3.mk checks for a system-provided GNU readline or
                   4209:     editline (libedit) installation, or adds a dependency on devel/readline,
                   4210:     devel/editline. The user can set READLINE_DEFAULT to choose readline
1.56      ryoon    4211:     implementation. If your package really needs GNU readline library, its
                   4212:     Makefile should include devel/readline/buildlink3.mk instead of
                   4213:     readline.buildlink3.mk.
                   4214: 
1.1       dsieger  4215:   * oss.buildlink3.mk defines several variables that may be used by packages
                   4216:     that use the Open Sound System (OSS) API.
                   4217: 
1.36      wiz      4218:   * pgsql.buildlink3.mk will accept any of the Postgres versions in the
                   4219:     variable PGSQL_VERSIONS_ACCEPTED and default to the version
                   4220:     PGSQL_VERSION_DEFAULT. See the file for more information.
1.1       dsieger  4221: 
                   4222:   * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
                   4223:     pthreads or adds a dependency on devel/pth as needed.
                   4224: 
                   4225:   * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
                   4226:     widgets library.
                   4227: 
                   4228: The comments in those buildlink3.mk files provide a more complete description
                   4229: of how to use them properly.
                   4230: 
1.154     rillig   4231: 16.2. Writing buildlink3.mk files
1.1       dsieger  4232: 
                   4233: A package's buildlink3.mk file is included by Makefiles to indicate the need to
                   4234: compile and link against header files and libraries provided by the package. A
                   4235: buildlink3.mk file should always provide enough information to add the correct
                   4236: type of dependency relationship and include any other buildlink3.mk files that
                   4237: it needs to find headers and libraries that it needs in turn.
                   4238: 
                   4239: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
                   4240: pkgtools/createbuildlink package is highly recommended. For most packages, the
                   4241: following command will generate a good starting point for buildlink3.mk files:
                   4242: 
                   4243: % cd pkgsrc/category/pkgdir
                   4244: % createbuildlink >buildlink3.mk
                   4245: 
                   4246: 
1.154     rillig   4247: 16.2.1. Anatomy of a buildlink3.mk file
1.1       dsieger  4248: 
                   4249: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
                   4250: tiff:
                   4251: 
1.19      snj      4252: # $NetBSD: buildlink3.mk,v 1.16 2009/03/20 19:24:45 joerg Exp $
1.1       dsieger  4253: 
1.19      snj      4254: BUILDLINK_TREE+=        tiff
1.1       dsieger  4255: 
1.19      snj      4256: .if !defined(TIFF_BUILDLINK3_MK)
                   4257: TIFF_BUILDLINK3_MK:=
1.1       dsieger  4258: 
1.19      snj      4259: BUILDLINK_API_DEPENDS.tiff+=    tiff>=3.6.1
                   4260: BUILDLINK_ABI_DEPENDS.tiff+=    tiff>=3.7.2nb1
1.1       dsieger  4261: BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
                   4262: 
                   4263: .include "../../devel/zlib/buildlink3.mk"
                   4264: .include "../../graphics/jpeg/buildlink3.mk"
1.19      snj      4265: .endif # TIFF_BUILDLINK3_MK
1.1       dsieger  4266: 
1.19      snj      4267: BUILDLINK_TREE+=        -tiff
1.1       dsieger  4268: 
1.19      snj      4269: The header and footer manipulate BUILDLINK_TREE, which is common across all
                   4270: buildlink3.mk files and is used to track the dependency tree.
1.1       dsieger  4271: 
1.19      snj      4272: The main section is protected from multiple inclusion and controls how the
1.1       dsieger  4273: dependency on pkg is added. Several important variables are set in the section:
                   4274: 
                   4275:   * BUILDLINK_API_DEPENDS.pkg is the actual dependency recorded in the
                   4276:     installed package; this should always be set using += to ensure that we're
                   4277:     appending to any pre-existing list of values. This variable should be set
1.27      wiz      4278:     to the first version of the package that had an backwards-incompatible API
                   4279:     change.
1.1       dsieger  4280: 
                   4281:   * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
                   4282: 
                   4283:   * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
                   4284:     BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
                   4285:     is selected by setting BUILDLINK_DEPMETHOD.pkg to "build". By default, the
                   4286:     full dependency is used.
                   4287: 
                   4288:   * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
                   4289:     of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
                   4290:     library search paths. These default to "include" and "lib" respectively.
                   4291: 
                   4292:   * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
                   4293:     to add to CPPFLAGS, which are passed on to the configure and build phases.
                   4294:     The "-I" option should be avoided and instead be handled using
                   4295:     BUILDLINK_INCDIRS.pkg as above.
                   4296: 
                   4297: The following variables are all optionally defined within this second section
                   4298: (protected against multiple inclusion) and control which package files are
                   4299: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
                   4300: symlinking:
                   4301: 
                   4302:   * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
                   4303:     {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
                   4304:     *.h.
                   4305: 
                   4306:   * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
                   4307:     to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
                   4308:     resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
                   4309:     takes the +CONTENTS of a pkg and filters it through $
                   4310:     {BUILDLINK_CONTENTS_FILTER.pkg}.
                   4311: 
                   4312:   * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
                   4313:     filters +CONTENTS input into a list of files relative to $
1.84      wiz      4314:     {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
                   4315:     outputs the contents of the include and lib directories in the package
                   4316:     +CONTENTS.
1.1       dsieger  4317: 
                   4318:   * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
                   4319:     used to transform the name of the source filename into a destination
                   4320:     filename, e.g. -e "s|/curses.h|/ncurses.h|g".
                   4321: 
1.19      snj      4322: This section can additionally include any buildlink3.mk needed for pkg's
                   4323: library dependencies. Including these buildlink3.mk files means that the
                   4324: headers and libraries for these dependencies are also symlinked into $
                   4325: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
                   4326: are only added for directly include buildlink3.mk files.
1.1       dsieger  4327: 
1.48      wiz      4328: When providing a buildlink3.mk and including other buildlink3.mk files in it,
1.51      wiz      4329: please only add necessary ones, i.e., those whose libraries or header files are
1.48      wiz      4330: automatically exposed when the package is use.
                   4331: 
                   4332: In particular, if only an executable (bin/foo) is linked against a library,
                   4333: that library does not need to be propagated in the buildlink3.mk file.
                   4334: 
                   4335: The following steps should help you decide if a buildlink3.mk file needs to be
                   4336: included:
                   4337: 
                   4338:   * Look at the installed header files: What headers do they include? The
                   4339:     packages providing these files must be buildlinked.
                   4340: 
1.50      wiz      4341:   * Run ldd on all installed libraries and look against what other libraries
                   4342:     they link. Some of the packages providing these probably need to be
                   4343:     buildlinked; however, it's not automatic, since e.g. GTK on some systems
                   4344:     pulls in the X libraries, so they will show up in the ldd output, while on
1.51      wiz      4345:     others (like OS X) it won't. ldd output can thus only be used as a hint.
1.50      wiz      4346: 
1.154     rillig   4347: 16.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.27      wiz      4348: buildlink3.mk files
1.1       dsieger  4349: 
1.27      wiz      4350: These two variables differ in that one describes source compatibility (API) and
                   4351: the other binary compatibility (ABI). The difference is that a change in the
                   4352: API breaks compilation of programs while changes in the ABI stop compiled
                   4353: programs from running.
                   4354: 
1.28      wiz      4355: Changes to the BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk file
                   4356: happen very rarely. One possible reason is that all packages depending on this
                   4357: already need a newer version. In case it is bumped see the description below.
1.27      wiz      4358: 
                   4359: The most common example of an ABI change is that the major version of a shared
                   4360: library is increased. In this case, BUILDLINK_ABI_DEPENDS.pkg should be
                   4361: adjusted to require at least the new package version. Then the packages that
                   4362: depend on this package need their PKGREVISIONs increased and, if they have
                   4363: buildlink3.mk files, their BUILDLINK_ABI_DEPENDS.pkg adjusted, too. This is
                   4364: needed so pkgsrc will require the correct package dependency and not settle for
                   4365: an older one when building the source.
1.1       dsieger  4366: 
1.154     rillig   4367: See Section 21.1.5, "Handling dependencies" for more information about
1.1       dsieger  4368: dependencies on other packages, including the BUILDLINK_ABI_DEPENDS and
                   4369: ABI_DEPENDS definitions.
                   4370: 
                   4371: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
                   4372: BUILDLINK_ABI_DEPENDS.pkg as we don't want to cause unneeded package deletions
                   4373: and rebuilds. In many cases, new versions of packages work just fine with older
                   4374: dependencies.
                   4375: 
                   4376: Also it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
                   4377: BUILDLINK_API_DEPENDS.pkg.
                   4378: 
1.154     rillig   4379: 16.3. Writing builtin.mk files
1.1       dsieger  4380: 
                   4381: Some packages in pkgsrc install headers and libraries that coincide with
                   4382: headers and libraries present in the base system. Aside from a buildlink3.mk
                   4383: file, these packages should also include a builtin.mk file that includes the
                   4384: necessary checks to decide whether using the built-in software or the pkgsrc
                   4385: software is appropriate.
                   4386: 
                   4387: The only requirements of a builtin.mk file for pkg are:
                   4388: 
                   4389:  1. It should set USE_BUILTIN.pkg to either "yes" or "no" after it is included.
                   4390: 
                   4391:  2. It should not override any USE_BUILTIN.pkg which is already set before the
                   4392:     builtin.mk file is included.
                   4393: 
                   4394:  3. It should be written to allow multiple inclusion. This is very important
                   4395:     and takes careful attention to Makefile coding.
                   4396: 
1.154     rillig   4397: 16.3.1. Anatomy of a builtin.mk file
1.1       dsieger  4398: 
                   4399: The following is the recommended template for builtin.mk files:
                   4400: 
                   4401: .if !defined(IS_BUILTIN.foo)
                   4402: #
                   4403: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
                   4404: # genuinely exists in the system or not.
                   4405: #
                   4406: IS_BUILTIN.foo?=        no
                   4407: 
                   4408: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
                   4409: # version can be determined.
                   4410: #
                   4411: .  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
                   4412: BUILTIN_PKG.foo?=       foo-1.0
                   4413: .  endif
                   4414: .endif  # IS_BUILTIN.foo
                   4415: 
                   4416: .if !defined(USE_BUILTIN.foo)
                   4417: USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
                   4418: .  if defined(BUILTIN_PKG.foo)
                   4419: .    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
                   4420: .      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
                   4421: USE_BUILTIN.foo!=                                                       \
                   4422:         ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}            \
                   4423:         && ${ECHO} "yes" || ${ECHO} "no"
                   4424: .      endif
                   4425: .    endfor
                   4426: .  endif
                   4427: .endif  # USE_BUILTIN.foo
                   4428: 
                   4429: CHECK_BUILTIN.foo?=     no
                   4430: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
                   4431: #
                   4432: # Here we place code that depends on whether USE_BUILTIN.foo is set to
                   4433: # "yes" or "no".
                   4434: #
                   4435: .endif  # CHECK_BUILTIN.foo
                   4436: 
                   4437: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
                   4438: base system. This should not be a base system software with similar
                   4439: functionality to pkg; it should only be "yes" if the actual package is included
                   4440: as part of the base system. This variable is only used internally within the
                   4441: builtin.mk file.
                   4442: 
                   4443: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
                   4444: system if it exists (if IS_BUILTIN.pkg is "yes"). This variable is only used
                   4445: internally within the builtin.mk file.
                   4446: 
                   4447: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
                   4448: The code in this section must make the determination whether the built-in
                   4449: software is adequate to satisfy the dependencies listed in
                   4450: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
1.25      wiz      4451: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg 
1.1       dsieger  4452: must be set to the correct value by the end of the builtin.mk file. Note that
                   4453: USE_BUILTIN.pkg may be "yes" even if IS_BUILTIN.pkg is "no" because we may make
                   4454: the determination that the built-in version of the software is similar enough
                   4455: to be used as a replacement.
                   4456: 
                   4457: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
                   4458: the value of USE_BUILTIN.pkg set in the previous section. This typically
                   4459: includes, e.g., adding additional dependency restrictions and listing
                   4460: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
                   4461: 
1.154     rillig   4462: 16.3.2. Global preferences for native or pkgsrc software
1.1       dsieger  4463: 
                   4464: When building packages, it's possible to choose whether to set a global
                   4465: preference for using either the built-in (native) version or the pkgsrc version
                   4466: of software to satisfy a dependency. This is controlled by setting
1.25      wiz      4467: PREFER_PKGSRC and PREFER_NATIVE. These variables take values of either "yes", "
                   4468: no", or a list of packages. PREFER_PKGSRC tells pkgsrc to use the pkgsrc
1.1       dsieger  4469: versions of software, while PREFER_NATIVE tells pkgsrc to use the built-in
                   4470: versions. Preferences are determined by the most specific instance of the
                   4471: package in either PREFER_PKGSRC or PREFER_NATIVE. If a package is specified in
                   4472: neither or in both variables, then PREFER_PKGSRC has precedence over
                   4473: PREFER_NATIVE. For example, to require using pkgsrc versions of software for
                   4474: all but the most basic bits on a NetBSD system, you can set:
                   4475: 
                   4476: PREFER_PKGSRC=  yes
                   4477: PREFER_NATIVE=  getopt skey tcp_wrappers
                   4478: 
                   4479: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
                   4480: it is simply ignored in that list.
                   4481: 
1.117     sevan    4482: Setting PREFER_NATIVE should be performed straight after bootstrap and
                   4483: PREFER_PKGSRC during bootstrap. Switching between settings globally at a later
                   4484: date can introduce complications with dependency resolution. This is caused by
                   4485: packages built with the opposite preference being installed alongside each
                   4486: other.
                   4487: 
                   4488: # ./bootstrap --prefer-pkgsrc yes
                   4489: 
1.154     rillig   4490: Chapter 17. The pkginstall framework
1.1       dsieger  4491: 
                   4492: Table of Contents
                   4493: 
1.154     rillig   4494: 17.1. Files and directories outside the installation prefix
1.1       dsieger  4495: 
1.154     rillig   4496:     17.1.1. Directory manipulation
                   4497:     17.1.2. File manipulation
1.1       dsieger  4498: 
1.154     rillig   4499: 17.2. Configuration files
1.1       dsieger  4500: 
1.154     rillig   4501:     17.2.1. How PKG_SYSCONFDIR is set
                   4502:     17.2.2. Telling the software where configuration files are
                   4503:     17.2.3. Patching installations
                   4504:     17.2.4. Disabling handling of configuration files
1.1       dsieger  4505: 
1.154     rillig   4506: 17.3. System startup scripts
1.1       dsieger  4507: 
1.154     rillig   4508:     17.3.1. Disabling handling of system startup scripts
1.1       dsieger  4509: 
1.154     rillig   4510: 17.4. System users and groups
                   4511: 17.5. System shells
1.1       dsieger  4512: 
1.154     rillig   4513:     17.5.1. Disabling shell registration
1.1       dsieger  4514: 
1.154     rillig   4515: 17.6. Fonts
1.1       dsieger  4516: 
1.154     rillig   4517:     17.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  4518: 
                   4519: This chapter describes the framework known as pkginstall, whose key features
                   4520: are:
                   4521: 
                   4522:   * Generic installation and manipulation of directories and files outside the
                   4523:     pkgsrc-handled tree, LOCALBASE.
                   4524: 
                   4525:   * Automatic handling of configuration files during installation, provided
                   4526:     that packages are correctly designed.
                   4527: 
                   4528:   * Generation and installation of system startup scripts.
                   4529: 
                   4530:   * Registration of system users and groups.
                   4531: 
                   4532:   * Registration of system shells.
                   4533: 
                   4534:   * Automatic updating of fonts databases.
                   4535: 
                   4536: The following sections inspect each of the above points in detail.
                   4537: 
                   4538: You may be thinking that many of the things described here could be easily done
                   4539: with simple code in the package's post-installation target (post-install). This
                   4540: is incorrect, as the code in them is only executed when building from source.
                   4541: Machines using binary packages could not benefit from it at all (as the code
                   4542: itself could be unavailable). Therefore, the only way to achieve any of the
                   4543: items described above is by means of the installation scripts, which are
                   4544: automatically generated by pkginstall.
                   4545: 
1.154     rillig   4546: 17.1. Files and directories outside the installation prefix
1.1       dsieger  4547: 
                   4548: As you already know, the PLIST file holds a list of files and directories that
                   4549: belong to a package. The names used in it are relative to the installation
                   4550: prefix (${PREFIX}), which means that it cannot register files outside this
                   4551: directory (absolute path names are not allowed). Despite this restriction, some
                   4552: packages need to install files outside this location; e.g., under ${VARBASE} or
                   4553: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
                   4554: installation time by using installation scripts.
                   4555: 
                   4556: The generic installation scripts are shell scripts that can contain arbitrary
                   4557: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
                   4558: which defaults to INSTALL. A similar variable exists for package removal
                   4559: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
                   4560: commands, so they have the potential to create and manage files anywhere in the
                   4561: file system.
                   4562: 
                   4563: Using these general installation files is not recommended, but may be needed in
                   4564: some special cases. One reason for avoiding them is that the user has to trust
                   4565: the packager that there is no unwanted or simply erroneous code included in the
                   4566: installation script. Also, previously there were many similar scripts for the
                   4567: same functionality, and fixing a common error involved finding and changing all
                   4568: of them.
                   4569: 
                   4570: The pkginstall framework offers another, standardized way. It provides generic
                   4571: scripts to abstract the manipulation of such files and directories based on
                   4572: variables set in the package's Makefile. The rest of this section describes
                   4573: these variables.
                   4574: 
1.154     rillig   4575: 17.1.1. Directory manipulation
1.1       dsieger  4576: 
                   4577: The following variables can be set to request the creation of directories
                   4578: anywhere in the file system:
                   4579: 
                   4580:   * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
                   4581:     and should attempt to be destroyed by the installation scripts. The
                   4582:     difference between the two is that the latter prompts the administrator to
                   4583:     remove any directories that may be left after deinstallation (because they
1.108     rillig   4584:     were not empty), while the former does not. Example:
                   4585: 
                   4586:     MAKE_DIRS+=             ${VARBASE}/foo/private
1.1       dsieger  4587: 
                   4588:   * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
                   4589:     which directories should be created and should attempt to be destroyed by
                   4590:     the installation scripts. Each tuple holds the following values, separated
                   4591:     by spaces: the directory name, its owner, its group and its numerical mode.
                   4592:     For example:
                   4593: 
1.108     rillig   4594:     MAKE_DIRS_PERMS+=       ${VARBASE}/foo/private \
                   4595:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  4596: 
                   4597:     The difference between the two is exactly the same as their non-PERMS
                   4598:     counterparts.
                   4599: 
1.154     rillig   4600: 17.1.2. File manipulation
1.1       dsieger  4601: 
                   4602: Creating non-empty files outside the installation prefix is tricky because the
                   4603: PLIST forces all files to be inside it. To overcome this problem, the only
                   4604: solution is to extract the file in the known place (i.e., inside the
                   4605: installation prefix) and copy it to the appropriate location during
                   4606: installation (done by the installation scripts generated by pkginstall). We
                   4607: will call the former the master file in the following paragraphs, which
                   4608: describe the variables that can be used to automatically and consistently
                   4609: handle files outside the installation prefix:
                   4610: 
1.31      wiz      4611:   * CONF_FILES and REQD_FILES are pairs of master and target files. During
1.1       dsieger  4612:     installation time, the master file is copied to the target one if and only
                   4613:     if the latter does not exist. Upon deinstallation, the target file is
                   4614:     removed provided that it was not modified by the installation.
                   4615: 
                   4616:     The difference between the two is that the latter prompts the administrator
                   4617:     to remove any files that may be left after deinstallation (because they
                   4618:     were not empty), while the former does not.
                   4619: 
1.31      wiz      4620:   * CONF_FILES_PERMS and REQD_FILES_PERMS contain tuples describing master
1.1       dsieger  4621:     files as well as their target locations. For each of them, it also
                   4622:     specifies their owner, their group and their numeric permissions, in this
                   4623:     order. For example:
                   4624: 
1.108     rillig   4625:     REQD_FILES_PERMS+=      ${PREFIX}/share/somefile ${VARBASE}/somefile \
                   4626:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  4627: 
                   4628:     The difference between the two is exactly the same as their non-PERMS
                   4629:     counterparts.
                   4630: 
1.154     rillig   4631: 17.2. Configuration files
1.1       dsieger  4632: 
                   4633: Configuration files are special in the sense that they are installed in their
                   4634: own specific directory, PKG_SYSCONFDIR, and need special treatment during
                   4635: installation (most of which is automated by pkginstall). The main concept you
                   4636: must bear in mind is that files marked as configuration files are automatically
                   4637: copied to the right place (somewhere inside PKG_SYSCONFDIR) during installation
                   4638: if and only if they didn't exist before. Similarly, they will not be removed if
                   4639: they have local modifications. This ensures that administrators never lose any
                   4640: custom changes they may have made.
                   4641: 
1.154     rillig   4642: 17.2.1. How PKG_SYSCONFDIR is set
1.1       dsieger  4643: 
                   4644: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
                   4645: shall be installed. Its contents are set based upon the following variables:
                   4646: 
                   4647:   * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
                   4648:     etc although it may be overridden by the user to point to his preferred
                   4649:     location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
                   4650: 
                   4651:   * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
                   4652:     configuration files for the package being built shall be installed. The
                   4653:     definition of this variable only makes sense in the package's Makefile
                   4654:     (i.e., it is not user-customizable).
                   4655: 
1.68      asau     4656:     As an example, consider the Apache package, www/apache24, which places its
1.1       dsieger  4657:     configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
                   4658:     should be set in the package Makefile.
                   4659: 
                   4660:   * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
                   4661:     package's configuration directory (if different from PKG_SYSCONFBASE). It
                   4662:     defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
                   4663: 
                   4664:   * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
                   4665:     configuration files for the package identified by PKG_SYSCONFVAR's shall be
                   4666:     placed.
                   4667: 
                   4668: Based on the above variables, pkginstall determines the value of
                   4669: PKG_SYSCONFDIR, which is the only variable that can be used within a package to
                   4670: refer to its configuration directory. The algorithm used to set its value is
                   4671: basically the following:
                   4672: 
                   4673:  1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
                   4674: 
                   4675:  2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
                   4676:     package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
                   4677:     {PKG_SYSCONFSUBDIR}.
                   4678: 
                   4679:  3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
                   4680: 
                   4681: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
1.154     rillig   4682: OWN_DIRS. See Section 17.1.1, "Directory manipulation" what this means. This
1.16      jnemeth  4683: does not apply to subdirectories of ${PKG_SYSCONFDIR}, they still have to be
                   4684: created with OWN_DIRS or MAKE_DIRS.
1.1       dsieger  4685: 
1.154     rillig   4686: 17.2.2. Telling the software where configuration files are
1.1       dsieger  4687: 
                   4688: Given that pkgsrc (and users!) expect configuration files to be in a known
                   4689: place, you need to teach each package where it shall install its files. In some
                   4690: cases you will have to patch the package Makefiles to achieve it. If you are
                   4691: lucky, though, it may be as easy as passing an extra flag to the configuration
                   4692: script; this is the case of GNU Autoconf- generated files:
                   4693: 
                   4694: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
                   4695: 
                   4696: Note that this specifies where the package has to look for its configuration
                   4697: files, not where they will be originally installed (although the difference is
                   4698: never explicit, unfortunately).
                   4699: 
1.154     rillig   4700: 17.2.3. Patching installations
1.1       dsieger  4701: 
                   4702: As said before, pkginstall automatically handles configuration files. This
                   4703: means that the packages themselves must not touch the contents of $
                   4704: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
                   4705: will, out of the box, mess with the contents of that directory. So what is the
                   4706: correct procedure to fix this issue?
                   4707: 
                   4708: You must teach the package (usually by manually patching it) to install any
                   4709: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
                   4710: This way, the PLIST registers them and the administrator always has the
                   4711: original copies available.
                   4712: 
                   4713: Once the required configuration files are in place (i.e., under the examples
                   4714: hierarchy), the pkginstall framework can use them as master copies during the
                   4715: package installation to update what is in ${PKG_SYSCONFDIR}. To achieve this,
                   4716: the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
1.154     rillig   4717: Section 17.1.2, "File manipulation" for information about their syntax and
1.1       dsieger  4718: their purpose. Here is an example, taken from the mail/mutt package:
                   4719: 
                   4720: EGDIR=        ${PREFIX}/share/doc/mutt/samples
                   4721: CONF_FILES=   ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
                   4722: 
                   4723: Note that the EGDIR variable is specific to that package and has no meaning
                   4724: outside it.
                   4725: 
1.154     rillig   4726: 17.2.4. Disabling handling of configuration files
1.1       dsieger  4727: 
                   4728: The automatic copying of config files can be toggled by setting the environment
                   4729: variable PKG_CONFIG prior to package installation.
                   4730: 
1.154     rillig   4731: 17.3. System startup scripts
1.1       dsieger  4732: 
                   4733: System startup scripts are special files because they must be installed in a
                   4734: place known by the underlying OS, usually outside the installation prefix.
1.154     rillig   4735: Therefore, the same rules described in Section 17.1, "Files and directories
1.1       dsieger  4736: outside the installation prefix" apply, and the same solutions can be used.
                   4737: However, pkginstall provides a special mechanism to handle these files.
                   4738: 
                   4739: In order to provide system startup scripts, the package has to:
                   4740: 
                   4741:  1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
                   4742:     Considering the print/cups package as an example, it has a cupsd.sh in its
                   4743:     files directory.
                   4744: 
                   4745:  2. Tell pkginstall to handle it, appending the name of the script, without its
                   4746:     extension, to the RCD_SCRIPTS variable. Continuing the previous example:
                   4747: 
                   4748:     RCD_SCRIPTS+=   cupsd
                   4749: 
                   4750: Once this is done, pkginstall will do the following steps for each script in an
                   4751: automated fashion:
                   4752: 
                   4753:  1. Process the file found in the files directory applying all the
                   4754:     substitutions described in the FILES_SUBST variable.
                   4755: 
                   4756:  2. Copy the script from the files directory to the examples hierarchy, $
                   4757:     {PREFIX}/share/examples/rc.d/. Note that this master file must be
                   4758:     explicitly registered in the PLIST.
                   4759: 
                   4760:  3. Add code to the installation scripts to copy the startup script from the
                   4761:     examples hierarchy into the system-wide startup scripts directory.
                   4762: 
1.154     rillig   4763: 17.3.1. Disabling handling of system startup scripts
1.1       dsieger  4764: 
                   4765: The automatic copying of config files can be toggled by setting the environment
                   4766: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
                   4767: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
                   4768: rc.d/, no matter what the value of this variable is.
                   4769: 
1.154     rillig   4770: 17.4. System users and groups
1.1       dsieger  4771: 
                   4772: If a package needs to create special users and/or groups during installation,
                   4773: it can do so by using the pkginstall framework.
                   4774: 
                   4775: Users can be created by adding entries to the PKG_USERS variable. Each entry
                   4776: has the following syntax:
                   4777: 
                   4778: user:group
                   4779: 
                   4780: Further specification of user details may be done by setting per-user
                   4781: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
                   4782: user's description or comment. PKG_HOME.user is the user's home directory, and
                   4783: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
                   4784: and defaults to /sbin/nologin if not specified.
                   4785: 
                   4786: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
                   4787: whose syntax is:
                   4788: 
                   4789: group
                   4790: 
                   4791: The numeric GID of the group may be set by defining PKG_GID.group.
                   4792: 
                   4793: If a package needs to create the users and groups at an earlier stage, then it
1.116     wiz      4794: can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
                   4795: the phase before which the users and groups are created. In this case, the
                   4796: numeric UIDs and GIDs of the created users and groups are automatically
                   4797: hardcoded into the final installation scripts.
1.1       dsieger  4798: 
1.154     rillig   4799: 17.5. System shells
1.1       dsieger  4800: 
                   4801: Packages that install system shells should register them in the shell database,
                   4802: /etc/shells, to make things easier to the administrator. This must be done from
                   4803: the installation scripts to keep binary packages working on any system.
                   4804: pkginstall provides an easy way to accomplish this task.
                   4805: 
                   4806: When a package provides a shell interpreter, it has to set the PKG_SHELL
                   4807: variable to its absolute file name. This will add some hooks to the
                   4808: installation scripts to handle it. Consider the following example, taken from
                   4809: shells/zsh:
                   4810: 
                   4811: PKG_SHELL=      ${PREFIX}/bin/zsh
                   4812: 
1.154     rillig   4813: 17.5.1. Disabling shell registration
1.1       dsieger  4814: 
                   4815: The automatic registration of shell interpreters can be disabled by the
                   4816: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
                   4817: 
1.154     rillig   4818: 17.6. Fonts
1.1       dsieger  4819: 
                   4820: Packages that install X11 fonts should update the database files that index the
                   4821: fonts within each fonts directory. This can easily be accomplished within the
                   4822: pkginstall framework.
                   4823: 
                   4824: When a package installs X11 fonts, it must list the directories in which fonts
                   4825: are installed in the FONTS_DIRS.type variables, where type can be one of "ttf",
                   4826: "type1" or "x11". This will add hooks to the installation scripts to run the
                   4827: appropriate commands to update the fonts database files within each of those
                   4828: directories. For convenience, if the directory path is relative, it is taken to
                   4829: be relative to the package's installation prefix. Consider the following
                   4830: example, taken from fonts/dbz-ttf:
                   4831: 
1.67      wiz      4832: FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
1.1       dsieger  4833: 
1.154     rillig   4834: 17.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  4835: 
                   4836: The automatic update of fonts databases can be disabled by the administrator by
                   4837: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
                   4838: 
1.154     rillig   4839: Chapter 18. Options handling
1.1       dsieger  4840: 
                   4841: Table of Contents
                   4842: 
1.154     rillig   4843: 18.1. Global default options
                   4844: 18.2. Converting packages to use bsd.options.mk
                   4845: 18.3. Option Names
                   4846: 18.4. Determining the options of dependencies
1.1       dsieger  4847: 
                   4848: Many packages have the ability to be built to support different sets of
                   4849: features. bsd.options.mk is a framework in pkgsrc that provides generic
                   4850: handling of those options that determine different ways in which the packages
                   4851: can be built. It's possible for the user to specify exactly which sets of
                   4852: options will be built into a package or to allow a set of global default
                   4853: options apply.
                   4854: 
1.7       rillig   4855: There are two broad classes of behaviors that one might want to control via
                   4856: options. One is whether some particular feature is enabled in a program that
                   4857: will be built anyway, often by including or not including a dependency on some
                   4858: other package. The other is whether or not an additional program will be built
                   4859: as part of the package. Generally, it is better to make a split package for
                   4860: such additional programs instead of using options, because it enables binary
                   4861: packages to be built which can then be added separately. For example, the foo
                   4862: package might have minimal dependencies (those packages without which foo
                   4863: doesn't make sense), and then the foo-gfoo package might include the GTK
                   4864: frontend program gfoo. This is better than including a gtk option to foo that
                   4865: adds gfoo, because either that option is default, in which case binary users
                   4866: can't get foo without gfoo, or not default, in which case they can't get gfoo.
                   4867: With split packages, they can install foo without having GTK, and later decide
                   4868: to install gfoo (pulling in GTK at that time). This is an advantage to source
                   4869: users too, avoiding the need for rebuilds.
                   4870: 
                   4871: Plugins with widely varying dependencies should usually be split instead of
                   4872: options.
                   4873: 
                   4874: It is often more work to maintain split packages, especially if the upstream
                   4875: package does not support this. The decision of split vs. option should be made
                   4876: based on the likelihood that users will want or object to the various pieces,
                   4877: the size of the dependencies that are included, and the amount of work.
                   4878: 
                   4879: A further consideration is licensing. Non-free parts, or parts that depend on
                   4880: non-free dependencies (especially plugins) should almost always be split if
                   4881: feasible.
                   4882: 
1.154     rillig   4883: 18.1. Global default options
1.1       dsieger  4884: 
                   4885: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
                   4886: the options that should be built into every package if that option is
1.4       rillig   4887: supported. This variable should be set in mk.conf.
1.1       dsieger  4888: 
1.154     rillig   4889: 18.2. Converting packages to use bsd.options.mk
1.1       dsieger  4890: 
                   4891: The following example shows how bsd.options.mk should be used by the
                   4892: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
                   4893: e.g. options.mk, that is included by the main package Makefile.
                   4894: 
                   4895: PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
                   4896: PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
                   4897: PKG_OPTIONS_OPTIONAL_GROUPS=    database
                   4898: PKG_OPTIONS_GROUP.database=     mysql pgsql
                   4899: PKG_SUGGESTED_OPTIONS=          wibble-foo
                   4900: PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
                   4901: PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
                   4902: 
                   4903: .include "../../mk/bsd.prefs.mk"
                   4904: 
                   4905: # this package was previously named wibble2
                   4906: .if defined(PKG_OPTIONS.wibble2)
                   4907: PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
                   4908: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
                   4909:         "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
                   4910: .endif
                   4911: 
                   4912: .include "../../mk/bsd.options.mk"
                   4913: 
                   4914: # Package-specific option-handling
                   4915: 
                   4916: ###
                   4917: ### FOO support
                   4918: ###
                   4919: .if !empty(PKG_OPTIONS:Mwibble-foo)
                   4920: CONFIGURE_ARGS+=    --enable-foo
                   4921: .endif
                   4922: 
                   4923: ###
                   4924: ### LDAP support
                   4925: ###
                   4926: .if !empty(PKG_OPTIONS:Mldap)
                   4927: .  include "../../databases/openldap-client/buildlink3.mk"
                   4928: CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
                   4929: .endif
                   4930: 
                   4931: ###
                   4932: ### database support
                   4933: ###
                   4934: .if !empty(PKG_OPTIONS:Mmysql)
                   4935: .  include "../../mk/mysql.buildlink3.mk"
                   4936: .endif
                   4937: .if !empty(PKG_OPTIONS:Mpgsql)
                   4938: .  include "../../mk/pgsql.buildlink3.mk"
                   4939: .endif
                   4940: 
                   4941: The first section contains the information about which build options are
                   4942: supported by the package, and any default options settings if needed.
                   4943: 
                   4944:  1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
                   4945:     to override the default options. It should be set to PKG_OPTIONS.pkgbase.
                   4946:     Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
                   4947:     the point where the options are processed.
                   4948: 
                   4949:  2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
                   4950: 
                   4951:  3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
                   4952:     exclusive options. The options in each group are listed in
                   4953:     PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
                   4954:     the group takes precedence over all other options in the group. Options
                   4955:     from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
                   4956: 
                   4957:  4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
                   4958:     building the packages will fail if no option from the group is selected.
                   4959: 
                   4960:  5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
                   4961:     one option from each set must be selected. The options in each set are
                   4962:     listed in PKG_OPTIONS_SET.setname. Options from the sets will be
                   4963:     automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
                   4964:     fail if no option from the set is selected.
                   4965: 
                   4966:  6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
                   4967:     default.
                   4968: 
                   4969:  7. PKG_OPTIONS_LEGACY_VARS is a list of "USE_VARIABLE:option" pairs that map
1.4       rillig   4970:     legacy mk.conf variables to their option counterparts. Pairs should be
1.1       dsieger  4971:     added with "+=" to keep the listing of global legacy variables. A warning
                   4972:     will be issued if the user uses a legacy variable.
                   4973: 
                   4974:  8. PKG_OPTIONS_LEGACY_OPTS is a list of "old-option:new-option" pairs that map
                   4975:     options that have been renamed to their new counterparts. Pairs should be
                   4976:     added with "+=" to keep the listing of global legacy options. A warning
                   4977:     will be issued if the user uses a legacy option.
                   4978: 
                   4979:  9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
                   4980:     used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
                   4981:     PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
                   4982: 
                   4983: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
                   4984:     variables or options used, and what to use instead.
                   4985: 
                   4986: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
                   4987: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
                   4988: options, use PKG_SUGGESTED_OPTIONS.
                   4989: 
                   4990: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
                   4991: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
                   4992: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
                   4993: options if none of them is supported on the current platform), PKG_OPTIONS is
                   4994: set to the empty list and the package is otherwise treated as not using the
                   4995: options framework.
                   4996: 
                   4997: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
                   4998: list of selected build options, properly filtered to remove unsupported and
                   4999: duplicate options.
                   5000: 
                   5001: The remaining sections contain the logic that is specific to each option. The
                   5002: correct way to check for an option is to check whether it is listed in
                   5003: PKG_OPTIONS:
                   5004: 
                   5005: .if !empty(PKG_OPTIONS:Moption)
                   5006: 
1.154     rillig   5007: 18.3. Option Names
1.1       dsieger  5008: 
                   5009: Options that enable similar features in different packages (like optional
                   5010: support for a library) should use a common name in all packages that support it
                   5011: (like the name of the library). If another package already has an option with
                   5012: the same meaning, use the same name.
                   5013: 
                   5014: Options that enable features specific to one package, where it's unlikely that
                   5015: another (unrelated) package has the same (or a similar) optional feature,
                   5016: should use a name prefixed with pkgname-.
                   5017: 
                   5018: If a group of related packages share an optional feature specific to that
                   5019: group, prefix it with the name of the "main" package (e. g.
                   5020: djbware-errno-hack).
                   5021: 
                   5022: For new options, add a line to mk/defaults/options.description. Lines have two
                   5023: fields, separated by tab. The first field is the option name, the second its
                   5024: description. The description should be a whole sentence (starting with an
                   5025: uppercase letter and ending with a period) that describes what enabling the
                   5026: option does. E. g. "Enable ispell support." The file is sorted by option names.
                   5027: 
1.154     rillig   5028: 18.4. Determining the options of dependencies
1.7       rillig   5029: 
                   5030: When writing buildlink3.mk files, it is often necessary to list different
                   5031: dependencies based on the options with which the package was built. For
                   5032: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
                   5033: A typical example looks like this:
                   5034: 
                   5035: pkgbase := libpurple
                   5036: .include "../../mk/pkg-build-options.mk"
                   5037: 
                   5038: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
                   5039: ...
                   5040: .endif
                   5041: 
                   5042: Including pkg-build-options.mk here will set the variable
                   5043: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
                   5044: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
                   5045: pkg-build-options.mk for more details.
                   5046: 
1.154     rillig   5047: Chapter 19. The build process
1.1       dsieger  5048: 
                   5049: Table of Contents
                   5050: 
1.154     rillig   5051: 19.1. Introduction
                   5052: 19.2. Program location
                   5053: 19.3. Directories used during the build process
                   5054: 19.4. Running a phase
                   5055: 19.5. The fetch phase
                   5056: 
                   5057:     19.5.1. What to fetch and where to get it from
                   5058:     19.5.2. How are the files fetched?
                   5059: 
                   5060: 19.6. The checksum phase
                   5061: 19.7. The extract phase
                   5062: 19.8. The patch phase
                   5063: 19.9. The tools phase
                   5064: 19.10. The wrapper phase
                   5065: 19.11. The configure phase
                   5066: 19.12. The build phase
                   5067: 19.13. The test phase
                   5068: 19.14. The install phase
                   5069: 19.15. The package phase
                   5070: 19.16. Cleaning up
                   5071: 19.17. Other helpful targets
1.1       dsieger  5072: 
1.154     rillig   5073: 19.1. Introduction
1.1       dsieger  5074: 
                   5075: This chapter gives a detailed description on how a package is built. Building a
                   5076: package is separated into different phases (for example fetch, build, install),
1.19      snj      5077: all of which are described in the following sections. Each phase is split into
                   5078: so-called stages, which take the name of the containing phase, prefixed by one
                   5079: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
                   5080: actual work is done in the do-* stages.
1.1       dsieger  5081: 
                   5082: Never override the regular targets (like fetch), if you have to, override the
                   5083: do-* ones instead.
                   5084: 
                   5085: The basic steps for building a program are always the same. First the program's
                   5086: source (distfile) must be brought to the local system and then extracted. After
                   5087: any pkgsrc-specific patches to compile properly are applied, the software can
                   5088: be configured, then built (usually by compiling), and finally the generated
                   5089: binaries, etc. can be put into place on the system.
                   5090: 
                   5091: To get more details about what is happening at each step, you can set the
                   5092: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
                   5093: more details about the patch step.
                   5094: 
1.154     rillig   5095: 19.2. Program location
1.1       dsieger  5096: 
                   5097: Before outlining the process performed by the NetBSD package system in the next
                   5098: section, here's a brief discussion on where programs are installed, and which
                   5099: variables influence this.
                   5100: 
                   5101: The automatic variable PREFIX indicates where all files of the final program
                   5102: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
                   5103: pkgs in the cross category. The value of PREFIX needs to be put into the
                   5104: various places in the program's source where paths to these files are encoded.
1.154     rillig   5105: See Section 13.3, "patches/*" and Section 21.3.1, "Shared libraries - libtool"
1.1       dsieger  5106: for more details.
                   5107: 
                   5108: When choosing which of these variables to use, follow the following rules:
                   5109: 
                   5110:   * PREFIX always points to the location where the current pkg will be
1.25      wiz      5111:     installed. When referring to a pkg's own installation path, use "${PREFIX}"
                   5112:     .
1.1       dsieger  5113: 
                   5114:   * LOCALBASE is where all non-X11 pkgs are installed. If you need to construct
                   5115:     a -I or -L argument to the compiler to find includes and libraries
                   5116:     installed by another non-X11 pkg, use "${LOCALBASE}". The name LOCALBASE
                   5117:     stems from FreeBSD, which installed all packages in /usr/local. As pkgsrc
                   5118:     leaves /usr/local for the system administrator, this variable is a
                   5119:     misnomer.
                   5120: 
                   5121:   * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
                   5122:     installed. When looking for standard X11 includes (not those installed by a
                   5123:     package), use "${X11BASE}".
                   5124: 
1.99      sevan    5125:   * X11-based packages using imake must set USE_IMAKE to be installed correctly
                   5126:     under LOCALBASE.
1.1       dsieger  5127: 
                   5128:   * Within ${PREFIX}, packages should install files according to hier(7), with
                   5129:     the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
                   5130:     man.
                   5131: 
1.154     rillig   5132: 19.3. Directories used during the build process
1.1       dsieger  5133: 
1.14      jmcneill 5134: When building a package, various directories are used to store source files,
1.1       dsieger  5135: temporary files, pkgsrc-internal files, and so on. These directories are
                   5136: explained here.
                   5137: 
                   5138: Some of the directory variables contain relative pathnames. There are two
                   5139: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
                   5140: used for directories that are pkgsrc-specific. WRKSRC is used for directories
                   5141: inside the package itself.
                   5142: 
                   5143: PKGSRCDIR
                   5144: 
                   5145:     This is an absolute pathname that points to the pkgsrc root directory.
                   5146:     Generally, you don't need it.
                   5147: 
                   5148: PKGDIR
                   5149: 
                   5150:     This is an absolute pathname that points to the current package.
                   5151: 
                   5152: PKGPATH
                   5153: 
                   5154:     This is a pathname relative to PKGSRCDIR that points to the current
                   5155:     package.
                   5156: 
                   5157: WRKDIR
                   5158: 
                   5159:     This is an absolute pathname pointing to the directory where all work takes
                   5160:     place. The distfiles are extracted to this directory. It also contains
                   5161:     temporary directories and log files used by the various pkgsrc frameworks,
                   5162:     like buildlink or the wrappers.
                   5163: 
                   5164: WRKSRC
                   5165: 
                   5166:     This is an absolute pathname pointing to the directory where the distfiles
                   5167:     are extracted. It is usually a direct subdirectory of WRKDIR, and often
                   5168:     it's the only directory entry that isn't hidden. This variable may be
                   5169:     changed by a package Makefile.
                   5170: 
1.14      jmcneill 5171: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
1.15      rillig   5172: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
1.14      jmcneill 5173: created in the pkgsrc entry's directory. If users would like to have their
                   5174: pkgsrc trees behave in a read-only manner, then the value of
                   5175: CREATE_WRKDIR_SYMLINK should be set to no.
                   5176: 
1.154     rillig   5177: 19.4. Running a phase
1.1       dsieger  5178: 
                   5179: You can run a particular phase by typing make phase, where phase is the name of
                   5180: the phase. This will automatically run all phases that are required for this
                   5181: phase. The default phase is build, that is, when you run make without
                   5182: parameters in a package directory, the package will be built, but not
                   5183: installed.
                   5184: 
1.154     rillig   5185: 19.5. The fetch phase
1.1       dsieger  5186: 
                   5187: The first step in building a package is to fetch the distribution files
1.25      wiz      5188: (distfiles) from the sites that are providing them. This is the task of the 
1.1       dsieger  5189: fetch phase.
                   5190: 
1.154     rillig   5191: 19.5.1. What to fetch and where to get it from
1.1       dsieger  5192: 
                   5193: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
                   5194: name is derived from the DISTNAME variable, is fetched. The more complicated
                   5195: cases are described below.
                   5196: 
                   5197: The variable DISTFILES specifies the list of distfiles that have to be fetched.
1.66      asau     5198: Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
                   5199: {EXTRACT_SUFX}, so that most packages don't need to define it at all.
                   5200: EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
                   5201: your package requires additional distfiles to the default one, you cannot just
                   5202: append the additional filenames using the += operator, but you have write for
                   5203: example:
1.1       dsieger  5204: 
1.66      asau     5205: DISTFILES=      ${DEFAULT_DISTFILES} additional-files.tar.gz
1.1       dsieger  5206: 
                   5207: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
                   5208: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
                   5209: can set SITES.distfile to the list of URLs where the file distfile (including
                   5210: the suffix) can be found.
                   5211: 
                   5212: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
                   5213: DISTFILES+=     foo-file.tar.gz
                   5214: SITES.foo-file.tar.gz= \
1.174     leot     5215: https://www.somewhere.com/somehow/ \
                   5216: https://www.somewhereelse.com/mirror/somehow/
1.1       dsieger  5217: 
                   5218: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
                   5219: gets the name of each distfile appended to it, without an intermediate slash.
                   5220: Therefore, all site values have to end with a slash or other separator
                   5221: character. This allows for example to set MASTER_SITES to a URL of a CGI script
                   5222: that gets the name of the distfile as a parameter. In this case, the definition
                   5223: would look like:
                   5224: 
1.174     leot     5225: MASTER_SITES=   https://www.example.com/download.cgi?file=
1.1       dsieger  5226: 
1.23      jakllsch 5227: The exception to this rule are URLs starting with a dash. In that case the URL
                   5228: is taken as is, fetched and the result stored under the name of the distfile.
1.66      asau     5229: You can use this style for the case when the download URL style does not match
                   5230: the above common case. For example, if permanent download URL is a redirector
                   5231: to the real download URL, or the download file name is offered by an HTTP
                   5232: Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
                   5233: created instead of the default v1.0.0.tar.gz.
                   5234: 
                   5235: DISTNAME=       foo-1.0.0
1.174     leot     5236: MASTER_SITES=   -https://www.example.com/archive/v1.0.0.tar.gz
1.23      jakllsch 5237: 
1.1       dsieger  5238: There are some predefined values for MASTER_SITES, which can be used in
                   5239: packages. The names of the variables should speak for themselves.
                   5240: 
1.156     leot     5241: MASTER_SITE_APACHE          MASTER_SITE_BACKUP
                   5242: MASTER_SITE_CRATESIO        MASTER_SITE_CYGWIN
                   5243: MASTER_SITE_DEBIAN          MASTER_SITE_FREEBSD
                   5244: MASTER_SITE_FREEBSD_LOCAL   MASTER_SITE_GENTOO
                   5245: MASTER_SITE_GITHUB          MASTER_SITE_GNOME
                   5246: MASTER_SITE_GNU             MASTER_SITE_GNUSTEP
                   5247: MASTER_SITE_HASKELL_HACKAGE MASTER_SITE_IFARCHIVE
                   5248: MASTER_SITE_KDE             MASTER_SITE_MOZILLA
                   5249: MASTER_SITE_MOZILLA_ALL     MASTER_SITE_MYSQL
                   5250: MASTER_SITE_NETLIB          MASTER_SITE_OPENBSD
                   5251: MASTER_SITE_OPENOFFICE      MASTER_SITE_OSDN
                   5252: MASTER_SITE_PERL_CPAN       MASTER_SITE_PGSQL
                   5253: MASTER_SITE_PYPI            MASTER_SITE_RUBYGEMS
                   5254: MASTER_SITE_R_CRAN          MASTER_SITE_SOURCEFORGE
                   5255: MASTER_SITE_SUNSITE         MASTER_SITE_SUSE
                   5256: MASTER_SITE_TEX_CTAN        MASTER_SITE_XCONTRIB
                   5257: MASTER_SITE_XEMACS          MASTER_SITE_XORG
1.1       dsieger  5258: 
                   5259: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
                   5260: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
1.27      wiz      5261: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
1.26      spz      5262: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
                   5263: distfiles/LOCAL_PORTS/.
1.1       dsieger  5264: 
                   5265: If you choose one of these predefined sites, you may want to specify a
                   5266: subdirectory of that site. Since these macros may expand to more than one
                   5267: actual site, you must use the following construct to specify a subdirectory:
                   5268: 
                   5269: MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
                   5270: MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
                   5271: 
                   5272: Note the trailing slash after the subdirectory name.
                   5273: 
1.154     rillig   5274: 19.5.2. How are the files fetched?
1.1       dsieger  5275: 
                   5276: The fetch phase makes sure that all the distfiles exist in a local directory
                   5277: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
                   5278: are fetched using commands of the form
                   5279: 
                   5280: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
                   5281: 
                   5282: where ${site} varies through several possibilities in turn: first,
                   5283: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
                   5284: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
                   5285: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
                   5286: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
                   5287: MASTER_SORT_AWK or MASTER_SORT_REGEX.
                   5288: 
1.16      jnemeth  5289: The specific command and arguments used depend on the FETCH_USING parameter.
                   5290: The example above is for FETCH_USING=custom.
                   5291: 
1.1       dsieger  5292: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
                   5293: target to mirror the distfiles, if they are freely distributable. Packages
                   5294: setting NO_SRC_ON_FTP (usually to "${RESTRICTED}") will not have their
                   5295: distfiles mirrored.
                   5296: 
1.154     rillig   5297: 19.6. The checksum phase
1.1       dsieger  5298: 
                   5299: After the distfile(s) are fetched, their checksum is generated and compared
                   5300: with the checksums stored in the distinfo file. If the checksums don't match,
                   5301: the build is aborted. This is to ensure the same distfile is used for building,
                   5302: and that the distfile wasn't changed, e.g. by some malign force, deliberately
                   5303: changed distfiles on the master distribution site or network lossage.
                   5304: 
1.154     rillig   5305: 19.7. The extract phase
1.1       dsieger  5306: 
                   5307: When the distfiles are present on the local system, they need to be extracted,
                   5308: as they usually come in the form of some compressed archive format.
                   5309: 
                   5310: By default, all DISTFILES are extracted. If you only need some of them, you can
                   5311: set the EXTRACT_ONLY variable to the list of those files.
                   5312: 
                   5313: Extracting the files is usually done by a little program, mk/extract/extract,
                   5314: which already knows how to extract various archive formats, so most likely you
                   5315: will not need to change anything here. But if you need, the following variables
                   5316: may help you:
                   5317: 
                   5318: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
                   5319: 
                   5320:     Use these variables to override the default options for an extract command,
                   5321:     which are defined in mk/extract/extract.
                   5322: 
                   5323: EXTRACT_USING
                   5324: 
1.14      jmcneill 5325:     This variable can be set to bsdtar, gtar, nbtar (which is the default
                   5326:     value), pax, or an absolute pathname pointing to the command with which tar
                   5327:     archives should be extracted. It is preferred to choose bsdtar over gtar if
                   5328:     NetBSD's pax-as-tar is not good enough.
1.1       dsieger  5329: 
                   5330: If the extract program doesn't serve your needs, you can also override the
                   5331: EXTRACT_CMD variable, which holds the command used for extracting the files.
                   5332: This command is executed in the ${WRKSRC} directory. During execution of this
                   5333: command, the shell variable extract_file holds the absolute pathname of the
                   5334: file that is going to be extracted.
                   5335: 
                   5336: And if that still does not suffice, you can override the do-extract target in
                   5337: the package Makefile.
                   5338: 
1.154     rillig   5339: 19.8. The patch phase
1.1       dsieger  5340: 
                   5341: After extraction, all the patches named by the PATCHFILES, those present in the
                   5342: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
                   5343: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
                   5344: are uncompressed before they are applied, files ending in .orig or .rej are
                   5345: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
1.154     rillig   5346: Section 13.3, "patches/*" for more details.
1.1       dsieger  5347: 
1.180     rillig   5348: By default patch(1) is given special arguments to make it fail if the expected
                   5349: text from the patch context is not found in the patched file. If that happens,
                   5350: fix the patch file by comparing it with the actual text in the file to be
                   5351: patched.
1.1       dsieger  5352: 
1.154     rillig   5353: 19.9. The tools phase
1.1       dsieger  5354: 
1.154     rillig   5355: This is covered in Chapter 20, Tools needed for building or running.
1.1       dsieger  5356: 
1.154     rillig   5357: 19.10. The wrapper phase
1.1       dsieger  5358: 
                   5359: This phase creates wrapper programs for the compilers and linkers. The
                   5360: following variables can be used to tweak the wrappers.
                   5361: 
                   5362: ECHO_WRAPPER_MSG
                   5363: 
                   5364:     The command used to print progress messages. Does nothing by default. Set
                   5365:     to ${ECHO} to see the progress messages.
                   5366: 
                   5367: WRAPPER_DEBUG
                   5368: 
                   5369:     This variable can be set to yes (default) or no, depending on whether you
                   5370:     want additional information in the wrapper log file.
                   5371: 
                   5372: WRAPPER_UPDATE_CACHE
                   5373: 
                   5374:     This variable can be set to yes or no, depending on whether the wrapper
                   5375:     should use its cache, which will improve the speed. The default value is
                   5376:     yes, but is forced to no if the platform does not support it.
                   5377: 
                   5378: WRAPPER_REORDER_CMDS
                   5379: 
                   5380:     A list of reordering commands. A reordering command has the form reorder:l:
                   5381:     lib1:lib2. It ensures that that -llib1 occurs before -llib2.
                   5382: 
1.154     rillig   5383: 19.11. The configure phase
1.1       dsieger  5384: 
                   5385: Most pieces of software need information on the header files, system calls, and
                   5386: library routines which are available on the platform they run on. The process
                   5387: of determining this information is known as configuration, and is usually
                   5388: automated. In most cases, a script is supplied with the distfiles, and its
                   5389: invocation results in generation of header files, Makefiles, etc.
                   5390: 
                   5391: If the package contains a configure script, this can be invoked by setting
                   5392: HAS_CONFIGURE to "yes". If the configure script is a GNU autoconf script, you
                   5393: should set GNU_CONFIGURE to "yes" instead. What happens in the configure phase
                   5394: is roughly:
                   5395: 
                   5396: .for d in ${CONFIGURE_DIRS}
                   5397:         cd ${WRKSRC} \
                   5398:         && cd ${d} \
                   5399:         && env ${CONFIGURE_ENV} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
                   5400: .endfor
                   5401: 
                   5402: CONFIGURE_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In
                   5403: each of these directories, the configure script is run with the environment
                   5404: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
                   5405: CONFIGURE_SCRIPT (default: "./configure") and CONFIGURE_ARGS may all be changed
                   5406: by the package.
                   5407: 
1.38      wiz      5408: If the program uses the Perl way of configuration (mainly Perl modules, but not
                   5409: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
                   5410: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
                   5411: (e.g., MAKE_PARAMS+=foo=bar
                   5412: 
1.1       dsieger  5413: If the program uses an Imakefile for configuration, the appropriate steps can
1.99      sevan    5414: be invoked by setting USE_IMAKE to "yes". If you only need xmkmf, add it to
                   5415: USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
                   5416: SCRIPTS_ENV variable.
1.1       dsieger  5417: 
1.11      rillig   5418: If the program uses cmake for configuration, the appropriate steps can be
                   5419: invoked by setting USE_CMAKE to "yes". You can add variables to cmake's
                   5420: environment by adding them to the CONFIGURE_ENV variable and arguments to cmake
                   5421: by adding them to the CMAKE_ARGS variable. The top directory argument is given
                   5422: by the CMAKE_ARG_PATH variable, that defaults to "." (relative to
                   5423: CONFIGURE_DIRS)
                   5424: 
1.1       dsieger  5425: If there is no configure step at all, set NO_CONFIGURE to "yes".
                   5426: 
1.154     rillig   5427: 19.12. The build phase
1.1       dsieger  5428: 
                   5429: For building a package, a rough equivalent of the following code is executed.
                   5430: 
                   5431: .for d in ${BUILD_DIRS}
                   5432:         cd ${WRKSRC} \
                   5433:         && cd ${d} \
                   5434:         && env ${MAKE_ENV} \
                   5435:             ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
                   5436:                 -f ${MAKE_FILE} \
                   5437:                 ${BUILD_TARGET}
                   5438: .endfor
                   5439: 
                   5440: BUILD_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In each of
                   5441: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
                   5442: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
                   5443: and BUILD_TARGET may all be changed by the package.
                   5444: 
1.25      wiz      5445: The default value of MAKE_PROGRAM is "gmake" if USE_TOOLS contains "gmake", "
                   5446: make" otherwise. The default value of MAKE_FILE is "Makefile", and BUILD_TARGET
                   5447: defaults to "all".
1.1       dsieger  5448: 
                   5449: If there is no build step at all, set NO_BUILD to "yes".
                   5450: 
1.154     rillig   5451: 19.13. The test phase
1.1       dsieger  5452: 
                   5453: [TODO]
                   5454: 
1.154     rillig   5455: 19.14. The install phase
1.1       dsieger  5456: 
                   5457: Once the build stage has completed, the final step is to install the software
                   5458: in public directories, so users can access the programs and files.
                   5459: 
                   5460: In the install phase, a rough equivalent of the following code is executed.
                   5461: Additionally, before and after this code, much magic is performed to do
                   5462: consistency checks, registering the package, and so on.
                   5463: 
                   5464: .for d in ${INSTALL_DIRS}
                   5465:         cd ${WRKSRC} \
                   5466:         && cd ${d} \
                   5467:         && env ${MAKE_ENV} \
                   5468:             ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
                   5469:                 -f ${MAKE_FILE} \
                   5470:                 ${INSTALL_TARGET}
                   5471: .endfor
                   5472: 
                   5473: The variable's meanings are analogous to the ones in the build phase.
                   5474: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is "install" by default,
                   5475: plus "install.man" if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
                   5476: defined.
                   5477: 
                   5478: In the install phase, the following variables are useful. They are all
                   5479: variations of the install(1) command that have the owner, group and permissions
                   5480: preset. INSTALL is the plain install command. The specialized variants,
                   5481: together with their intended use, are:
                   5482: 
                   5483: INSTALL_PROGRAM_DIR
                   5484: 
                   5485:     directories that contain binaries
                   5486: 
                   5487: INSTALL_SCRIPT_DIR
                   5488: 
                   5489:     directories that contain scripts
                   5490: 
                   5491: INSTALL_LIB_DIR
                   5492: 
                   5493:     directories that contain shared and static libraries
                   5494: 
                   5495: INSTALL_DATA_DIR
                   5496: 
                   5497:     directories that contain data files
                   5498: 
                   5499: INSTALL_MAN_DIR
                   5500: 
                   5501:     directories that contain man pages
                   5502: 
1.100     leot     5503: INSTALL_GAME_DIR
                   5504: 
                   5505:     directories that contain data files for games
                   5506: 
1.1       dsieger  5507: INSTALL_PROGRAM
                   5508: 
                   5509:     binaries that can be stripped from debugging symbols
                   5510: 
                   5511: INSTALL_SCRIPT
                   5512: 
                   5513:     binaries that cannot be stripped
                   5514: 
                   5515: INSTALL_GAME
                   5516: 
                   5517:     game binaries
                   5518: 
                   5519: INSTALL_LIB
                   5520: 
                   5521:     shared and static libraries
                   5522: 
                   5523: INSTALL_DATA
                   5524: 
                   5525:     data files
                   5526: 
                   5527: INSTALL_GAME_DATA
                   5528: 
                   5529:     data files for games
                   5530: 
                   5531: INSTALL_MAN
                   5532: 
                   5533:     man pages
                   5534: 
                   5535: Some other variables are:
                   5536: 
1.106     tnn      5537: INSTALL_UNSTRIPPED
                   5538: 
                   5539:     If set to yes, do not run strip(1) when installing binaries. Any debugging
                   5540:     sections and symbols present in binaries will be preserved.
                   5541: 
1.1       dsieger  5542: INSTALLATION_DIRS
                   5543: 
                   5544:     A list of directories relative to PREFIX that are created by pkgsrc at the
                   5545:     beginning of the install phase. The package is supposed to create all
                   5546:     needed directories itself before installing files to it and list all other
                   5547:     directories here.
                   5548: 
1.25      wiz      5549: In the rare cases that a package shouldn't install anything, set NO_INSTALL to 
1.1       dsieger  5550: "yes". This is mostly relevant for packages in the regress category.
                   5551: 
1.154     rillig   5552: 19.15. The package phase
1.1       dsieger  5553: 
                   5554: Once the install stage has completed, a binary package of the installed files
                   5555: can be built. These binary packages can be used for quick installation without
                   5556: previous compilation, e.g. by the make bin-install or by using pkg_add.
                   5557: 
                   5558: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
                   5559: created in ${PACKAGES}/category, one for each category in the CATEGORIES
                   5560: variable. PACKAGES defaults to pkgsrc/packages.
                   5561: 
1.154     rillig   5562: 19.16. Cleaning up
1.1       dsieger  5563: 
                   5564: Once you're finished with a package, you can clean the work directory by
                   5565: running make clean. If you want to clean the work directories of all
                   5566: dependencies too, use make clean-depends.
                   5567: 
1.154     rillig   5568: 19.17. Other helpful targets
1.1       dsieger  5569: 
                   5570: pre/post-*
                   5571: 
                   5572:     For any of the main targets described in the previous section, two
                   5573:     auxiliary targets exist with "pre-" and "post-" used as a prefix for the
                   5574:     main target's name. These targets are invoked before and after the main
                   5575:     target is called, allowing extra configuration or installation steps be
                   5576:     performed from a package's Makefile, for example, which a program's
                   5577:     configure script or install target omitted.
                   5578: 
                   5579: do-*
                   5580: 
                   5581:     Should one of the main targets do the wrong thing, and should there be no
                   5582:     variable to fix this, you can redefine it with the do-* target. (Note that
                   5583:     redefining the target itself instead of the do-* target is a bad idea, as
                   5584:     the pre-* and post-* targets won't be called anymore, etc.) You will not
                   5585:     usually need to do this.
                   5586: 
                   5587: reinstall
                   5588: 
                   5589:     If you did a make install and you noticed some file was not installed
                   5590:     properly, you can repeat the installation with this target, which will
                   5591:     ignore the "already installed" flag.
                   5592: 
                   5593:     This is the default value of DEPENDS_TARGET except in the case of make
                   5594:     update and make package, where the defaults are "package" and "update",
                   5595:     respectively.
                   5596: 
                   5597: deinstall
                   5598: 
                   5599:     This target does a pkg_delete(1) in the current directory, effectively
                   5600:     de-installing the package. The following variables can be used to tune the
                   5601:     behaviour:
                   5602: 
                   5603:     PKG_VERBOSE
                   5604: 
                   5605:         Add a "-v" to the pkg_delete(1) command.
                   5606: 
                   5607:     DEINSTALLDEPENDS
                   5608: 
                   5609:         Remove all packages that require (depend on) the given package. This
                   5610:         can be used to remove any packages that may have been pulled in by a
                   5611:         given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
1.25      wiz      5612:         pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding "-R
                   5613:         " to the pkg_delete(1) command line.
1.1       dsieger  5614: 
                   5615: bin-install
                   5616: 
                   5617:     Install a binary package from local disk and via FTP from a list of sites
                   5618:     (see the BINPKG_SITES variable), and do a make package if no binary package
                   5619:     is available anywhere. The arguments given to pkg_add can be set via
                   5620:     BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
                   5621: 
1.95      wiz      5622: install-clean
                   5623: 
                   5624:     This target removes the state files for the "install" and later phases so
                   5625:     that the "install" target may be re-invoked. This can be used after editing
                   5626:     the PLIST to install the package without rebuilding it.
                   5627: 
                   5628: build-clean
                   5629: 
                   5630:     This target removes the state files for the "build" and later phases so
                   5631:     that the "build" target may be re-invoked.
                   5632: 
1.1       dsieger  5633: update
                   5634: 
                   5635:     This target causes the current package to be updated to the latest version.
                   5636:     The package and all depending packages first get de-installed, then current
                   5637:     versions of the corresponding packages get compiled and installed. This is
                   5638:     similar to manually noting which packages are currently installed, then
                   5639:     performing a series of make deinstall and make install (or whatever
                   5640:     UPDATE_TARGET is set to) for these packages.
                   5641: 
                   5642:     You can use the "update" target to resume package updating in case a
                   5643:     previous make update was interrupted for some reason. However, in this
                   5644:     case, make sure you don't call make clean or otherwise remove the list of
                   5645:     dependent packages in WRKDIR. Otherwise, you lose the ability to
                   5646:     automatically update the current package along with the dependent packages
                   5647:     you have installed.
                   5648: 
                   5649:     Resuming an interrupted make update will only work as long as the package
                   5650:     tree remains unchanged. If the source code for one of the packages to be
                   5651:     updated has been changed, resuming make update will most certainly fail!
                   5652: 
1.4       rillig   5653:     The following variables can be used either on the command line or in
1.1       dsieger  5654:     mk.conf to alter the behaviour of make update:
                   5655: 
                   5656:     UPDATE_TARGET
                   5657: 
                   5658:         Install target to recursively use for the updated package and the
                   5659:         dependent packages. Defaults to DEPENDS_TARGET if set, "install"
1.25      wiz      5660:         otherwise for make update. Other good targets are "package" or "
                   5661:         bin-install". Do not set this to "update" or you will get stuck in an
1.1       dsieger  5662:         endless loop!
                   5663: 
                   5664:     NOCLEAN
                   5665: 
                   5666:         Don't clean up after updating. Useful if you want to leave the work
                   5667:         sources of the updated packages around for inspection or other
1.25      wiz      5668:         purposes. Be sure you eventually clean up the source tree (see the "
                   5669:         clean-update" target below) or you may run into troubles with old
1.1       dsieger  5670:         source code still lying around on your next make or make update.
                   5671: 
                   5672:     REINSTALL
                   5673: 
                   5674:         Deinstall each package before installing (making DEPENDS_TARGET). This
                   5675:         may be necessary if the "clean-update" target (see below) was called
                   5676:         after interrupting a running make update.
                   5677: 
                   5678:     DEPENDS_TARGET
                   5679: 
                   5680:         Allows you to disable recursion and hardcode the target for packages.
                   5681:         The default is "update" for the update target, facilitating a recursive
                   5682:         update of prerequisite packages. Only set DEPENDS_TARGET if you want to
                   5683:         disable recursive updates. Use UPDATE_TARGET instead to just set a
                   5684:         specific target for each package to be installed during make update
                   5685:         (see above).
                   5686: 
                   5687: clean-update
                   5688: 
                   5689:     Clean the source tree for all packages that would get updated if make
                   5690:     update was called from the current directory. This target should not be
                   5691:     used if the current package (or any of its depending packages) have already
                   5692:     been de-installed (e.g., after calling make update) or you may lose some
1.25      wiz      5693:     packages you intended to update. As a rule of thumb: only use this target 
1.1       dsieger  5694:     before the first time you run make update and only if you have a dirty
                   5695:     package tree (e.g., if you used NOCLEAN).
                   5696: 
                   5697:     If you are unsure about whether your tree is clean, you can either perform
                   5698:     a make clean at the top of the tree, or use the following sequence of
                   5699:     commands from the directory of the package you want to update (before
                   5700:     running make update for the first time, otherwise you lose all the packages
                   5701:     you wanted to update!):
                   5702: 
                   5703:     # make clean-update
                   5704:     # make clean CLEANDEPENDS=YES
                   5705:     # make update
                   5706: 
                   5707: 
1.4       rillig   5708:     The following variables can be used either on the command line or in
1.1       dsieger  5709:     mk.conf to alter the behaviour of make clean-update:
                   5710: 
                   5711:     CLEAR_DIRLIST
                   5712: 
                   5713:         After make clean, do not reconstruct the list of directories to update
                   5714:         for this package. Only use this if make update successfully installed
                   5715:         all packages you wanted to update. Normally, this is done automatically
                   5716:         on make update, but may have been suppressed by the NOCLEAN variable
                   5717:         (see above).
                   5718: 
                   5719: replace
                   5720: 
                   5721:     Update the installation of the current package. This differs from update in
                   5722:     that it does not replace dependent packages. You will need to install
                   5723:     pkgtools/pkg_tarup for this target to work.
                   5724: 
                   5725:     Be careful when using this target! There are no guarantees that dependent
                   5726:     packages will still work, in particular they will most certainly break if
                   5727:     you make replace a library package whose shared library major version
                   5728:     changed between your installed version and the new one. For this reason,
                   5729:     this target is not officially supported and only recommended for advanced
                   5730:     users.
                   5731: 
                   5732: info
                   5733: 
                   5734:     This target invokes pkg_info(1) for the current package. You can use this
                   5735:     to check which version of a package is installed.
                   5736: 
                   5737: index
                   5738: 
                   5739:     This is a top-level command, i.e. it should be used in the pkgsrc
                   5740:     directory. It creates a database of all packages in the local pkgsrc tree,
                   5741:     including dependencies, comment, maintainer, and some other useful
                   5742:     information. Individual entries are created by running make describe in the
                   5743:     packages' directories. This index file is saved as pkgsrc/INDEX. It can be
                   5744:     displayed in verbose format by running make print-index. You can search in
                   5745:     it with make search key=something. You can extract a list of all packages
                   5746:     that depend on a particular one by running make show-deps PKG=somepackage.
                   5747: 
                   5748:     Running this command takes a very long time, some hours even on fast
                   5749:     machines!
                   5750: 
                   5751: readme
                   5752: 
                   5753:     This target generates a README.html file, which can be viewed using a
                   5754:     browser such as www/firefox or www/links. The generated files contain
                   5755:     references to any packages which are in the PACKAGES directory on the local
                   5756:     host. The generated files can be made to refer to URLs based on
                   5757:     FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
                   5758:     README.html files which pointed to binary packages on the local machine, in
                   5759:     the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
                   5760:     FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
                   5761:     subdirectories will be searched for all the binary packages.
                   5762: 
                   5763:     The target can be run at the toplevel or in category directories, in which
                   5764:     case it descends recursively.
                   5765: 
                   5766: readme-all
                   5767: 
                   5768:     This is a top-level command, run it in pkgsrc. Use this target to create a
                   5769:     file README-all.html which contains a list of all packages currently
                   5770:     available in the NetBSD Packages Collection, together with the category
                   5771:     they belong to and a short description. This file is compiled from the
                   5772:     pkgsrc/*/README.html files, so be sure to run this after a make readme.
                   5773: 
                   5774: cdrom-readme
                   5775: 
                   5776:     This is very much the same as the "readme" target (see above), but is to be
                   5777:     used when generating a pkgsrc tree to be written to a CD-ROM. This target
                   5778:     also produces README.html files, and can be made to refer to URLs based on
                   5779:     CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
                   5780: 
                   5781: show-distfiles
                   5782: 
                   5783:     This target shows which distfiles and patchfiles are needed to build the
                   5784:     package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
                   5785:     patches/*).
                   5786: 
                   5787: show-downlevel
                   5788: 
                   5789:     This target shows nothing if the package is not installed. If a version of
                   5790:     this package is installed, but is not the version provided in this version
                   5791:     of pkgsrc, then a warning message is displayed. This target can be used to
                   5792:     show which of your installed packages are downlevel, and so the old
                   5793:     versions can be deleted, and the current ones added.
                   5794: 
                   5795: show-pkgsrc-dir
                   5796: 
                   5797:     This target shows the directory in the pkgsrc hierarchy from which the
                   5798:     package can be built and installed. This may not be the same directory as
                   5799:     the one from which the package was installed. This target is intended to be
                   5800:     used by people who may wish to upgrade many packages on a single host, and
1.25      wiz      5801:     can be invoked from the top-level pkgsrc Makefile by using the "
                   5802:     show-host-specific-pkgs" target.
1.1       dsieger  5803: 
                   5804: show-installed-depends
                   5805: 
                   5806:     This target shows which installed packages match the current package's
                   5807:     DEPENDS. Useful if out of date dependencies are causing build problems.
                   5808: 
1.95      wiz      5809: print-build-depends-list
                   5810: 
                   5811:     This target shows the list of packages that the current package depends on
                   5812:     for building.
                   5813: 
                   5814: print-run-depends-list
                   5815: 
                   5816:     This target shows the list of packages that the current package depends on
                   5817:     for running.
                   5818: 
1.1       dsieger  5819: check-shlibs
                   5820: 
                   5821:     After a package is installed, check all its binaries and (on ELF platforms)
                   5822:     shared libraries to see if they find the shared libs they need. Run by
1.4       rillig   5823:     default if PKG_DEVELOPER is set in mk.conf.
1.1       dsieger  5824: 
                   5825: print-PLIST
                   5826: 
                   5827:     After a "make install" from a new or upgraded pkg, this prints out an
                   5828:     attempt to generate a new PLIST from a find -newer work/.extract_done. An
                   5829:     attempt is made to care for shared libs etc., but it is strongly
                   5830:     recommended to review the result before putting it into PLIST. On upgrades,
                   5831:     it's useful to diff the output of this command against an already existing
                   5832:     PLIST file.
                   5833: 
                   5834:     If the package installs files via tar(1) or other methods that don't update
                   5835:     file access times, be sure to add these files manually to your PLIST, as
                   5836:     the "find -newer" command used by this target won't catch them!
                   5837: 
1.154     rillig   5838:     See Section 15.3, "Tweaking output of make print-PLIST" for more
1.1       dsieger  5839:     information on this target.
                   5840: 
1.154     rillig   5841: Chapter 20. Tools needed for building or running
1.1       dsieger  5842: 
                   5843: Table of Contents
                   5844: 
1.154     rillig   5845: 20.1. Tools for pkgsrc builds
                   5846: 20.2. Tools needed by packages
                   5847: 20.3. Tools provided by platforms
1.1       dsieger  5848: 
                   5849: The USE_TOOLS definition is used both internally by pkgsrc and also for
                   5850: individual packages to define what commands are needed for building a package
1.156     leot     5851: (like TOOL_DEPENDS) or for later run-time of an installed packaged (such as
1.1       dsieger  5852: DEPENDS). If the native system provides an adequate tool, then in many cases, a
                   5853: pkgsrc package will not be used.
                   5854: 
                   5855: When building a package, the replacement tools are made available in a
                   5856: directory (as symlinks or wrapper scripts) that is early in the executable
                   5857: search path. Just like the buildlink system, this helps with consistent builds.
                   5858: 
                   5859: A tool may be needed to help build a specific package. For example, perl, GNU
                   5860: make (gmake) or yacc may be needed.
                   5861: 
                   5862: Also a tool may be needed, for example, because the native system's supplied
                   5863: tool may be inefficient for building a package with pkgsrc. For example, a
                   5864: package may need GNU awk, bison (instead of yacc) or a better sed.
                   5865: 
                   5866: The tools used by a package can be listed by running make show-tools.
                   5867: 
1.154     rillig   5868: 20.1. Tools for pkgsrc builds
1.1       dsieger  5869: 
                   5870: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
                   5871: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
                   5872: seen by running: make show-var VARNAME=USE_TOOLS.
                   5873: 
                   5874: If a package needs a specific program to build then the USE_TOOLS variable can
                   5875: be used to define the tools needed.
                   5876: 
1.154     rillig   5877: 20.2. Tools needed by packages
1.1       dsieger  5878: 
1.29      wiz      5879: In the following examples, the :run means that it is needed at run-time (and
                   5880: becomes a DEPENDS). The default is a build dependency which can be set with
                   5881: :build. (So in this example, it is the same as gmake:build and
                   5882: pkg-config:build.)
1.1       dsieger  5883: 
                   5884: USE_TOOLS+=     gmake perl:run pkg-config
                   5885: 
                   5886: When using the tools framework, a TOOLS_PATH.foo variable is defined which
                   5887: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
                   5888: could be "/bin/bash" on Linux systems.
                   5889: 
                   5890: If you always need a pkgsrc version of the tool at run-time, then just use
                   5891: DEPENDS instead.
                   5892: 
1.154     rillig   5893: 20.3. Tools provided by platforms
1.1       dsieger  5894: 
                   5895: When improving or porting pkgsrc to a new platform, have a look at (or create)
                   5896: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
                   5897: tools.${OPSYS}.mk which defines the name of the common tools. For example:
                   5898: 
                   5899: .if exists(/usr/bin/bzcat)
                   5900: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
                   5901: .elif exists(/usr/bin/bzip2)
                   5902: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
                   5903: .endif
                   5904: 
                   5905: TOOLS_PLATFORM.true?=           true                    # shell builtin
                   5906: 
1.154     rillig   5907: Chapter 21. Making your package work
1.1       dsieger  5908: 
                   5909: Table of Contents
                   5910: 
1.154     rillig   5911: 21.1. General operation
1.1       dsieger  5912: 
1.154     rillig   5913:     21.1.1. How to pull in user-settable variables from mk.conf
                   5914:     21.1.2. User interaction
                   5915:     21.1.3. Handling licenses
                   5916:     21.1.4. Restricted packages
                   5917:     21.1.5. Handling dependencies
                   5918:     21.1.6. Handling conflicts with other packages
                   5919:     21.1.7. Packages that cannot or should not be built
                   5920:     21.1.8. Packages which should not be deleted, once installed
                   5921:     21.1.9. Handling packages with security problems
                   5922:     21.1.10. How to handle incrementing versions when fixing an existing
1.1       dsieger  5923:         package
1.154     rillig   5924:     21.1.11. Substituting variable text in the package files (the SUBST
1.1       dsieger  5925:         framework)
                   5926: 
1.154     rillig   5927: 21.2. The fetch phase
1.1       dsieger  5928: 
1.154     rillig   5929:     21.2.1. Packages whose distfiles aren't available for plain downloading
                   5930:     21.2.2. How to handle modified distfiles with the 'old' name
                   5931:     21.2.3. Packages hosted on github.com
                   5932: 
                   5933: 21.3. The configure phase
                   5934: 
                   5935:     21.3.1. Shared libraries - libtool
                   5936:     21.3.2. Using libtool on GNU packages that already support libtool
                   5937:     21.3.3. GNU Autoconf/Automake
                   5938: 
                   5939: 21.4. Programming languages
                   5940: 
                   5941:     21.4.1. C, C++, and Fortran
                   5942:     21.4.2. Java
                   5943:     21.4.3. Packages containing perl scripts
                   5944:     21.4.4. Packages containing shell scripts
                   5945:     21.4.5. Other programming languages
                   5946: 
                   5947: 21.5. The build phase
                   5948: 
                   5949:     21.5.1. Compiling C and C++ code conditionally
                   5950:     21.5.2. How to handle compiler bugs
1.172     rillig   5951:     21.5.3. No such file or directory
                   5952:     21.5.4. Undefined reference to "..."
                   5953:     21.5.5. Running out of memory
1.154     rillig   5954: 
                   5955: 21.6. The install phase
                   5956: 
                   5957:     21.6.1. Creating needed directories
                   5958:     21.6.2. Where to install documentation
                   5959:     21.6.3. Installing highscore files
                   5960:     21.6.4. Adding DESTDIR support to packages
                   5961:     21.6.5. Packages with hardcoded paths to other interpreters
                   5962:     21.6.6. Packages installing perl modules
                   5963:     21.6.7. Packages installing info files
                   5964:     21.6.8. Packages installing man pages
                   5965:     21.6.9. Packages installing GConf data files
                   5966:     21.6.10. Packages installing scrollkeeper/rarian data files
                   5967:     21.6.11. Packages installing X11 fonts
                   5968:     21.6.12. Packages installing GTK2 modules
                   5969:     21.6.13. Packages installing SGML or XML data
                   5970:     21.6.14. Packages installing extensions to the MIME database
                   5971:     21.6.15. Packages using intltool
                   5972:     21.6.16. Packages installing startup scripts
                   5973:     21.6.17. Packages installing TeX modules
                   5974:     21.6.18. Packages supporting running binaries in emulation
                   5975:     21.6.19. Packages installing hicolor theme icons
                   5976:     21.6.20. Packages installing desktop files
1.1       dsieger  5977: 
1.154     rillig   5978: 21.7. Marking packages as having problems
1.1       dsieger  5979: 
1.154     rillig   5980: 21.1. General operation
1.1       dsieger  5981: 
                   5982: One appealing feature of pkgsrc is that it runs on many different platforms. As
                   5983: a result, it is important to ensure, where possible, that packages in pkgsrc
                   5984: are portable. This chapter mentions some particular details you should pay
                   5985: attention to while working on pkgsrc.
                   5986: 
1.154     rillig   5987: 21.1.1. How to pull in user-settable variables from mk.conf
1.1       dsieger  5988: 
                   5989: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4       rillig   5990: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
                   5991: those variables in the preprocessor directives of make(1) (for example .if or
                   5992: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
                   5993: loads the user preferences.
1.1       dsieger  5994: 
                   5995: But note that some variables may not be completely defined after ../../mk/
                   5996: bsd.prefs.mk has been included, as they may contain references to variables
1.108     rillig   5997: that are not yet defined. In shell commands (the lines in Makefile that are
                   5998: indented with a tab) this is no problem, since variables are only expanded when
                   5999: they are used. But in the preprocessor directives mentioned above and in
                   6000: dependency lines (of the form target: dependencies) the variables are expanded
                   6001: at load time.
1.1       dsieger  6002: 
                   6003: Note
                   6004: 
1.108     rillig   6005: To check whether a variable can be used at load time, run pkglint -Wall on your
                   6006: package.
1.1       dsieger  6007: 
1.154     rillig   6008: 21.1.2. User interaction
1.1       dsieger  6009: 
                   6010: Occasionally, packages require interaction from the user, and this can be in a
                   6011: number of ways:
                   6012: 
                   6013:   * When fetching the distfiles, some packages require user interaction such as
                   6014:     entering username/password or accepting a license on a web page.
                   6015: 
                   6016:   * When extracting the distfiles, some packages may ask for passwords.
                   6017: 
                   6018:   * help to configure the package before it is built
                   6019: 
                   6020:   * help during the build process
                   6021: 
                   6022:   * help during the installation of a package
                   6023: 
1.108     rillig   6024: A package can set the INTERACTIVE_STAGE variable to define which stages need
                   6025: interaction. This should be done in the package's Makefile, e.g.:
1.1       dsieger  6026: 
                   6027: INTERACTIVE_STAGE=      configure install
                   6028: 
                   6029: The user can then decide to skip this package by setting the BATCH variable.
1.108     rillig   6030: Packages that require interaction are also excluded from bulk builds.
1.1       dsieger  6031: 
1.154     rillig   6032: 21.1.3. Handling licenses
1.1       dsieger  6033: 
                   6034: Authors of software can choose the licence under which software can be copied.
1.111     sevan    6035: The Free Software Foundation has declared some licenses "Free", and the Open
                   6036: Source Initiative has a definition of "Open Source".
                   6037: 
                   6038: By default, pkgsrc allows packages with Free or Open Source licenses to be
                   6039: built. To allow packages with other licenses to be built as well, the pkgsrc
                   6040: user needs to add these licenses to the ACCEPTABLE_LICENSES variable in mk.conf
                   6041: . Note that this variable only affects which packages may be built, while the
                   6042: license terms often also restrict the actual use of the package and its
                   6043: redistribution.
1.1       dsieger  6044: 
                   6045: One might want to only install packages with a BSD license, or the GPL, and not
1.20      jnemeth  6046: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
1.111     sevan    6047: variable. The pkgsrc user can override the default by setting the
                   6048: ACCEPTABLE_LICENSES variable with "=" instead of "+=". The licenses accepted by
                   6049: default are defined in the DEFAULT_ACCEPTABLE_LICENSES variable in the file
                   6050: pkgsrc/mk/license.mk.
1.1       dsieger  6051: 
                   6052: The license tag mechanism is intended to address copyright-related issues
                   6053: surrounding building, installing and using a package, and not to address
1.20      jnemeth  6054: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
                   6055: redistribution restrictions should set these tags.
1.1       dsieger  6056: 
                   6057: Denoting that a package may be copied according to a particular license is done
                   6058: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
                   6059: string identifying the license, e.g. in graphics/xv:
                   6060: 
                   6061: LICENSE=        xv-license
                   6062: 
                   6063: When trying to build, the user will get a notice that the package is covered by
                   6064: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
                   6065: 
                   6066: % make
                   6067: ===> xv-3.10anb9 has an unacceptable license: xv-license.
                   6068: ===>     To view the license, enter "/usr/bin/make show-license".
                   6069: ===>     To indicate acceptance, add this line to your /etc/mk.conf:
                   6070: ===>     ACCEPTABLE_LICENSES+=xv-license
                   6071: *** Error code 1
                   6072: 
                   6073: The license can be viewed with make show-license, and if the user so chooses,
1.4       rillig   6074: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1       dsieger  6075: should not in the future fail because of that license:
                   6076: 
                   6077: ACCEPTABLE_LICENSES+=xv-license
                   6078: 
1.111     sevan    6079: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
                   6080: is deprecated because it does not crisply refer to a particular license text.
                   6081: Another problem with such usage is that it does not enable a user to tell
                   6082: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
                   6083: for all packages with that tag.
                   6084: 
1.154     rillig   6085: 21.1.3.1. Adding a package with a new license
1.1       dsieger  6086: 
1.49      rodent   6087: When adding a package with a new license, the following steps are required:
                   6088: 
1.111     sevan    6089:  1. Check whether the license qualifies as Free or Open Source by referencing
                   6090:     Various Licenses and Comments about Them and Licenses by Name | Open Source
                   6091:     Initiative. If this is the case, the filename in pkgsrc/licenses/ does not
                   6092:     need the -license suffix, and the license name should be added to:
1.49      rodent   6093: 
                   6094:       + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
                   6095: 
                   6096:       + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
                   6097:         license.c
                   6098: 
                   6099:  2. The license text should be added to pkgsrc/licenses for displaying. A list
                   6100:     of known licenses can be seen in this directory.
1.1       dsieger  6101: 
1.154     rillig   6102: 21.1.3.2. Change to the license
1.1       dsieger  6103: 
1.111     sevan    6104: When the license changes (in a way other than formatting), make sure that the
                   6105: new license has a different name (e.g., append the version number if it exists,
                   6106: or the date). Just because a user told pkgsrc to build programs under a
                   6107: previous version of a license does not mean that pkgsrc should build programs
                   6108: under the new licenses. The higher-level point is that pkgsrc does not evaluate
                   6109: licenses for reasonableness; the only test is a mechanistic test of whether a
                   6110: particular text has been approved by either of two bodies (FSF or OSI).
1.1       dsieger  6111: 
1.154     rillig   6112: 21.1.4. Restricted packages
1.1       dsieger  6113: 
1.111     sevan    6114: Some licenses restrict how software may be re-distributed. By declaring the
                   6115: restrictions, package tools can automatically refrain from e.g. placing binary
                   6116: packages on FTP sites.
                   6117: 
                   6118: There are four possible restrictions, which are the cross product of sources
                   6119: (distfiles) and binaries not being placed on FTP sites and CD-ROMs. Because
                   6120: this is rarely the exact language in any license, and because non-Free licenses
                   6121: tend to be different from each other, pkgsrc adopts a definition of FTP and
                   6122: CD-ROM. "FTP" means making the source or binary file available over the
                   6123: Internet at no charge. "CD-ROM" means making the source or binary available on
                   6124: some kind of media, together with other source and binary packages, which is
                   6125: sold for a distribution charge.
1.1       dsieger  6126: 
                   6127: In order to encode these restrictions, the package system defines five make
                   6128: variables that can be set to note these restrictions:
                   6129: 
                   6130:   * RESTRICTED
                   6131: 
                   6132:     This variable should be set whenever a restriction exists (regardless of
                   6133:     its kind). Set this variable to a string containing the reason for the
                   6134:     restriction. It should be understood that those wanting to understand the
                   6135:     restriction will have to read the license, and perhaps seek advice of
                   6136:     counsel.
                   6137: 
                   6138:   * NO_BIN_ON_CDROM
                   6139: 
                   6140:     Binaries may not be placed on CD-ROM containing other binary packages, for
                   6141:     which a distribution charge may be made. In this case, set this variable to
                   6142:     ${RESTRICTED}.
                   6143: 
                   6144:   * NO_BIN_ON_FTP
                   6145: 
                   6146:     Binaries may not made available on the Internet without charge. In this
                   6147:     case, set this variable to ${RESTRICTED}. If this variable is set, binary
                   6148:     packages will not be included on ftp.NetBSD.org.
                   6149: 
                   6150:   * NO_SRC_ON_CDROM
                   6151: 
                   6152:     Distfiles may not be placed on CD-ROM, together with other distfiles, for
                   6153:     which a fee may be charged. In this case, set this variable to $
                   6154:     {RESTRICTED}.
                   6155: 
                   6156:   * NO_SRC_ON_FTP
                   6157: 
                   6158:     Distfiles may not made available via FTP at no charge. In this case, set
                   6159:     this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
                   6160:     will not be mirrored on ftp.NetBSD.org.
                   6161: 
1.111     sevan    6162: Please note that packages will be removed from pkgsrc when the distfiles are
1.33      wiz      6163: not distributable and cannot be obtained for a period of one full quarter
1.111     sevan    6164: branch. Packages with manual/interactive fetch must have a maintainer and it is
                   6165: his/her responsibility to ensure this.
1.33      wiz      6166: 
1.154     rillig   6167: 21.1.5. Handling dependencies
1.1       dsieger  6168: 
1.175     gutterid 6169: Your package may depend on some other package being present, and there are
                   6170: various ways of expressing this dependency. pkgsrc supports the DEPENDS,
                   6171: BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS definitions, the USE_TOOLS
                   6172: definition, as well as dependencies via buildlink3.mk, which is the preferred
                   6173: way to handle dependencies, and which uses the variables named above. See
                   6174: Chapter 16, Buildlink methodology for more information.
                   6175: 
                   6176: The basic difference is that the DEPENDS definition registers that
                   6177: pre-requisite in the binary package so it will be pulled in when the binary
                   6178: package is later installed, whilst the BUILD_DEPENDS, TOOL_DEPENDS, and
                   6179: TEST_DEPENDS definitions do not, marking a dependency that is only needed for
                   6180: building or testing the resulting package. See also Chapter 12, Creating a new
                   6181: pkgsrc package from scratch for more information.
                   6182: 
                   6183: This means that if you only need a package present whilst you are building or
                   6184: testing, it should be noted as a TOOL_DEPENDS, BUILD_DEPENDS, or TEST_DEPENDS.
                   6185: When cross-compiling, TOOL_DEPENDS are native packages, i.e. packages for the
                   6186: architecture where the package is built; BUILD_DEPENDS are target packages,
                   6187: i.e., packages for the architecture for which the package is built.
1.1       dsieger  6188: 
1.175     gutterid 6189: The format for a DEPENDS, BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS
                   6190: definition is:
1.1       dsieger  6191: 
                   6192: <pre-req-package-name>:../../<category>/<pre-req-package>
                   6193: 
                   6194: Please note that the "pre-req-package-name" may include any of the wildcard
                   6195: version numbers recognized by pkg_info(1).
                   6196: 
1.55      wiz      6197:  1. If your package needs another package's binaries or libraries to build and
1.1       dsieger  6198:     run, and if that package has a buildlink3.mk file available, use it:
                   6199: 
                   6200:     .include "../../graphics/jpeg/buildlink3.mk"
                   6201: 
1.55      wiz      6202:  2. If your package needs another package's binaries or libraries only for
                   6203:     building, and if that package has a buildlink3.mk file available, use it:
                   6204: 
                   6205:     .include "../../graphics/jpeg/buildlink3.mk"
                   6206: 
                   6207:     but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
                   6208:     This case is rather rare.
                   6209: 
                   6210:  3. If your package needs binaries from another package to build, use the
1.156     leot     6211:     TOOL_DEPENDS definition:
                   6212: 
                   6213:     TOOL_DEPENDS+= itstool-[0-9]*:../../textproc/itstool
1.1       dsieger  6214: 
1.156     leot     6215:  4. If your package needs static libraries to link against, header files to
                   6216:     include, etc. from another package to build, use the BUILD_DEPENDS
                   6217:     definition.
1.1       dsieger  6218: 
1.156     leot     6219:  5. If your package needs a library with which to link and there is no
1.26      spz      6220:     buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
                   6221:     because the include files and libraries will be hidden from the compiler.
1.1       dsieger  6222: 
1.156     leot     6223:  6. If your package needs some executable to be able to run correctly and if
1.26      spz      6224:     there's no buildlink3.mk file, this is specified using the DEPENDS
                   6225:     variable. The print/lyx package needs to be able to execute the latex
1.129     wiz      6226:     binary from the tex-latex-bin package when it runs, and that is specified:
1.1       dsieger  6227: 
1.129     wiz      6228:     DEPENDS+=        tex-latex-bin-[0-9]*:../../print/tex-latex-bin
1.1       dsieger  6229: 
1.175     gutterid 6230:  7. If your package includes a test suite that has extra dependencies only
                   6231:     required for this purpose (frequently this can be run as a "make test"
                   6232:     target), use the TEST_DEPENDS variable.
                   6233: 
                   6234:  8. You can use wildcards in package dependencies. Note that such wildcard
1.26      spz      6235:     dependencies are retained when creating binary packages. The dependency is
                   6236:     checked when installing the binary package and any package which matches
                   6237:     the pattern will be used. Wildcard dependencies should be used with care.
1.1       dsieger  6238: 
                   6239:     The "-[0-9]*" should be used instead of "-*" to avoid potentially ambiguous
                   6240:     matches such as "tk-postgresql" matching a "tk-*" DEPENDS.
                   6241: 
                   6242:     Wildcards can also be used to specify that a package will only build
                   6243:     against a certain minimum version of a pre-requisite:
                   6244: 
1.26      spz      6245:     DEPENDS+=       ImageMagick>=6.0:../../graphics/ImageMagick
1.1       dsieger  6246: 
1.26      spz      6247:     This means that the package will build using version 6.0 of ImageMagick or
                   6248:     newer. Such a dependency may be warranted if, for example, the command line
                   6249:     options of an executable have changed.
                   6250: 
                   6251:     If you need to depend on minimum versions of libraries, see the buildlink
                   6252:     section of the pkgsrc guide.
1.1       dsieger  6253: 
                   6254:     For security fixes, please update the package vulnerabilities file. See
1.154     rillig   6255:     Section 21.1.9, "Handling packages with security problems" for more
1.1       dsieger  6256:     information.
                   6257: 
                   6258: If your package needs files from another package to build, add the relevant
                   6259: distribution files to DISTFILES, so they will be extracted automatically. See
                   6260: the print/ghostscript package for an example. (It relies on the jpeg sources
                   6261: being present in source form during the build.)
                   6262: 
1.154     rillig   6263: 21.1.6. Handling conflicts with other packages
1.1       dsieger  6264: 
                   6265: Your package may conflict with other packages a user might already have
                   6266: installed on his system, e.g. if your package installs the same set of files as
1.80      wiz      6267: another package in the pkgsrc tree or has the same PKGNAME.
1.1       dsieger  6268: 
1.142     leot     6269: For example, x11/libXaw3d and x11/Xaw-Xpm install the same shared library, thus
                   6270: you set in pkgsrc/x11/libXaw3d/Makefile:
1.1       dsieger  6271: 
1.142     leot     6272: CONFLICTS=      Xaw-Xpm-[0-9]*
1.1       dsieger  6273: 
                   6274: 
1.142     leot     6275: and in pkgsrc/x11/Xaw-Xpm/Makefile:
1.1       dsieger  6276: 
1.142     leot     6277: CONFLICTS=      libXaw3d-[0-9]*
1.1       dsieger  6278: 
1.142     leot     6279: 
                   6280: pkg_add(1) is able to detect attempts to install packages that conflict with
                   6281: existing packages and abort. However, in many situations this is too late in
                   6282: the process. Binary package managers will not know about the conflict until
                   6283: they attempt to install the package after already downloading it and all its
                   6284: dependencies. Users may also waste time building a package and its dependencies
                   6285: only to find out at the end that it conflicts with another package they have
                   6286: installed.
                   6287: 
                   6288: To avoid these issues CONFLICTS entries should be added in all cases where it
                   6289: is known that packages conflict with each other. These CONFLICTS entries are
                   6290: exported in pkg_summary(5) files and consumed by binary package managers to
                   6291: inform users that packages cannot be installed onto the target system.
1.1       dsieger  6292: 
1.154     rillig   6293: 21.1.7. Packages that cannot or should not be built
1.1       dsieger  6294: 
                   6295: There are several reasons why a package might be instructed to not build under
                   6296: certain circumstances. If the package builds and runs on most platforms, the
1.83      dholland 6297: exceptions should be noted with BROKEN_ON_PLATFORM. If the package builds and
                   6298: runs on a small handful of platforms, set BROKEN_EXCEPT_ON_PLATFORM instead.
                   6299: Both BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM are OS triples
                   6300: (OS-version-platform) that can use glob-style wildcards.
                   6301: 
1.114     maya     6302: If a package is not appropriate for some platforms (as opposed to merely
1.83      dholland 6303: broken), a different set of variables should be used as this affects failure
                   6304: reporting and statistics. If the package is appropriate for most platforms, the
                   6305: exceptions should be noted with NOT_FOR_PLATFORM. If the package is appropriate
                   6306: for only a small handful of platforms (often exactly one), set
                   6307: ONLY_FOR_PLATFORM instead. Both ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS
                   6308: triples (OS-version-platform) that can use glob-style wildcards.
1.1       dsieger  6309: 
                   6310: Some packages are tightly bound to a specific version of an operating system,
                   6311: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
                   6312: with other versions of the OS, and should be uploaded to a version specific
                   6313: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
                   6314: to "yes". This variable is not currently used by any of the package system
                   6315: internals, but may be used in the future.
                   6316: 
                   6317: If the package should be skipped (for example, because it provides
                   6318: functionality already provided by the system), set PKG_SKIP_REASON to a
                   6319: descriptive message. If the package should fail because some preconditions are
                   6320: not met, set PKG_FAIL_REASON to a descriptive message.
                   6321: 
1.154     rillig   6322: 21.1.8. Packages which should not be deleted, once installed
1.1       dsieger  6323: 
                   6324: To ensure that a package may not be deleted, once it has been installed, the
                   6325: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.25      wiz      6326: carried into any binary package that is made from this pkgsrc entry. A "
                   6327: preserved" package will not be deleted using pkg_delete(1) unless the "-f"
1.1       dsieger  6328: option is used.
                   6329: 
1.154     rillig   6330: 21.1.9. Handling packages with security problems
1.1       dsieger  6331: 
                   6332: When a vulnerability is found, this should be noted in localsrc/security/
1.32      wiz      6333: advisories/pkg-vulnerabilities, and after committing that file, ask
                   6334: pkgsrc-security@NetBSD.org to update the file on ftp.NetBSD.org.
1.1       dsieger  6335: 
                   6336: After fixing the vulnerability by a patch, its PKGREVISION should be increased
                   6337: (this is of course not necessary if the problem is fixed by using a newer
1.32      wiz      6338: release of the software), and the pattern in the pkg-vulnerabilities file must
                   6339: be updated.
1.1       dsieger  6340: 
                   6341: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
                   6342: submit a pullup request!
                   6343: 
                   6344: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
                   6345: a weekly cron job.
                   6346: 
1.154     rillig   6347: 21.1.10. How to handle incrementing versions when fixing an existing package
1.1       dsieger  6348: 
                   6349: When making fixes to an existing package it can be useful to change the version
                   6350: number in PKGNAME. To avoid conflicting with future versions by the original
                   6351: author, a "nb1", "nb2", ... suffix can be used on package versions by setting
                   6352: PKGREVISION=1 (2, ...). The "nb" is treated like a "." by the package tools.
                   6353: e.g.
                   6354: 
                   6355: DISTNAME=       foo-17.42
                   6356: PKGREVISION=    9
                   6357: 
                   6358: will result in a PKGNAME of "foo-17.42nb9". If you want to use the original
                   6359: value of PKGNAME without the "nbX" suffix, e.g. for setting DIST_SUBDIR, use
                   6360: PKGNAME_NOREV.
                   6361: 
                   6362: When a new release of the package is released, the PKGREVISION should be
                   6363: removed, e.g. on a new minor release of the above package, things should be
                   6364: like:
                   6365: 
                   6366: DISTNAME=       foo-17.43
                   6367: 
                   6368: PKGREVISION should be incremented for any non-trivial change in the resulting
                   6369: binary package. Without a PKGREVISION bump, someone with the previous version
                   6370: installed has no way of knowing that their package is out of date. Thus,
                   6371: changes without increasing PKGREVISION are essentially labeled "this is so
                   6372: trivial that no reasonable person would want to upgrade", and this is the rough
                   6373: test for when increasing PKGREVISION is appropriate. Examples of changes that
                   6374: do not merit increasing PKGREVISION are:
                   6375: 
1.14      jmcneill 6376:   * Changing HOMEPAGE, MAINTAINER, OWNER, or comments in Makefile.
1.1       dsieger  6377: 
                   6378:   * Changing build variables if the resulting binary package is the same.
                   6379: 
                   6380:   * Changing DESCR.
                   6381: 
                   6382:   * Adding PKG_OPTIONS if the default options don't change.
                   6383: 
                   6384: Examples of changes that do merit an increase to PKGREVISION include:
                   6385: 
                   6386:   * Security fixes
                   6387: 
                   6388:   * Changes or additions to a patch file
                   6389: 
                   6390:   * Changes to the PLIST
                   6391: 
1.12      weinem   6392:   * A dependency is changed or renamed.
                   6393: 
1.1       dsieger  6394: PKGREVISION must also be incremented when dependencies have ABI changes.
                   6395: 
1.154     rillig   6396: 21.1.11. Substituting variable text in the package files (the SUBST framework)
1.1       dsieger  6397: 
1.180     rillig   6398: When you want to replace the same text in multiple files, or multiple times in
                   6399: the same file, it is cumbersome to maintain a patch file for this. This is
                   6400: where the SUBST framework steps in. It provides an easy-to-use interface for
                   6401: replacing text in files. It just needs the following information:
1.172     rillig   6402: 
1.180     rillig   6403:   * In which phase of the package build cycle should the replacement happen?
1.172     rillig   6404: 
1.180     rillig   6405:   * In which files should the replacement happen?
1.172     rillig   6406: 
                   6407:   * Which text should be replaced with what?
                   6408: 
1.180     rillig   6409: This information is encoded in a block of SUBST variables. A minimal example
                   6410: is:
                   6411: 
                   6412: SUBST_CLASSES+=         paths
                   6413: SUBST_STAGE.paths=      pre-configure
                   6414: SUBST_FILES.paths=      src/*.c
                   6415: SUBST_SED.paths=        -e 's,/usr/local,${PREFIX},g'
                   6416: 
                   6417: Translated into English, it means: In the pre-configure stage (that is, after
                   6418: applying the patches from the patches/ directory and before running the
                   6419: configure script and the portability check), replace the text /usr/local with
                   6420: the content of the variable PREFIX.
                   6421: 
                   6422: Each SUBST block starts by appending an identifier to SUBST_CLASSES (note the +
                   6423: =). This identifier can be chosen freely by the package. If there should ever
                   6424: be duplicate identifiers, the pkgsrc infrastructure will catch this and fail
                   6425: early, so don't worry about name collisions.
                   6426: 
                   6427: Except for SUBST_CLASSES, all variables in a SUBST block are parameterized
                   6428: using this identifier. In the remainder of this section, these parameterized
                   6429: variables are written as SUBST_STAGE.*.
                   6430: 
                   6431: SUBST_CLASSES+=         paths
                   6432: SUBST_STAGE.paths=      pre-configure
                   6433: SUBST_MESSAGE.paths=    Fixing absolute paths.
                   6434: SUBST_FILES.paths=      src/*.c
                   6435: SUBST_FILES.paths+=     scripts/*.sh
                   6436: SUBST_SED.paths=        -e 's,"/usr/local,"${PREFIX},g'
                   6437: SUBST_SED.paths+=       -e 's,"/var/log,"${VARBASE}/log,g'
                   6438: SUBST_VARS.paths=       LOCALBASE PREFIX PKGVERSION
                   6439: 
                   6440: To get a complete picture about the SUBST substitutions, run bmake
                   6441: show-all-subst. If something doesn't work as expected, run pkglint on the
                   6442: package, which detects several typical mistakes surrounding the SUBST blocks.
                   6443: For any questions that might remain after this, have a look at mk/subst.mk.
                   6444: 
                   6445: 21.1.11.1. Choosing the time where the substitutions happen
                   6446: 
                   6447: The SUBST_STAGE.* is one of {pre,do,post}-
                   6448: {extract,patch,configure,build,test,install}. Of these, pre-configure is used
                   6449: most often, by far. The most popular stages are, in chronological order:
                   6450: 
                   6451: post-extract
                   6452: 
                   6453:     The substitutions are applied immediately after the distfiles are
                   6454:     extracted. Running bmake extract on the package will leave no traces of the
                   6455:     original files.
                   6456: 
                   6457:     When the substitution applies to files for which there is also a patch in
                   6458:     the patches/ directory, this means that the patches will be computed based
                   6459:     on the result of the substitution. When these patches are sent to the
                   6460:     upstream maintainer later, to be fixed in the upstream package, these
                   6461:     patches may no longer match what the upstream author is used to. Because of
                   6462:     this, pre-configure is often a better choice.
                   6463: 
                   6464: pre-configure
                   6465: 
                   6466:     The substitutions are applied after the patches from the patches/
                   6467:     directory. This makes it possible to run bmake patch on the package, after
                   6468:     which the patches can be edited using the tools pkgvi and mkpatches from
                   6469:     the pkgtools/pkgdiff package.
                   6470: 
                   6471:     When updating the patches, it is helpful to explicitly separate the bmake
                   6472:     patch from the bmake configure, and to only edit the patches between these
                   6473:     commands. Otherwise the substitutions from the SUBST block will end up in
                   6474:     the patch file. When this happens in really obvious ways, pkglint will
                   6475:     complain about patches that contain a hard-coded /usr/pkg instead of the
                   6476:     correct and intended @PREFIX@, but it can only detect these really obvious
                   6477:     cases.
                   6478: 
                   6479: do-configure
                   6480: 
                   6481:     This stage should only be used if the package defines a pre-configure
                   6482:     action itself, and the substitution must happen after that. Typical
                   6483:     examples are packages that use the pre-configure stage to regenerate the
                   6484:     GNU configure script from configure.ac.
                   6485: 
                   6486: post-configure
                   6487: 
                   6488:     This stage is used to fix up any mistakes by the configure stage.
                   6489: 
                   6490: pre-build
                   6491: 
                   6492:     This stage should only be used for substitutions that are clearly related
                   6493:     to building the package, not for fixing the configuration. Substitutions
                   6494:     for pathnames (such as replacing /usr/local with ${PREFIX}) or user names
                   6495:     (such as replacing @MY_USER@ with the actual username) belong in
                   6496:     pre-configure or post-configure instead.
                   6497: 
                   6498: post-build
                   6499: 
                   6500:     Just as with pre-build, this stage should only be used for substitutions
                   6501:     that are clearly related to building the package, not for fixing the
                   6502:     configuration. Substitutions for pathnames (such as replacing /usr/local
                   6503:     with ${PREFIX}) or user names (such as replacing @MY_USER@ with the actual
                   6504:     username) belong in pre-configure or post-configure instead.
                   6505: 
                   6506:     A typical use is to update pkg-config files to include the rpath compiler
                   6507:     options.
                   6508: 
                   6509: pre-install
                   6510: 
                   6511:     In general, the install phase should be as simple as possible. As with the
                   6512:     pre-build and post-build stages, it should not be used to fix pathnames or
                   6513:     user names, these belong in pre-configure instead. There are only few
                   6514:     legitimate use cases for applying substitutions in this stage.
                   6515: 
1.181   ! rillig   6516: 21.1.11.2. Choosing the files where the substitutions happen
1.180     rillig   6517: 
                   6518: The SUBST_FILES.* variable contains a list of filename patterns. These patterns
                   6519: are relative to WRKSRC since that is where most substitutions happen. A typical
                   6520: example is:
                   6521: 
                   6522: SUBST_FILES.path=       Makefile */Makefile */*/Makefile *.[ch]
                   6523: 
                   6524: The above patterns, especially the last, are quite broad. The SUBST
                   6525: implementation checks that each filename pattern that is mentioned here has an
                   6526: effect. For example, if none of the */*/Makefile files contains the patterns to
                   6527: be found and substituted, that filename pattern is redundant and should be left
1.181   ! rillig   6528: out. By default, the SUBST framework will complain with an error message. If
        !          6529: the text to be substituted occurs in some of the files from a single pattern,
        !          6530: but not in all of them, that is totally ok, and the SUBST framework will only
        !          6531: print an INFO message for those files.
1.180     rillig   6532: 
                   6533: If there is a good reason for having redundant filename patterns, set
1.181   ! rillig   6534: SUBST_NOOP_OK.* to yes.
1.180     rillig   6535: 
                   6536: Another popular way of choosing the files for the substitutions is via a shell
                   6537: command, like this:
                   6538: 
1.181   ! rillig   6539: C_FILES_CMD=            cd ${WRKSRC} && ${FIND} . -name '*.c'
1.180     rillig   6540: SUBST_FILES.path=       ${C_FILES_CMD:sh}
                   6541: 
                   6542: The variable name C_FILES_CMD in this example is freely chosen and independent
                   6543: of the SUBST framework.
                   6544: 
                   6545: In this variant, the SUBST_FILES.* variable lists each file individually.
                   6546: Thereby chances are higher that there are filename patterns in which no
                   6547: substitution happens. Since the SUBST framework cannot know whether the
                   6548: filename patterns in SUBST_FILES.* have been explicitly listed in the Makefile
                   6549: (where any redundant filename pattern would be suspicious) or been generated by
                   6550: a shell command (in which redundant filename patterns are more likely and to be
                   6551: expected), it will complain about these redundant filename patterns. Therefore,
                   6552: SUBST blocks that use a shell command to generate the list of filename patterns
                   6553: often need to set SUBST_NOOP_OK.* to yes.
                   6554: 
                   6555: 21.1.11.3. Choosing what to substitute
                   6556: 
                   6557: In most cases, the substitutions are given using one or more sed(1) commands,
                   6558: like this:
                   6559: 
                   6560: SUBST_SED.path=         -e 's|/usr/local|${PREFIX}|g'
                   6561: 
                   6562: Each of the sed commands needs to be preceded by the -e option and should be
                   6563: specified on a line of its own, to avoid hiding short sed commands at the end
                   6564: of a line.
                   6565: 
                   6566: Since the sed commands often contain shell metacharacters as the separator (the
                   6567: | in the above example), it is common to enclose them in single quotes.
                   6568: 
                   6569: A common substitution is to replace placeholders of the form @VARNAME@ with
                   6570: their pkgsrc counterpart variable ${VARNAME}. A typical example is:
                   6571: 
                   6572: SUBST_VARS.path=        PREFIX
                   6573: 
1.181   ! rillig   6574: This type of substitutions is typically done by the GNU configure scripts
        !          6575: during the do-configure stage, but in some cases these need to be overridden.
        !          6576: The same pattern is also used when a package defines patches that replace
        !          6577: previously hard-coded paths like /usr/local with a @PREFIX@ placeholder first,
        !          6578: which then gets substituted by the actual ${PREFIX} in the pre-configure stage.
        !          6579: In many of these cases, it works equally well to just use the SUBST framework
        !          6580: to directly replace /usr/local with ${PREFIX}, thereby omitting the
        !          6581: intermediate patch file.
1.180     rillig   6582: 
                   6583: If the above is not flexible enough, it is possible to not use sed at all for
                   6584: the substitution but to specify an entirely different command, like this:
                   6585: 
                   6586: SUBST_FILTER_CMD.path=  LC_ALL=C ${TR} -d '\r'
1.1       dsieger  6587: 
1.180     rillig   6588: This is used for the few remaining packages in which the distributed files use
                   6589: Windows-style line endings that need to be converted to UNIX-style line
                   6590: endings.
1.1       dsieger  6591: 
1.180     rillig   6592: 21.1.11.4. Other SUBST variables
1.172     rillig   6593: 
1.180     rillig   6594: When a SUBST block is applied during a package build, a message is logged. The
                   6595: default message is fine for most purposes but can be overridden by setting
                   6596: SUBST_MESSAGE.* to an individual message.
1.1       dsieger  6597: 
1.154     rillig   6598: 21.2. The fetch phase
1.1       dsieger  6599: 
1.154     rillig   6600: 21.2.1. Packages whose distfiles aren't available for plain downloading
1.1       dsieger  6601: 
                   6602: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
                   6603: a make fetch will call files/getsite.sh with the name of each file to download
                   6604: as an argument, expecting it to output the URL of the directory from which to
                   6605: download it. graphics/ns-cult3d is an example of this usage.
                   6606: 
                   6607: If the download can't be automated, because the user must submit personal
                   6608: information to apply for a password, or must pay for the source, or whatever,
                   6609: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
                   6610: before aborting the build. Example:
                   6611: 
                   6612: FETCH_MESSAGE=  "Please download the files"
                   6613: FETCH_MESSAGE+= "    "${DISTFILES:Q}
                   6614: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
                   6615: 
1.154     rillig   6616: 21.2.2. How to handle modified distfiles with the 'old' name
1.1       dsieger  6617: 
                   6618: Sometimes authors of a software package make some modifications after the
                   6619: software was released, and they put up a new distfile without changing the
                   6620: package's version number. If a package is already in pkgsrc at that time, the
                   6621: checksum will no longer match. The contents of the new distfile should be
                   6622: compared against the old one before changing anything, to make sure the
                   6623: distfile was really updated on purpose, and that no trojan horse or so crept
                   6624: in. Please mention that the distfiles were compared and what was found in your
1.54      rodent   6625: commit message.
                   6626: 
                   6627: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
1.109     wiz      6628: directory name, usually based on PKGNAME_NOREV (but take care with python or
                   6629: ruby packages, where PKGNAME includes a variable prefix). All DISTFILES and
                   6630: PATCHFILES for this package will be put in that subdirectory of the local
1.154     rillig   6631: distfiles directory. (See Section 21.1.10, "How to handle incrementing versions
1.109     wiz      6632: when fixing an existing package" for more details.) In case this happens more
                   6633: often, PKGNAME can be used (thus including the nbX suffix) or a date stamp can
                   6634: be appended, like ${PKGNAME_NOREV}-YYYYMMDD.
1.54      rodent   6635: 
                   6636: DIST_SUBDIR is also used when a distfile's name does not contain a version and
                   6637: the distfile is apt to change. In cases where the likelihood of this is very
                   6638: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
                   6639: removed unless the distfile name changes, even if a package is being moved or
                   6640: renamed.
                   6641: 
                   6642: Do not forget regenerating the distinfo file after that, since it contains the
                   6643: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
                   6644: installed package is different. Furthermore, a mail to the package's authors
                   6645: seems appropriate telling them that changing distfiles after releases without
                   6646: changing the file names is not good practice.
1.1       dsieger  6647: 
1.154     rillig   6648: 21.2.3. Packages hosted on github.com
1.88      tnn      6649: 
1.90      tnn      6650: Helper methods exist for packages hosted on github.com which will often have
                   6651: distfile names that clash with other packages, for example 1.0.tar.gz. Use one
                   6652: of the three recipes from below:
1.88      tnn      6653: 
1.154     rillig   6654: 21.2.3.1. Fetch based on a tagged release
1.88      tnn      6655: 
1.174     leot     6656: If your distfile URL looks similar to https://github.com/username/
                   6657: exampleproject/archive/v1.0.zip, then you are packaging a tagged release.
1.88      tnn      6658: 
                   6659: DISTNAME=       exampleproject-1.0
1.90      tnn      6660: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6661: #GITHUB_PROJECT=        # can be omitted if same as DISTNAME
                   6662: GITHUB_TAG=     v${PKGVERSION_NOREV}
1.88      tnn      6663: EXTRACT_SUFX=   .zip
                   6664: 
1.154     rillig   6665: 21.2.3.2. Fetch based on a specific commit
1.88      tnn      6666: 
1.174     leot     6667: If your distfile URL looks similar to https://github.com?/example?/example?/
1.169     rillig   6668: archive?/988881adc9fc3655077dc2d4d757d480b5ea0e11.tar.gz, then you are
                   6669: packaging a specific commit not tied to a release.
1.88      tnn      6670: 
                   6671: DISTNAME=       example-1.0
1.107     jnemeth  6672: MASTER_SITES=   ${MASTER_SITE_GITHUB:=example/}
1.90      tnn      6673: #GITHUB_PROJECT=        # can be omitted if same as DISTNAME
                   6674: GITHUB_TAG=     988881adc9fc3655077dc2d4d757d480b5ea0e11
1.88      tnn      6675: 
1.154     rillig   6676: 21.2.3.3. Fetch based on release
1.88      tnn      6677: 
1.174     leot     6678: If your distfile URL looks similar to https://github.com?/username/
1.169     rillig   6679: exampleproject?/releases?/download?/rel-1.6?/offensive-1.6.zip, then you are
                   6680: packaging a release.
1.88      tnn      6681: 
1.90      tnn      6682: DISTNAME=       offensive-1.6
1.88      tnn      6683: PKGNAME=        ${DISTNAME:S/offensive/proper/}
1.90      tnn      6684: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6685: GITHUB_PROJECT= exampleproject
                   6686: GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
                   6687: EXTRACT_SUFX=   .zip
1.88      tnn      6688: 
1.154     rillig   6689: 21.3. The configure phase
1.1       dsieger  6690: 
1.154     rillig   6691: 21.3.1. Shared libraries - libtool
1.1       dsieger  6692: 
                   6693: pkgsrc supports many different machines, with different object formats like
                   6694: a.out and ELF, and varying abilities to do shared library and dynamic loading
                   6695: at all. To accompany this, varying commands and options have to be passed to
                   6696: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
                   6697: especially if you don't have all the machines at your hand to test things. The
                   6698: devel/libtool pkg can help here, as it just "knows" how to build both static
                   6699: and dynamic libraries from a set of source files, thus being
                   6700: platform-independent.
                   6701: 
                   6702: Here's how to use libtool in a package in seven simple steps:
                   6703: 
                   6704:  1. Add USE_LIBTOOL=yes to the package Makefile.
                   6705: 
                   6706:  2. For library objects, use "${LIBTOOL} --mode=compile ${CC}" in place of "$
                   6707:     {CC}". You could even add it to the definition of CC, if only libraries are
                   6708:     being built in a given Makefile. This one command will build both PIC and
                   6709:     non-PIC library objects, so you need not have separate shared and
                   6710:     non-shared library rules.
                   6711: 
                   6712:  3. For the linking of the library, remove any "ar", "ranlib", and "ld
                   6713:     -Bshareable" commands, and instead use:
                   6714: 
                   6715:     ${LIBTOOL} --mode=link \
                   6716:         ${CC} -o ${.TARGET:.a=.la} \
                   6717:             ${OBJS:.o=.lo} \
                   6718:             -rpath ${PREFIX}/lib \
                   6719:             -version-info major:minor
                   6720: 
                   6721:     Note that the library is changed to have a .la extension, and the objects
                   6722:     are changed to have a .lo extension. Change OBJS as necessary. This
                   6723:     automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
                   6724:     necessary) in the build directory. Be sure to include "-version-info",
                   6725:     especially when major and minor are zero, as libtool will otherwise strip
                   6726:     off the shared library version.
                   6727: 
                   6728:     From the libtool manual:
                   6729: 
                   6730:     So, libtool library versions are described by three integers:
                   6731: 
                   6732:     CURRENT
                   6733:     The most recent interface number that this library implements.
                   6734: 
                   6735:     REVISION
                   6736:     The implementation number of the CURRENT interface.
                   6737: 
                   6738:     AGE
                   6739:     The difference between the newest and oldest interfaces that
                   6740:     this library implements.  In other words, the library implements
                   6741:     all the interface numbers in the range from number `CURRENT -
                   6742:     AGE' to `CURRENT'.
                   6743: 
                   6744:     If two libraries have identical CURRENT and AGE numbers, then the
                   6745:     dynamic linker chooses the library with the greater REVISION number.
                   6746: 
                   6747:     The "-release" option will produce different results for a.out and ELF
1.25      wiz      6748:     (excluding symlinks) in only one case. An ELF library of the form "
                   6749:     libfoo-release.so.x.y" will have a symlink of "libfoo.so.x.y" on an a.out
1.1       dsieger  6750:     platform. This is handled automatically.
                   6751: 
                   6752:     The "-rpath argument" is the install directory of the library being built.
                   6753: 
                   6754:     In the PLIST, include only the .la file, the other files will be added
                   6755:     automatically.
                   6756: 
                   6757:  4. When linking shared object (.so) files, i.e. files that are loaded via
                   6758:     dlopen(3), NOT shared libraries, use "-module -avoid-version" to prevent
                   6759:     them getting version tacked on.
                   6760: 
                   6761:     The PLIST file gets the foo.so entry.
                   6762: 
                   6763:  5. When linking programs that depend on these libraries before they are
                   6764:     installed, preface the cc(1) or ld(1) line with "${LIBTOOL} --mode=link",
                   6765:     and it will find the correct libraries (static or shared), but please be
                   6766:     aware that libtool will not allow you to specify a relative path in -L
                   6767:     (such as "-L../somelib"), because it expects you to change that argument to
                   6768:     be the .la file. e.g.
                   6769: 
                   6770:     ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
                   6771: 
                   6772:     should be changed to:
                   6773: 
                   6774:     ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
                   6775: 
                   6776:     and it will do the right thing with the libraries.
                   6777: 
                   6778:  6. When installing libraries, preface the install(1) or cp(1) command with "$
                   6779:     {LIBTOOL} --mode=install", and change the library name to .la. e.g.
                   6780: 
1.23      jakllsch 6781:     ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1       dsieger  6782: 
                   6783:     This will install the static .a, shared library, any needed symlinks, and
                   6784:     run ldconfig(8).
                   6785: 
                   6786:  7. In your PLIST, include only the .la file (this is a change from previous
                   6787:     behaviour).
                   6788: 
1.154     rillig   6789: 21.3.2. Using libtool on GNU packages that already support libtool
1.1       dsieger  6790: 
                   6791: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
                   6792: own libtool in most cases. For older libtool using packages, libtool is made by
                   6793: ltconfig script during the do-configure step; you can check the libtool script
                   6794: location by doing make configure; find work*/ -name libtool.
                   6795: 
                   6796: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
                   6797: override. By default, it is set to "libtool */libtool */*/libtool". If this
                   6798: does not match the location of the package's libtool script(s), set it as
                   6799: appropriate.
                   6800: 
                   6801: If you do not need *.a static libraries built and installed, then use
                   6802: SHLIBTOOL_OVERRIDE instead.
                   6803: 
                   6804: If your package makes use of the platform-independent library for loading
                   6805: dynamic shared objects, that comes with libtool (libltdl), you should include
                   6806: devel/libltdl/buildlink3.mk.
                   6807: 
                   6808: Some packages use libtool incorrectly so that the package may not work or build
                   6809: in some circumstances. Some of the more common errors are:
                   6810: 
                   6811:   * The inclusion of a shared object (-module) as a dependent library in an
                   6812:     executable or library. This in itself isn't a problem if one of two things
                   6813:     has been done:
                   6814: 
                   6815:      1. The shared object is named correctly, i.e. libfoo.la, not foo.la
                   6816: 
                   6817:      2. The -dlopen option is used when linking an executable.
                   6818: 
                   6819:   * The use of libltdl without the correct calls to initialisation routines.
                   6820:     The function lt_dlinit() should be called and the macro
                   6821:     LTDL_SET_PRELOADED_SYMBOLS included in executables.
                   6822: 
1.154     rillig   6823: 21.3.3. GNU Autoconf/Automake
1.1       dsieger  6824: 
                   6825: If a package needs GNU autoconf or automake to be executed to regenerate the
                   6826: configure script and Makefile.in makefile templates, then they should be
                   6827: executed in a pre-configure target.
                   6828: 
                   6829: For packages that need only autoconf:
                   6830: 
                   6831: AUTOCONF_REQD=  2.50            # if default version is not good enough
                   6832: USE_TOOLS+=     autoconf        # use "autoconf213" for autoconf-2.13
                   6833: ...
                   6834: 
                   6835: pre-configure:
                   6836:         cd ${WRKSRC} && autoconf
                   6837: 
                   6838: ...
                   6839: 
                   6840: and for packages that need automake and autoconf:
                   6841: 
                   6842: AUTOMAKE_REQD=  1.7.1           # if default version is not good enough
                   6843: USE_TOOLS+=     automake        # use "automake14" for automake-1.4
                   6844: ...
                   6845: 
                   6846: pre-configure:
                   6847:         set -e; cd ${WRKSRC}; \
                   6848:         aclocal; autoheader; automake -a --foreign -i; autoconf
                   6849: 
                   6850: ...
                   6851: 
                   6852: Packages which use GNU Automake will almost certainly require GNU Make.
                   6853: 
                   6854: There are times when the configure process makes additional changes to the
                   6855: generated files, which then causes the build process to try to re-execute the
                   6856: automake sequence. This is prevented by touching various files in the configure
                   6857: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
                   6858: NO in the package Makefile.
                   6859: 
1.154     rillig   6860: 21.4. Programming languages
1.1       dsieger  6861: 
1.154     rillig   6862: 21.4.1. C, C++, and Fortran
1.1       dsieger  6863: 
                   6864: Compilers for the C, C++, and Fortran languages comes with the NetBSD base
                   6865: system. By default, pkgsrc assumes that a package is written in C and will hide
1.154     rillig   6866: all other compilers (via the wrapper framework, see Chapter 16, Buildlink
1.1       dsieger  6867: methodology).
                   6868: 
                   6869: To declare which language's compiler a package needs, set the USE_LANGUAGES
                   6870: variable. Allowed values currently are "c", "c++", and "fortran" (and any
                   6871: combination). The default is "c". Packages using GNU configure scripts, even if
                   6872: written in C++, usually need a C compiler for the configure phase.
                   6873: 
1.154     rillig   6874: 21.4.2. Java
1.1       dsieger  6875: 
                   6876: If a program is written in Java, use the Java framework in pkgsrc. The package
                   6877: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
                   6878: variables:
                   6879: 
                   6880:   * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
                   6881:     set to "run", then there is only a runtime dependency on the JDK. The
                   6882:     default is "yes", which also adds a build dependency on the JDK.
                   6883: 
                   6884:   * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
                   6885:     supported values are "yes", "1.4", and "1.5". "yes" accepts any Java2
                   6886:     implementation, "1.4" insists on versions 1.4 or above, and "1.5" only
                   6887:     accepts versions 1.5 or above. This variable is not set by default.
                   6888: 
1.25      wiz      6889:   * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
                   6890:     implementation dependency. It may be used to set JAVA_HOME to a good value
                   6891:     if the program needs this variable to be defined.
                   6892: 
1.154     rillig   6893: 21.4.3. Packages containing perl scripts
1.1       dsieger  6894: 
                   6895: If your package contains interpreted perl scripts, add "perl" to the USE_TOOLS
                   6896: variable and set REPLACE_PERL to ensure that the proper interpreter path is
                   6897: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
1.74      wiz      6898: you want adjusted. Every occurrence of */bin/perl in a she-bang line will be
                   6899: replaced with the full path to the perl executable.
1.1       dsieger  6900: 
                   6901: If a particular version of perl is needed, set the PERL5_REQD variable to the
                   6902: version number. The default is "5.0".
                   6903: 
1.154     rillig   6904: See Section 21.6.6, "Packages installing perl modules" for information about
1.1       dsieger  6905: handling perl modules.
                   6906: 
1.154     rillig   6907: 21.4.4. Packages containing shell scripts
1.41      wiz      6908: 
                   6909: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
                   6910: shell hash bangs in files. Please use the appropriate one, prefering REPLACE_SH
1.74      wiz      6911: in case this shell is sufficient. Each should contain a list of scripts,
                   6912: relative to WRKSRC, that you want adjusted. Every occurrence of the matching
                   6913: shell in a she-bang line will be replaced with the full path to the shell
                   6914: executable. When using REPLACE_BASH, don't forget to add bash to USE_TOOLS.
1.41      wiz      6915: 
1.154     rillig   6916: 21.4.5. Other programming languages
1.1       dsieger  6917: 
                   6918: Currently, there is no special handling for other languages in pkgsrc. If a
                   6919: compiler package provides a buildlink3.mk file, include that, otherwise just
                   6920: add a (build) dependency on the appropriate compiler package.
                   6921: 
1.154     rillig   6922: 21.5. The build phase
1.1       dsieger  6923: 
                   6924: The most common failures when building a package are that some platforms do not
                   6925: provide certain header files, functions or libraries, or they provide the
                   6926: functions in a library that the original package author didn't know. To work
                   6927: around this, you can rewrite the source code in most cases so that it does not
                   6928: use the missing functions or provides a replacement function.
                   6929: 
1.154     rillig   6930: 21.5.1. Compiling C and C++ code conditionally
1.1       dsieger  6931: 
                   6932: If a package already comes with a GNU configure script, the preferred way to
                   6933: fix the build failure is to change the configure script, not the code. In the
                   6934: other cases, you can utilize the C preprocessor, which defines certain macros
                   6935: depending on the operating system and hardware architecture it compiles for.
                   6936: These macros can be queried using for example #if defined(__i386). Almost every
                   6937: operating system, hardware architecture and compiler has its own macro. For
                   6938: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
                   6939: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
                   6940: GCC.
                   6941: 
                   6942: The list of the following macros for hardware and operating system depends on
                   6943: the compiler that is used. For example, if you want to conditionally compile
                   6944: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
                   6945: Use __sun instead.
                   6946: 
1.154     rillig   6947: 21.5.1.1. C preprocessor macros to identify the operating system
1.1       dsieger  6948: 
                   6949: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
                   6950: should use the following code.
                   6951: 
                   6952: #include <sys/param.h>
                   6953: #if (defined(BSD) && BSD >= 199306)
                   6954: /* BSD-specific code goes here */
                   6955: #else
                   6956: /* non-BSD-specific code goes here */
                   6957: #endif
                   6958: 
                   6959: If this distinction is not fine enough, you can also test for the following
                   6960: macros.
                   6961: 
1.46      obache   6962: Cygwin      __CYGWIN__
                   6963: DragonFly   __DragonFly__
1.1       dsieger  6964: FreeBSD     __FreeBSD__
1.46      obache   6965: Haiku       __HAIKU__
1.1       dsieger  6966: Interix     __INTERIX
                   6967: IRIX        __sgi (TODO: get a definite source for this)
                   6968: Linux       linux, __linux, __linux__
1.83      dholland 6969: Mac OS X    __APPLE__
1.46      obache   6970: MirBSD      __MirBSD__ (__OpenBSD__ is also defined)
                   6971: Minix3      __minix
1.1       dsieger  6972: NetBSD      __NetBSD__
                   6973: OpenBSD     __OpenBSD__
                   6974: Solaris     sun, __sun
                   6975: 
1.154     rillig   6976: 21.5.1.2. C preprocessor macros to identify the hardware architecture
1.1       dsieger  6977: 
                   6978: i386        i386, __i386, __i386__
                   6979: MIPS        __mips
                   6980: SPARC       sparc, __sparc
                   6981: 
1.154     rillig   6982: 21.5.1.3. C preprocessor macros to identify the compiler
1.1       dsieger  6983: 
                   6984: GCC         __GNUC__ (major version), __GNUC_MINOR__
                   6985: MIPSpro     _COMPILER_VERSION (0x741 for MIPSpro 7.41)
                   6986: SunPro      __SUNPRO_C (0x570 for Sun C 5.7)
                   6987: SunPro C++  __SUNPRO_CC (0x580 for Sun C++ 5.8)
                   6988: 
1.154     rillig   6989: 21.5.2. How to handle compiler bugs
1.1       dsieger  6990: 
                   6991: Some source files trigger bugs in the compiler, based on combinations of
                   6992: compiler version and architecture and almost always relation to optimisation
                   6993: being enabled. Common symptoms are gcc internal errors or never finishing
                   6994: compiling a file.
                   6995: 
                   6996: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
1.87      tnn      6997: disabling optimisation for that combination of file, MACHINE_ARCH and compiler.
                   6998: 
                   6999: This used to be a big problem in the past, but is rarely needed now as compiler
                   7000: technology has matured. If you still need to add a compiler specific
                   7001: workaround, please do so in the file hacks.mk and describe the symptom and
                   7002: compiler version as detailed as possible.
1.1       dsieger  7003: 
1.172     rillig   7004: 21.5.3. No such file or directory
                   7005: 
                   7006: Compilation sometimes fails with an error message like this:
                   7007: 
                   7008: .../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10:
                   7009:     fatal error: pango/pango.h: No such file or directory
                   7010: 
                   7011: The proper way to fix this problem depends on the type of the header, which is
                   7012: described in the following sections.
                   7013: 
                   7014: 21.5.3.1. Headers from other packages
                   7015: 
                   7016: If the header name looks like it comes from a different package, that other
                   7017: package should be included via the buildlink3 framework.
                   7018: 
                   7019: First, look whether the header is somewhere in the buildlink3 directory below
                   7020: WRKDIR. In the above case of the missing Pango header:
                   7021: 
                   7022: $ find work/.buildlink/ -print | grep -F pango/pango.h
                   7023: 
                   7024: In the case of Pango, the output is:
                   7025: 
                   7026: work/.buildlink/include/pango-1.0/pango/pango.h
                   7027: 
                   7028: If the pango/pango.h file were placed directly in the .buildlink directory, it
                   7029: would have been found automatically. There is an extra pango-1.0 path component
                   7030: though, which means that the compiler command line must contain an option of
                   7031: the form -I${BUILDLINK3_PREFIX.pango}/include/pango-1.0. In most cases this
                   7032: option is generated by the configure script, which can be examined using:
                   7033: 
                   7034: $ $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile
                   7035: -I/usr/pkg/include/pango-1.0
                   7036: -I/usr/pkg/include/pango-1.0
                   7037: -I/usr/pkg/include/pango-1.0
                   7038: -I/usr/pkg/include/pango-1.0
                   7039: -I/usr/pkg/include/pango-1.0
                   7040: 
                   7041: This looks good. These options are transformed by the buildlink wrapper to
                   7042: refer to the correct path inside work/.buildlink.
                   7043: 
                   7044: Since the compilation fails though, examine the compiler command lines in work
                   7045: /.work.log to see whether the -I option is included in the particular command
                   7046: line.
                   7047: 
                   7048: To further analyze the situation, run bmake build-env, which sets up an
                   7049: interactive, realistic environment including all the pkgsrc wrapper commands
                   7050: and environment variables. From there, try to compile some simple example
                   7051: programs that use the header.
                   7052: 
                   7053: 21.5.3.2. Headers generated during the build
                   7054: 
                   7055: If the name of the header seems to come from the package itself, and if the
                   7056: build is run with parallel jobs, the package may have some undeclared
                   7057: dependencies between the .c and the .h files, and a C file is compiled before
                   7058: its required header is generated.
                   7059: 
                   7060: To see whether the build runs with parallel jobs, run bmake show-all-build |
                   7061: grep JOBS. Its output looks like this:
                   7062: 
                   7063:   usr   MAKE_JOBS=              7
                   7064:   pkg   MAKE_JOBS_SAFE          # undefined
                   7065:   def   _MAKE_JOBS_N=           7
                   7066: 
                   7067: In this case the pkgsrc user has asked pkgsrc to build packages with 7 jobs in
                   7068: parallel (MAKE_JOBS). The package could have disabled parallel builds by
                   7069: setting MAKE_JOBS_SAFE to no, but in this case it hasn't.
                   7070: 
                   7071: To see whether the build failure is caused by parallel builds, first save the
                   7072: exact error message and a bit of context, maybe you need it later for reporting
                   7073: a bug. Next, run:
                   7074: 
                   7075: MAKE_JOBS_SAFE=no bmake clean build
                   7076: 
                   7077: If that succeeds, file a bug report against the pkgsrc package, including the
                   7078: exact error message and the contents of your mk.conf file.
                   7079: 
1.173     rillig   7080: 21.5.3.3. Symlinks
                   7081: 
                   7082: Pkgsrc does not work reliably if any of LOCALBASE, VARBASE or WRKDIR contains a
                   7083: symlink. Since 2019Q2, the pkgsrc bootstrap program prevents installing pkgsrc
                   7084: in symlink-based directories. Existing pkgsrc installations are not checked for
                   7085: symlinks though.
                   7086: 
                   7087: The "No such file or directory" error messages are a typical symptom of
                   7088: symlinks, and it's quite difficult to find out that this is the actual cause.
                   7089: 
                   7090: 21.5.3.4. Stale working directories
                   7091: 
                   7092: When building a hierarchy of packages, it may happen that one package is built
                   7093: and then pkgsrc is updated. This situation can provoke various hard to diagnose
                   7094: build errors. To clean up the situation:
                   7095: 
                   7096: $ (cd ../../ && test -f mk/bsd.pkg.mk && rm -rf */*/work)
                   7097: 
                   7098: (The test for bsd.pkg.mk just prevents running this command in the wrong
                   7099: directory.)
                   7100: 
                   7101: If you have set WRKOBJDIR in mk.conf, remove that directory as well.
                   7102: 
                   7103: 21.5.3.5. Other possible reasons
                   7104: 
                   7105: On platforms other than BSD, third-party packages are installed in /usr/
                   7106: include, together with the base system. This means that pkgsrc cannot
                   7107: distinguish between headers provided by the base system (which it needs) and
                   7108: headers from third-party packages (which are often included in pkgsrc as well).
                   7109: This can lead to subtle version mismatches.
                   7110: 
                   7111: In pkgsrc installations that have been active for several years, it may happen
                   7112: that some files are manually deleted. To exclude this unlikely reason, run 
                   7113: pkg_admin check.
                   7114: 
                   7115: It may help to run pkg_admin rebuild-tree to check/fix dependencies.
                   7116: 
                   7117: If all of the above doesn't help, see Chapter 2, Getting help for contact
                   7118: information. Be prepared to describe what you have tried so far and what any
                   7119: error messages were.
                   7120: 
1.172     rillig   7121: 21.5.4. Undefined reference to "..."
1.1       dsieger  7122: 
                   7123: This error message often means that a package did not link to a shared library
                   7124: it needs. The following functions are known to cause this error message over
                   7125: and over.
                   7126: 
                   7127: +-----------------------------------------------------+
                   7128: |        Function         |Library |Affected platforms|
                   7129: |-------------------------+--------+------------------|
                   7130: |accept, bind, connect    |-lsocket|Solaris           |
                   7131: |-------------------------+--------+------------------|
                   7132: |crypt                    |-lcrypt |DragonFly, NetBSD |
                   7133: |-------------------------+--------+------------------|
                   7134: |dlopen, dlsym            |-ldl    |Linux             |
                   7135: |-------------------------+--------+------------------|
                   7136: |gethost*                 |-lnsl   |Solaris           |
                   7137: |-------------------------+--------+------------------|
                   7138: |inet_aton                |-lresolv|Solaris           |
                   7139: |-------------------------+--------+------------------|
                   7140: |nanosleep, sem_*, timer_*|-lrt    |Solaris           |
                   7141: |-------------------------+--------+------------------|
                   7142: |openpty                  |-lutil  |Linux             |
                   7143: +-----------------------------------------------------+
                   7144: 
                   7145: To fix these linker errors, it is often sufficient to say LIBS.OperatingSystem+
                   7146: = -lfoo to the package Makefile and then say bmake clean; bmake.
                   7147: 
1.172     rillig   7148: 21.5.4.1. Special issue: The SunPro compiler
1.1       dsieger  7149: 
                   7150: When you are using the SunPro compiler, there is another possibility. That
                   7151: compiler cannot handle the following code:
                   7152: 
                   7153: extern int extern_func(int);
                   7154: 
                   7155: static inline int
                   7156: inline_func(int x)
                   7157: {
                   7158:         return extern_func(x);
                   7159: }
                   7160: 
                   7161: int main(void)
                   7162: {
                   7163:         return 0;
                   7164: }
                   7165: 
                   7166: It generates the code for inline_func even if that function is never used. This
                   7167: code then refers to extern_func, which can usually not be resolved. To solve
                   7168: this problem you can try to tell the package to disable inlining of functions.
                   7169: 
1.172     rillig   7170: 21.5.5. Running out of memory
1.1       dsieger  7171: 
                   7172: Sometimes packages fail to build because the compiler runs into an operating
                   7173: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
1.94      wiz      7174: told to unlimit the resources. Currently, the allowed values are any
                   7175: combination of "cputime", "datasize", "memorysize", and "stacksize". Setting
                   7176: this variable is similar to running the shell builtin ulimit command to raise
                   7177: the maximum data segment size or maximum stack size of a process, respectively,
                   7178: to their hard limits.
1.1       dsieger  7179: 
1.154     rillig   7180: 21.6. The install phase
1.1       dsieger  7181: 
1.154     rillig   7182: 21.6.1. Creating needed directories
1.1       dsieger  7183: 
                   7184: The BSD-compatible install supplied with some operating systems cannot create
                   7185: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
                   7186: like this:
                   7187: 
                   7188: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
                   7189: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
                   7190: 
                   7191: You can also just append "dir1 dir2" to the INSTALLATION_DIRS variable, which
                   7192: will automatically do the right thing.
                   7193: 
1.154     rillig   7194: 21.6.2. Where to install documentation
1.1       dsieger  7195: 
                   7196: In general, documentation should be installed into ${PREFIX}/share/doc/$
                   7197: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME} (the latter includes the version
                   7198: number of the package).
                   7199: 
                   7200: Many modern packages using GNU autoconf allow to set the directory where HTML
                   7201: documentation is installed with the "--with-html-dir" option. Sometimes using
                   7202: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
                   7203: share/doc/html or other places.
                   7204: 
                   7205: An exception to the above is that library API documentation generated with the
                   7206: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
                   7207: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
                   7208: can be recognized from files ending in .devhelp or .devhelp2. (It is also
                   7209: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
                   7210: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
                   7211: then, no additional subdirectory level is allowed in this case. This is usually
                   7212: achieved by using "--with-html-dir=${PREFIX}/share/doc". ${PREFIX}/share/
                   7213: gtk-doc is preferred though.)
                   7214: 
1.154     rillig   7215: 21.6.3. Installing highscore files
1.1       dsieger  7216: 
                   7217: Certain packages, most of them in the games category, install a score file that
                   7218: allows all users on the system to record their highscores. In order for this to
                   7219: work, the binaries need to be installed setgid and the score files owned by the
1.36      wiz      7220: appropriate group and/or owner (traditionally the "games" user/group). Set
                   7221: USE_GAMESGROUP to yes to support this. The following variables, documented in
                   7222: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
1.100     leot     7223: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER. Other useful variables are:
                   7224: GAMEDIR_PERMS, GAMEDATA_PERMS and SETGID_GAMES_PERMS.
                   7225: 
                   7226: An example that illustrates some of the variables described above is games/
                   7227: moon-buggy. OWN_DIRS_PERMS is used to properly set directory permissions of the
                   7228: directory where the scorefile is saved, REQD_FILES_PERMS is used to create a
                   7229: dummy scorefile (mbscore) with the proper permissions and SPECIAL_PERMS is used
                   7230: to install setgid the game binary:
                   7231: 
                   7232: USE_GAMESGROUP=         yes
                   7233: 
                   7234: BUILD_DEFS+=            VARBASE
                   7235: 
                   7236: OWN_DIRS_PERMS+=        ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
                   7237: REQD_FILES_PERMS+=      /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
                   7238: SPECIAL_PERMS+=         ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
                   7239: 
                   7240: Various INSTALL_* variables are also available: INSTALL_GAME to install setgid
                   7241: game binaries, INSTALL_GAME_DIR to install game directories that are needed to
                   7242: be accessed by setgid games and INSTALL_GAME_DATA to install scorefiles.
1.1       dsieger  7243: 
1.14      jmcneill 7244: A package should therefore never hard code file ownership or access permissions
1.100     leot     7245: but rely on *_PERMS as described above or alternatively on INSTALL_GAME,
                   7246: INSTALL_GAME_DATA and INSTALL_GAME_DIR to set these correctly.
1.1       dsieger  7247: 
1.154     rillig   7248: 21.6.4. Adding DESTDIR support to packages
1.4       rillig   7249: 
1.14      jmcneill 7250: DESTDIR support means that a package installs into a staging directory, not the
                   7251: final location of the files. Then a binary package is created which can be used
                   7252: for installation as usual. There are two ways: Either the package must install
1.25      wiz      7253: as root ("destdir") or the package can install as non-root user ("user-destdir"
                   7254: ).
1.14      jmcneill 7255: 
1.113     leot     7256:   * PKG_DESTDIR_SUPPORT has to be set to "destdir" or "user-destdir". By
                   7257:     default PKG_DESTDIR_SUPPORT is set to "user-destdir" to help catching more
                   7258:     potential packaging problems. If bsd.prefs.mk is included in the Makefile,
                   7259:     PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14      jmcneill 7260: 
1.4       rillig   7261:   * All installation operations have to be prefixed with ${DESTDIR}.
                   7262: 
                   7263:   * automake gets this DESTDIR mostly right automatically. Many manual rules
                   7264:     and pre/post-install often are incorrect; fix them.
                   7265: 
1.17      imil     7266:   * If files are installed with special owner/group use SPECIAL_PERMS.
1.4       rillig   7267: 
                   7268:   * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
                   7269: 
1.154     rillig   7270: 21.6.5. Packages with hardcoded paths to other interpreters
1.1       dsieger  7271: 
                   7272: Your package may also contain scripts with hardcoded paths to other
                   7273: interpreters besides (or as well as) perl. To correct the full pathname to the
                   7274: script interpreter, you need to set the following definitions in your Makefile
                   7275: (we shall use tclsh in this example):
                   7276: 
                   7277: REPLACE_INTERPRETER+=   tcl
                   7278: REPLACE.tcl.old=        .*/bin/tclsh
                   7279: REPLACE.tcl.new=        ${PREFIX}/bin/tclsh
                   7280: REPLACE_FILES.tcl=      # list of tcl scripts which need to be fixed,
                   7281: # relative to ${WRKSRC}, just as in REPLACE_PERL
                   7282: 
                   7283: Note
                   7284: 
                   7285: Before March 2006, these variables were called _REPLACE.* and _REPLACE_FILES.*.
                   7286: 
1.154     rillig   7287: 21.6.6. Packages installing perl modules
1.1       dsieger  7288: 
                   7289: Makefiles of packages providing perl5 modules should include the Makefile
                   7290: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
                   7291: standard perl configuration for such modules as well as various hooks to tune
                   7292: this configuration. See comments in this file for details.
                   7293: 
                   7294: Perl5 modules will install into different places depending on the version of
                   7295: perl used during the build process. To address this, pkgsrc will append lines
                   7296: to the PLIST corresponding to the files listed in the installed .packlist file
                   7297: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48      wiz      7298: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
                   7299: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1       dsieger  7300: 
1.48      wiz      7301: PERL5_PACKLIST= auto/Pg/.packlist
1.1       dsieger  7302: 
1.48      wiz      7303: The perl5 config variables installarchlib, installscript, installvendorbin,
                   7304: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
                   7305: and installvendorman3dir represent those locations in which components of perl5
                   7306: modules may be installed, provided as variable with uppercase and prefixed with
                   7307: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
                   7308: have a packlist. These variables are also substituted for in the PLIST as
                   7309: uppercase prefixed with PERL5_SUB_.
1.1       dsieger  7310: 
1.154     rillig   7311: 21.6.7. Packages installing info files
1.1       dsieger  7312: 
                   7313: Some packages install info files or use the "makeinfo" or "install-info"
                   7314: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
                   7315: and DEINSTALL scripts will be generated to handle registration of the info
                   7316: files in the Info directory file. The "install-info" command used for the info
                   7317: files registration is either provided by the system, or by a special purpose
                   7318: package automatically added as dependency if needed.
                   7319: 
                   7320: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
                   7321: located. PKGINFODIR defaults to "info" and can be overridden by the user.
                   7322: 
                   7323: The info files for the package should be listed in the package PLIST; however
                   7324: any split info files need not be listed.
                   7325: 
                   7326: A package which needs the "makeinfo" command at build time must add "makeinfo"
                   7327: to USE_TOOLS in its Makefile. If a minimum version of the "makeinfo" command is
                   7328: needed it should be noted with the TEXINFO_REQD variable in the package
                   7329: Makefile. By default, a minimum version of 3.12 is required. If the system does
                   7330: not provide a makeinfo command or if it does not match the required minimum, a
                   7331: build dependency on the devel/gtexinfo package will be added automatically.
                   7332: 
                   7333: The build and installation process of the software provided by the package
                   7334: should not use the install-info command as the registration of info files is
1.25      wiz      7335: the task of the package INSTALL script, and it must use the appropriate 
1.1       dsieger  7336: makeinfo command.
                   7337: 
                   7338: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
                   7339: the install-info and makeinfo commands in a directory listed early in PATH.
                   7340: 
                   7341: The script overriding install-info has no effect except the logging of a
                   7342: message. The script overriding makeinfo logs a message and according to the
                   7343: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
                   7344: error.
                   7345: 
1.154     rillig   7346: 21.6.8. Packages installing man pages
1.1       dsieger  7347: 
                   7348: All packages that install manual pages should install them into the same
                   7349: directory, so that there is one common place to look for them. In pkgsrc, this
                   7350: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.25      wiz      7351: packages. The default for PKGMANDIR is "man". Another often-used value is "
                   7352: share/man".
1.1       dsieger  7353: 
                   7354: Note
                   7355: 
                   7356: The support for a custom PKGMANDIR is far from complete.
                   7357: 
                   7358: The PLIST files can just use man/ as the top level directory for the man page
                   7359: file entries, and the pkgsrc framework will convert as needed. In all other
                   7360: places, the correct PKGMANDIR must be used.
                   7361: 
                   7362: Packages that are configured with GNU_CONFIGURE set as "yes", by default will
                   7363: use the ./configure --mandir switch to set where the man pages should be
                   7364: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
                   7365: {PKGMANDIR}.
                   7366: 
                   7367: Packages that use GNU_CONFIGURE but do not use --mandir, can set
                   7368: CONFIGURE_HAS_MANDIR to "no". Or if the ./configure script uses a non-standard
                   7369: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
                   7370: 
1.154     rillig   7371: See Section 15.5, "Man page compression" for information on installation of
1.1       dsieger  7372: compressed manual pages.
                   7373: 
1.154     rillig   7374: 21.6.9. Packages installing GConf data files
1.1       dsieger  7375: 
1.7       rillig   7376: If a package installs .schemas or .entries files, used by GConf, you need to
1.1       dsieger  7377: take some extra steps to make sure they get registered in the database:
                   7378: 
1.7       rillig   7379:  1. Include ../../devel/GConf/schemas.mk instead of its buildlink3.mk file.
                   7380:     This takes care of rebuilding the GConf database at installation and
                   7381:     deinstallation time, and tells the package where to install GConf data
1.1       dsieger  7382:     files using some standard configure arguments. It also disallows any access
                   7383:     to the database directly from the package.
                   7384: 
                   7385:  2. Ensure that the package installs its .schemas files under ${PREFIX}/share/
                   7386:     gconf/schemas. If they get installed under ${PREFIX}/etc, you will need to
                   7387:     manually patch the package.
                   7388: 
                   7389:  3. Check the PLIST and remove any entries under the etc/gconf directory, as
1.154     rillig   7390:     they will be handled automatically. See Section 10.13, "How do I change the
1.1       dsieger  7391:     location of configuration files?" for more information.
                   7392: 
1.7       rillig   7393:  4. Define the GCONF_SCHEMAS variable in your Makefile with a list of all
1.1       dsieger  7394:     .schemas files installed by the package, if any. Names must not contain any
                   7395:     directories in them.
                   7396: 
1.7       rillig   7397:  5. Define the GCONF_ENTRIES variable in your Makefile with a list of all
1.1       dsieger  7398:     .entries files installed by the package, if any. Names must not contain any
                   7399:     directories in them.
                   7400: 
1.154     rillig   7401: 21.6.10. Packages installing scrollkeeper/rarian data files
1.1       dsieger  7402: 
1.18      mishka   7403: If a package installs .omf files, used by scrollkeeper/rarian, you need to take
                   7404: some extra steps to make sure they get registered in the database:
1.1       dsieger  7405: 
1.18      mishka   7406:  1. Include ../../mk/omf-scrollkeeper.mk instead of rarian's buildlink3.mk
                   7407:     file. This takes care of rebuilding the scrollkeeper database at
                   7408:     installation and deinstallation time, and disallows any access to it
                   7409:     directly from the package.
1.1       dsieger  7410: 
                   7411:  2. Check the PLIST and remove any entries under the libdata/scrollkeeper
                   7412:     directory, as they will be handled automatically.
                   7413: 
                   7414:  3. Remove the share/omf directory from the PLIST. It will be handled by
1.18      mishka   7415:     rarian. (make print-PLIST does this automatically.)
1.1       dsieger  7416: 
1.154     rillig   7417: 21.6.11. Packages installing X11 fonts
1.1       dsieger  7418: 
                   7419: If a package installs font files, you will need to rebuild the fonts database
                   7420: in the directory where they get installed at installation and deinstallation
                   7421: time. This can be automatically done by using the pkginstall framework.
                   7422: 
                   7423: You can list the directories where fonts are installed in the FONTS_DIRS.type
                   7424: variables, where type can be one of "ttf", "type1" or "x11". Also make sure
                   7425: that the database file fonts.dir is not listed in the PLIST.
                   7426: 
                   7427: Note that you should not create new directories for fonts; instead use the
                   7428: standard ones to avoid that the user needs to manually configure his X server
                   7429: to find them.
                   7430: 
1.154     rillig   7431: 21.6.12. Packages installing GTK2 modules
1.1       dsieger  7432: 
                   7433: If a package installs GTK2 immodules or loaders, you need to take some extra
                   7434: steps to get them registered in the GTK2 database properly:
                   7435: 
                   7436:  1. Include ../../x11/gtk2/modules.mk instead of its buildlink3.mk file. This
                   7437:     takes care of rebuilding the database at installation and deinstallation
                   7438:     time.
                   7439: 
                   7440:  2. Set GTK2_IMMODULES=YES if your package installs GTK2 immodules.
                   7441: 
                   7442:  3. Set GTK2_LOADERS=YES if your package installs GTK2 loaders.
                   7443: 
                   7444:  4. Patch the package to not touch any of the GTK2 databases directly. These
                   7445:     are:
                   7446: 
1.42      asau     7447:       + libdata/gtk-2.0/gdk-pixbuf.loaders
1.1       dsieger  7448: 
1.42      asau     7449:       + libdata/gtk-2.0/gtk.immodules
1.1       dsieger  7450: 
                   7451:  5. Check the PLIST and remove any entries under the libdata/gtk-2.0 directory,
                   7452:     as they will be handled automatically.
                   7453: 
1.154     rillig   7454: 21.6.13. Packages installing SGML or XML data
1.1       dsieger  7455: 
                   7456: If a package installs SGML or XML data files that need to be registered in
                   7457: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
                   7458: extra steps:
                   7459: 
                   7460:  1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
                   7461:     care of registering those files in system-wide catalogs at installation and
                   7462:     deinstallation time.
                   7463: 
                   7464:  2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
                   7465:     package.
                   7466: 
                   7467:  3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
                   7468:     package.
                   7469: 
                   7470:  4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
                   7471:     These come in groups of three strings; see xmlcatmgr(1) for more
                   7472:     information (specifically, arguments recognized by the 'add' action). Note
                   7473:     that you will normally not use this variable.
                   7474: 
                   7475:  5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
                   7476:     come in groups of three strings; see xmlcatmgr(1) for more information
                   7477:     (specifically, arguments recognized by the 'add' action). Note that you
                   7478:     will normally not use this variable.
                   7479: 
1.154     rillig   7480: 21.6.14. Packages installing extensions to the MIME database
1.1       dsieger  7481: 
                   7482: If a package provides extensions to the MIME database by installing .xml files
                   7483: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
                   7484: ensure that the database is kept consistent with respect to these new files:
                   7485: 
                   7486:  1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
                   7487:     buildlink3.mk file from this same directory, which is reserved for
                   7488:     inclusion from other buildlink3.mk files). It takes care of rebuilding the
                   7489:     MIME database at installation and deinstallation time, and disallows any
                   7490:     access to it directly from the package.
                   7491: 
1.25      wiz      7492:  2. Check the PLIST and remove any entries under the share/mime directory, 
1.1       dsieger  7493:     except for files saved under share/mime/packages. The former are handled
                   7494:     automatically by the update-mime-database program, but the latter are
                   7495:     package-dependent and must be removed by the package that installed them in
                   7496:     the first place.
                   7497: 
                   7498:  3. Remove any share/mime/* directories from the PLIST. They will be handled by
                   7499:     the shared-mime-info package.
                   7500: 
1.154     rillig   7501: 21.6.15. Packages using intltool
1.1       dsieger  7502: 
                   7503: If a package uses intltool during its build, add intltool to the USE_TOOLS,
                   7504: which forces it to use the intltool package provided by pkgsrc, instead of the
                   7505: one bundled with the distribution file.
                   7506: 
                   7507: This tracks intltool's build-time dependencies and uses the latest available
                   7508: version; this way, the package benefits of any bug fixes that may have appeared
                   7509: since it was released.
                   7510: 
1.154     rillig   7511: 21.6.16. Packages installing startup scripts
1.1       dsieger  7512: 
                   7513: If a package contains a rc.d script, it won't be copied into the startup
                   7514: directory by default, but you can enable it, by adding the option
1.4       rillig   7515: PKG_RCD_SCRIPTS=YES in mk.conf. This option will copy the scripts into /etc/
                   7516: rc.d when a package is installed, and it will automatically remove the scripts
                   7517: when the package is deinstalled.
1.1       dsieger  7518: 
1.154     rillig   7519: 21.6.17. Packages installing TeX modules
1.1       dsieger  7520: 
                   7521: If a package installs TeX packages into the texmf tree, the ls-R database of
                   7522: the tree needs to be updated.
                   7523: 
                   7524: Note
                   7525: 
1.23      jakllsch 7526: Except the main TeX packages such as kpathsea, packages should install files
                   7527: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1       dsieger  7528: 
1.23      jakllsch 7529:  1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
                   7530:     ls-R database at installation and deinstallation time.
1.1       dsieger  7531: 
1.23      jakllsch 7532:  2. If your package installs files into a texmf tree other than the one at $
                   7533:     {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
                   7534:     trees that need database update.
1.1       dsieger  7535: 
                   7536:     If your package also installs font map files that need to be registered
1.30      dholland 7537:     using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
                   7538:     and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then 
                   7539:     updmap will be run automatically at installation/deinstallation to enable/
                   7540:     disable font map files for TeX output drivers.
1.1       dsieger  7541: 
                   7542:  3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30      dholland 7543:     be removed only by the kpathsea package.
1.1       dsieger  7544: 
1.154     rillig   7545: 21.6.18. Packages supporting running binaries in emulation
1.1       dsieger  7546: 
                   7547: There are some packages that provide libraries and executables for running
                   7548: binaries from a one operating system on a different one (if the latter supports
                   7549: it). One example is running Linux binaries on NetBSD.
                   7550: 
                   7551: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
                   7552: 
                   7553: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
                   7554: if all libraries for each installed executable can be found by the dynamic
                   7555: linker. Since the standard dynamic linker is run, this fails for emulation
                   7556: packages, because the libraries used by the emulation are not in the standard
                   7557: directories.
                   7558: 
1.154     rillig   7559: 21.6.19. Packages installing hicolor theme icons
1.1       dsieger  7560: 
                   7561: If a package installs images under the share/icons/hicolor and/or updates the
                   7562: share/icons/hicolor/icon-theme.cache database, you need to take some extra
                   7563: steps to make sure that the shared theme directory is handled appropriately and
                   7564: that the cache database is rebuilt:
                   7565: 
                   7566:  1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
                   7567: 
                   7568:  2. Check the PLIST and remove the entry that refers to the theme cache.
                   7569: 
                   7570:  3. Ensure that the PLIST does not remove the shared icon directories from the
                   7571:     share/icons/hicolor hierarchy because they will be handled automatically.
                   7572: 
                   7573: The best way to verify that the PLIST is correct with respect to the last two
                   7574: points is to regenerate it using make print-PLIST.
                   7575: 
1.154     rillig   7576: 21.6.20. Packages installing desktop files
1.1       dsieger  7577: 
                   7578: If a package installs .desktop files under share/applications and these include
1.54      rodent   7579: MIME information (MimeType key), you need to take extra steps to ensure that
                   7580: they are registered into the MIME database:
1.1       dsieger  7581: 
                   7582:  1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
                   7583: 
                   7584:  2. Check the PLIST and remove the entry that refers to the share/applications/
                   7585:     mimeinfo.cache file. It will be handled automatically.
                   7586: 
                   7587: The best way to verify that the PLIST is correct with respect to the last point
                   7588: is to regenerate it using make print-PLIST.
                   7589: 
1.154     rillig   7590: 21.7. Marking packages as having problems
1.1       dsieger  7591: 
1.23      jakllsch 7592: In some cases one does not have the time to solve a problem immediately. In
                   7593: this case, one can plainly mark a package as broken. For this, one just sets
                   7594: the variable BROKEN to the reason why the package is broken (similar to the
1.162     rillig   7595: PKG_FAIL_REASON variable). A user trying to build the package will immediately
                   7596: be shown this message, and the build will not be even tried.
1.1       dsieger  7597: 
1.23      jakllsch 7598: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1       dsieger  7599: 
1.154     rillig   7600: Chapter 22. Debugging
1.1       dsieger  7601: 
                   7602: To check out all the gotchas when building a package, here are the steps that I
                   7603: do in order to get a package working. Please note this is basically the same as
                   7604: what was explained in the previous sections, only with some debugging aids.
                   7605: 
1.4       rillig   7606:   * Be sure to set PKG_DEVELOPER=yes in mk.conf.
1.1       dsieger  7607: 
                   7608:   * Install pkgtools/url2pkg, create a directory for a new package, change into
                   7609:     it, then run url2pkg:
                   7610: 
                   7611:     % mkdir /usr/pkgsrc/category/examplepkg
                   7612:     % cd /usr/pkgsrc/category/examplepkg
1.174     leot     7613:     % url2pkg https://www.example.com/path/to/distfile.tar.gz
1.1       dsieger  7614: 
                   7615:   * Edit the Makefile as requested.
                   7616: 
                   7617:   * Fill in the DESCR file
                   7618: 
                   7619:   * Run make configure
                   7620: 
                   7621:   * Add any dependencies glimpsed from documentation and the configure step to
                   7622:     the package's Makefile.
                   7623: 
                   7624:   * Make the package compile, doing multiple rounds of
                   7625: 
                   7626:     % make
                   7627:     % pkgvi ${WRKSRC}/some/file/that/does/not/compile
                   7628:     % mkpatches
                   7629:     % patchdiff
                   7630:     % mv ${WRKDIR}/.newpatches/* patches
                   7631:     % make mps
                   7632:     % make clean
                   7633: 
                   7634:     Doing this step as non-root user will ensure that no files are modified
                   7635:     that shouldn't be, especially during the build phase. mkpatches, patchdiff
                   7636:     and pkgvi are from the pkgtools/pkgdiff package.
                   7637: 
1.154     rillig   7638:   * Look at the Makefile, fix if necessary; see Section 13.1, "Makefile".
1.1       dsieger  7639: 
                   7640:   * Generate a PLIST:
                   7641: 
                   7642:     # make install
                   7643:     # make print-PLIST >PLIST
                   7644:     # make deinstall
                   7645:     # make install
                   7646:     # make deinstall
                   7647: 
                   7648:     You usually need to be root to do this. Look if there are any files left:
                   7649: 
                   7650:     # make print-PLIST
                   7651: 
                   7652:     If this reveals any files that are missing in PLIST, add them.
                   7653: 
                   7654:   * Now that the PLIST is OK, install the package again and make a binary
                   7655:     package:
                   7656: 
                   7657:     # make reinstall
                   7658:     # make package
                   7659: 
                   7660:   * Delete the installed package:
                   7661: 
                   7662:     # pkg_delete examplepkg
                   7663: 
                   7664:   * Repeat the above make print-PLIST command, which shouldn't find anything
                   7665:     now:
                   7666: 
                   7667:     # make print-PLIST
                   7668: 
                   7669:   * Reinstall the binary package:
                   7670: 
                   7671:     # pkg_add .../examplepkg.tgz
                   7672: 
                   7673:   * Play with it. Make sure everything works.
                   7674: 
                   7675:   * Run pkglint from pkgtools/pkglint, and fix the problems it reports:
                   7676: 
                   7677:     # pkglint
                   7678: 
1.154     rillig   7679:   * Submit (or commit, if you have cvs access); see Chapter 23, Submitting and
1.1       dsieger  7680:     Committing.
                   7681: 
1.154     rillig   7682: Chapter 23. Submitting and Committing
1.1       dsieger  7683: 
                   7684: Table of Contents
                   7685: 
1.154     rillig   7686: 23.1. Submitting binary packages
                   7687: 23.2. Submitting source packages (for non-NetBSD-developers)
                   7688: 23.3. General notes when adding, updating, or removing packages
                   7689: 23.4. Commit Messages
                   7690: 23.5. Committing: Adding a package to CVS
                   7691: 23.6. Updating a package to a newer version
                   7692: 23.7. Renaming a package in pkgsrc
                   7693: 23.8. Moving a package in pkgsrc
1.1       dsieger  7694: 
1.154     rillig   7695: 23.1. Submitting binary packages
1.1       dsieger  7696: 
                   7697: Our policy is that we accept binaries only from pkgsrc developers to guarantee
                   7698: that the packages don't contain any trojan horses etc. This is not to annoy
                   7699: anyone but rather to protect our users! You're still free to put up your
                   7700: home-made binary packages and tell the world where to get them. NetBSD
1.154     rillig   7701: developers doing bulk builds and wanting to upload them please see Chapter 8, 
1.66      asau     7702: Creating binary packages for everything in pkgsrc (bulk builds).
1.1       dsieger  7703: 
1.154     rillig   7704: 23.2. Submitting source packages (for non-NetBSD-developers)
1.1       dsieger  7705: 
                   7706: First, check that your package is complete, compiles and runs well; see
1.154     rillig   7707: Chapter 22, Debugging and the rest of this document. Next, generate an
1.1       dsieger  7708: uuencoded gzipped tar(1) archive that contains all files that make up the
                   7709: package. Finally, send this package to the pkgsrc bug tracking system, either
                   7710: with the send-pr(1) command, or if you don't have that, go to the web page
1.174     leot     7711: https://www.NetBSD.org/support/send-pr.html, which contains some instructions
1.22      snj      7712: and a link to a form where you can submit packages. The sysutils/gtk-send-pr
                   7713: package is also available as a substitute for either of the above two tools.
1.1       dsieger  7714: 
                   7715: In the form of the problem report, the category should be "pkg", the synopsis
                   7716: should include the package name and version number, and the description field
                   7717: should contain a short description of your package (contents of the COMMENT
1.25      wiz      7718: variable or DESCR file are OK). The uuencoded package data should go into the "
                   7719: fix" field.
1.1       dsieger  7720: 
                   7721: If you want to submit several packages, please send a separate PR for each one,
                   7722: it's easier for us to track things that way.
                   7723: 
                   7724: Alternatively, you can also import new packages into pkgsrc-wip ("pkgsrc
1.174     leot     7725: work-in-progress"); see the homepage at https://pkgsrc.org/wip/ for details.
1.1       dsieger  7726: 
1.154     rillig   7727: 23.3. General notes when adding, updating, or removing packages
1.1       dsieger  7728: 
                   7729: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
                   7730: CHANGES-YYYY. It's very important to keep this file up to date and conforming
                   7731: to the existing format, because it will be used by scripts to automatically
                   7732: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
                   7733: doc/TODO file and remove the entry for the package you updated or removed, in
                   7734: case it was mentioned there.
                   7735: 
                   7736: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
                   7737: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
                   7738: that result from a dependency being updated should not be mentioned. In all
                   7739: other cases it's the developer's decision.
                   7740: 
                   7741: There is a make target that helps in creating proper CHANGES-YYYY entries: make
                   7742: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
                   7743: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
                   7744: (to avoid having to resolve conflicts later-on) and then to cd to the package
                   7745: directory. For package updates, make changes-entry is enough. For new packages,
                   7746: or package moves or removals, set the CTYPE variable on the command line to
1.4       rillig   7747: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23      jakllsch 7748: your local login name is not the same as your NetBSD login name. The target
                   7749: also automatically removes possibly existing entries for the package in the
                   7750: TODO file. Don't forget to commit the changes, e.g. by using make
1.66      asau     7751: commit-changes-entry! If you are not using a checkout directly from
1.23      jakllsch 7752: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
                   7753: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1       dsieger  7754: 
1.154     rillig   7755: 23.4. Commit Messages
1.130     wiz      7756: 
                   7757: For several years, there have been mirrors of pkgsrc in fossil, git, and hg.
                   7758: Standard practise when using these tools is to make the first line of a commit
                   7759: message function as a summary that can be read without the rest, such as is
                   7760: commonly done with "git log --oneline". For this reason, we have the following
                   7761: guidelines for pkgsrc commit messages:
                   7762: 
1.131     wiz      7763:   * Start the commit message with a line that explains the big picture in 65
1.130     wiz      7764:     characters or less. When a commit is for one package, include the name of
                   7765:     the package. For updates, include the version to which it is updated.
                   7766: 
                   7767:   * Leave the next line empty.
                   7768: 
                   7769:   * Then come the details for the commit (changes in that package, reason for a
                   7770:     change) and any relevant PRs. Wrap this section.
                   7771: 
                   7772: Here is an example:
                   7773: 
                   7774:   libxslt: update to 1.0.30
                   7775: 
                   7776:   Changes since 1.0.29:
                   7777:   ...
                   7778: 
                   7779: 
                   7780: Here is another example:
                   7781: 
                   7782:   mk/bsd.pkg.mk: enable SSP by default on NetBSD
                   7783: 
                   7784:   (rationale)
                   7785: 
                   7786: 
                   7787: Commit messages are final: no "cvs admin" is allowed on the pkgsrc repository
                   7788: to change commit messages.
                   7789: 
1.154     rillig   7790: 23.5. Committing: Adding a package to CVS
1.1       dsieger  7791: 
                   7792: This section is only of interest for pkgsrc developers with write access to the
1.34      wiz      7793: pkgsrc repository.
                   7794: 
                   7795: When the package is finished, "cvs add" the files. Start by adding the
                   7796: directory and then files in the directory. Don't forget to add the new package
                   7797: to the category's Makefile. Make sure you don't forget any files; you can check
                   7798: by running "cvs status". An example:
                   7799: 
                   7800: $ cd .../pkgsrc/category
                   7801: $ cvs add pkgname
                   7802: $ cd pkgname
                   7803: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
                   7804: $ cvs add patches/p*
                   7805: $ cvs status | less
1.35      wiz      7806: $ cvs commit
1.34      wiz      7807: $ cd ..
                   7808: $ vi Makefile # add SUBDIRS+=pkgname line
1.35      wiz      7809: $ cvs commit Makefile
1.66      asau     7810: $ cd pkgname
1.73      jnemeth  7811: $ make CTYPE=Added commit-changes-entry
1.1       dsieger  7812: 
                   7813: The commit message of the initial import should include part of the DESCR file,
                   7814: so people reading the mailing lists know what the package is/does.
                   7815: 
1.34      wiz      7816: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
                   7817: 
                   7818: Previously, "cvs import" was suggested, but it was much easier to get wrong
                   7819: than "cvs add".
1.1       dsieger  7820: 
1.154     rillig   7821: 23.6. Updating a package to a newer version
1.1       dsieger  7822: 
                   7823: Please always put a concise, appropriate and relevant summary of the changes
                   7824: between old and new versions into the commit log when updating a package. There
                   7825: are various reasons for this:
                   7826: 
                   7827:   * A URL is volatile, and can change over time. It may go away completely or
                   7828:     its information may be overwritten by newer information.
                   7829: 
                   7830:   * Having the change information between old and new versions in our CVS
                   7831:     repository is very useful for people who use either cvs or anoncvs.
                   7832: 
                   7833:   * Having the change information between old and new versions in our CVS
                   7834:     repository is very useful for people who read the pkgsrc-changes mailing
                   7835:     list, so that they can make tactical decisions about when to upgrade the
                   7836:     package.
                   7837: 
                   7838: Please also recognize that, just because a new version of a package has been
                   7839: released, it should not automatically be upgraded in the CVS repository. We
                   7840: prefer to be conservative in the packages that are included in pkgsrc -
                   7841: development or beta packages are not really the best thing for most places in
                   7842: which pkgsrc is used. Please use your judgement about what should go into
                   7843: pkgsrc, and bear in mind that stability is to be preferred above new and
                   7844: possibly untested features.
                   7845: 
1.154     rillig   7846: 23.7. Renaming a package in pkgsrc
1.21      snj      7847: 
                   7848: Renaming packages is not recommended.
                   7849: 
1.175     gutterid 7850: When renaming packages, be sure to fix any references to the old name in other
1.21      snj      7851: Makefiles, options, buildlink files, etc.
                   7852: 
1.175     gutterid 7853: Also, when renaming a package, please add the package name and version pattern
1.167     leot     7854: (s) of the previous package to SUPERSEDES. This may be repeated for multiple
                   7855: renames. The new package would be an exact replacement. Example:
                   7856: 
                   7857: SUPERSEDES+=    p5-IO-Compress-Zlib<2.017
                   7858: SUPERSEDES+=    optcomp-[0-9]*
1.21      snj      7859: 
                   7860: Note that "successor" in the CHANGES-YYYY file doesn't necessarily mean that it
                   7861: supersedes, as that successor may not be an exact replacement but is a
                   7862: suggestion for the replaced functionality.
                   7863: 
1.154     rillig   7864: 23.8. Moving a package in pkgsrc
1.21      snj      7865: 
                   7866: It is preferred that packages are not renamed or moved, but if needed please
                   7867: follow these steps.
1.1       dsieger  7868: 
                   7869:  1. Make a copy of the directory somewhere else.
                   7870: 
                   7871:  2. Remove all CVS dirs.
                   7872: 
                   7873:     Alternatively to the first two steps you can also do:
                   7874: 
                   7875:     % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
                   7876: 
                   7877:     and use that for further work.
                   7878: 
1.25      wiz      7879:  3. Fix CATEGORIES and any DEPENDS paths that just did "../package" instead of 
1.1       dsieger  7880:     "../../category/package".
                   7881: 
1.21      snj      7882:  4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
                   7883:     previous category/package pathname. The PREV_PKGPATH can be used by tools
                   7884:     for doing an update using pkgsrc building; for example, it can search the
                   7885:     pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
                   7886:     the corresponding new PKGPATH for that moved package. Note that it may have
                   7887:     multiple matches, so the tool should also check on the PKGBASE too. The
                   7888:     PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
                   7889:     PKGBASE stays the same.
                   7890: 
                   7891:  5. cvs import the modified package in the new place.
1.1       dsieger  7892: 
1.21      snj      7893:  6. Check if any package depends on it:
1.1       dsieger  7894: 
                   7895:     % cd /usr/pkgsrc
                   7896:     % grep /package */*/Makefile* */*/buildlink*
                   7897: 
1.21      snj      7898:  7. Fix paths in packages from step 5 to point to new location.
1.1       dsieger  7899: 
1.21      snj      7900:  8. cvs rm (-f) the package at the old location.
1.1       dsieger  7901: 
1.21      snj      7902:  9. Remove from oldcategory/Makefile.
1.1       dsieger  7903: 
1.21      snj      7904: 10. Add to newcategory/Makefile.
1.1       dsieger  7905: 
1.21      snj      7906: 11. Commit the changed and removed files:
1.1       dsieger  7907: 
                   7908:     % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
                   7909: 
                   7910:     (and any packages from step 5, of course).
                   7911: 
1.154     rillig   7912: Chapter 24. Frequently Asked Questions
1.1       dsieger  7913: 
                   7914: This section contains the answers to questions that may arise when you are
                   7915: writing a package. If you don't find your question answered here, first have a
                   7916: look in the other chapters, and if you still don't have the answer, ask on the
                   7917: pkgsrc-users mailing list.
                   7918: 
1.154     rillig   7919: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
                   7920: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
                   7921: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
                   7922: 24.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1       dsieger  7923:     BUILDLINK_LIBS?
1.154     rillig   7924: 24.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
                   7925: 24.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1       dsieger  7926:     the := inside it.
1.154     rillig   7927: 24.7. Which mailing lists are there for package developers?
                   7928: 24.8. Where is the pkgsrc documentation?
                   7929: 24.9. I have a little time to kill. What shall I do?
1.1       dsieger  7930: 
1.154     rillig   7931: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1       dsieger  7932: 
                   7933:       MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
                   7934:       (1), while MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM
                   7935:       when building the package. [FIXME: What is .MAKEFLAGS for?]
                   7936: 
1.154     rillig   7937: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1       dsieger  7938: 
                   7939:       MAKE is the path to the make(1) program that is used in the pkgsrc
                   7940:       infrastructure. GMAKE is the path to GNU Make, but you need to say
                   7941:       USE_TOOLS+=gmake to use that. MAKE_PROGRAM is the path to the Make
                   7942:       program that is used for building the package.
                   7943: 
1.154     rillig   7944: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1       dsieger  7945: 
                   7946:       CC is the path to the real C compiler, which can be configured by the
                   7947:       pkgsrc user. PKG_CC is the path to the compiler wrapper. PKGSRC_COMPILER
                   7948:       is not a path to a compiler, but the type of compiler that should be
                   7949:       used. See mk/compiler.mk for more information about the latter variable.
                   7950: 
1.154     rillig   7951: 24.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1       dsieger  7952:       BUILDLINK_LIBS?
                   7953: 
                   7954:       [FIXME]
                   7955: 
1.154     rillig   7956: 24.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1       dsieger  7957: 
1.25      wiz      7958:       For optimization reasons, some variables are only available in the "
                   7959:       wrapper" phase and later. To "simulate" the wrapper phase, append 
1.1       dsieger  7960:       PKG_PHASE=wrapper to the above command.
                   7961: 
1.154     rillig   7962: 24.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1       dsieger  7963:       the := inside it.
                   7964: 
1.108     rillig   7965:       The := is not really an assignment operator, although it looks like it.
                   7966:       Instead, it is a degenerate form of ${LIST:old_string=new_string}, which
                   7967:       is documented in the make(1) man page and which is commonly used in the
                   7968:       form ${SRCS:.c=.o}. In the case of MASTER_SITE_*, old_string is the empty
                   7969:       string and new_string is package/. That's where the : and the = fall
                   7970:       together.
1.1       dsieger  7971: 
1.154     rillig   7972: 24.7. Which mailing lists are there for package developers?
1.1       dsieger  7973: 
                   7974:       tech-pkg
                   7975: 
                   7976:           This is a list for technical discussions related to pkgsrc
                   7977:           development, e.g. soliciting feedback for changes to pkgsrc
                   7978:           infrastructure, proposed new features, questions related to porting
                   7979:           pkgsrc to a new platform, advice for maintaining a package, patches
                   7980:           that affect many packages, help requests moved from pkgsrc-users when
                   7981:           an infrastructure bug is found, etc.
                   7982: 
                   7983:       pkgsrc-bugs
                   7984: 
                   7985:           All bug reports in category "pkg" sent with send-pr(1) appear here.
                   7986:           Please do not report your bugs here directly; use one of the other
                   7987:           mailing lists.
                   7988: 
1.154     rillig   7989: 24.8. Where is the pkgsrc documentation?
1.1       dsieger  7990: 
                   7991:       There are many places where you can find documentation about pkgsrc:
                   7992: 
                   7993:         * The pkgsrc guide (this document) is a collection of chapters that
                   7994:           explain large parts of pkgsrc, but some chapters tend to be outdated.
                   7995:           Which ones they are is hard to say.
                   7996: 
1.174     leot     7997:         * On the mailing list archives (see https://mail-index.NetBSD.org/),
                   7998:           you can find discussions about certain features, announcements of new
1.1       dsieger  7999:           parts of the pkgsrc infrastructure and sometimes even announcements
                   8000:           that a certain feature has been marked as obsolete. The benefit here
                   8001:           is that each message has a date appended to it.
                   8002: 
                   8003:         * Many of the files in the mk/ directory start with a comment that
                   8004:           describes the purpose of the file and how it can be used by the
                   8005:           pkgsrc user and package authors. An easy way to find this
                   8006:           documentation is to run bmake help.
                   8007: 
                   8008:         * The CVS log messages are a rich source of information, but they tend
                   8009:           to be highly abbreviated, especially for actions that occur often.
                   8010:           Some contain a detailed description of what has changed, but they are
                   8011:           geared towards the other pkgsrc developers, not towards an average
                   8012:           pkgsrc user. They also only document changes, so if you don't know
                   8013:           what has been before, these messages may not be worth too much to
                   8014:           you.
                   8015: 
                   8016:         * Some parts of pkgsrc are only "implicitly documented", that is the
                   8017:           documentation exists only in the mind of the developer who wrote the
                   8018:           code. To get this information, use the cvs annotate command to see
                   8019:           who has written it and ask on the tech-pkg mailing list, so that
                   8020:           others can find your questions later (see above). To be sure that the
                   8021:           developer in charge reads the mail, you may CC him or her.
                   8022: 
1.154     rillig   8023: 24.9. I have a little time to kill. What shall I do?
1.1       dsieger  8024: 
                   8025:       This is not really an FAQ yet, but here's the answer anyway.
                   8026: 
                   8027:         * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
                   8028:           about newer versions of installed packages that are available, but
                   8029:           not yet updated in pkgsrc.
                   8030: 
                   8031:         * Browse pkgsrc/doc/TODO ? it contains a list of suggested new packages
                   8032:           and a list of cleanups and enhancements for pkgsrc that would be nice
                   8033:           to have.
                   8034: 
1.71      wiz      8035:         * Review packages for which review was requested on the tech-pkg
                   8036:           mailing list.
1.1       dsieger  8037: 
1.154     rillig   8038: Chapter 25. GNOME packaging and porting
1.1       dsieger  8039: 
                   8040: Table of Contents
                   8041: 
1.154     rillig   8042: 25.1. Meta packages
                   8043: 25.2. Packaging a GNOME application
                   8044: 25.3. Updating GNOME to a newer version
                   8045: 25.4. Patching guidelines
1.1       dsieger  8046: 
                   8047: Quoting GNOME's web site:
                   8048: 
                   8049:     The GNOME project provides two things: The GNOME desktop environment, an
                   8050:     intuitive and attractive desktop for users, and the GNOME development
                   8051:     platform, an extensive framework for building applications that integrate
                   8052:     into the rest of the desktop.
                   8053: 
                   8054: pkgsrc provides a seamless way to automatically build and install a complete
                   8055: GNOME environment under many different platforms. We can say with confidence
                   8056: that pkgsrc is one of the most advanced build and packaging systems for GNOME
                   8057: due to its included technologies buildlink3, the wrappers and tools framework
                   8058: and automatic configuration file management. Lots of efforts are put into
                   8059: achieving a completely clean deinstallation of installed software components.
                   8060: 
                   8061: Given that pkgsrc is NetBSD's official packaging system, the above also means
                   8062: that great efforts are put into making GNOME work under this operating system.
                   8063: Recently, DragonFly BSD also adopted pkgsrc as its preferred packaging system,
                   8064: contributing lots of portability fixes to make GNOME build and install under
                   8065: it.
                   8066: 
                   8067: This chapter is aimed at pkgsrc developers and other people interested in
                   8068: helping our GNOME porting and packaging efforts. It provides instructions on
                   8069: how to manage the existing packages and some important information regarding
                   8070: their internals.
                   8071: 
                   8072: We need your help!
                   8073: 
                   8074: Should you have some spare cycles to devote to NetBSD, pkgsrc and GNOME and are
                   8075: willing to learn new exciting stuff, please jump straight to the pending work
                   8076: list! There is still a long way to go to get a fully-functional GNOME desktop
                   8077: under NetBSD and we need your help to achieve it!
                   8078: 
1.154     rillig   8079: 25.1. Meta packages
1.1       dsieger  8080: 
                   8081: pkgsrc includes three GNOME-related meta packages:
                   8082: 
                   8083:   * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
                   8084:     includes the necessary bits to get it to boot correctly, although it may
                   8085:     lack important functionality for daily operation. The idea behind this
                   8086:     package is to let end users build their own configurations on top of this
                   8087:     one, first installing this meta package to achieve a functional setup and
                   8088:     then adding individual applications.
                   8089: 
                   8090:   * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
                   8091:     desktop as defined by the GNOME project; this is based on the components
                   8092:     distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
                   8093:     directories of the official FTP server. Developer-only tools found in those
                   8094:     directories are not installed unless required by some other component to
                   8095:     work properly. Similarly, packages from the bindings set (bindings/x.y/
                   8096:     x.y.z/sources) are not pulled in unless required as a dependency for an
                   8097:     end-user component. This package "extends" meta-pkgs/gnome-base.
                   8098: 
                   8099:   * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
                   8100:     component when fetched from the CVS repository. These are required to let
                   8101:     the autogen.sh scripts work appropriately.
                   8102: 
                   8103: In all these packages, the DEPENDS lines are sorted in a way that eases
                   8104: updates: a package may depend on other packages listed before it but not on any
1.25      wiz      8105: listed after it. It is very important to keep this order to ease updates so... 
1.1       dsieger  8106: do not change it to alphabetical sorting!
                   8107: 
1.154     rillig   8108: 25.2. Packaging a GNOME application
1.1       dsieger  8109: 
                   8110: Almost all GNOME applications are written in C and use a common set of tools as
                   8111: their build system. Things get different with the new bindings to other
                   8112: languages (such as Python), but the following will give you a general idea on
                   8113: the minimum required tools:
                   8114: 
                   8115:   * Almost all GNOME applications use the GNU Autotools as their build system.
                   8116:     As a general rule you will need to tell this to your package:
                   8117: 
                   8118:     GNU_CONFIGURE=yes
                   8119:     USE_LIBTOOL=yes
                   8120:     USE_TOOLS+=gmake
                   8121: 
                   8122:   * If the package uses pkg-config to detect dependencies, add this tool to the
                   8123:     list of required utilities:
                   8124: 
                   8125:     USE_TOOLS+=pkg-config
                   8126: 
                   8127:     Also use pkgtools/verifypc at the end of the build process to ensure that
                   8128:     you did not miss to specify any dependency in your package and that the
                   8129:     version requirements are all correct.
                   8130: 
                   8131:   * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
                   8132:     handle dependencies and to force the package to use the latest available
                   8133:     version.
                   8134: 
                   8135:   * If the package uses gtk-doc (a documentation generation utility), do not
                   8136:     add a dependency on it. The tool is rather big and the distfile should come
                   8137:     with pregenerated documentation anyway; if it does not, it is a bug that
                   8138:     you ought to report. For such packages you should disable gtk-doc (unless
                   8139:     it is the default):
                   8140: 
                   8141:     CONFIGURE_ARGS+=--disable-gtk-doc
                   8142: 
                   8143:     The default location of installed HTML files (share/gtk-doc/<package-name>)
                   8144:     is correct and should not be changed unless the package insists on
                   8145:     installing them somewhere else. Otherwise programs as devhelp will not be
                   8146:     able to open them. You can do that with an entry similar to:
                   8147: 
                   8148:     CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...
                   8149: 
                   8150: GNOME uses multiple shared directories and files under the installation prefix
                   8151: to maintain databases. In this context, shared means that those exact same
                   8152: directories and files are used among several different packages, leading to
                   8153: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
                   8154: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
                   8155: your file lists and omitting shared files from them. If you find yourself doing
                   8156: those, your package is most likely incorrect.
                   8157: 
                   8158: The following table lists the common situations that result in using shared
                   8159: directories or files. For each of them, the appropriate solution is given.
1.25      wiz      8160: After applying the solution be sure to regenerate the package's file list with 
1.1       dsieger  8161: make print-PLIST and ensure it is correct.
                   8162: 
1.154     rillig   8163: Table 25.1. PLIST handling for GNOME packages
1.1       dsieger  8164: 
                   8165: +-----------------------------------------------------------------------------+
                   8166: |             If the package...             |             Then...             |
                   8167: |-------------------------------------------+---------------------------------|
1.154     rillig   8168: |                                           |See Section 21.6.10, "Packages   |
1.18      mishka   8169: |Installs OMF files under share/omf.        |installing scrollkeeper/rarian   |
                   8170: |                                           |data files".                     |
1.1       dsieger  8171: |-------------------------------------------+---------------------------------|
1.154     rillig   8172: |Installs icons under the share/icons/      |See Section 21.6.19, "Packages   |
1.1       dsieger  8173: |hicolor hierarchy or updates share/icons/  |installing hicolor theme icons". |
                   8174: |hicolor/icon-theme.cache.                  |                                 |
                   8175: |-------------------------------------------+---------------------------------|
1.154     rillig   8176: |                                           |See Section 21.6.14, "Packages   |
1.1       dsieger  8177: |Installs files under share/mime/packages.  |installing extensions to the MIME|
                   8178: |                                           |database".                       |
                   8179: |-------------------------------------------+---------------------------------|
1.154     rillig   8180: |Installs .desktop files under share/       |See Section 21.6.20, "Packages   |
1.1       dsieger  8181: |applications and these include MIME        |installing desktop files".       |
                   8182: |information.                               |                                 |
                   8183: +-----------------------------------------------------------------------------+
                   8184: 
                   8185: 
1.154     rillig   8186: 25.3. Updating GNOME to a newer version
1.1       dsieger  8187: 
                   8188: When seeing GNOME as a whole, there are two kinds of updates:
                   8189: 
                   8190: Major update
                   8191: 
                   8192:     Given that there is still a very long way for GNOME 3 (if it ever appears),
                   8193:     we consider a major update one that goes from a 2.X version to a 2.Y one,
                   8194:     where Y is even and greater than X. These are hard to achieve because they
                   8195:     introduce lots of changes in the components' code and almost all GNOME
                   8196:     distfiles are updated to newer versions. Some of them can even break API
                   8197:     and ABI compatibility with the previous major version series. As a result,
                   8198:     the update needs to be done all at once to minimize breakage.
                   8199: 
                   8200:     A major update typically consists of around 80 package updates and the
                   8201:     addition of some new ones.
                   8202: 
                   8203: Minor update
                   8204: 
                   8205:     We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
                   8206:     one where Y is greater than X. These are easy to achieve because they do
                   8207:     not update all GNOME components, can be done in an incremental way and do
                   8208:     not break API nor ABI compatibility.
                   8209: 
                   8210:     A minor update typically consists of around 50 package updates, although
                   8211:     the numbers here may vary a lot.
                   8212: 
                   8213: In order to update the GNOME components in pkgsrc to a new stable release
                   8214: (either major or minor), the following steps should be followed:
                   8215: 
                   8216:  1. Get a list of all the tarballs that form the new release by using the
1.19      snj      8217:     following commands. These will leave the full list of the components'
1.1       dsieger  8218:     distfiles into the list.txt file:
                   8219: 
                   8220:     % echo ls "*.tar.bz2" | \
                   8221:         ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
                   8222:         awk '{ print $9 }' >list.txt
                   8223:     % echo ls "*.tar.bz2" | \
                   8224:         ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
                   8225:         awk '{ print $9 }' >>list.txt
                   8226: 
                   8227:  2. Open each meta package's Makefile and bump their version to the release you
                   8228:     are updating them to. The three meta packages should be always consistent
                   8229:     with versioning. Obviously remove any PKGREVISIONs that might be in them.
                   8230: 
                   8231:  3. For each meta package, update all its DEPENDS lines to match the latest
                   8232:     versions as shown by the above commands. Do not list any newer version
                   8233:     (even if found in the FTP) because the meta packages are supposed to list
                   8234:     the exact versions that form a specific GNOME release. Exceptions are
                   8235:     permitted here if a newer version solves a serious issue in the overall
                   8236:     desktop experience; these typically come in the form of a revision bump in
                   8237:     pkgsrc, not in newer versions from the developers.
                   8238: 
                   8239:     Packages not listed in the list.txt file should be updated to the latest
                   8240:     version available (if found in pkgsrc). This is the case, for example, of
                   8241:     the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
                   8242:     package.
                   8243: 
                   8244:  4. Generate a patch from the modified meta packages and extract the list of
                   8245:     "new" lines. This will provide you an outline on what packages need to be
                   8246:     updated in pkgsrc and in what order:
                   8247: 
                   8248:     % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
                   8249: 
                   8250:  5. For major desktop updates it is recommended to zap all your installed
                   8251:     packages and start over from scratch at this point.
                   8252: 
                   8253:  6. Now comes the longest step by far: iterate over the contents of todo.txt
                   8254:     and update the packages listed in it in order. For major desktop updates
                   8255:     none of these should be committed until the entire set is completed because
                   8256:     there are chances of breaking not-yet-updated packages.
                   8257: 
                   8258:  7. Once the packages are up to date and working, commit them to the tree one
                   8259:     by one with appropriate log messages. At the end, commit the three meta
                   8260:     package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
                   8261:     and pkgsrc/doc/TODO files.
                   8262: 
1.154     rillig   8263: 25.4. Patching guidelines
1.1       dsieger  8264: 
                   8265: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
                   8266: it is very important that you always, always, always feed back any portability
                   8267: fixes you do to a GNOME package to the mainstream developers (see
1.154     rillig   8268: Section 13.3.5, "Feedback to the author"). This is the only way to get their
1.1       dsieger  8269: attention on portability issues and to ensure that future versions can be built
                   8270: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
                   8271: updates are. Those developers in charge of issuing major GNOME updates will be
                   8272: grateful if you do that.
                   8273: 
                   8274: The most common places to report bugs are the GNOME's Bugzilla and the
                   8275: freedesktop.org's Bugzilla. Not all components use these to track bugs, but
                   8276: most of them do. Do not be short on your reports: always provide detailed
                   8277: explanations of the current failure, how it can be improved to achieve maximum
                   8278: portability and, if at all possible, provide a patch against CVS head. The more
                   8279: verbose you are, the higher chances of your patch being accepted.
                   8280: 
                   8281: Also, please avoid using preprocessor magic to fix portability issues. While
                   8282: the FreeBSD GNOME people are doing a great job in porting GNOME to their
                   8283: operating system, the official GNOME sources are now plagued by conditionals
                   8284: that check for __FreeBSD__ and similar macros. This hurts portability. Please
1.154     rillig   8285: see our patching guidelines (Section 13.3.4, "Patching guidelines") for more
1.1       dsieger  8286: details.
                   8287: 
                   8288: Part III. The pkgsrc infrastructure internals
                   8289: 
                   8290: This part of the guide deals with everything from the infrastructure that is
                   8291: behind the interfaces described in the developer's guide. A casual package
                   8292: maintainer should not need anything from this part.
                   8293: 
                   8294: Table of Contents
                   8295: 
1.154     rillig   8296: 26. Design of the pkgsrc infrastructure
1.1       dsieger  8297: 
1.154     rillig   8298:     26.1. The meaning of variable definitions
                   8299:     26.2. Avoiding problems before they arise
                   8300:     26.3. Variable evaluation
1.1       dsieger  8301: 
1.154     rillig   8302:         26.3.1. At load time
                   8303:         26.3.2. At runtime
1.1       dsieger  8304: 
1.154     rillig   8305:     26.4. How can variables be specified?
                   8306:     26.5. Designing interfaces for Makefile fragments
1.1       dsieger  8307: 
1.154     rillig   8308:         26.5.1. Procedures with parameters
                   8309:         26.5.2. Actions taken on behalf of parameters
1.1       dsieger  8310: 
1.154     rillig   8311:     26.6. The order in which files are loaded
1.1       dsieger  8312: 
1.154     rillig   8313:         26.6.1. The order in bsd.prefs.mk
                   8314:         26.6.2. The order in bsd.pkg.mk
1.1       dsieger  8315: 
1.154     rillig   8316: 27. Regression tests
1.1       dsieger  8317: 
1.154     rillig   8318:     27.1. Running the regression tests
                   8319:     27.2. Adding a new regression test
1.1       dsieger  8320: 
1.154     rillig   8321:         27.2.1. Overridable functions
                   8322:         27.2.2. Helper functions
1.1       dsieger  8323: 
1.154     rillig   8324: 28. Porting pkgsrc
1.1       dsieger  8325: 
1.154     rillig   8326:     28.1. Porting pkgsrc to a new operating system
1.1       dsieger  8327: 
1.154     rillig   8328: Chapter 26. Design of the pkgsrc infrastructure
1.1       dsieger  8329: 
                   8330: Table of Contents
                   8331: 
1.154     rillig   8332: 26.1. The meaning of variable definitions
                   8333: 26.2. Avoiding problems before they arise
                   8334: 26.3. Variable evaluation
1.1       dsieger  8335: 
1.154     rillig   8336:     26.3.1. At load time
                   8337:     26.3.2. At runtime
1.1       dsieger  8338: 
1.154     rillig   8339: 26.4. How can variables be specified?
                   8340: 26.5. Designing interfaces for Makefile fragments
1.1       dsieger  8341: 
1.154     rillig   8342:     26.5.1. Procedures with parameters
                   8343:     26.5.2. Actions taken on behalf of parameters
1.1       dsieger  8344: 
1.154     rillig   8345: 26.6. The order in which files are loaded
1.1       dsieger  8346: 
1.154     rillig   8347:     26.6.1. The order in bsd.prefs.mk
                   8348:     26.6.2. The order in bsd.pkg.mk
1.1       dsieger  8349: 
                   8350: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
                   8351: fragment needs a properly specified interface. This chapter explains how such
                   8352: an interface looks like.
                   8353: 
1.154     rillig   8354: 26.1. The meaning of variable definitions
1.1       dsieger  8355: 
                   8356: Whenever a variable is defined in the pkgsrc infrastructure, the location and
                   8357: the way of definition provide much information about the intended use of that
                   8358: variable. Additionally, more documentation may be found in a header comment or
                   8359: in this pkgsrc guide.
                   8360: 
                   8361: A special file is mk/defaults/mk.conf, which lists all variables that are
                   8362: intended to be user-defined. They are either defined using the ?= operator or
                   8363: they are left undefined because defining them to anything would effectively
                   8364: mean "yes". All these variables may be overridden by the pkgsrc user in the
                   8365: MAKECONF file.
                   8366: 
                   8367: Outside this file, the following conventions apply: Variables that are defined
                   8368: using the ?= operator may be overridden by a package.
                   8369: 
                   8370: Variables that are defined using the = operator may be used read-only at
                   8371: run-time.
                   8372: 
                   8373: Variables whose name starts with an underscore must not be accessed outside the
                   8374: pkgsrc infrastructure at all. They may change without further notice.
                   8375: 
                   8376: Note
                   8377: 
                   8378: These conventions are currently not applied consistently to the complete pkgsrc
                   8379: infrastructure.
                   8380: 
1.154     rillig   8381: 26.2. Avoiding problems before they arise
1.1       dsieger  8382: 
                   8383: All variables that contain lists of things should default to being empty. Two
                   8384: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
                   8385: variables cannot simply be modified using the += operator in package Makefiles
                   8386: (or other files included by them), since there is no guarantee whether the
                   8387: variable is already set or not, and what its value is. In the case of
                   8388: DISTFILES, the packages "know" the default value and just define it as in the
                   8389: following example.
                   8390: 
                   8391: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   8392: 
                   8393: Because of the selection of this default value, the same value appears in many
                   8394: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
                   8395: value ("c") is so short that it doesn't stand out. Nevertheless it is mentioned
                   8396: in many files.
                   8397: 
1.154     rillig   8398: 26.3. Variable evaluation
1.1       dsieger  8399: 
1.154     rillig   8400: 26.3.1. At load time
1.1       dsieger  8401: 
                   8402: Variable evaluation takes place either at load time or at runtime, depending on
                   8403: the context in which they occur. The contexts where variables are evaluated at
                   8404: load time are:
                   8405: 
                   8406:   * The right hand side of the := and != operators,
                   8407: 
                   8408:   * Make directives like .if or .for,
                   8409: 
                   8410:   * Dependency lines.
                   8411: 
                   8412: A special exception are references to the iteration variables of .for loops,
                   8413: which are expanded inline, no matter in which context they appear.
                   8414: 
                   8415: As the values of variables may change during load time, care must be taken not
                   8416: to evaluate them by accident. Typical examples for variables that should not be
                   8417: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
                   8418: clear, here is an example:
                   8419: 
                   8420: CONFIGURE_ARGS=         # none
                   8421: CFLAGS=                 -O
                   8422: CONFIGURE_ARGS+=        CFLAGS=${CFLAGS:Q}
                   8423: 
                   8424: CONFIGURE_ARGS:=        ${CONFIGURE_ARGS}
                   8425: 
                   8426: CFLAGS+=                -Wall
                   8427: 
                   8428: This code shows how the use of the := operator can quickly lead to unexpected
                   8429: results. The first paragraph is fairly common code. The second paragraph
                   8430: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
                   8431: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
                   8432: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
                   8433: typically occur in completely unrelated files.
                   8434: 
1.154     rillig   8435: 26.3.2. At runtime
1.1       dsieger  8436: 
                   8437: After all the files have been loaded, the values of the variables cannot be
                   8438: changed anymore. Variables that are used in the shell commands are expanded at
                   8439: this point.
                   8440: 
1.154     rillig   8441: 26.4. How can variables be specified?
1.1       dsieger  8442: 
                   8443: There are many ways in which the definition and use of a variable can be
                   8444: restricted in order to detect bugs and violations of the (mostly unwritten)
1.108     rillig   8445: policies. A package can be checked with pkglint -Wall to see whether it meets
                   8446: these rules.
1.1       dsieger  8447: 
1.154     rillig   8448: 26.5. Designing interfaces for Makefile fragments
1.1       dsieger  8449: 
                   8450: Most of the .mk files fall into one of the following classes. Cases where a
                   8451: file falls into more than one class should be avoided as it often leads to
                   8452: subtle bugs.
                   8453: 
1.154     rillig   8454: 26.5.1. Procedures with parameters
1.1       dsieger  8455: 
                   8456: In a traditional imperative programming language some of the .mk files could be
1.23      jakllsch 8457: described as procedures. They take some input parameters and?after
                   8458: inclusion?provide a result in output parameters. Since all variables in
                   8459: Makefiles have global scope care must be taken not to use parameter names that
                   8460: have already another meaning. For example, PKGNAME is a bad choice for a
                   8461: parameter name.
1.1       dsieger  8462: 
                   8463: Procedures are completely evaluated at preprocessing time. That is, when
                   8464: calling a procedure all input parameters must be completely resolvable. For
                   8465: example, CONFIGURE_ARGS should never be an input parameter since it is very
                   8466: likely that further text will be added after calling the procedure, which would
                   8467: effectively apply the procedure to only a part of the variable. Also,
1.108     rillig   8468: references to other variables will be modified after calling the procedure.
1.1       dsieger  8469: 
                   8470: A procedure can declare its output parameters either as suitable for use in
                   8471: preprocessing directives or as only available at runtime. The latter
                   8472: alternative is for variables that contain references to other runtime
                   8473: variables.
                   8474: 
                   8475: Procedures shall be written such that it is possible to call the procedure more
                   8476: than once. That is, the file must not contain multiple-inclusion guards.
                   8477: 
                   8478: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
                   8479: To express that the parameters are evaluated at load time, they should be
                   8480: assigned using the := operator, which should be used only for this purpose.
                   8481: 
1.154     rillig   8482: 26.5.2. Actions taken on behalf of parameters
1.1       dsieger  8483: 
                   8484: Action files take some input parameters and may define runtime variables. They
                   8485: shall not define loadtime variables. There are action files that are included
                   8486: implicitly by the pkgsrc infrastructure, while other must be included
                   8487: explicitly.
                   8488: 
                   8489: An example for action files is mk/subst.mk.
                   8490: 
1.154     rillig   8491: 26.6. The order in which files are loaded
1.1       dsieger  8492: 
                   8493: Package Makefiles usually consist of a set of variable definitions, and include
                   8494: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
                   8495: include various other *.mk files if they need to query the availability of
                   8496: certain features like the type of compiler or the X11 implementation. Due to
                   8497: the heavy use of preprocessor directives like .if and .for, the order in which
                   8498: the files are loaded matters.
                   8499: 
                   8500: This section describes at which point the various files are loaded and gives
                   8501: reasons for that order.
                   8502: 
1.154     rillig   8503: 26.6.1. The order in bsd.prefs.mk
1.1       dsieger  8504: 
                   8505: The very first action in bsd.prefs.mk is to define some essential variables
                   8506: like OPSYS, OS_VERSION and MACHINE_ARCH.
                   8507: 
1.4       rillig   8508: Then, the user settings are loaded from the file specified in MAKECONF, which
                   8509: is usually mk.conf. After that, those variables that have not been overridden
                   8510: by the user are loaded from mk/defaults/mk.conf.
1.1       dsieger  8511: 
                   8512: After the user settings, the system settings and platform settings are loaded,
                   8513: which may override the user settings.
                   8514: 
                   8515: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
                   8516: This only happens when building a package, so the proper variables must be used
                   8517: instead of the direct tool names.
                   8518: 
                   8519: As the last steps, some essential variables from the wrapper and the package
                   8520: system flavor are loaded, as well as the variables that have been cached in
                   8521: earlier phases of a package build.
                   8522: 
1.154     rillig   8523: 26.6.2. The order in bsd.pkg.mk
1.1       dsieger  8524: 
                   8525: First, bsd.prefs.mk is loaded.
                   8526: 
                   8527: Then, the various *-vars.mk files are loaded, which fill default values for
                   8528: those variables that have not been defined by the package. These variables may
                   8529: later be used even in unrelated files.
                   8530: 
                   8531: Then, the file bsd.pkg.error.mk provides the target error-check that is added
                   8532: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
                   8533: DELAYED_WARNING_MSG.
                   8534: 
                   8535: Then, the package-specific hacks from hacks.mk are included.
                   8536: 
                   8537: Then, various other files follow. Most of them don't have any dependencies on
                   8538: what they need to have included before or after them, though some do.
                   8539: 
                   8540: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
                   8541: restricts the use of these variables to all the files that have been included
                   8542: before. Appearances in later files will be silently ignored.
                   8543: 
                   8544: Then, the files for the main targets are included, in the order of later
                   8545: execution, though the actual order should not matter.
                   8546: 
                   8547: At last, some more files are included that don't set any interesting variables
                   8548: but rather just define make targets to be executed.
                   8549: 
1.154     rillig   8550: Chapter 27. Regression tests
1.1       dsieger  8551: 
                   8552: Table of Contents
                   8553: 
1.154     rillig   8554: 27.1. Running the regression tests
                   8555: 27.2. Adding a new regression test
1.1       dsieger  8556: 
1.154     rillig   8557:     27.2.1. Overridable functions
                   8558:     27.2.2. Helper functions
1.1       dsieger  8559: 
                   8560: The pkgsrc infrastructure consists of a large codebase, and there are many
                   8561: corners where every little bit of a file is well thought out, making pkgsrc
                   8562: likely to fail as soon as anything is changed near those parts. To prevent most
                   8563: changes from breaking anything, a suite of regression tests should go along
                   8564: with every important part of the pkgsrc infrastructure. This chapter describes
                   8565: how regression tests work in pkgsrc and how you can add new tests.
                   8566: 
1.154     rillig   8567: 27.1. Running the regression tests
1.1       dsieger  8568: 
1.25      wiz      8569: You first need to install the pkgtools/pkg_regress package, which provides the 
1.1       dsieger  8570: pkg_regress command. Then you can simply run that command, which will run all
1.168     rillig   8571: tests in the regress/ directory.
1.1       dsieger  8572: 
1.154     rillig   8573: 27.2. Adding a new regression test
1.1       dsieger  8574: 
1.168     rillig   8575: Every directory in the regress/ directory that contains a file called spec is
1.1       dsieger  8576: considered a regression test. This file is a shell program that is included by
                   8577: the pkg_regress command. The following functions can be overridden to suit your
                   8578: needs.
                   8579: 
1.154     rillig   8580: 27.2.1. Overridable functions
1.1       dsieger  8581: 
1.108     rillig   8582: These functions do not take any parameters. Although they are called in "set -e
1.168     rillig   8583: " mode, they don't stop at the first failing command. See this Stack Overflow
1.108     rillig   8584: question for details.
1.1       dsieger  8585: 
1.108     rillig   8586: do_setup
1.1       dsieger  8587: 
                   8588:     This function prepares the environment for the test. By default it does
                   8589:     nothing.
                   8590: 
1.108     rillig   8591: do_test
1.1       dsieger  8592: 
                   8593:     This function runs the actual test. By default, it calls TEST_MAKE with the
                   8594:     arguments MAKEARGS_TEST and writes its output including error messages into
                   8595:     the file TEST_OUTFILE.
                   8596: 
1.108     rillig   8597:     When defining this function, make sure that all output that needs to be
                   8598:     checked is written to the correct output file. Example:
                   8599: 
                   8600:     do_test() {
                   8601:             echo "Example output"
                   8602:     } 1>$TEST_OUTFILE 2>&1
                   8603: 
                   8604: check_result
1.1       dsieger  8605: 
                   8606:     This function is run after the test and is typically used to compare the
                   8607:     actual output from the one that is expected. It can make use of the various
1.108     rillig   8608:     helper functions from the next section. Example:
                   8609: 
                   8610:     check_result() {
                   8611:             exit_status 0
                   8612:             output_require "Example"
                   8613:             output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
                   8614:             output_prohibit "no such file or directory"
1.169     rillig   8615:             regress_fail "expected $expected but got $actual for input $input"
1.108     rillig   8616:     }
1.1       dsieger  8617: 
1.108     rillig   8618: do_cleanup
1.1       dsieger  8619: 
                   8620:     This function cleans everything up after the test has been run. By default
                   8621:     it does nothing.
                   8622: 
1.154     rillig   8623: 27.2.2. Helper functions
1.1       dsieger  8624: 
1.168     rillig   8625: regress_fail message...
                   8626: 
                   8627:     This function makes the test fail with the given error message.
                   8628: 
1.108     rillig   8629: exit_status expected
1.1       dsieger  8630: 
1.108     rillig   8631:     This function compares the exitcode of the do_test function with its first
                   8632:     parameter. If they differ, the test will fail.
1.1       dsieger  8633: 
1.108     rillig   8634: output_require regex...
1.1       dsieger  8635: 
                   8636:     This function checks for each of its parameters if the output from do_test
1.108     rillig   8637:     matches the extended regular expression. If it does not, the test will
                   8638:     fail. Example:
                   8639: 
                   8640:     output_require "looks fine"
                   8641:     output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
1.1       dsieger  8642: 
1.177     leot     8643: output_prohibit regex...
1.1       dsieger  8644: 
                   8645:     This function checks for each of its parameters if the output from do_test
                   8646:     () does not match the extended regular expression. If any of the regular
                   8647:     expressions matches, the test will fail.
                   8648: 
1.154     rillig   8649: Chapter 28. Porting pkgsrc
1.1       dsieger  8650: 
                   8651: Table of Contents
                   8652: 
1.154     rillig   8653: 28.1. Porting pkgsrc to a new operating system
1.1       dsieger  8654: 
                   8655: The pkgsrc system has already been ported to many operating systems, hardware
                   8656: architectures and compilers. This chapter explains the necessary steps to make
                   8657: pkgsrc even more portable.
                   8658: 
1.154     rillig   8659: 28.1. Porting pkgsrc to a new operating system
1.1       dsieger  8660: 
                   8661: To port pkgsrc to a new operating system (called MyOS in this example), you
                   8662: need to touch the following files:
                   8663: 
                   8664: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
                   8665: 
                   8666:     This file contains some basic definitions, for example the name of the C
                   8667:     compiler.
                   8668: 
                   8669: mk/bsd.prefs.mk
                   8670: 
                   8671:     Insert code that defines the variables OPSYS, OS_VERSION, LOWER_OS_VERSION,
                   8672:     LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
                   8673:     that appear in this file.
                   8674: 
                   8675: mk/platform/MyOS.mk
                   8676: 
                   8677:     This file contains the platform-specific definitions that are used by
                   8678:     pkgsrc. Start by copying one of the other files and edit it to your needs.
                   8679: 
                   8680: mk/tools/tools.MyOS.mk
                   8681: 
                   8682:     This file defines the paths to all the tools that are needed by one or the
                   8683:     other package in pkgsrc, as well as by pkgsrc itself. Find out where these
                   8684:     tools are on your platform and add them.
                   8685: 
                   8686: Now, you should be able to build some basic packages, like lang/perl5, shells/
                   8687: bash.
                   8688: 
                   8689: Appendix A. A simple example package: bison
                   8690: 
                   8691: Table of Contents
                   8692: 
                   8693: A.1. files
                   8694: 
                   8695:     A.1.1. Makefile
                   8696:     A.1.2. DESCR
                   8697:     A.1.3. PLIST
                   8698:     A.1.4. Checking a package with pkglint
                   8699: 
                   8700: A.2. Steps for building, installing, packaging
                   8701: 
                   8702: We checked to find a piece of software that wasn't in the packages collection,
1.25      wiz      8703: and picked GNU bison. Quite why someone would want to have bison when Berkeley 
1.1       dsieger  8704: yacc is already present in the tree is beyond us, but it's useful for the
                   8705: purposes of this exercise.
                   8706: 
                   8707: A.1. files
                   8708: 
                   8709: A.1.1. Makefile
                   8710: 
1.2       rillig   8711: # $NetBSD$
1.1       dsieger  8712: #
                   8713: 
                   8714: DISTNAME=       bison-1.25
                   8715: CATEGORIES=     devel
1.171     rillig   8716: MASTER_SITES=   ${MASTER_SITE_GNU:=bison/}
1.1       dsieger  8717: 
1.30      dholland 8718: MAINTAINER=     pkgsrc-users@NetBSD.org
1.174     leot     8719: HOMEPAGE=       https://www.gnu.org/software/bison/bison.html
1.1       dsieger  8720: COMMENT=        GNU yacc clone
                   8721: 
                   8722: GNU_CONFIGURE=  yes
1.47      wiz      8723: INFO_FILES=     yes
1.1       dsieger  8724: 
                   8725: .include "../../mk/bsd.pkg.mk"
                   8726: 
                   8727: A.1.2. DESCR
                   8728: 
                   8729: GNU version of yacc.  Can make re-entrant parsers, and numerous other
                   8730: improvements.  Why you would want this when Berkeley yacc(1) is part
                   8731: of the NetBSD source tree is beyond me.
                   8732: 
                   8733: A.1.3. PLIST
                   8734: 
1.2       rillig   8735: @comment $NetBSD$
1.1       dsieger  8736: bin/bison
                   8737: man/man1/bison.1.gz
                   8738: share/bison.simple
                   8739: share/bison.hairy
                   8740: 
                   8741: A.1.4. Checking a package with pkglint
                   8742: 
                   8743: The NetBSD package system comes with pkgtools/pkglint which helps to check the
                   8744: contents of these files. After installation it is quite easy to use, just
1.171     rillig   8745: change to the directory of the package you wish to examine and run pkglint:
1.1       dsieger  8746: 
                   8747: $ pkglint
1.171     rillig   8748: ERROR: Makefile: Each package must define its LICENSE.
                   8749: WARN: Makefile:9: HOMEPAGE should migrate from http to https.
                   8750: NOTE: PLIST:3: The .gz extension is unnecessary for manual pages.
                   8751: WARN: PLIST:5: "share/bison.hairy" should be sorted before "share/bison.simple".
                   8752: 1 error, 2 warnings and 1 note found.
                   8753: (Run "pkglint -e" to show explanations.)
                   8754: (Run "pkglint -fs" to show what can be fixed automatically.)
1.172     rillig   8755: (Run "pkglint -F" to automatically fix some issues.)
1.1       dsieger  8756: 
                   8757: Depending on the supplied command line arguments (see pkglint(1)), more checks
1.170     rillig   8758: will be performed. Use e.g. pkglint -Wall for a very thorough check.
1.1       dsieger  8759: 
                   8760: A.2. Steps for building, installing, packaging
                   8761: 
                   8762: Create the directory where the package lives, plus any auxiliary directories:
                   8763: 
                   8764: # cd /usr/pkgsrc/lang
                   8765: # mkdir bison
                   8766: # cd bison
                   8767: # mkdir patches
                   8768: 
1.154     rillig   8769: Create Makefile, DESCR and PLIST (see Chapter 13, Package components - files,
1.1       dsieger  8770: directories and contents) then continue with fetching the distfile:
                   8771: 
                   8772: # make fetch
                   8773: >> bison-1.25.tar.gz doesn't seem to exist on this system.
                   8774: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
                   8775: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8776: ftp: Error retrieving file: 500 Internal error
                   8777: 
                   8778: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
                   8779: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8780: ftp: Error retrieving file: 500 Internal error
                   8781: 
                   8782: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
                   8783: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8784: Successfully retrieved file.
                   8785: 
                   8786: Generate the checksum of the distfile into distinfo:
                   8787: 
                   8788: # make makedistinfo
                   8789: 
                   8790: Now compile:
                   8791: 
                   8792: # make
                   8793: >> Checksum OK for bison-1.25.tar.gz.
                   8794: ===>  Extracting for bison-1.25
                   8795: ===>  Patching for bison-1.25
                   8796: ===>   Ignoring empty patch directory
                   8797: ===>  Configuring for bison-1.25
                   8798: creating cache ./config.cache
                   8799: checking for gcc... cc
                   8800: checking whether we are using GNU C... yes
                   8801: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
                   8802: checking how to run the C preprocessor... cc -E
                   8803: checking for minix/config.h... no
                   8804: checking for POSIXized ISC... no
                   8805: checking whether cross-compiling... no
                   8806: checking for ANSI C header files... yes
                   8807: checking for string.h... yes
                   8808: checking for stdlib.h... yes
                   8809: checking for memory.h... yes
                   8810: checking for working const... yes
                   8811: checking for working alloca.h... no
                   8812: checking for alloca... yes
                   8813: checking for strerror... yes
                   8814: updating cache ./config.cache
                   8815: creating ./config.status
                   8816: creating Makefile
                   8817: ===>  Building for bison-1.25
                   8818: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g LR0.c
                   8819: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g allocate.c
                   8820: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g closure.c
                   8821: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g conflicts.c
                   8822: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g derives.c
                   8823: 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
                   8824: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g getargs.c
                   8825: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g gram.c
                   8826: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g lalr.c
                   8827: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g lex.c
                   8828: cc -c -DSTDC_HEADERS=1 -DHAVE_STRING_H=1 -DHAVE_STDLIB_H=1 -DHAVE_MEMORY_H=1 -DHAVE_ALLOCA=1 -DHAVE_STRERROR=1 -I./../include  -g main.c
                   8829: 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
                   8830: 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
                   8831: 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
                   8832: 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
                   8833: 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
                   8834: 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
                   8835: 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
                   8836: 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
                   8837: 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
                   8838: 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
                   8839: 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
                   8840: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
                   8841: rm -f bison.s1
                   8842: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
                   8843: 
                   8844: Everything seems OK, so install the files:
                   8845: 
                   8846: # make install
                   8847: >> Checksum OK for bison-1.25.tar.gz.
                   8848: ===>  Installing for bison-1.25
                   8849: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
                   8850: rm -f /usr/pkg/bin/bison
                   8851: cd /usr/pkg/share; rm -f bison.simple bison.hairy
                   8852: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
                   8853: install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
                   8854: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
                   8855: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
                   8856: cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
                   8857: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
                   8858: ===>  Registering installation for bison-1.25
                   8859: 
                   8860: You can now use bison, and also - if you decide so - remove it with pkg_delete
                   8861: bison. Should you decide that you want a binary package, do this now:
                   8862: 
                   8863: # make package
                   8864: >> Checksum OK for bison-1.25.tar.gz.
                   8865: ===>  Building package for bison-1.25
                   8866: Creating package bison-1.25.tgz
                   8867: Registering depends:.
                   8868: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
                   8869: 
                   8870: Now that you don't need the source and object files any more, clean up:
                   8871: 
                   8872: # make clean
                   8873: ===>  Cleaning for bison-1.25
                   8874: 
                   8875: Appendix B. Build logs
                   8876: 
                   8877: Table of Contents
                   8878: 
                   8879: B.1. Building figlet
                   8880: B.2. Packaging figlet
                   8881: 
                   8882: B.1. Building figlet
                   8883: 
                   8884: # make
                   8885: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   8886: => figlet221.tar.gz doesn't seem to exist on this system.
                   8887: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
                   8888: => [172219 bytes]
                   8889: Connected to ftp.plig.net.
                   8890: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
                   8891: 331 Guest login ok, send your complete e-mail address as password.
                   8892: 230-You are user #5 of 500 simultaneous users allowed.
                   8893: 230-
                   8894: 230-  ___ _             _ _
                   8895: 230- |  _| |_ ___   ___| |_|___   ___ ___ ___
                   8896: 230- |  _|  _| . |_| . | | | . |_| . |  _| . |
                   8897: 230- |_| |_| |  _|_|  _|_|_|_  |_|___|_| |_  |
                   8898: 230-         |_|   |_|     |___|         |___|
                   8899: 230-
                   8900: 230-** Welcome to ftp.plig.org **
                   8901: 230-
                   8902: 230-Please note that all transfers from this FTP site are logged. If you
                   8903: 230-do not like this, please disconnect now.
                   8904: 230-
1.19      snj      8905: 230-This archive is available via
1.1       dsieger  8906: 230-
                   8907: 230-HTTP:  http://ftp.plig.org/
                   8908: 230-FTP:   ftp://ftp.plig.org/     (max 500 connections)
                   8909: 230-RSYNC: rsync://ftp.plig.org/   (max  30 connections)
                   8910: 230-
                   8911: 230-Please email comments, bug reports and requests for packages to be
                   8912: 230-mirrored to ftp-admin@plig.org.
                   8913: 230-
                   8914: 230-
                   8915: 230 Logged in anonymously.
                   8916: Remote system type is UNIX.
                   8917: Using binary mode to transfer files.
                   8918: 200 Type okay.
                   8919: 250 "/pub" is new cwd.
                   8920: 250-"/pub/figlet" is new cwd.
                   8921: 250-
                   8922: 250-Welcome to the figlet archive at ftp.figlet.org
                   8923: 250-
                   8924: 250-    ftp://ftp.figlet.org/pub/figlet/
                   8925: 250-
                   8926: 250-The official FIGlet web page is:
                   8927: 250-    http://www.figlet.org/
                   8928: 250-
                   8929: 250-If you have questions, please mailto:info@figlet.org. If you want to
                   8930: 250-contribute a font or something else, you can email us.
                   8931: 250
                   8932: 250 "/pub/figlet/program" is new cwd.
                   8933: 250 "/pub/figlet/program/unix" is new cwd.
                   8934: local: figlet221.tar.gz remote: figlet221.tar.gz
                   8935: 502 Unimplemented command.
                   8936: 227 Entering Passive Mode (195,40,6,41,246,104)
                   8937: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
                   8938: 38% |**************                       | 65800      64.16 KB/s    00:01 ETA
                   8939: 226 Transfer completed.
                   8940: 172219 bytes received in 00:02 (75.99 KB/s)
                   8941: 221 Goodbye.
                   8942: => Checksum OK for figlet221.tar.gz.
                   8943: ===> Extracting for figlet-2.2.1nb2
                   8944: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
                   8945: ===> Patching for figlet-2.2.1nb2
                   8946: ===> Applying pkgsrc patches for figlet-2.2.1nb2
                   8947: ===> Overriding tools for figlet-2.2.1nb2
                   8948: ===> Creating toolchain wrappers for figlet-2.2.1nb2
                   8949: ===> Configuring for figlet-2.2.1nb2
                   8950: ===> Building for figlet-2.2.1nb2
                   8951: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\"  -DDEFAULTFONTFILE=\"standard.flf\"  figlet.c zipio.c crc.c inflate.c -o figlet
                   8952: chmod a+x figlet
                   8953: gcc -O2 -o chkfont chkfont.c
                   8954: => Unwrapping files-to-be-installed.
                   8955: #
                   8956: # make install
                   8957: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   8958: ===> Installing for figlet-2.2.1nb2
                   8959: install -d -o root -g wheel -m 755 /usr/pkg/bin
                   8960: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
                   8961: mkdir -p /usr/pkg/share/figlet
                   8962: cp figlet /usr/pkg/bin
                   8963: cp chkfont /usr/pkg/bin
                   8964: chmod 555 figlist showfigfonts
                   8965: cp figlist /usr/pkg/bin
                   8966: cp showfigfonts /usr/pkg/bin
                   8967: cp fonts/*.flf /usr/pkg/share/figlet
                   8968: cp fonts/*.flc /usr/pkg/share/figlet
                   8969: cp figlet.6 /usr/pkg/man/man6
                   8970: ===> Registering installation for figlet-2.2.1nb2
                   8971: #
                   8972: 
                   8973: B.2. Packaging figlet
                   8974: 
                   8975: # make package
                   8976: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   8977: ===> Packaging figlet-2.2.1nb2
                   8978: ===> Building binary package for figlet-2.2.1nb2
                   8979: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
                   8980: Using SrcDir value of /usr/pkg
                   8981: Registering depends:.
                   8982: #
                   8983: 
                   8984: Appendix C. Directory layout of the pkgsrc FTP server
                   8985: 
                   8986: Table of Contents
                   8987: 
1.23      jakllsch 8988: C.1. distfiles: The distributed source files
                   8989: C.2. misc: Miscellaneous things
                   8990: C.3. packages: Binary packages
                   8991: C.4. reports: Bulk build reports
1.148     leot     8992: C.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  8993: 
                   8994: As in other big projects, the directory layout of pkgsrc is quite complex for
                   8995: newbies. This chapter explains where you find things on the FTP server. The
                   8996: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
                   8997: different, but inside this directory, everything should look the same, no
                   8998: matter on which server you are. This directory contains some subdirectories,
                   8999: which are explained below.
                   9000: 
1.23      jakllsch 9001: C.1. distfiles: The distributed source files
1.1       dsieger  9002: 
                   9003: The directory distfiles contains lots of archive files from all pkgsrc
                   9004: packages, which are mirrored here. The subdirectories are called after their
                   9005: package names and are used when the distributed files have names that don't
                   9006: explicitly contain a version number or are otherwise too generic (for example
                   9007: release.tar.gz).
                   9008: 
1.23      jakllsch 9009: C.2. misc: Miscellaneous things
1.1       dsieger  9010: 
                   9011: This directory contains things that individual pkgsrc developers find worth
                   9012: publishing.
                   9013: 
1.23      jakllsch 9014: C.3. packages: Binary packages
1.1       dsieger  9015: 
1.3       rillig   9016: This directory contains binary packages for the various platforms that are
                   9017: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
                   9018: The meaning of these variables is:
                   9019: 
                   9020:   * OPSYS is the name of the operating system for which the packages have been
1.9       rillig   9021:     built. The name is taken from the output of the uname command, so it may
                   9022:     differ from the one you are used to hear.
1.3       rillig   9023: 
1.8       rillig   9024:   * ARCH is the hardware architecture of the platform for which the packages
1.10      hubertf  9025:     have been built. It also includes the ABI (Application Binary Interface)
                   9026:     for platforms that have several of them.
1.3       rillig   9027: 
1.8       rillig   9028:   * OSVERSION is the version of the operating system. For version numbers that
                   9029:     change often (for example NetBSD-current), the often-changing part should
                   9030:     be replaced with an x, for example 4.99.x.
1.3       rillig   9031: 
1.23      jakllsch 9032:   * TAG is either 20xxQy for a stable branch, or head for packages built from
1.8       rillig   9033:     the HEAD branch. The latter should only be used when the packages are
                   9034:     updated on a regular basis. Otherwise the date from checking out pkgsrc
                   9035:     should be appended, for example head_20071015.
1.3       rillig   9036: 
                   9037: The rationale for exactly this scheme is that the pkgsrc users looking for
                   9038: binary packages can quickly click through the directories on the server and
                   9039: find the best binary packages for their machines. Since they usually know the
                   9040: operating system and the hardware architecture, OPSYS and ARCH are placed
                   9041: first. After these choices, they can select the best combination of OSVERSION
                   9042: and TAG together, since it is usually the case that packages stay compatible
                   9043: between different version of the operating system.
                   9044: 
                   9045: In each of these directories, there is a whole binary packages collection for a
                   9046: specific platform. It has a directory called All which contains all binary
                   9047: packages. Besides that, there are various category directories that contain
                   9048: symbolic links to the real binary packages.
1.1       dsieger  9049: 
1.23      jakllsch 9050: C.4. reports: Bulk build reports
1.8       rillig   9051: 
                   9052: Here are the reports from bulk builds, for those who want to fix packages that
                   9053: didn't build on some of the platforms. The structure of subdirectories should
1.23      jakllsch 9054: look like the one in Section C.3, "packages: Binary packages".
1.8       rillig   9055: 
1.148     leot     9056: C.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  9057: 
                   9058: These directories contain the "real" pkgsrc, that is the files that define how
                   9059: to create binary packages from source archives.
                   9060: 
1.149     leot     9061: Each of the current, stable and pkgsrc-20xxQy directories share the same
                   9062: structure. They each contain a pkgsrc directory and pkgsrc.tar.{bz,gz,xz} file.
                   9063: 
1.1       dsieger  9064: The directory pkgsrc contains a snapshot of the CVS repository, which is
1.149     leot     9065: updated regularly. The file pkgsrc.tar.{bz,gz,xz} contains the same as the
                   9066: directory, ready to be downloaded as a whole.
1.1       dsieger  9067: 
1.149     leot     9068: The current directory contains files related to the HEAD branch of the CVS
                   9069: repository. In this directory there is an additional file called
                   9070: pkgsrc-readmes.tar.{bz,gz,xz} that contains all pkgsrc READMEs with information
                   9071: about categories and packages.
                   9072: 
                   9073: The stable directory is a symlink to the latest pkgsrc-20xxQy.
                   9074: 
                   9075: The pkgsrc-20xxQy. directories contain files related to the -20xxQy stable
                   9076: branch of the CVS repository. In these directories there is an additional file
                   9077: called pkgsrc-20xxQy.tar.{bz,gz,xz}, which contains the state of pkgsrc when it
                   9078: was branched.
1.148     leot     9079: 
1.154     rillig   9080: Appendix D. Help topics
                   9081: 
                   9082: The following list contains all help topics that are available when running 
                   9083: bmake help topic=:index.
                   9084: 
1.180     rillig   9085: #!                               -lintl
                   9086: 64bit                            ABI
                   9087: ACCEPTABLE_LICENSES              ACROREAD_FONTPATH
                   9088: ADDITIONAL                       AFAIK
                   9089: AIX                              ALLOW_VULNERABLE_PACKAGES
                   9090: ALL_ENV                          ALSA_PC
                   9091: ALTERNATIVES_SRC                 AMANDA_TMP
                   9092: AMANDA_USER                      AMANDA_VAR
                   9093: APACHE_GROUP                     APACHE_MODULE_NAME
                   9094: APACHE_MODULE_SRC                APACHE_MODULE_SRCDIR
                   9095: APACHE_PKG_PREFIX                APACHE_SUEXEC_CONFIGURE_ARGS
                   9096: APACHE_SUEXEC_DOCROOT            APACHE_USER
                   9097: APPEND_ABI                       APPEND_ELF
                   9098: ARLA_CACHE                       AUDIT_PACKAGES_FLAGS
                   9099: AUTOCONF_REQD                    AUTOMAKE_OVERRIDE
                   9100: AUTOMAKE_REQD                    AUTO_MKDIRS
                   9101: BDB185_DEFAULT                   BDBBASE
                   9102: BDB_ACCEPTED                     BDB_DEFAULT
                   9103: BDB_LIBS                         BDB_TYPE
                   9104: BIND_DIR                         BIND_GROUP
                   9105: BIND_USER                        BINPKG_SITES
                   9106: BIN_INSTALL_FLAGS                BISON_PKGDATADIR
                   9107: BLAS_ACCEPTED                    BLAS_LIBS
                   9108: BLAS_TYPE                        BOOTSTRAP_DEPENDS
                   9109: BOOTSTRAP_SETUPTOOLS             BROKEN
                   9110: BROKEN_EXCEPT_ON_PLATFORM        BROKEN_ON_PLATFORM
                   9111: BSDSRCDIR                        BSDXSRCDIR
                   9112: BSD_MAKE_ENV                     BUILDLINK_AUTO_DIRS
                   9113: BUILDLINK_AUTO_VARS              BUILDLINK_CFLAGS
                   9114: BUILDLINK_CONTENTS_FILTER        BUILDLINK_CPPFLAGS
                   9115: BUILDLINK_DEPMETHOD              BUILDLINK_FILES
                   9116: BUILDLINK_FILES_CMD              BUILDLINK_FNAME_TRANSFORM
                   9117: BUILDLINK_LDFLAGS                BUILDLINK_LIBS
                   9118: BUILDLINK_OPSYS_SUPPORT_PTHREAD  BUILDLINK_PKGNAME
                   9119: BUILDLINK_PREFIX                 BUILDLINK_RPATHDIRS
                   9120: BUILDLINK_TREE                   BUILD_DEFS
                   9121: BUILD_DEFS_EFFECTS               BUILD_DEPENDS
                   9122: BUILD_DIRS                       BUILD_ENV_SHELL
                   9123: BUILD_MAKE_CMD                   BUILD_MAKE_FLAGS
                   9124: BUILD_TARGET                     BUILTIN_FIND_FILES
                   9125: BUILTIN_FIND_FILES_VAR           BUILTIN_FIND_GREP
                   9126: BUILTIN_FIND_HEADERS             BUILTIN_FIND_HEADERS_VAR
                   9127: BUILTIN_PKG                      BUILTIN_TEST_CURSES_DEFINES
                   9128: BUILTIN_TEST_CURSES_FUNCS        BUILTIN_VERSION_SCRIPT
                   9129: BUILTIN_X11_TYPE                 BUILTIN_X11_VERSION
                   9130: CACTI_GROUP                      CACTI_USER
                   9131: CANNA_GROUP                      CANNA_USER
                   9132: CAT                              CCACHE_BASE
                   9133: CCACHE_DIR                       CCACHE_LOGFILE
                   9134: CC_VERSION                       CC_VERSION_STRING
                   9135: CDRECORD_CONF                    CDROM_PKG_URL_DIR
                   9136: CDROM_PKG_URL_HOST               CHECKOUT_DATE
                   9137: CHECK_COMPILER                   CHECK_FAKEHOME
                   9138: CHECK_FILES                      CHECK_FILES_SKIP
                   9139: CHECK_FILES_STRICT               CHECK_HEADERS
                   9140: CHECK_HEADERS_SKIP               CHECK_INTERPRETER
                   9141: CHECK_INTERPRETER_SKIP           CHECK_PERMS
                   9142: CHECK_PERMS_AUTOFIX              CHECK_PERMS_SKIP
                   9143: CHECK_PORTABILITY                CHECK_PORTABILITY_EXPERIMENTAL
                   9144: CHECK_PORTABILITY_SKIP           CHECK_RELRO
                   9145: CHECK_RELRO_SKIP                 CHECK_RELRO_SUPPORTED
                   9146: CHECK_SHLIBS                     CHECK_SHLIBS_BLACKLIST
                   9147: CHECK_SHLIBS_SKIP                CHECK_SHLIBS_SUPPORTED
                   9148: CHECK_SSP                        CHECK_SSP_SKIP
                   9149: CHECK_SSP_SUPPORTED              CHECK_STRIPPED
                   9150: CHECK_STRIPPED_SKIP              CHECK_WRKREF
                   9151: CHECK_WRKREF_EXTRA_DIRS          CHECK_WRKREF_SKIP
                   9152: CLAMAV_DBDIR                     CLAMAV_GROUP
                   9153: CLAMAV_USER                      CLANGBASE
                   9154: CLEANDEPENDS                     CMAKE_DEPENDENCIES_REWRITE
                   9155: CMAKE_INSTALL_PREFIX             CMAKE_MODULE_PATH_OVERRIDE
                   9156: CMAKE_PKGSRC_BUILD_FLAGS         CMAKE_PREFIX_PATH
                   9157: CMAKE_USE_GNU_INSTALL_DIRS       COMMON_LISP_DOCFILES
                   9158: COMMON_LISP_EXAMPLES             COMMON_LISP_EXTRAFILES
                   9159: COMMON_LISP_PACKAGES             COMMON_LISP_SYSTEM
                   9160: COMPILER_RPATH_FLAG              COMPILER_USE_SYMLINKS
                   9161: CONFIGURE_ARGS                   CONFIGURE_DIRS
                   9162: CONFIGURE_ENV                    CONFIGURE_ENV_SHELL
                   9163: CONFIGURE_HAS_INFODIR            CONFIGURE_HAS_MANDIR
                   9164: CONFIGURE_SCRIPT                 CONFIG_SHELL
                   9165: CONFIG_SHELL_FLAGS               CONF_FILES
                   9166: CONF_FILES_MODE                  CONF_FILES_PERMS
                   9167: CONSERVER_DEFAULTHOST            CONSERVER_DEFAULTPORT
                   9168: CP                               CPP
                   9169: CPP_PRECOMP_FLAGS                CREATE_WRKDIR_SYMLINK
                   9170: CROSSBASE                        CTFCONVERT
                   9171: CTF_FILES_SKIP                   CTF_SUPPORTED
                   9172: CTYPE                            CUPS_GROUP
                   9173: CUPS_SYSTEM_GROUPS               CUPS_USER
                   9174: CURSES_DEFAULT                   CURSES_TYPE
                   9175: CVS_EXTRACTDIR                   CVS_MODULE
                   9176: CVS_PROJECT                      CVS_REPOSITORIES
                   9177: CVS_ROOT                         CVS_ROOT_GNU
                   9178: CVS_ROOT_NONGNU                  CVS_ROOT_SOURCEFORGE
                   9179: CVS_TAG                          CXX
                   9180: CYRUS_GROUP                      CYRUS_IDLE
                   9181: CYRUS_USER                       DAEMONTOOLS_GROUP
                   9182: DAEMONTOOLS_LOG_USER             DBUS_GROUP
                   9183: DBUS_USER                        DEFANG_GROUP
                   9184: DEFANG_USER                      DEFAULT_ACCEPTABLE_LICENSES
                   9185: DEFAULT_DISTFILES                DEFAULT_IRC_SERVER
                   9186: DEFAULT_SERIAL_DEVICE            DEF_UMASK
                   9187: DEINSTALLDEPENDS                 DEINSTALL_SRC
                   9188: DEINSTALL_TEMPLATES              DELAYED_ERROR_MSG
                   9189: DELAYED_WARNING_MSG              DEPENDS
                   9190: DEPENDS_TARGET                   DEPENDS_TYPE
                   9191: DESTDIR                          DESTDIR_VARNAME
                   9192: DIALER_GROUP                     DIGEST_REQD
                   9193: DISTDIR                          DISTFILES
                   9194: DISTINFO_FILE                    DISTNAME
                   9195: DIST_PATH                        DIST_SUBDIR
                   9196: DJBDNS_AXFR_USER                 DJBDNS_CACHE_USER
                   9197: DJBDNS_DJBDNS_GROUP              DJBDNS_LOG_USER
                   9198: DJBDNS_RBL_USER                  DJBDNS_TINY_USER
                   9199: DLOPEN_REQUIRE_PTHREADS          DL_AUTO_VARS
                   9200: DL_CFLAGS                        DL_LDFLAGS
                   9201: DL_LIBS                          DNS
                   9202: DOWNLOADED_DISTFILE              DT_LAYOUT
                   9203: DYNAMIC_SITES_CMD                DYNAMIC_SITES_SCRIPT
                   9204: ECHO                             ECHO_N
                   9205: ELK_GUI                          EMACS_TYPE
                   9206: EMULDIR                          EMULSUBDIR
                   9207: EMULSUBDIRSLASH                  EMUL_ARCH
                   9208: EMUL_DISTRO                      EMUL_EXEC_FMT
                   9209: EMUL_IS_NATIVE                   EMUL_MODULES
                   9210: EMUL_OPSYS                       EMUL_PKG_FMT
                   9211: EMUL_PLATFORM                    EMUL_PLATFORMS
                   9212: EMUL_PREFER                      EMUL_REQD
                   9213: EMUL_TYPE                        ERROR_MSG
                   9214: EXIM_GROUP                       EXIM_USER
                   9215: EXPORT_SYMBOLS_LDFLAGS           EXTRACTOR
                   9216: EXTRACT_CMD                      EXTRACT_CMD_DEFAULT
                   9217: EXTRACT_DIR                      EXTRACT_ELEMENTS
                   9218: EXTRACT_ENV                      EXTRACT_ONLY
                   9219: EXTRACT_OPTS                     EXTRACT_SUFX
                   9220: EXTRACT_USING                    FAIL
                   9221: FAILOVER_FETCH                   FAIL_MSG
                   9222: FAKE_NCURSES                     FAM
                   9223: FAM_ACCEPTED                     FAM_DEFAULT
                   9224: FAM_SERVER                       FCPATH
                   9225: FEATURE_CPPFLAGS                 FEATURE_LDFLAGS
                   9226: FEATURE_LIBS                     FETCH_AFTER_ARGS
                   9227: FETCH_BEFORE_ARGS                FETCH_CMD
                   9228: FETCH_OUTPUT_ARGS                FETCH_PROXY
                   9229: FETCH_RESUME_ARGS                FETCH_USING
                   9230: FILES_SUBST                      FILES_SUBST_SED
                   9231: FIX_SYSTEM_HEADERS               FLUXBOX_USE_GNOME
                   9232: FLUXBOX_USE_KDE                  FLUXBOX_USE_XFT
                   9233: FLUXBOX_USE_XINERAMA             FONTDIR
                   9234: FONTS_DIRS                       FONTS_VERBOSE
                   9235: FOO_HACKS_MK                     FOSSIL_EXTRACTDIR
                   9236: FOSSIL_REPO                      FOSSIL_REPOSITORIES
                   9237: FOSSIL_VERSION                   FOX_USE_XUNICODE
                   9238: FREEWNN_GROUP                    FREEWNN_USER
                   9239: FTP_PKG_URL_DIR                  FTP_PKG_URL_HOST
                   9240: GAMEDATAMODE                     GAMEDATA_PERMS
                   9241: GAMEDIRMODE                      GAMEDIR_PERMS
                   9242: GAMEGRP                          GAMEMODE
                   9243: GAMEOWN                          GAMES_GROUP
                   9244: GAMES_USER                       GCC
                   9245: GCCBASE                          GCC_REQD
                   9246: GCC_VERSION_SUFFIX               GEM_BUILD
                   9247: GEM_CLEANBUILD                   GEM_CLEANBUILD_EXTENSIONS
                   9248: GEM_DOCDIR                       GEM_EXTSDIR
                   9249: GEM_HOME                         GEM_KEEPBUILD
                   9250: GEM_LIBDIR                       GEM_NAME
                   9251: GEM_PATH                         GEM_SPECFILE
                   9252: GENERATE_PLIST                   GHOSTSCRIPT_REQD
                   9253: GITHUB_PROJECT                   GITHUB_RELEASE
                   9254: GITHUB_TAG                       GITHUB_TYPE
                   9255: GITLAB_PROJECT                   GITLAB_TAG
                   9256: GITLAB_TYPE                      GIT_BRANCH
                   9257: GIT_ENV                          GIT_EXTRACTDIR
                   9258: GIT_REPO                         GIT_REPOSITORIES
                   9259: GIT_REVISION                     GIT_TAG
                   9260: GNU                              GNU_CONFIGURE
                   9261: GNU_CONFIGURE_INFODIR            GNU_CONFIGURE_MANDIR
                   9262: GNU_CONFIGURE_QUIET              GNU_CONFIGURE_STRICT
                   9263: GODEP_REDIRECTS                  GO_BUILD_PATTERN
                   9264: GO_DEPS                          GO_DIST_BASE
                   9265: GO_MODULE_FILES                  GO_SRCPATH
                   9266: GO_VERSION_DEFAULT               GROUP_SPECIFIC_PKGS
                   9267: GRUB_NETWORK_CARDS               GRUB_PRESET_COMMAND
                   9268: GRUB_SCAN_ARGS                   GZIP
                   9269: HASKELL_COMPILER                 HASKELL_ENABLE_HADDOCK_DOCUMENTATION
                   9270: HASKELL_ENABLE_LIBRARY_PROFILING HASKELL_ENABLE_SHARED_LIBRARY
                   9271: HASKELL_OPTIMIZATION_LEVEL       HAS_CONFIGURE
                   9272: HEADER_TEMPLATES                 HG_REPO
                   9273: HG_REPOSITORIES                  HG_TAG
                   9274: HOST_PKGTOOLS_ARGS               HOST_SPECIFIC_PKGS
                   9275: HOWL_GROUP                       HOWL_USER
                   9276: ICCBASE                          ICECAST_CHROOTDIR
                   9277: ICON_THEMES                      IDOBASE
                   9278: IGNORE_CCACHE                    IGNORE_INFO_DIRS
                   9279: IGNORE_INTERACTIVE_FETCH         IMAKE
                   9280: IMAKEOPTS                        IMAKE_MAKE
                   9281: IMAKE_MANINSTALL                 IMAP_UW_CCLIENT_MBOX_FMT
                   9282: IMDICTDIR                        INCOMPAT_CURSES
                   9283: INFO_DIR                         INFO_FILES
                   9284: INFO_FILES_VERBOSE               INFO_MSG
                   9285: INIT_SYSTEM                      INN_DATA_DIR
                   9286: INN_GROUP                        INN_USER
                   9287: INSTALLATION_DIRS                INSTALLATION_DIRS_FROM_PLIST
                   9288: INSTALL_ENV                      INSTALL_SH_OVERRIDE
                   9289: INSTALL_SRC                      INSTALL_TEMPLATES
                   9290: INSTALL_UNSTRIPPED               IRCD_HYBRID_IRC_GROUP
                   9291: IRCD_HYBRID_IRC_USER             IRCD_HYBRID_MAXCONN
                   9292: IRCD_HYBRID_NICLEN               IRCD_HYBRID_SYSLOG_EVENTS
                   9293: IRCD_HYBRID_SYSLOG_FACILITY      IRCD_HYBRID_TOPICLEN
                   9294: IRIX                             IRRD_USE_PGP
                   9295: JABBERD_GROUP                    JABBERD_LOGDIR
                   9296: JABBERD_PIDDIR                   JABBERD_SPOOLDIR
                   9297: JABBERD_USER                     JAKARTA_HOME
                   9298: JAVA_APP_PATH                    JAVA_APP_TARGETS
                   9299: JAVA_BINPREFIX                   JAVA_CLASSPATH
                   9300: JAVA_HOME                        JAVA_LD_LIBRARY_PATH
                   9301: JAVA_NAME                        JAVA_UNLIMIT
                   9302: JAVA_WRAPPERS                    JPEG_ACCEPTED
                   9303: JPEG_DEFAULT                     KERBEROS
                   9304: KERMIT_SUID_UUCP                 KJS_USE_PCRE
                   9305: KNEWS_DOMAIN_FILE                KNEWS_DOMAIN_NAME
                   9306: KRB5_ACCEPTED                    KRB5_DEFAULT
                   9307: LANGUAGES                        LAPACK_LIBS
                   9308: LATEX2HTML_ICONPATH              LDCONFIG_ADD_CMD
                   9309: LDCONFIG_REMOVE_CMD              LEAFNODE_DATA_DIR
                   9310: LEAFNODE_GROUP                   LEAFNODE_USER
                   9311: LIBDVDCSS_HOMEPAGE               LIBDVDCSS_MASTER_SITES
                   9312: LIBRSVG_TYPE                     LIBTOOL
                   9313: LIBTOOLIZE_PLIST                 LIBTOOL_M4_OVERRIDE
                   9314: LIBUSB_TYPE                      LICENSE
                   9315: LINKER_RPATH_FLAG                LINK_RPATH_FLAG
                   9316: LINUX_BASE_NODEPS                LINUX_BASE_PREFERRED
                   9317: LINUX_BASE_REQUIRED              LINUX_LOCALES
                   9318: LOCALBASE                        LOCALBASE_LOCKTYPE
                   9319: LOCALPATCHES                     LOVE_DATA
                   9320: LOVE_GAME                        LOVE_VERSION
                   9321: LP64PLATFORMS                    MACHINE_PLATFORM
                   9322: MAILAGENT_DOMAIN                 MAILAGENT_EMAIL
                   9323: MAILAGENT_FQDN                   MAILAGENT_ORGANIZATION
                   9324: MAJORDOMO_HOMEDIR                MAJOR_OS_VERSION
                   9325: MAKEINFO_ARGS                    MAKE_DIRS
                   9326: MAKE_DIRS_PERMS                  MAKE_ENV
                   9327: MAKE_FILE                        MAKE_FLAGS
                   9328: MAKE_JOBS                        MAKE_JOBS_SAFE
                   9329: MAKE_PROGRAM                     MANINSTALL
                   9330: MANZ                             MASTER_SITES
                   9331: MASTER_SITE_BACKUP               MASTER_SITE_LOCAL
                   9332: MASTER_SITE_MOZILLA              MASTER_SITE_OVERRIDE
                   9333: MASTER_SITE_PERL_CPAN            MASTER_SORT
                   9334: MASTER_SORT_RANDOM               MASTER_SORT_REGEX
                   9335: MECAB_CHARSET                    MEDIATOMB_GROUP
                   9336: MEDIATOMB_USER                   MIPSPROBASE
                   9337: MIREDO_GROUP                     MIREDO_USER
                   9338: MISSING_FEATURES                 MKDIR
                   9339: MLDONKEY_GROUP                   MLDONKEY_HOME
                   9340: MLDONKEY_USER                    MONOTONE_GROUP
                   9341: MONOTONE_USER                    MOTIFBASE
                   9342: MOTIF_TYPE                       MOTIF_TYPE_DEFAULT
                   9343: MPI_TYPE                         MSGFMT_STRIP_MSGCTXT
                   9344: MSGFMT_STRIP_MSGID_PLURAL        MTOOLS_ENABLE_FLOPPYD
                   9345: MUST                             MV
                   9346: MYSQL_CHARSET                    MYSQL_DATADIR
                   9347: MYSQL_EXTRA_CHARSET              MYSQL_GROUP
                   9348: MYSQL_PKGSRCDIR                  MYSQL_USER
                   9349: MYSQL_VERSIONS_ACCEPTED          MYSQL_VERSION_DEFAULT
                   9350: NAGIOSCMD_GROUP                  NAGIOSDIR
                   9351: NAGIOS_GROUP                     NAGIOS_USER
                   9352: NATIVE_APPEND_ABI                NATIVE_APPEND_ELF
                   9353: NATIVE_EXEC_FMT                  NATIVE_MACHINE_PLATFORM
                   9354: NATIVE_OBJECT_FMT                NBPAX_PROGRAM_PREFIX
                   9355: NETBSD_LOGIN_NAME                NMH_EDITOR
                   9356: NMH_MTA                          NMH_PAGER
                   9357: NOLOGIN                          NOTE
                   9358: NOT_FOR_PLATFORM                 NOT_PAX_ASLR_SAFE
                   9359: NOT_PAX_MPROTECT_SAFE            NO_BUILD
                   9360: NO_CHECKSUM                      NO_CONFIGURE
                   9361: NO_SKIP                          NS_PREFERRED
                   9362: NULLMAILER_GROUP                 NULLMAILER_USER
                   9363: OASIS                            OASIS_BUILD_ARGS
                   9364: OBJHOSTNAME                      OBJMACHINE
                   9365: OCAML_FINDLIB_DIRS               OCAML_FINDLIB_REGISTER
                   9366: OCAML_FINDLIB_REGISTER_VERBOSE   OCAML_SITELIBDIR
                   9367: OCAML_TOPKG_DOCDIR               OCAML_USE_DUNE
                   9368: OCAML_USE_FINDLIB                OCAML_USE_JBUILDER
                   9369: OCAML_USE_OASIS                  OCAML_USE_OASIS_DYNRUN
                   9370: OCAML_USE_OPAM                   OCAML_USE_OPT_COMPILER
                   9371: OCAML_USE_TOPKG                  OMF
                   9372: ONLY_FOR_COMPILER                ONLY_FOR_PLATFORM
                   9373: OPENSSH_CHROOT                   OPENSSH_GROUP
                   9374: OPENSSH_USER                     OPSYS
                   9375: OPSYS_EMULDIR                    OSS_TYPE
                   9376: OSX                              OSX_TOLERATE_SDK_SKEW
                   9377: OS_HAVE_ALSA                     OS_HAVE_RCD
                   9378: OS_VARIANT                       OS_VERSION
                   9379: OTF_FONTS_DIR                    OVERRIDE_DIRDEPTH
                   9380: OVERRIDE_GEMSPEC                 OVERRIDE_GNU_CONFIG_SCRIPTS
                   9381: OVERRIDE_ROCKSPEC                OWN_DIRS
                   9382: OWN_DIRS_PERMS                   P4GROUP
                   9383: P4PORT                           P4ROOT
                   9384: P4USER                           PACKAGES
                   9385: PALMOS_DEFAULT_SDK               PAMBASE
                   9386: PAM_DEFAULT                      PAPERSIZE
                   9387: PASSIVE_FETCH                    PATCHDIR
                   9388: PATCHFILES                       PATCH_ARGS
                   9389: PATCH_DEBUG                      PATCH_DIST_ARGS
                   9390: PATCH_DIST_CAT                   PATCH_DIST_STRIP
                   9391: PATCH_FUZZ_FACTOR                PATCH_STRIP
                   9392: PATH                             PCCBASE
                   9393: PEAR                             PEAR_CHANNEL
                   9394: PEAR_CHANNEL_ALIAS               PEAR_CHANNEL_VERSION
                   9395: PEAR_CMD                         PEAR_LIB
                   9396: PEAR_PACKAGE_XML                 PERL5
                   9397: PERL5_CONFIGURE                  PERL5_CONFIGURE_DIRS
                   9398: PERL5_LDFLAGS                    PERL5_LICENSE
                   9399: PERL5_MODULE_TYPE                PERL5_PACKLIST
                   9400: PERL5_PACKLIST_DIR               PERL5_PERLBASE
                   9401: PERL5_SITEBASE                   PERL5_USE_PACKLIST
                   9402: PERL5_VENDORBASE                 PFCTL
                   9403: PFVAR_H                          PF_VERSION
                   9404: PGGROUP                          PGHOME
                   9405: PGPKGSRCDIR                      PGSQL_TYPE
                   9406: PGSQL_VERSIONS_ACCEPTED          PGSQL_VERSION_DEFAULT
                   9407: PGUSER                           PG_LIB_EXT
                   9408: PHP                              PHPCOMMON_MK
                   9409: PHPPKGSRCDIR                     PHP_BASE_VERS
                   9410: PHP_CHECK_INSTALLED              PHP_EXTENSION_DIR
                   9411: PHP_INITIAL_TEENY                PHP_PKG_PREFIX
                   9412: PHP_VERSION                      PHP_VERSIONS_ACCEPTED
                   9413: PHP_VERSIONS_INCOMPATIBLE        PHP_VERSION_DEFAULT
                   9414: PHP_VERSION_REQD                 PILRC_USE_GTK
                   9415: PKGCONFIG_BASE                   PKGCONFIG_FILE
                   9416: PKGCONFIG_OVERRIDE               PKGCONFIG_OVERRIDE_STAGE
                   9417: PKGDIR                           PKGGNUDIR
                   9418: PKGINFODIR                       PKGLOCALEDIR
                   9419: PKGMANDIR                        PKGNAME
                   9420: PKGNAME_REQD                     PKGPATH
                   9421: PKGREVISION                      PKGSRC_BLAS_TYPES
                   9422: PKGSRC_CHANGES                   PKGSRC_COMPILER
                   9423: PKGSRC_KEEP_BIN_PKGS             PKGSRC_LOCKTYPE
                   9424: PKGSRC_MAKE_ENV                  PKGSRC_MESSAGE_RECIPIENTS
                   9425: PKGSRC_MKPIE                     PKGSRC_MKREPRO
                   9426: PKGSRC_RUN_TEST                  PKGSRC_SETENV
                   9427: PKGSRC_SLEEPSECS                 PKGSRC_TODO
                   9428: PKGSRC_USE_CTF                   PKGSRC_USE_FORTIFY
                   9429: PKGSRC_USE_RELRO                 PKGSRC_USE_SSP
                   9430: PKGSRC_USE_STACK_CHECK           PKGTASKS_DATAFILE
                   9431: PKGTOOLS_ARGS                    PKGTOOLS_ENV
                   9432: PKG_ALTERNATIVES                 PKG_APACHE
                   9433: PKG_APACHE_ACCEPTED              PKG_APACHE_DEFAULT
                   9434: PKG_BEST_EXISTS                  PKG_BUILD_OPTIONS
                   9435: PKG_COMPRESSION                  PKG_CONFIG
                   9436: PKG_CONFIG_PERMS                 PKG_CREATE_USERGROUP
                   9437: PKG_DB_TMPDIR                    PKG_DEBUG_LEVEL
                   9438: PKG_DEFAULT_OPTIONS              PKG_DESTDIR_SUPPORT
                   9439: PKG_DEVELOPER                    PKG_DISABLED_OPTIONS
                   9440: PKG_FATAL_ERRORS                 PKG_FC
                   9441: PKG_FILELIST_CMD                 PKG_GECOS
                   9442: PKG_GID                          PKG_GROUPS
                   9443: PKG_GROUPS_VARS                  PKG_HOME
                   9444: PKG_INIT_SCRIPTS                 PKG_JAVA_HOME
                   9445: PKG_JVM                          PKG_JVMS_ACCEPTED
                   9446: PKG_JVM_DEFAULT                  PKG_LEGACY_OPTIONS
                   9447: PKG_LIBTOOL                      PKG_OPTIONS
                   9448: PKG_OPTIONS_DEPRECATED_WARNINGS  PKG_OPTIONS_LEGACY_OPTS
                   9449: PKG_OPTIONS_LEGACY_VARS          PKG_OPTIONS_NONEMPTY_SETS
                   9450: PKG_OPTIONS_OPTIONAL_GROUPS      PKG_OPTIONS_REQUIRED_GROUPS
                   9451: PKG_OPTIONS_VAR                  PKG_PHP
                   9452: PKG_PHP_MAJOR_VERS               PKG_PHP_VERSION
                   9453: PKG_RCD_SCRIPTS                  PKG_REFCOUNT_DBDIR
                   9454: PKG_REGISTER_SHELLS              PKG_RESUME_TRANSFERS
                   9455: PKG_SHELL                        PKG_SUGGESTED_OPTIONS
                   9456: PKG_SUPPORTED_OPTIONS            PKG_SYSCONFBASE
                   9457: PKG_SYSCONFBASEDIR               PKG_SYSCONFDIR
                   9458: PKG_SYSCONFDIR_PERMS             PKG_SYSCONFSUBDIR
                   9459: PKG_SYSCONFVAR                   PKG_TOOLS_BIN
                   9460: PKG_UID                          PKG_UPDATE_FONTS_DB
                   9461: PKG_USERS                        PKG_USERS_VARS
                   9462: PKG_VERBOSE                      PLIST
                   9463: PLIST_AWK                        PLIST_AWK_ENV
                   9464: PLIST_SRC                        PLIST_SUBST
                   9465: PLIST_TYPE                       PLIST_VARS
                   9466: POPTOP_USE_MPPE                  POSSIBLE_GFORTRAN_VERSION
                   9467: POST_FETCH_HOOK                  PREFER
                   9468: PREFER_NATIVE                    PREFER_NATIVE_PTHREADS
                   9469: PREFER_PKGSRC                    PREFIX
                   9470: PREPEND_PATH                     PRE_ROOT_CMD
                   9471: PRIVILEGED_STAGES                PS
                   9472: PTHREAD_AUTO_VARS                PTHREAD_CFLAGS
                   9473: PTHREAD_LDFLAGS                  PTHREAD_LIBS
                   9474: PTHREAD_OPTS                     PTHREAD_TYPE
                   9475: PVM_SSH                          PYPKGPREFIX
                   9476: PYTHON_FOR_BUILD_ONLY            PYTHON_SELF_CONFLICT
                   9477: PYTHON_VERSIONED_DEPENDENCIES    PYTHON_VERSIONS_ACCEPTED
                   9478: PYTHON_VERSIONS_INCOMPATIBLE     PYTHON_VERSION_DEFAULT
                   9479: PYTHON_VERSION_REQD              PYVERSSUFFIX
                   9480: PY_NO_EGG                        QMAILDIR
                   9481: QMAIL_ALIAS_USER                 QMAIL_DAEMON_USER
                   9482: QMAIL_LOG_USER                   QMAIL_NOFILES_GROUP
                   9483: QMAIL_PASSWD_USER                QMAIL_QMAIL_GROUP
                   9484: QMAIL_QUEUE_DIR                  QMAIL_QUEUE_EXTRA
                   9485: QMAIL_QUEUE_USER                 QMAIL_REMOTE_USER
                   9486: QMAIL_ROOT_USER                  QMAIL_SEND_USER
                   9487: QPOPPER_FAC                      QPOPPER_SPOOL_DIR
                   9488: QPOPPER_USER                     RAKE_NAME
                   9489: RASMOL_DEPTH                     RCD_DIR
                   9490: RCD_ORDER                        RCD_SCRIPTS
                   9491: RCD_SCRIPTS_DIR                  RCD_SCRIPTS_EXAMPLEDIR
                   9492: RCD_SCRIPTS_MODE                 RCD_SCRIPTS_SHELL
                   9493: RCD_SCRIPT_SRC                   RCD_SUBR
                   9494: RDOC                             READLINE_DEFAULT
                   9495: READLINE_TYPE                    REAL_ROOT_GROUP
                   9496: REAL_ROOT_USER                   RECURSIVE_MAKE
                   9497: RELAY_CTRL_DIR                   REPLACE_AWK
                   9498: REPLACE_BASH                     REPLACE_CSH
                   9499: REPLACE_KSH                      REPLACE_PERL
                   9500: REPLACE_PERL6                    REPLACE_PHP
                   9501: REPLACE_PYTHON                   REPLACE_RUBY
                   9502: REPLACE_RUBY_DIRS                REPLACE_RUBY_PAT
                   9503: REPLACE_SH                       REPLACE_TEXLUA
                   9504: REQD_DIRS                        REQD_DIRS_PERMS
                   9505: REQD_FILES                       REQD_FILES_MODE
                   9506: REQD_FILES_PERMS                 RESOLV_AUTO_VARS
                   9507: RESOLV_LDFLAGS                   RESOLV_LIBS
                   9508: RM                               ROCKSPEC_NAME
                   9509: ROCKSPEC_SPECFILE                ROOT_CMD
                   9510: ROOT_GROUP                       ROOT_USER
                   9511: RPCGEN                           RPM
                   9512: RPM2PKG_PLIST                    RPM2PKG_PREFIX
                   9513: RPM2PKG_STAGE                    RPM2PKG_STRIP
                   9514: RPM2PKG_SUBPREFIX                RPMFILES
                   9515: RPMIGNOREPATH                    RPM_DB_PREFIX
                   9516: RSSH_CVS_PATH                    RSSH_RDIST_PATH
                   9517: RSSH_RSYNC_PATH                  RSSH_SCP_PATH
                   9518: RSSH_SFTP_SERVER_PATH            RUBY
                   9519: RUBYGEM                          RUBYGEM_NAME
                   9520: RUBYGEM_OPTIONS                  RUBY_ABI_VERSION
                   9521: RUBY_ARCH                        RUBY_ARCHINC
                   9522: RUBY_ARCHLIB                     RUBY_BASE
                   9523: RUBY_BASERIDIR                   RUBY_BUILD_DOCUMENT
                   9524: RUBY_DLEXT                       RUBY_DOC
                   9525: RUBY_DYNAMIC_DIRS                RUBY_EG
                   9526: RUBY_ENCODING_ARG                RUBY_EXTCONF
                   9527: RUBY_EXTCONF_CHECK               RUBY_EXTCONF_DEBUG
                   9528: RUBY_EXTCONF_MAKEFILE            RUBY_GEM_BASE
                   9529: RUBY_INC                         RUBY_LIB
                   9530: RUBY_LIB_BASE                    RUBY_NAME
                   9531: RUBY_NOVERSION                   RUBY_PKGPREFIX
                   9532: RUBY_RAILS                       RUBY_RAILS51_VERSION
                   9533: RUBY_RAILS52_VERSION             RUBY_RAILS60_VERSION
                   9534: RUBY_RAILS_ACCEPTED              RUBY_RAILS_DEFAULT
                   9535: RUBY_RAILS_REQD                  RUBY_RAILS_STRICT_DEP
                   9536: RUBY_RIDIR                       RUBY_SETUP
                   9537: RUBY_SHLIB                       RUBY_SHLIBALIAS
                   9538: RUBY_SHLIBVER                    RUBY_SIMPLE_INSTALL
                   9539: RUBY_SITEARCHLIB                 RUBY_SITELIB
                   9540: RUBY_SITELIB_BASE                RUBY_SITERIDIR
                   9541: RUBY_SLEXT                       RUBY_SRCDIR
                   9542: RUBY_STATICLIB                   RUBY_SUFFIX
                   9543: RUBY_SYSRIDIR                    RUBY_USE_PTHREAD
                   9544: RUBY_VENDORARCHLIB               RUBY_VENDORLIB
                   9545: RUBY_VENDORLIB_BASE              RUBY_VER
                   9546: RUBY_VERSION                     RUBY_VERSIONS_ACCEPTED
                   9547: RUBY_VERSIONS_INCOMPATIBLE       RUBY_VERSION_DEFAULT
                   9548: RUBY_VERSION_REQD                RUBY_VER_DIR
                   9549: RUN                              RUN_LDCONFIG
                   9550: SAWFISH_THEMES                   SCO
                   9551: SCREWS_GROUP                     SCREWS_USER
                   9552: SCRIPTS_ENV                      SCROLLKEEPER_DATADIR
                   9553: SCROLLKEEPER_REBUILDDB           SCROLLKEEPER_UPDATEDB
                   9554: SDIST_PAWD                       SERIAL_DEVICES
                   9555: SETGIDGAME                       SETGID_GAMES_PERMS
                   9556: SETUID_ROOT_PERMS                SH
                   9557: SHLIB                            SHORTNAME
                   9558: SIGN_PACKAGES                    SILC_CLIENT_WITH_PERL
                   9559: SITE_SPECIFIC_PKGS               SKIP_DEPENDS
                   9560: SMF_INSTANCES                    SMF_MANIFEST
                   9561: SMF_METHODS                      SMF_METHOD_SHELL
                   9562: SMF_METHOD_SRC                   SMF_NAME
                   9563: SMF_PREFIX                       SMF_SRCDIR
                   9564: SNIPROXY_GROUP                   SNIPROXY_USER
                   9565: SOURCE_BUFFSIZE                  SPECIAL_PERMS
                   9566: SPECIFIC_PKGS                    SSH_SUID
                   9567: SSP_SUPPORTED                    SSYNC_PAWD
                   9568: STEP_MSG                         STRIP
                   9569: STRIP_DBG                        STRIP_DEBUG
                   9570: STRIP_DEBUG_SUPPORTED            STRIP_FILES_SKIP
                   9571: SU                               SUBDIR
                   9572: SUBST                            SUBST_CLASSES
                   9573: SUBST_FILES                      SUBST_FILTER_CMD
                   9574: SUBST_MESSAGE                    SUBST_NOOP_OK
                   9575: SUBST_SED                        SUBST_SHOW_DIFF
                   9576: SUBST_SKIP_TEXT_CHECK            SUBST_STAGE
                   9577: SUBST_VARS                       SUNWSPROBASE
                   9578: SUSE_PREFER                      SU_CMD
                   9579: SVN_EXTRACTDIR                   SVN_REPO
                   9580: SVN_REPOSITORIES                 SVN_REVISION
                   9581: TERMCAP_TYPE                     TERMINFO_DEFAULT
                   9582: TERMINFO_TYPE                    TEST
                   9583: TEST_DEPENDS                     TEST_DIRS
                   9584: TEST_ENV                         TEST_ENV_SHELL
                   9585: TEST_MAKE_CMD                    TEST_MAKE_FLAGS
                   9586: TEST_TARGET                      TEXLIVE_IGNORE_PATTERNS
                   9587: TEXLIVE_REV                      TEXLIVE_UNVERSIONED
                   9588: TEXMFSITE                        TEX_FORMATS
                   9589: TEX_HYPHEN_DAT                   TEX_HYPHEN_DEF
                   9590: TEX_TEXMF_DIRS                   THTTPD_LOG_FACILITY
                   9591: TO                               TOOLS_ALIASES
                   9592: TOOLS_ALWAYS_WRAP                TOOLS_ARGS
                   9593: TOOLS_BROKEN                     TOOLS_CMD
                   9594: TOOLS_CREATE                     TOOLS_DIR
                   9595: TOOLS_FAIL                       TOOLS_GNU_MISSING
                   9596: TOOLS_LDCONFIG                   TOOLS_NOOP
                   9597: TOOLS_PATH                       TOOLS_SCRIPT
                   9598: TOOL_DEPENDS                     TTF_FONTDIR
                   9599: TTF_FONTS_DIR                    TYPE
                   9600: UAC_REQD_EXECS                   UCSPI_SSL_GROUP
                   9601: UCSPI_SSL_USER                   UNLIMIT_RESOURCES
                   9602: UNPRIVILEGED                     UNPRIVILEGED_GROUP
                   9603: UNPRIVILEGED_GROUPS              UNPRIVILEGED_USER
                   9604: UNWRAP_FILES                     UNWRAP_PATTERNS
                   9605: UPDATE_GEMSPEC                   UPDATE_TARGET
                   9606: URI                              USERGROUP_PHASE
                   9607: USERPPP_GROUP                    USER_SPECIFIC_PKGS
                   9608: USE_ABI_DEPENDS                  USE_APR
                   9609: USE_BSD_MAKEFILE                 USE_BUILTIN
                   9610: USE_CROSS_COMPILE                USE_CURSES
                   9611: USE_CWRAPPERS                    USE_DB185
                   9612: USE_FEATURES                     USE_GAMESGROUP
                   9613: USE_GCC_RUNTIME                  USE_IMAKE
                   9614: USE_JAVA                         USE_JAVA2
                   9615: USE_LANGUAGES                    USE_LIBTOOL
                   9616: USE_NATIVE_GCC                   USE_NETBSD_REPO
                   9617: USE_PKGSRC_GCC                   USE_PKGSRC_GCC_RUNTIME
                   9618: USE_PKGTASKS                     USE_PKG_ADMIN_DIGEST
                   9619: USE_RUBY_EXTCONF                 USE_RUBY_INSTALL
                   9620: USE_RUBY_SETUP                   USE_RUBY_SETUP_PKG
                   9621: USE_TOOLS                        UUCP_GROUP
                   9622: UUCP_USER                        VARBASE
                   9623: VARNAME                          VIM_EXTRA_OPTS
                   9624: WARNING_MSG                      WCALC_CGIDIR
                   9625: WCALC_CGIPATH                    WCALC_HTMLDIR
                   9626: WCALC_HTMLPATH                   WDM_MANAGERS
                   9627: WRAPPER_REORDER_CMDS             WRKDIR
                   9628: WRKDIR_BASENAME                  WRKDIR_LOCKTYPE
                   9629: WRKLOG                           WRKOBJDIR
                   9630: WRKSRC                           X10_PORT
                   9631: X11                              X11BASE
                   9632: X11_PKGSRCDIR                    X11_TYPE
                   9633: X509_CERTIFICATE                 X509_KEY
                   9634: XAW_TYPE                         XLOCK_DEFAULT_MODE
                   9635: XMKMF_FLAGS                      XXX
                   9636: XXXX                             YES
                   9637: ZSH_STATIC                       __stdc__
                   9638: _vargroups                       accept
                   9639: acquire-localbase-lock           acquire-lock
                   9640: add                              administrator
                   9641: alloca                           alternatives
                   9642: aslr                             asprintf
                   9643: atlas                            autoconf
                   9644: automake                         autoreconf
                   9645: awk                              bash
                   9646: big-endian                       bin-install
                   9647: bind                             binpkg-list
                   9648: blas                             bootstrap-depends
                   9649: broken                           broken_on_platform
                   9650: bsd                              bsd.prog.mk
                   9651: build                            build-env
                   9652: buildlink-directories            buildlink-oss-soundcard-h
                   9653: c                                c++
                   9654: ccache                           cce
                   9655: cdefs                            ceil
                   9656: changes                          changes-entry
                   9657: changes-entry-noupdate           check
                   9658: check-clean                      check-files
                   9659: check-files-clean                check-vulnerable
                   9660: checksum                         checksum-phase
                   9661: clean                            clean-depends
                   9662: cleandir                         commit
                   9663: commit-changes-entry             compact
                   9664: compiler                         conf
                   9665: config.guess                     config.sub
                   9666: configuration                    configure
                   9667: configure-env                    configure-help
                   9668: configure_args                   connect
                   9669: cos                              cputime
                   9670: create-usergroup                 csh
                   9671: ctf                              cvs
                   9672: debug                            declaration
                   9673: declare                          defined
                   9674: depend                           dependencies
                   9675: depends                          depends-checksum
                   9676: depends-fetch                    deps
                   9677: describe                         destdir
                   9678: disable                          distclean
                   9679: distinfo                         dl
                   9680: dlopen                           do-build
                   9681: do-buildlink                     do-clean
                   9682: do-configure                     do-configure-post-hook
                   9683: do-extract                       do-fetch
                   9684: do-install                       emul
                   9685: emul-distinfo                    emul-fetch
                   9686: emulation                        emulator
                   9687: enable                           endian
                   9688: endif                            enomem
                   9689: err                              errx
                   9690: etc                              exp
                   9691: extract-rpm                      fabs
                   9692: feature                          features
                   9693: fetch                            fetch-list
                   9694: follows                          forbids
                   9695: form                             format
                   9696: fortify                          fortify_source
                   9697: fossil                           friend
                   9698: fts                              fts_close
                   9699: fts_open                         fts_read
                   9700: fts_set                          gcc
                   9701: gethostbyaddr                    gethostbyname
                   9702: gethostbyname2                   getopt_long
                   9703: getprogname                      getservbyname
                   9704: getservbyport                    getservent
                   9705: gettext                          git
                   9706: github                           gitlab
                   9707: glob                             gnu
                   9708: gnu_configure_strict             go
                   9709: go-deps                          golang
                   9710: guess-license                    hashbang
                   9711: heimdal                          help
                   9712: hg                               imake
                   9713: increment                        inet_aton
                   9714: interp                           interpreter
                   9715: intl                             iso
                   9716: kerberos                         krb
                   9717: krb5                             ksh
                   9718: lapack                           latex
                   9719: libintl_bindtextdomain           libintl_gettext
                   9720: libintl_textdomain               libnbcompat
                   9721: libs                             libtool
                   9722: licence                          license
                   9723: lintl                            little-endian
                   9724: lock                             locking
                   9725: lvalue                           make
                   9726: makesum                          memory
                   9727: mercurial                        meta
                   9728: meta-package                     meta_package
                   9729: mit-krb5                         mk.conf
                   9730: mkl                              mount
                   9731: mprotect                         mremap
                   9732: nb                               nbcompat
                   9733: obstack                          obstack_ptr_grow
                   9734: occurs                           only
                   9735: openblas                         options
                   9736: options.mk                       order
                   9737: override                         override-intltool
                   9738: override-message-intltool        package
                   9739: parallel                         path
                   9740: pax                              paxctl
                   9741: pbulk-index                      pc
                   9742: perl                             perl5
                   9743: perms                            php
                   9744: pkg-build-options                pkg-config
                   9745: pkg_build_options                platform
                   9746: plist                            post-extract
                   9747: post-fetch                       post-wrapper
                   9748: pre-build-checks-hook            pre-configure
                   9749: pre-configure-checks-hook        pre-extract
                   9750: pre-fetch                        print-go-deps
                   9751: print-plist                      print-summary-data
                   9752: privileged-install-hook          pypi
                   9753: python                           readme-all
                   9754: recv                             recvfrom
                   9755: regcomp                          release-localbase-lock
                   9756: release-lock                     relro
                   9757: rename                           reorder
                   9758: replace                          replace_interpreter
                   9759: reproducible                     resolv
                   9760: root                             ruby
                   9761: send                             sendfile
                   9762: sendto                           setenv
                   9763: setgid                           setprogname
                   9764: setuid                           sh
1.181   ! rillig   9765: shebang                          show
        !          9766: show-all                         show-build-defs
        !          9767: show-depends                     show-deps
        !          9768: show-distfiles                   show-downlevel
        !          9769: show-subdir-var                  show-tools
        !          9770: show-var                         show-vars
        !          9771: snprintf                         socket
        !          9772: ssp                              st_mode
        !          9773: stage-install                    strcasestr
        !          9774: strict                           strip
        !          9775: strndup                          strnlen
        !          9776: strsep                           subst
        !          9777: substitutions                    subversion
        !          9778: sun                              sunpro
        !          9779: sunwspro                         svn
        !          9780: symlink                          test
        !          9781: test-env                         tex
        !          9782: texlive                          tmp
        !          9783: tool                             tools
        !          9784: tools-libtool-m4-override        type
        !          9785: ulimit                           undefined
        !          9786: undo-replace                     unlimit
        !          9787: unprivileged                     unprivileged-install-hook
        !          9788: unstripped                       update
        !          9789: upload                           upload-distfiles
        !          9790: use_tools                        user
        !          9791: utimes                           vasprintf
        !          9792: verbose                          vsnprintf
        !          9793: warn                             warning
        !          9794: warnings                         warnx
        !          9795: wattr_off                        wattr_on
        !          9796: work                             wrapper
        !          9797: wrkdir                            
1.154     rillig   9798: 
                   9799: Appendix E. Editing guidelines for the pkgsrc guide
1.1       dsieger  9800: 
                   9801: Table of Contents
                   9802: 
1.154     rillig   9803: E.1. Make targets
                   9804: E.2. Procedure
1.1       dsieger  9805: 
                   9806: This section contains information on editing the pkgsrc guide itself.
                   9807: 
1.154     rillig   9808: E.1. Make targets
1.1       dsieger  9809: 
                   9810: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
                   9811: files are created from it:
                   9812: 
                   9813:   * pkgsrc/doc/pkgsrc.txt
                   9814: 
                   9815:   * pkgsrc/doc/pkgsrc.html
                   9816: 
1.174     leot     9817:   * https://www.NetBSD.org/docs/pkgsrc/
1.1       dsieger  9818: 
1.174     leot     9819:   * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the
                   9820:     pkgsrc guide.
1.1       dsieger  9821: 
1.174     leot     9822:   * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
1.2       rillig   9823:     pkgsrc guide.
1.1       dsieger  9824: 
1.154     rillig   9825: E.2. Procedure
1.1       dsieger  9826: 
                   9827: The procedure to edit the pkgsrc guide is:
                   9828: 
                   9829:  1. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46      obache   9830:     other XML-based NetBSD documentation) installed. These are automatically
                   9831:     installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1       dsieger  9832: 
                   9833:  2. Run cd doc/guide to get to the right directory. All further steps will take
                   9834:     place here.
                   9835: 
                   9836:  3. Edit the XML file(s) in files/.
                   9837: 
                   9838:  4. Run bmake to check the pkgsrc guide for valid XML and to build the final
                   9839:     output files. If you get any errors at this stage, you can just edit the
                   9840:     files, as there are only symbolic links in the working directory, pointing
                   9841:     to the files in files/.
                   9842: 
                   9843:  5. (cd files && cvs commit)
                   9844: 
                   9845:  6. Run bmake clean && bmake to regenerate the output files with the proper RCS
                   9846:     Ids.
                   9847: 
                   9848:  7. Run bmake regen to install and commit the files in both pkgsrc/doc and
                   9849:     htdocs.
                   9850: 
                   9851:     Note
                   9852: 
                   9853:     If you have added, removed or renamed some chapters, you need to
                   9854:     synchronize them using cvs add or cvs delete in the htdocs directory.
                   9855: 

CVSweb <webmaster@jp.NetBSD.org>