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

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
                    105:         8.2. Running a pbulk-style 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.178   ! rillig    112:             8.4.1. Strict SUBST blocks
        !           113:             8.4.2. Detect unknown configure options
        !           114:             8.4.3. Detect classes of bugs by forcing compiler warnings
        !           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
        !           122:             8.4.11. Select random sets of options
        !           123:             8.4.12. Select random configurations of BUILD_DEFS
        !           124: 
        !           125:         8.5. Creating a multiple CD-ROM packages collection
        !           126: 
        !           127:             8.5.1. Example of cdpack
1.6       rillig    128: 
1.154     rillig    129:     9. Directory layout of the installed files
1.6       rillig    130: 
1.154     rillig    131:         9.1. File system layout in ${LOCALBASE}
                    132:         9.2. File system layout in ${VARBASE}
1.6       rillig    133: 
1.154     rillig    134:     10. Frequently Asked Questions
1.6       rillig    135: 
1.154     rillig    136:         10.1. Are there any mailing lists for pkg-related discussion?
                    137:         10.2. Utilities for package management (pkgtools)
                    138:         10.3. How to use pkgsrc as non-root
                    139:         10.4. How to resume transfers when fetching distfiles?
                    140:         10.5. How can I install/use modular X.org from pkgsrc?
                    141:         10.6. How to fetch files from behind a firewall
                    142:         10.7. How to fetch files from HTTPS sites
                    143:         10.8. How do I tell make fetch to do passive FTP?
                    144:         10.9. How to fetch all distfiles at once
                    145:         10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc"
1.24      wiz       146:             mean?
1.154     rillig    147:         10.11. What does "Could not find bsd.own.mk" mean?
                    148:         10.12. Using 'sudo' with pkgsrc
                    149:         10.13. How do I change the location of configuration files?
                    150:         10.14. Automated security checks
                    151:         10.15. Why do some packages ignore my CFLAGS?
                    152:         10.16. A package does not build. What shall I do?
                    153:         10.17. What does "Makefile appears to contain unresolved cvs/rcs/???
1.24      wiz       154:             merge conflicts" mean?
1.1       dsieger   155: 
                    156: II. The pkgsrc developer's guide
                    157: 
1.154     rillig    158:     11. Getting help
                    159:     12. Creating a new pkgsrc package from scratch
1.1       dsieger   160: 
1.154     rillig    161:         12.1. Common types of packages
1.1       dsieger   162: 
1.154     rillig    163:             12.1.1. Perl modules
                    164:             12.1.2. Python modules and programs
1.160     brook     165:             12.1.3. R packages
                    166:             12.1.4. TeXlive packages
1.1       dsieger   167: 
1.154     rillig    168:         12.2. Examples
1.1       dsieger   169: 
1.154     rillig    170:             12.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger   171: 
1.154     rillig    172:     13. Package components - files, directories and contents
1.1       dsieger   173: 
1.154     rillig    174:         13.1. Makefile
                    175:         13.2. distinfo
                    176:         13.3. patches/*
1.1       dsieger   177: 
1.154     rillig    178:             13.3.1. Structure of a single patch file
                    179:             13.3.2. Creating patch files
                    180:             13.3.3. Sources where the patch files come from
                    181:             13.3.4. Patching guidelines
                    182:             13.3.5. Feedback to the author
1.1       dsieger   183: 
1.154     rillig    184:         13.4. Other mandatory files
                    185:         13.5. Optional files
1.1       dsieger   186: 
1.154     rillig    187:             13.5.1. Files affecting the binary package
                    188:             13.5.2. Files affecting the build process
                    189:             13.5.3. Files affecting nothing at all
1.1       dsieger   190: 
1.154     rillig    191:         13.6. work*
                    192:         13.7. files/*
1.1       dsieger   193: 
1.154     rillig    194:     14. Programming in Makefiles
1.1       dsieger   195: 
1.154     rillig    196:         14.1. Caveats
                    197:         14.2. Makefile variables
1.1       dsieger   198: 
1.154     rillig    199:             14.2.1. Naming conventions
1.1       dsieger   200: 
1.154     rillig    201:         14.3. Code snippets
1.1       dsieger   202: 
1.154     rillig    203:             14.3.1. Adding things to a list
                    204:             14.3.2. Echoing a string exactly as-is
                    205:             14.3.3. Passing CFLAGS to GNU configure scripts
                    206:             14.3.4. Handling possibly empty variables
1.1       dsieger   207: 
1.154     rillig    208:     15. PLIST issues
1.1       dsieger   209: 
1.154     rillig    210:         15.1. RCS ID
                    211:         15.2. Semi-automatic PLIST generation
                    212:         15.3. Tweaking output of make print-PLIST
                    213:         15.4. Variable substitution in PLIST
                    214:         15.5. Man page compression
                    215:         15.6. Changing PLIST source with PLIST_SRC
                    216:         15.7. Platform-specific and differing PLISTs
                    217:         15.8. Build-specific PLISTs
                    218:         15.9. Sharing directories between packages
1.1       dsieger   219: 
1.154     rillig    220:     16. Buildlink methodology
1.1       dsieger   221: 
1.154     rillig    222:         16.1. Converting packages to use buildlink3
                    223:         16.2. Writing buildlink3.mk files
1.1       dsieger   224: 
1.154     rillig    225:             16.2.1. Anatomy of a buildlink3.mk file
                    226:             16.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
1.27      wiz       227:                 BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
1.1       dsieger   228: 
1.154     rillig    229:         16.3. Writing builtin.mk files
1.1       dsieger   230: 
1.154     rillig    231:             16.3.1. Anatomy of a builtin.mk file
                    232:             16.3.2. Global preferences for native or pkgsrc software
1.1       dsieger   233: 
1.154     rillig    234:     17. The pkginstall framework
1.1       dsieger   235: 
1.154     rillig    236:         17.1. Files and directories outside the installation prefix
1.1       dsieger   237: 
1.154     rillig    238:             17.1.1. Directory manipulation
                    239:             17.1.2. File manipulation
1.1       dsieger   240: 
1.154     rillig    241:         17.2. Configuration files
1.1       dsieger   242: 
1.154     rillig    243:             17.2.1. How PKG_SYSCONFDIR is set
                    244:             17.2.2. Telling the software where configuration files are
                    245:             17.2.3. Patching installations
                    246:             17.2.4. Disabling handling of configuration files
1.1       dsieger   247: 
1.154     rillig    248:         17.3. System startup scripts
1.1       dsieger   249: 
1.154     rillig    250:             17.3.1. Disabling handling of system startup scripts
1.1       dsieger   251: 
1.154     rillig    252:         17.4. System users and groups
                    253:         17.5. System shells
1.1       dsieger   254: 
1.154     rillig    255:             17.5.1. Disabling shell registration
1.1       dsieger   256: 
1.154     rillig    257:         17.6. Fonts
1.1       dsieger   258: 
1.154     rillig    259:             17.6.1. Disabling automatic update of the fonts databases
1.1       dsieger   260: 
1.154     rillig    261:     18. Options handling
1.1       dsieger   262: 
1.154     rillig    263:         18.1. Global default options
                    264:         18.2. Converting packages to use bsd.options.mk
                    265:         18.3. Option Names
                    266:         18.4. Determining the options of dependencies
1.1       dsieger   267: 
1.154     rillig    268:     19. The build process
1.1       dsieger   269: 
1.154     rillig    270:         19.1. Introduction
                    271:         19.2. Program location
                    272:         19.3. Directories used during the build process
                    273:         19.4. Running a phase
                    274:         19.5. The fetch phase
1.1       dsieger   275: 
1.154     rillig    276:             19.5.1. What to fetch and where to get it from
                    277:             19.5.2. How are the files fetched?
1.1       dsieger   278: 
1.154     rillig    279:         19.6. The checksum phase
                    280:         19.7. The extract phase
                    281:         19.8. The patch phase
                    282:         19.9. The tools phase
                    283:         19.10. The wrapper phase
                    284:         19.11. The configure phase
                    285:         19.12. The build phase
                    286:         19.13. The test phase
                    287:         19.14. The install phase
                    288:         19.15. The package phase
                    289:         19.16. Cleaning up
                    290:         19.17. Other helpful targets
1.1       dsieger   291: 
1.154     rillig    292:     20. Tools needed for building or running
1.1       dsieger   293: 
1.154     rillig    294:         20.1. Tools for pkgsrc builds
                    295:         20.2. Tools needed by packages
                    296:         20.3. Tools provided by platforms
1.1       dsieger   297: 
1.154     rillig    298:     21. Making your package work
1.1       dsieger   299: 
1.154     rillig    300:         21.1. General operation
1.1       dsieger   301: 
1.154     rillig    302:             21.1.1. How to pull in user-settable variables from mk.conf
                    303:             21.1.2. User interaction
                    304:             21.1.3. Handling licenses
                    305:             21.1.4. Restricted packages
                    306:             21.1.5. Handling dependencies
                    307:             21.1.6. Handling conflicts with other packages
                    308:             21.1.7. Packages that cannot or should not be built
                    309:             21.1.8. Packages which should not be deleted, once installed
                    310:             21.1.9. Handling packages with security problems
                    311:             21.1.10. How to handle incrementing versions when fixing an
1.1       dsieger   312:                 existing package
1.154     rillig    313:             21.1.11. Substituting variable text in the package files (the SUBST
1.1       dsieger   314:                 framework)
                    315: 
1.154     rillig    316:         21.2. The fetch phase
1.1       dsieger   317: 
1.154     rillig    318:             21.2.1. Packages whose distfiles aren't available for plain
1.1       dsieger   319:                 downloading
1.154     rillig    320:             21.2.2. How to handle modified distfiles with the 'old' name
                    321:             21.2.3. Packages hosted on github.com
1.1       dsieger   322: 
1.154     rillig    323:         21.3. The configure phase
1.1       dsieger   324: 
1.154     rillig    325:             21.3.1. Shared libraries - libtool
                    326:             21.3.2. Using libtool on GNU packages that already support libtool
                    327:             21.3.3. GNU Autoconf/Automake
                    328: 
                    329:         21.4. Programming languages
                    330: 
                    331:             21.4.1. C, C++, and Fortran
                    332:             21.4.2. Java
                    333:             21.4.3. Packages containing perl scripts
                    334:             21.4.4. Packages containing shell scripts
                    335:             21.4.5. Other programming languages
                    336: 
                    337:         21.5. The build phase
                    338: 
                    339:             21.5.1. Compiling C and C++ code conditionally
                    340:             21.5.2. How to handle compiler bugs
1.172     rillig    341:             21.5.3. No such file or directory
                    342:             21.5.4. Undefined reference to "..."
                    343:             21.5.5. Running out of memory
1.154     rillig    344: 
                    345:         21.6. The install phase
                    346: 
                    347:             21.6.1. Creating needed directories
                    348:             21.6.2. Where to install documentation
                    349:             21.6.3. Installing highscore files
                    350:             21.6.4. Adding DESTDIR support to packages
                    351:             21.6.5. Packages with hardcoded paths to other interpreters
                    352:             21.6.6. Packages installing perl modules
                    353:             21.6.7. Packages installing info files
                    354:             21.6.8. Packages installing man pages
                    355:             21.6.9. Packages installing GConf data files
                    356:             21.6.10. Packages installing scrollkeeper/rarian data files
                    357:             21.6.11. Packages installing X11 fonts
                    358:             21.6.12. Packages installing GTK2 modules
                    359:             21.6.13. Packages installing SGML or XML data
                    360:             21.6.14. Packages installing extensions to the MIME database
                    361:             21.6.15. Packages using intltool
                    362:             21.6.16. Packages installing startup scripts
                    363:             21.6.17. Packages installing TeX modules
                    364:             21.6.18. Packages supporting running binaries in emulation
                    365:             21.6.19. Packages installing hicolor theme icons
                    366:             21.6.20. Packages installing desktop files
                    367: 
                    368:         21.7. Marking packages as having problems
                    369: 
                    370:     22. Debugging
                    371:     23. Submitting and Committing
                    372: 
                    373:         23.1. Submitting binary packages
                    374:         23.2. Submitting source packages (for non-NetBSD-developers)
                    375:         23.3. General notes when adding, updating, or removing packages
                    376:         23.4. Commit Messages
                    377:         23.5. Committing: Adding a package to CVS
                    378:         23.6. Updating a package to a newer version
                    379:         23.7. Renaming a package in pkgsrc
                    380:         23.8. Moving a package in pkgsrc
                    381: 
                    382:     24. Frequently Asked Questions
                    383:     25. GNOME packaging and porting
                    384: 
                    385:         25.1. Meta packages
                    386:         25.2. Packaging a GNOME application
                    387:         25.3. Updating GNOME to a newer version
                    388:         25.4. Patching guidelines
1.1       dsieger   389: 
                    390: III. The pkgsrc infrastructure internals
                    391: 
1.154     rillig    392:     26. Design of the pkgsrc infrastructure
1.1       dsieger   393: 
1.154     rillig    394:         26.1. The meaning of variable definitions
                    395:         26.2. Avoiding problems before they arise
                    396:         26.3. Variable evaluation
1.1       dsieger   397: 
1.154     rillig    398:             26.3.1. At load time
                    399:             26.3.2. At runtime
1.1       dsieger   400: 
1.154     rillig    401:         26.4. How can variables be specified?
                    402:         26.5. Designing interfaces for Makefile fragments
1.1       dsieger   403: 
1.154     rillig    404:             26.5.1. Procedures with parameters
                    405:             26.5.2. Actions taken on behalf of parameters
1.1       dsieger   406: 
1.154     rillig    407:         26.6. The order in which files are loaded
1.1       dsieger   408: 
1.154     rillig    409:             26.6.1. The order in bsd.prefs.mk
                    410:             26.6.2. The order in bsd.pkg.mk
1.1       dsieger   411: 
1.154     rillig    412:     27. Regression tests
1.1       dsieger   413: 
1.154     rillig    414:         27.1. Running the regression tests
                    415:         27.2. Adding a new regression test
1.1       dsieger   416: 
1.154     rillig    417:             27.2.1. Overridable functions
                    418:             27.2.2. Helper functions
1.1       dsieger   419: 
1.154     rillig    420:     28. Porting pkgsrc
1.1       dsieger   421: 
1.154     rillig    422:         28.1. Porting pkgsrc to a new operating system
1.1       dsieger   423: 
                    424: A. A simple example package: bison
                    425: 
                    426:     A.1. files
                    427: 
                    428:         A.1.1. Makefile
                    429:         A.1.2. DESCR
                    430:         A.1.3. PLIST
                    431:         A.1.4. Checking a package with pkglint
                    432: 
                    433:     A.2. Steps for building, installing, packaging
                    434: 
                    435: B. Build logs
                    436: 
                    437:     B.1. Building figlet
                    438:     B.2. Packaging figlet
                    439: 
                    440: C. Directory layout of the pkgsrc FTP server
                    441: 
1.23      jakllsch  442:     C.1. distfiles: The distributed source files
                    443:     C.2. misc: Miscellaneous things
                    444:     C.3. packages: Binary packages
                    445:     C.4. reports: Bulk build reports
1.148     leot      446:     C.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger   447: 
1.154     rillig    448: D. Help topics
                    449: E. Editing guidelines for the pkgsrc guide
1.1       dsieger   450: 
1.154     rillig    451:     E.1. Make targets
                    452:     E.2. Procedure
1.1       dsieger   453: 
                    454: List of Tables
                    455: 
                    456: 1.1. Platforms supported by pkgsrc
1.154     rillig    457: 13.1. Patching examples
                    458: 25.1. PLIST handling for GNOME packages
1.1       dsieger   459: 
                    460: Chapter 1. What is pkgsrc?
                    461: 
                    462: Table of Contents
                    463: 
                    464: 1.1. Introduction
                    465: 
                    466:     1.1.1. Why pkgsrc?
                    467:     1.1.2. Supported platforms
                    468: 
                    469: 1.2. Overview
                    470: 1.3. Terminology
                    471: 
                    472:     1.3.1. Roles involved in pkgsrc
                    473: 
                    474: 1.4. Typography
                    475: 
                    476: 1.1. Introduction
                    477: 
                    478: There is a lot of software freely available for Unix-based systems, which is
                    479: usually available in form of the source code. Before such software can be used,
                    480: it needs to be configured to the local system, compiled and installed, and this
                    481: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
                    482: some basic commands to handle binary packages, so that not every user has to
                    483: build the packages for himself, which is a time-costly task.
                    484: 
                    485: pkgsrc currently contains several thousand packages, including:
                    486: 
1.104     sevan     487:   * www/apache24 - The Apache web server
1.1       dsieger   488: 
                    489:   * www/firefox - The Firefox web browser
                    490: 
                    491:   * meta-pkgs/gnome - The GNOME Desktop Environment
                    492: 
1.102     ryoon     493:   * meta-pkgs/kde4 - The K Desktop Environment
1.1       dsieger   494: 
1.108     rillig    495: ? just to name a few.
1.1       dsieger   496: 
                    497: pkgsrc has built-in support for handling varying dependencies, such as pthreads
                    498: and X11, and extended features such as IPv6 support on a range of platforms.
                    499: 
                    500: 1.1.1. Why pkgsrc?
                    501: 
                    502: pkgsrc provides the following key features:
                    503: 
                    504:   * Easy building of software from source as well as the creation and
                    505:     installation of binary packages. The source and latest patches are
                    506:     retrieved from a master or mirror download site, checksum verified, then
                    507:     built on your system. Support for binary-only distributions is available
                    508:     for both native platforms and NetBSD emulated platforms.
                    509: 
                    510:   * All packages are installed in a consistent directory tree, including
                    511:     binaries, libraries, man pages and other documentation.
                    512: 
1.104     sevan     513:   * Tracking of package dependencies automatically, including when performing
                    514:     updates, to ensure required packages are installed. The configuration files
                    515:     of various packages are handled automatically during updates, so local
                    516:     changes are preserved.
1.1       dsieger   517: 
                    518:   * Like NetBSD, pkgsrc is designed with portability in mind and consists of
                    519:     highly portable code. This allows the greatest speed of development when
1.26      spz       520:     porting to a new platform. This portability also ensures that pkgsrc is 
1.1       dsieger   521:     consistent across all platforms.
                    522: 
                    523:   * The installation prefix, acceptable software licenses, international
                    524:     encryption requirements and build-time options for a large number of
                    525:     packages are all set in a simple, central configuration file.
                    526: 
                    527:   * The entire source (not including the distribution files) is freely
                    528:     available under a BSD license, so you may extend and adapt pkgsrc to your
                    529:     needs. Support for local packages and patches is available right out of the
                    530:     box, so you can configure it specifically for your environment.
                    531: 
                    532: The following principles are basic to pkgsrc:
                    533: 
                    534:   * "It should only work if it's right." ? That means, if a package contains
                    535:     bugs, it's better to find them and to complain about them rather than to
                    536:     just install the package and hope that it works. There are numerous checks
1.175     gutterid  537:     in pkgsrc that try to find such bugs: static analysis tools (pkgtools/
1.1       dsieger   538:     pkglint), build-time checks (portability of shell scripts), and
                    539:     post-installation checks (installed files, references to shared libraries,
                    540:     script interpreters).
                    541: 
                    542:   * "If it works, it should work everywhere" ? Like NetBSD has been ported to
                    543:     many hardware architectures, pkgsrc has been ported to many operating
                    544:     systems. Care is taken that packages behave the same on all platforms.
                    545: 
                    546: 1.1.2. Supported platforms
                    547: 
                    548: pkgsrc consists of both a source distribution and a binary distribution for
                    549: these operating systems. After retrieving the required source or binaries, you
                    550: can be up and running with pkgsrc in just minutes!
                    551: 
                    552: pkgsrc was derived from FreeBSD's ports system, and initially developed for
                    553: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
                    554: platforms:
                    555: 
                    556: Table 1.1. Platforms supported by pkgsrc
                    557: 
1.92      sevan     558: +-----------------------------------------------------------------------------+
                    559: |               Platform               | Date Support  |        Notes         |
                    560: |                                      |     Added     |                      |
                    561: |--------------------------------------+---------------+----------------------|
                    562: |NetBSD                                |   Aug 1997    |                      |
                    563: |--------------------------------------+---------------+----------------------|
                    564: |Solaris                               |   Mar 1999    |README.Solaris        |
                    565: |--------------------------------------+---------------+----------------------|
                    566: |Linux                                 |   Jun 1999    |README.Linux          |
                    567: |--------------------------------------+---------------+----------------------|
1.118     sevan     568: |Darwin / Mac OS X / OS X / macOS      |   Oct 2001    |README.MacOSX         |
1.92      sevan     569: |--------------------------------------+---------------+----------------------|
                    570: |FreeBSD                               |   Nov 2002    |README.FreeBSD        |
                    571: |--------------------------------------+---------------+----------------------|
                    572: |OpenBSD                               |   Nov 2002    |README.OpenBSD        |
                    573: |--------------------------------------+---------------+----------------------|
                    574: |IRIX                                  |   Dec 2002    |README.IRIX           |
                    575: |                                      |               |README.IRIX5.3        |
                    576: |--------------------------------------+---------------+----------------------|
                    577: |BSD/OS                                |   Dec 2003    |                      |
                    578: |--------------------------------------+---------------+----------------------|
                    579: |AIX                                   |   Dec 2003    |README.AIX            |
                    580: |--------------------------------------+---------------+----------------------|
                    581: |Interix (Microsoft Windows Services   |   Mar 2004    |README.Interix        |
                    582: |for Unix)                             |               |                      |
                    583: |--------------------------------------+---------------+----------------------|
                    584: |DragonFlyBSD                          |   Oct 2004    |                      |
                    585: |--------------------------------------+---------------+----------------------|
                    586: |OSF/1                                 |   Nov 2004    |README.OSF1           |
                    587: |--------------------------------------+---------------+----------------------|
                    588: |HP-UX                                 |   Apr 2007    |README.HPUX           |
                    589: |--------------------------------------+---------------+----------------------|
                    590: |Haiku                                 |   Sep 2010    |README.Haiku          |
                    591: |--------------------------------------+---------------+----------------------|
                    592: |MirBSD                                |   Jan 2011    |                      |
                    593: |--------------------------------------+---------------+----------------------|
                    594: |Minix3                                |   Nov 2011    |README.Minix3         |
                    595: |--------------------------------------+---------------+----------------------|
                    596: |Cygwin                                |   Mar 2013    |README.Cygwin         |
                    597: |--------------------------------------+---------------+----------------------|
                    598: |GNU/kFreeBSD                          |   Jul 2013    |README.GNUkFreeBSD    |
1.104     sevan     599: |--------------------------------------+---------------+----------------------|
                    600: |Bitrig                                |   Jun 2014    |README.Bitrig         |
1.92      sevan     601: +-----------------------------------------------------------------------------+
1.1       dsieger   602: 
                    603: 
                    604: 1.2. Overview
                    605: 
                    606: This document is divided into three parts. The first, The pkgsrc user's guide,
                    607: describes how one can use one of the packages in the Package Collection, either
                    608: by installing a precompiled binary package, or by building one's own copy using
                    609: the NetBSD package system. The second part, The pkgsrc developer's guide,
                    610: explains how to prepare a package so it can be easily built by other NetBSD
                    611: users without knowing about the package's building details. The third part, The
                    612: pkgsrc infrastructure internals is intended for those who want to understand
                    613: how pkgsrc is implemented.
                    614: 
                    615: This document is available in various formats: HTML, PDF, PS, TXT.
                    616: 
                    617: 1.3. Terminology
                    618: 
                    619: There has been a lot of talk about "ports", "packages", etc. so far. Here is a
                    620: description of all the terminology used within this document.
                    621: 
                    622: Package
                    623: 
                    624:     A set of files and building instructions that describe what's necessary to
                    625:     build a certain piece of software using pkgsrc. Packages are traditionally
1.123     wiz       626:     stored under /usr/pkgsrc, but may be stored in any location, referred to as
                    627:     PKGSRCDIR.
1.1       dsieger   628: 
                    629: The NetBSD package system
                    630: 
                    631:     This is the former name of "pkgsrc". It is part of the NetBSD operating
                    632:     system and can be bootstrapped to run on non-NetBSD operating systems as
                    633:     well. It handles building (compiling), installing, and removing of
                    634:     packages.
                    635: 
                    636: Distfile
                    637: 
                    638:     This term describes the file or files that are provided by the author of
                    639:     the piece of software to distribute his work. All the changes necessary to
                    640:     build on NetBSD are reflected in the corresponding package. Usually the
                    641:     distfile is in the form of a compressed tar-archive, but other types are
                    642:     possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
                    643: 
                    644: Port
                    645: 
                    646:     This is the term used by FreeBSD and OpenBSD people for what we call a
                    647:     package. In NetBSD terminology, "port" refers to a different architecture.
                    648: 
                    649: Precompiled/binary package
                    650: 
                    651:     A set of binaries built with pkgsrc from a distfile and stuffed together in
                    652:     a single .tgz file so it can be installed on machines of the same machine
                    653:     architecture without the need to recompile. Packages are usually generated
                    654:     in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
                    655: 
                    656:     Sometimes, this is referred to by the term "package" too, especially in the
                    657:     context of precompiled packages.
                    658: 
                    659: Program
                    660: 
                    661:     The piece of software to be installed which will be constructed from all
                    662:     the files in the distfile by the actions defined in the corresponding
                    663:     package.
                    664: 
                    665: 1.3.1. Roles involved in pkgsrc
                    666: 
                    667: pkgsrc users
                    668: 
                    669:     The pkgsrc users are people who use the packages provided by pkgsrc.
                    670:     Typically they are system administrators. The people using the software
                    671:     that is inside the packages (maybe called "end users") are not covered by
                    672:     the pkgsrc guide.
                    673: 
                    674:     There are two kinds of pkgsrc users: Some only want to install pre-built
                    675:     binary packages. Others build the pkgsrc packages from source, either for
                    676:     installing them directly or for building binary packages themselves. For
                    677:     pkgsrc users Part I, "The pkgsrc user's guide" should provide all necessary
                    678:     documentation.
                    679: 
                    680: package maintainers
                    681: 
                    682:     A package maintainer creates packages as described in Part II, "The pkgsrc
                    683:     developer's guide".
                    684: 
                    685: infrastructure developers
                    686: 
                    687:     These people are involved in all those files that live in the mk/ directory
                    688:     and below. Only these people should need to read through Part III, "The
                    689:     pkgsrc infrastructure internals", though others might be curious, too.
                    690: 
                    691: 1.4. Typography
                    692: 
                    693: When giving examples for commands, shell prompts are used to show if the
                    694: command should/can be issued as root, or if "normal" user privileges are
1.115     sevan     695: sufficient. We use a # for root's shell prompt, a % for users' shell prompt,
                    696: assuming they use the C-shell or tcsh and a $ for bourne shell and derivatives.
1.1       dsieger   697: 
                    698: Part I. The pkgsrc user's guide
                    699: 
                    700: Table of Contents
                    701: 
1.154     rillig    702: 2. Getting help
                    703: 3. Where to get pkgsrc and how to keep it up-to-date
1.1       dsieger   704: 
1.154     rillig    705:     3.1. Getting pkgsrc for the first time
1.1       dsieger   706: 
1.154     rillig    707:         3.1.1. As tar archive
                    708:         3.1.2. Via anonymous CVS
1.1       dsieger   709: 
1.154     rillig    710:     3.2. Keeping pkgsrc up-to-date
1.1       dsieger   711: 
1.154     rillig    712:         3.2.1. Via tar files
                    713:         3.2.2. Via CVS
1.1       dsieger   714: 
1.154     rillig    715: 4. Using pkgsrc on systems other than NetBSD
1.1       dsieger   716: 
1.154     rillig    717:     4.1. Binary distribution
                    718:     4.2. Bootstrapping pkgsrc
1.1       dsieger   719: 
1.154     rillig    720: 5. Using pkgsrc
1.1       dsieger   721: 
1.154     rillig    722:     5.1. Using binary packages
1.1       dsieger   723: 
1.154     rillig    724:         5.1.1. Finding binary packages
                    725:         5.1.2. Installing binary packages
                    726:         5.1.3. Deinstalling packages
                    727:         5.1.4. Getting information about installed packages
                    728:         5.1.5. Checking for security vulnerabilities in installed packages
                    729:         5.1.6. Finding if newer versions of your installed packages are in
1.1       dsieger   730:             pkgsrc
1.154     rillig    731:         5.1.7. Other administrative functions
1.1       dsieger   732: 
1.154     rillig    733:     5.2. Building packages from source
1.1       dsieger   734: 
1.154     rillig    735:         5.2.1. Requirements
                    736:         5.2.2. Fetching distfiles
                    737:         5.2.3. How to build and install
1.1       dsieger   738: 
1.154     rillig    739: 6. Configuring pkgsrc
1.1       dsieger   740: 
1.154     rillig    741:     6.1. General configuration
                    742:     6.2. Variables affecting the build process
                    743:     6.3. Variables affecting the installation process
                    744:     6.4. Selecting and configuring the compiler
1.1       dsieger   745: 
1.154     rillig    746:         6.4.1. Selecting the compiler
                    747:         6.4.2. Additional flags to the compiler (CFLAGS)
                    748:         6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger   749: 
1.154     rillig    750:     6.5. Developer/advanced settings
                    751:     6.6. Selecting Build Options
1.1       dsieger   752: 
1.154     rillig    753: 7. Creating binary packages
1.1       dsieger   754: 
1.154     rillig    755:     7.1. Building a single binary package
                    756:     7.2. Settings for creation of binary packages
1.1       dsieger   757: 
1.154     rillig    758: 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig    759: 
1.154     rillig    760:     8.1. Preparations
                    761:     8.2. Running a pbulk-style bulk build
1.6       rillig    762: 
1.154     rillig    763:         8.2.1. Configuration
1.6       rillig    764: 
1.154     rillig    765:     8.3. Requirements of a full bulk build
1.178   ! rillig    766:     8.4. Bulk build variants
        !           767: 
        !           768:         8.4.1. Strict SUBST blocks
        !           769:         8.4.2. Detect unknown configure options
        !           770:         8.4.3. Detect classes of bugs by forcing compiler warnings
        !           771:         8.4.4. Use custom directories
        !           772:         8.4.5. Turn warnings into errors
        !           773:         8.4.6. Reject packages for which pkglint reports errors
        !           774:         8.4.7. Reject packages that contain forbidden strings
        !           775:         8.4.8. Reject packages whose self-test fails
        !           776:         8.4.9. Reject packages that use undefined shell variables
        !           777:         8.4.10. Turn off verbose logging
        !           778:         8.4.11. Select random sets of options
        !           779:         8.4.12. Select random configurations of BUILD_DEFS
1.6       rillig    780: 
1.178   ! rillig    781:     8.5. Creating a multiple CD-ROM packages collection
        !           782: 
        !           783:         8.5.1. Example of cdpack
1.6       rillig    784: 
1.154     rillig    785: 9. Directory layout of the installed files
1.6       rillig    786: 
1.154     rillig    787:     9.1. File system layout in ${LOCALBASE}
                    788:     9.2. File system layout in ${VARBASE}
1.6       rillig    789: 
1.154     rillig    790: 10. Frequently Asked Questions
1.6       rillig    791: 
1.154     rillig    792:     10.1. Are there any mailing lists for pkg-related discussion?
                    793:     10.2. Utilities for package management (pkgtools)
                    794:     10.3. How to use pkgsrc as non-root
                    795:     10.4. How to resume transfers when fetching distfiles?
                    796:     10.5. How can I install/use modular X.org from pkgsrc?
                    797:     10.6. How to fetch files from behind a firewall
                    798:     10.7. How to fetch files from HTTPS sites
                    799:     10.8. How do I tell make fetch to do passive FTP?
                    800:     10.9. How to fetch all distfiles at once
                    801:     10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
                    802:     10.11. What does "Could not find bsd.own.mk" mean?
                    803:     10.12. Using 'sudo' with pkgsrc
                    804:     10.13. How do I change the location of configuration files?
                    805:     10.14. Automated security checks
                    806:     10.15. Why do some packages ignore my CFLAGS?
                    807:     10.16. A package does not build. What shall I do?
                    808:     10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24      wiz       809:         conflicts" mean?
1.1       dsieger   810: 
1.154     rillig    811: Chapter 2. Getting help
                    812: 
                    813: To get help when using pkgsrc, the definitive source is this document, the
                    814: pkgsrc guide. If you don't find anything here, there are alternatives:
                    815: 
                    816:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
                    817:     Run bmake help topic=? to get help for any topic, such as a variable name
                    818:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                    819:     like strcasecmp or any other topic.
                    820: 
                    821:     The available help topics are listed in Appendix D, Help topics.
                    822: 
1.163     rillig    823:   * To see the value of a single variable, run bmake show-var VARNAME=X.
                    824: 
                    825:   * To see the values of the most common variables, run bmake show-all. These
                    826:     variables are grouped by topic. To see the variables for a single topic,
                    827:     run bmake show-all-topic, for example bmake show-all-fetch.
                    828: 
1.154     rillig    829:   * The pkgsrc-users mailing list, to which you can subscribe and then ask your
                    830:     questions.
                    831: 
                    832:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                    833:     a specialized chat program such as XChat. Pick any user name and join the
                    834:     channel #pkgsrc.
                    835: 
                    836: Chapter 3. Where to get pkgsrc and how to keep it up-to-date
1.1       dsieger   837: 
                    838: Table of Contents
                    839: 
1.154     rillig    840: 3.1. Getting pkgsrc for the first time
1.1       dsieger   841: 
1.154     rillig    842:     3.1.1. As tar archive
                    843:     3.1.2. Via anonymous CVS
1.1       dsieger   844: 
1.154     rillig    845: 3.2. Keeping pkgsrc up-to-date
1.1       dsieger   846: 
1.154     rillig    847:     3.2.1. Via tar files
                    848:     3.2.2. Via CVS
1.1       dsieger   849: 
                    850: Before you download and extract the files, you need to decide where you want to
                    851: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
                    852: usr/pkgsrc. You are though free to install the sources and binary packages
                    853: wherever you want in your filesystem, provided that the pathname does not
                    854: contain white-space or other characters that are interpreted specially by the
                    855: shell and some other programs. A safe bet is to use only letters, digits,
                    856: underscores and dashes.
                    857: 
1.154     rillig    858: 3.1. Getting pkgsrc for the first time
1.1       dsieger   859: 
1.25      wiz       860: Before you download any pkgsrc files, you should decide whether you want the 
1.1       dsieger   861: current branch or the stable branch. The latter is forked on a quarterly basis
                    862: from the current branch and only gets modified for security updates. The names
                    863: of the stable branches are built from the year and the quarter, for example
1.174     leot      864: 2020Q1.
1.1       dsieger   865: 
                    866: The second step is to decide how you want to download pkgsrc. You can get it as
1.24      wiz       867: a tar file or via CVS. Both ways are described here.
1.1       dsieger   868: 
1.52      asau      869: Note that tar archive contains CVS working copy. Thus you can switch to using
                    870: CVS at any later time.
1.1       dsieger   871: 
1.154     rillig    872: 3.1.1. As tar archive
1.52      asau      873: 
1.151     sevan     874: The primary download location for all pkgsrc files is https://cdn.NetBSD.org/
                    875: pub/pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same
                    876: location). There are a number of subdirectories for different purposes, which
                    877: are described in detail in Appendix C, Directory layout of the pkgsrc FTP
                    878: server.
1.1       dsieger   879: 
1.52      asau      880: The tar archive for the current branch is in the directory current and is
1.118     sevan     881: called pkgsrc.tar.gz. It is autogenerated weekly.
1.52      asau      882: 
                    883: To save download time we provide bzip2- and xz-compressed archives which are
                    884: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
                    885: 
                    886: You can fetch the same files using FTP.
1.1       dsieger   887: 
1.174     leot      888: The tar file for the stable branch 2020Q1 is in the directory pkgsrc-2020Q1 and
1.59      jnemeth   889: is also called pkgsrc.tar.gz.
1.1       dsieger   890: 
1.136     leot      891: To download the latest pkgsrc stable tarball, run:
1.12      weinem    892: 
1.174     leot      893: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2020Q1/pkgsrc.tar.gz
1.12      weinem    894: 
1.78      snj       895: If you prefer, you can also fetch it using "wget", "curl", or your web browser.
1.52      asau      896: 
1.12      weinem    897: Then, extract it with:
                    898: 
1.78      snj       899: $ tar -xzf pkgsrc.tar.gz -C /usr
1.12      weinem    900: 
                    901: This will create the directory pkgsrc/ in /usr/ and all the package source will
                    902: be stored under /usr/pkgsrc/.
                    903: 
                    904: To download pkgsrc-current, run:
                    905: 
                    906: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1       dsieger   907: 
1.154     rillig    908: 3.1.2. Via anonymous CVS
1.1       dsieger   909: 
1.24      wiz       910: To fetch a specific pkgsrc stable branch, run:
1.1       dsieger   911: 
1.174     leot      912: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2020Q1 -P pkgsrc
1.13      weinem    913: 
1.24      wiz       914: This will create the directory pkgsrc/ in your /usr/ directory and all the
                    915: package source will be stored under /usr/pkgsrc/.
                    916: 
                    917: To fetch the pkgsrc current branch, run:
1.1       dsieger   918: 
1.40      wiz       919: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   920: 
1.30      dholland  921: Refer to the list of available mirrors to choose a faster CVS mirror, if
                    922: needed.
1.1       dsieger   923: 
1.24      wiz       924: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1       dsieger   925: 
1.40      wiz       926: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   927: 
1.24      wiz       928: Refer to documentation on your command shell how to set CVS_RSH=ssh
                    929: permanently. For Bourne shells, you can set it in your .profile or better
                    930: globally in /etc/profile:
                    931: 
                    932: # set CVS remote shell command
                    933: CVS_RSH=ssh
                    934: export CVS_RSH
1.12      weinem    935: 
1.13      weinem    936: By default, CVS doesn't do things like most people would expect it to do. But
                    937: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12      weinem    938: directory and saving the following lines to it. This file will save you lots of
                    939: headache and some bug reports, so we strongly recommend it. You can find an
                    940: explanation of this file in the CVS documentation.
1.2       rillig    941: 
                    942: # recommended CVS configuration file from the pkgsrc guide
1.155     sevan     943: cvs -q
1.2       rillig    944: checkout -P
1.4       rillig    945: update -dP
                    946: diff -upN
1.2       rillig    947: rdiff -u
1.24      wiz       948: release -d
1.1       dsieger   949: 
1.154     rillig    950: 3.2. Keeping pkgsrc up-to-date
1.1       dsieger   951: 
                    952: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
                    953: have first installed it via a tar file). It saves bandwidth and hard disk
                    954: activity, compared to downloading the tar file again.
                    955: 
1.154     rillig    956: 3.2.1. Via tar files
1.1       dsieger   957: 
                    958: Warning
                    959: 
                    960: When updating from a tar file, you first need to completely remove the old
                    961: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
                    962: the mean time will not be removed on your local disk, resulting in
                    963: inconsistencies. When removing the old files, any changes that you have done to
                    964: the pkgsrc files will be lost after updating. Therefore updating via CVS is
                    965: strongly recommended.
                    966: 
                    967: Note that by default the distfiles and the binary packages are saved in the
                    968: pkgsrc tree, so don't forget to rescue them before updating. You can also
1.78      snj       969: configure pkgsrc to store distfiles and packages in directories outside the
1.154     rillig    970: pkgsrc tree by setting the DISTDIR and PACKAGES variables. See Chapter 6, 
1.78      snj       971: Configuring pkgsrc for the details.
1.1       dsieger   972: 
                    973: To update pkgsrc from a tar file, download the tar file as explained above.
                    974: Then, make sure that you have not made any changes to the files in the pkgsrc
                    975: directory. Remove the pkgsrc directory and extract the new tar file. Done.
                    976: 
1.154     rillig    977: 3.2.2. Via CVS
1.1       dsieger   978: 
1.26      spz       979: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12      weinem    980: 
1.26      spz       981: $ cd /usr/pkgsrc && cvs update -dP
                    982: 
                    983: If you get error messages from rsh, you need to set CVS_RSH variable as
                    984: described above. E.g.:
                    985: 
                    986: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1       dsieger   987: 
1.154     rillig    988: 3.2.2.1. Switching between different pkgsrc branches
1.1       dsieger   989: 
                    990: When updating pkgsrc, the CVS program keeps track of the branch you selected.
                    991: But if you, for whatever reason, want to switch from the stable branch to the
                    992: current one, you can do it by adding the option "-A" after the "update"
1.25      wiz       993: keyword. To switch from the current branch back to the stable branch, add the "
1.174     leot      994: -rpkgsrc-2020Q1" option.
1.1       dsieger   995: 
1.154     rillig    996: 3.2.2.2. What happens to my changes when updating?
1.1       dsieger   997: 
                    998: When you update pkgsrc, the CVS program will only touch those files that are
                    999: registered in the CVS repository. That means that any packages that you created
                   1000: on your own will stay unmodified. If you change files that are managed by CVS,
                   1001: later updates will try to merge your changes with those that have been done by
                   1002: others. See the CVS manual, chapter "update" for details.
                   1003: 
1.154     rillig   1004: Chapter 4. Using pkgsrc on systems other than NetBSD
1.1       dsieger  1005: 
                   1006: Table of Contents
                   1007: 
1.154     rillig   1008: 4.1. Binary distribution
                   1009: 4.2. Bootstrapping pkgsrc
1.1       dsieger  1010: 
1.154     rillig   1011: 4.1. Binary distribution
1.1       dsieger  1012: 
1.154     rillig   1013: See Section 5.1, "Using binary packages".
1.1       dsieger  1014: 
1.154     rillig   1015: 4.2. Bootstrapping pkgsrc
1.1       dsieger  1016: 
1.44      asau     1017: pkgsrc can be bootstrapped for use in two different modes: privileged and
                   1018: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45      asau     1019: programs are installed under one particular user and cannot utilise privileged
1.44      asau     1020: operations (packages don't create special users and all special file
                   1021: permissions like setuid are ignored).
                   1022: 
1.1       dsieger  1023: Installing the bootstrap kit from source should be as simple as:
                   1024: 
1.60      asau     1025: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger  1026: # cd pkgsrc/bootstrap
                   1027: # ./bootstrap
                   1028: 
                   1029: 
1.44      asau     1030: To bootstrap in unprivileged mode pass "--unprivileged" flag to bootstrap
                   1031: 
                   1032: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
1.118     sevan    1033: will be installed in, and /usr/pkg/pkgdb for the package database directory
                   1034: where pkgsrc will do its internal bookkeeping, /var is used as varbase, where
1.44      asau     1035: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
1.118     sevan    1036: for prefix, ~/pkg/pkgdb for the package database, and ~/pkg/var for varbase.
1.44      asau     1037: 
                   1038: You can change default layout using command-line arguments. Run "./bootstrap
                   1039: --help" to get details.
1.1       dsieger  1040: 
                   1041: Note
                   1042: 
                   1043: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
                   1044: For examples in this guide, use bmake instead of "make".
                   1045: 
1.44      asau     1046: Note
                   1047: 
                   1048: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
                   1049: directories. Use bmake corresponding to the installation you're working with to
                   1050: build and install packages.
                   1051: 
1.154     rillig   1052: Chapter 5. Using pkgsrc
1.1       dsieger  1053: 
                   1054: Table of Contents
                   1055: 
1.154     rillig   1056: 5.1. Using binary packages
1.1       dsieger  1057: 
1.154     rillig   1058:     5.1.1. Finding binary packages
                   1059:     5.1.2. Installing binary packages
                   1060:     5.1.3. Deinstalling packages
                   1061:     5.1.4. Getting information about installed packages
                   1062:     5.1.5. Checking for security vulnerabilities in installed packages
                   1063:     5.1.6. Finding if newer versions of your installed packages are in pkgsrc
                   1064:     5.1.7. Other administrative functions
                   1065: 
                   1066: 5.2. Building packages from source
                   1067: 
                   1068:     5.2.1. Requirements
                   1069:     5.2.2. Fetching distfiles
                   1070:     5.2.3. How to build and install
1.1       dsieger  1071: 
                   1072: Basically, there are two ways of using pkgsrc. The first is to only install the
                   1073: package tools and to use binary packages that someone else has prepared. This
                   1074: is the "pkg" in pkgsrc. The second way is to install the "src" of pkgsrc, too.
                   1075: Then you are able to build your own packages, and you can still use binary
                   1076: packages from someone else.
                   1077: 
1.154     rillig   1078: 5.1. Using binary packages
1.1       dsieger  1079: 
1.151     sevan    1080: On the cdn.NetBSD.org site and mirrors, there are collections of binary
1.9       rillig   1081: packages, ready to be installed. These binary packages have been built using
                   1082: the default settings for the directories, that is:
                   1083: 
                   1084:   * /usr/pkg for LOCALBASE, where most of the files are installed,
                   1085: 
                   1086:   * /usr/pkg/etc for configuration files,
                   1087: 
                   1088:   * /var for VARBASE, where those files are installed that may change after
                   1089:     installation.
                   1090: 
                   1091: If you cannot use these directories for whatever reasons (maybe because you're
                   1092: not root), you cannot use these binary packages, but have to build the packages
1.154     rillig   1093: yourself, which is explained in Section 4.2, "Bootstrapping pkgsrc".
1.1       dsieger  1094: 
1.154     rillig   1095: 5.1.1. Finding binary packages
1.1       dsieger  1096: 
1.5       weinem   1097: To install binary packages, you first need to know from where to get them. The
                   1098: first place where you should look is on the main pkgsrc FTP server in the
                   1099: directory /pub/pkgsrc/packages.
                   1100: 
                   1101: This directory contains binary packages for multiple platforms. First, select
                   1102: your operating system. (Ignore the directories with version numbers attached to
                   1103: it, they just exist for legacy reasons.) Then, select your hardware
                   1104: architecture, and in the third step, the OS version and the "version" of
1.9       rillig   1105: pkgsrc.
                   1106: 
                   1107: In this directory, you often find a file called bootstrap.tar.gz which contains
                   1108: the package management tools. If the file is missing, it is likely that your
                   1109: operating system already provides those tools. Download the file and extract it
                   1110: in the / directory. It will create the directories /usr/pkg (containing the
1.118     sevan    1111: tools for managing binary packages and the database of installed packages).
1.1       dsieger  1112: 
1.154     rillig   1113: 5.1.2. Installing binary packages
1.1       dsieger  1114: 
1.85      wiz      1115: In the directory from the last section, there is a subdirectory called All/,
1.9       rillig   1116: which contains all the binary packages that are available for the platform,
                   1117: excluding those that may not be distributed via FTP or CDROM (depending on
1.24      wiz      1118: which medium you are using).
1.9       rillig   1119: 
                   1120: To install packages directly from an FTP or HTTP server, run the following
                   1121: commands in a Bourne-compatible shell (be sure to su to root first):
                   1122: 
                   1123: # PATH="/usr/pkg/sbin:$PATH"
1.174     leot     1124: # PKG_PATH="https://cdn.NetBSD.org/pub/pkgsrc/packages"
1.169     rillig   1125: # PKG_PATH="$PKG_PATH/OPSYS/ARCH/VERSIONS/All/"
1.9       rillig   1126: # export PATH PKG_PATH
                   1127: 
                   1128: Instead of URLs, you can also use local paths, for example if you are
                   1129: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
                   1130: to install packages from multiple sources, you can separate them by a semicolon
                   1131: in PKG_PATH.
                   1132: 
                   1133: After these preparations, installing a package is very easy:
                   1134: 
1.118     sevan    1135: # pkg_add libreoffice
                   1136: # pkg_add ap24-php71-*
1.1       dsieger  1137: 
                   1138: Note that any prerequisite packages needed to run the package in question will
                   1139: be installed, too, assuming they are present where you install from.
                   1140: 
1.25      wiz      1141: Adding packages might install vulnerable packages. Thus you should run 
1.24      wiz      1142: pkg_admin audit regularly, especially after installing new packages, and verify
                   1143: that the vulnerabilities are acceptable for your configuration.
1.1       dsieger  1144: 
                   1145: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
                   1146: in your PATH so you can actually start the just installed program.
                   1147: 
1.154     rillig   1148: 5.1.3. Deinstalling packages
1.1       dsieger  1149: 
                   1150: To deinstall a package, it does not matter whether it was installed from source
                   1151: code or from a binary package. The pkg_delete command does not know it anyway.
                   1152: To delete a package, you can just run pkg_delete package-name. The package name
                   1153: can be given with or without version number. Wildcards can also be used to
                   1154: deinstall a set of packages, for example *emacs*. Be sure to include them in
                   1155: quotes, so that the shell does not expand them before pkg_delete sees them.
                   1156: 
                   1157: The -r option is very powerful: it removes all the packages that require the
                   1158: package in question and then removes the package itself. For example:
                   1159: 
                   1160: # pkg_delete -r jpeg
                   1161: 
                   1162: 
                   1163: will remove jpeg and all the packages that used it; this allows upgrading the
                   1164: jpeg package.
                   1165: 
1.154     rillig   1166: 5.1.4. Getting information about installed packages
1.1       dsieger  1167: 
                   1168: The pkg_info shows information about installed packages or binary package
                   1169: files.
                   1170: 
1.154     rillig   1171: 5.1.5. Checking for security vulnerabilities in installed packages
1.1       dsieger  1172: 
1.164     leot     1173: The pkgsrc Security Team and Packages Groups maintain a list of known security
                   1174: vulnerabilities to packages which are (or have been) included in pkgsrc. The
1.174     leot     1175: list is available from the NetBSD FTP site at https://ftp.NetBSD.org/pub/NetBSD
                   1176: /packages/vulns/pkg-vulnerabilities.
1.1       dsieger  1177: 
1.23      jakllsch 1178: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
                   1179: automatically, and a security audit of all packages installed on a system can
                   1180: take place.
                   1181: 
                   1182: There are two components to auditing. The first step, pkg_admin
                   1183: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
                   1184: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
                   1185: your installed packages are vulnerable. If a package is vulnerable, you will
                   1186: see output similar to the following:
1.1       dsieger  1187: 
                   1188: Package samba-2.0.9 has a local-root-shell vulnerability, see
1.174     leot     1189:     https://www.samba.org/samba/whatsnew/macroexploit.html
1.1       dsieger  1190: 
1.23      jakllsch 1191: You may wish to have the vulnerabilities file downloaded daily so that it
                   1192: remains current. This may be done by adding an appropriate entry to the root
                   1193: users crontab(5) entry. For example the entry
                   1194: 
1.121     sevan    1195: # Download vulnerabilities file
1.118     sevan    1196: 0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1.121     sevan    1197: # Audit the installed packages and email results to root
                   1198: 9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
                   1199:             root >/dev/null 2>&1
1.118     sevan    1200: 
                   1201: 
                   1202: will update the vulnerability list every day at 3AM, followed by an audit at
                   1203: 3:09AM. The result of the audit are then emailed to root. On NetBSD this may be
                   1204: accomplished instead by adding the following line to /etc/daily.conf:
                   1205: 
                   1206: fetch_pkg_vulnerabilities=YES
                   1207: 
1.23      jakllsch 1208: 
1.118     sevan    1209: to fetch the vulnerability list from the daily security script. The system is
                   1210: set to audit the packages by default but can be set explicitly, if desired (not
1.123     wiz      1211: required), by adding the following line to /etc/security.conf:
1.23      jakllsch 1212: 
1.118     sevan    1213: check_pkg_vulnerabilities=YES
1.23      jakllsch 1214: 
                   1215: 
1.118     sevan    1216: see daily.conf(5) and security.conf(5) for more details.
1.1       dsieger  1217: 
1.154     rillig   1218: 5.1.6. Finding if newer versions of your installed packages are in pkgsrc
1.1       dsieger  1219: 
1.12      weinem   1220: Install pkgtools/lintpkgsrc and run lintpkgsrc with the "-i" argument to check
                   1221: if your packages are up-to-date, e.g.
1.1       dsieger  1222: 
                   1223: % lintpkgsrc -i
                   1224: ...
                   1225: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
                   1226: 
                   1227: 
                   1228: You can then use make update to update the package on your system and rebuild
                   1229: any dependencies.
                   1230: 
1.154     rillig   1231: 5.1.7. Other administrative functions
1.1       dsieger  1232: 
                   1233: The pkg_admin executes various administrative functions on the package system.
                   1234: 
1.154     rillig   1235: 5.2. Building packages from source
1.1       dsieger  1236: 
                   1237: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25      wiz      1238: organized into categories. You can browse the online index of packages, or run 
1.1       dsieger  1239: make readme from the pkgsrc directory to build local README.html files for all
                   1240: packages, viewable with any web browser such as www/lynx or www/firefox.
                   1241: 
                   1242: The default prefix for installed packages is /usr/pkg. If you wish to change
                   1243: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
                   1244: use multiple different LOCALBASE definitions on the same system (inside a
                   1245: chroot is an exception).
                   1246: 
                   1247: The rest of this chapter assumes that the package is already in pkgsrc. If it
                   1248: is not, see Part II, "The pkgsrc developer's guide" for instructions how to
                   1249: create your own packages.
                   1250: 
1.154     rillig   1251: 5.2.1. Requirements
1.1       dsieger  1252: 
                   1253: To build packages from source, you need a working C compiler. On NetBSD, you
                   1254: need to install the "comp" and the "text" distribution sets. If you want to
                   1255: build X11-related packages, the "xbase" and "xcomp" distribution sets are
                   1256: required, too.
                   1257: 
1.154     rillig   1258: 5.2.2. Fetching distfiles
1.1       dsieger  1259: 
                   1260: The first step for building a package is downloading the distfiles (i.e. the
                   1261: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
                   1262: them automatically.
                   1263: 
                   1264: If you have all files that you need in the distfiles directory, you don't need
                   1265: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
                   1266: and add:
                   1267: 
                   1268: DISTDIR=/cdrom/pkgsrc/distfiles
                   1269: 
                   1270: to your mk.conf.
                   1271: 
                   1272: By default a list of distribution sites will be randomly intermixed to prevent
                   1273: huge load on servers which holding popular packages (for example,
                   1274: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
                   1275: distfile all the mirrors will be tried in new (random) order. You can turn this
                   1276: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
                   1277: disabled).
                   1278: 
                   1279: You can overwrite some of the major distribution sites to fit to sites that are
                   1280: close to your own. By setting one or two variables you can modify the order in
                   1281: which the master sites are accessed. MASTER_SORT contains a whitespace
                   1282: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
                   1283: contains a whitespace delimited list of regular expressions. It has higher
                   1284: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
                   1285: some examples. This may save some of your bandwidth and time.
                   1286: 
                   1287: You can change these settings either in your shell's environment, or, if you
1.4       rillig   1288: want to keep the settings, by editing the mk.conf file, and adding the
1.1       dsieger  1289: definitions there.
                   1290: 
1.132     wiz      1291: If a package depends on many other packages (such as meta-pkgs/kde4), the build
1.1       dsieger  1292: process may alternate between periods of downloading source, and compiling. To
                   1293: ensure you have all the source downloaded initially you can run the command:
                   1294: 
                   1295: % make fetch-list | sh
                   1296: 
                   1297: which will output and run a set of shell commands to fetch the necessary files
                   1298: into the distfiles directory. You can also choose to download the files
                   1299: manually.
                   1300: 
1.154     rillig   1301: 5.2.3. How to build and install
1.1       dsieger  1302: 
                   1303: Once the software has downloaded, any patches will be applied, then it will be
                   1304: compiled for you. This may take some time depending on your computer, and how
                   1305: many other packages the software depends on and their compile time.
                   1306: 
                   1307: Note
                   1308: 
                   1309: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
                   1310: command instead of "make" in the examples in this guide.
                   1311: 
                   1312: For example, type
                   1313: 
                   1314: % cd misc/figlet
                   1315: % make
                   1316: 
                   1317: 
                   1318: at the shell prompt to build the various components of the package.
                   1319: 
                   1320: The next stage is to actually install the newly compiled program onto your
                   1321: system. Do this by entering:
                   1322: 
                   1323: % make install
                   1324: 
                   1325: 
                   1326: while you are still in the directory for whatever package you are installing.
                   1327: 
                   1328: Installing the package on your system may require you to be root. However,
                   1329: pkgsrc has a just-in-time-su feature, which allows you to only become root for
                   1330: the actual installation step.
                   1331: 
                   1332: That's it, the software should now be installed and setup for use. You can now
                   1333: enter:
                   1334: 
                   1335: % make clean
                   1336: 
                   1337: 
                   1338: to remove the compiled files in the work directory, as you shouldn't need them
                   1339: any more. If other packages were also added to your system (dependencies) to
                   1340: allow your program to compile, you can tidy these up also with the command:
                   1341: 
                   1342: % make clean-depends
                   1343: 
                   1344: 
                   1345: Taking the figlet utility as an example, we can install it on our system by
                   1346: building as shown in Appendix B, Build logs.
                   1347: 
                   1348: The program is installed under the default root of the packages tree - /usr/
                   1349: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
                   1350: environment, and it will use that value as the root of your packages tree. So,
                   1351: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
                   1352: that you should use a directory which is dedicated to packages and not shared
                   1353: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
                   1354: not try to add any of your own files or directories (such as src/, obj/, or
                   1355: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
                   1356: between programs and other files installed by the package system and whatever
                   1357: else may have been installed there.
                   1358: 
1.4       rillig   1359: Some packages look in mk.conf to alter some configuration options at build
1.1       dsieger  1360: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
                   1361: be set there by default. Environment variables such as LOCALBASE can be set in
1.4       rillig   1362: mk.conf to save having to remember to set them each time you want to use
1.1       dsieger  1363: pkgsrc.
                   1364: 
                   1365: Occasionally, people want to "look under the covers" to see what is going on
                   1366: when a package is building or being installed. This may be for debugging
                   1367: purposes, or out of simple curiosity. A number of utility values have been
                   1368: added to help with this.
                   1369: 
                   1370:  1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
                   1371:     amount of information will be displayed. For example,
                   1372: 
                   1373:     make patch PKG_DEBUG_LEVEL=2
                   1374: 
1.25      wiz      1375:     will show all the commands that are invoked, up to and including the "patch
                   1376:     " stage.
1.1       dsieger  1377: 
                   1378:  2. If you want to know the value of a certain make(1) definition, then the
                   1379:     VARNAME definition should be used, in conjunction with the show-var target.
                   1380:     e.g. to show the expansion of the make(1) variable LOCALBASE:
                   1381: 
                   1382:     % make show-var VARNAME=LOCALBASE
                   1383:     /usr/pkg
                   1384:     %
                   1385: 
                   1386: 
                   1387: If you want to install a binary package that you've either created yourself
                   1388: (see next section), that you put into pkgsrc/packages manually or that is
                   1389: located on a remote FTP server, you can use the "bin-install" target. This
                   1390: target will install a binary package - if available - via pkg_add(1), else do a
                   1391: make package. The list of remote FTP sites searched is kept in the variable
                   1392: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
                   1393: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
                   1394: for more details.
                   1395: 
                   1396: A final word of warning: If you set up a system that has a non-standard setting
                   1397: for LOCALBASE, be sure to set that before any packages are installed, as you
                   1398: cannot use several directories for the same purpose. Doing so will result in
                   1399: pkgsrc not being able to properly detect your installed packages, and fail
                   1400: miserably. Note also that precompiled binary packages are usually built with
                   1401: the default LOCALBASE of /usr/pkg, and that you should not install any if you
                   1402: use a non-standard LOCALBASE.
                   1403: 
1.154     rillig   1404: Chapter 6. Configuring pkgsrc
1.1       dsieger  1405: 
                   1406: Table of Contents
                   1407: 
1.154     rillig   1408: 6.1. General configuration
                   1409: 6.2. Variables affecting the build process
                   1410: 6.3. Variables affecting the installation process
                   1411: 6.4. Selecting and configuring the compiler
                   1412: 
                   1413:     6.4.1. Selecting the compiler
                   1414:     6.4.2. Additional flags to the compiler (CFLAGS)
                   1415:     6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger  1416: 
1.154     rillig   1417: 6.5. Developer/advanced settings
                   1418: 6.6. Selecting Build Options
1.1       dsieger  1419: 
                   1420: The whole pkgsrc system is configured in a single file, usually called mk.conf.
                   1421: In which directory pkgsrc looks for that file depends on the installation. On
                   1422: NetBSD, when you use make(1) from the base system, it is in the directory /etc
                   1423: /. In all other cases the default location is ${PREFIX}/etc/, depending on
                   1424: where you told the bootstrap program to install the binary packages.
                   1425: 
                   1426: The format of the configuration file is that of the usual BSD-style Makefiles.
                   1427: The whole pkgsrc configuration is done by setting variables in this file. Note
                   1428: that you can define all kinds of variables, and no special error checking (for
1.112     rillig   1429: example for spelling mistakes) takes place.
1.1       dsieger  1430: 
1.154     rillig   1431: 6.1. General configuration
1.1       dsieger  1432: 
1.112     rillig   1433: The following variables apply to all pkgsrc packages. A complete list of the
                   1434: variables that can be configured by the user is available in mk/defaults/
                   1435: mk.conf, together with some comments that describe each variable's intent.
1.1       dsieger  1436: 
                   1437:   * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
                   1438:     not mix binary packages with different LOCALBASEs!
                   1439: 
                   1440:   * CROSSBASE: Where "cross" category packages will be installed. The default
                   1441:     is ${LOCALBASE}/cross.
                   1442: 
1.84      wiz      1443:   * X11BASE: Where X11 is installed on the system. The default is /usr/X11R7.
1.1       dsieger  1444: 
                   1445:   * DISTDIR: Where to store the downloaded copies of the original source
                   1446:     distributions used for building pkgsrc packages. The default is $
                   1447:     {PKGSRCDIR}/distfiles.
                   1448: 
                   1449:   * PKG_DBDIR: Where the database about installed packages is stored. The
1.118     sevan    1450:     default is /usr/pkg/pkgdb.
1.1       dsieger  1451: 
                   1452:   * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
                   1453:     value.
                   1454: 
                   1455:   * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
                   1456:     files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.118     sevan    1457:     respectively. The defaults is ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1.1       dsieger  1458:     {DIST_SUBDIR}/.
                   1459: 
                   1460:   * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
                   1461:     with OS release ("2.0", etc.) and architecture ("mipsel", etc.).
                   1462: 
1.23      jakllsch 1463:   * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
                   1464:     case-sensitive. Whenever you try to build a package whose license is not in
                   1465:     this list, you will get an error message. If the license condition is
                   1466:     simple enough, the error message will include specific instructions on how
                   1467:     to change this variable.
1.1       dsieger  1468: 
1.154     rillig   1469: 6.2. Variables affecting the build process
1.1       dsieger  1470: 
                   1471:   * PACKAGES: The top level directory for the binary packages. The default is $
                   1472:     {PKGSRCDIR}/packages.
                   1473: 
                   1474:   * WRKOBJDIR: The top level directory where, if defined, the separate working
                   1475:     directories will get created, and symbolically linked to from ${WRKDIR}
                   1476:     (see below). This is useful for building packages on several architectures,
                   1477:     then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
                   1478:     architecture. (It should be noted that PKGSRCDIR should not be set by the
                   1479:     user ? it is an internal definition which refers to the root of the pkgsrc
                   1480:     tree. It is possible to have many pkgsrc tree instances.)
                   1481: 
                   1482:   * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.154     rillig   1483:     Section 13.3, "patches/*" for more information.
1.1       dsieger  1484: 
                   1485:   * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
                   1486:     Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
                   1487:     up settings used by builds in /usr/src.
                   1488: 
1.154     rillig   1489: 6.3. Variables affecting the installation process
1.1       dsieger  1490: 
1.143     maya     1491:   * PKGSRC_KEEP_BIN_PKGSRC: By default, binary packages of built packages are
1.150     leot     1492:     preserved in ${PACKAGES}/All. Setting this variable to "no" prevents this.
1.1       dsieger  1493: 
1.107     jnemeth  1494: Packages have to support installation into a subdirectory of WRKDIR. This
                   1495: allows a package to be built, before the actual filesystem is touched. DESTDIR
                   1496: support exists in two variations:
1.4       rillig   1497: 
                   1498:   * Basic DESTDIR support means that the package installation and packaging is
                   1499:     still run as root.
                   1500: 
                   1501:   * Full DESTDIR support can run the complete build, installation and packaging
                   1502:     as normal user. Root privileges are only needed to add packages.
                   1503: 
                   1504: With basic DESTDIR support, make clean needs to be run as root.
                   1505: 
1.17      imil     1506: Considering the foo/bar package, DESTDIR full support can be tested using the
                   1507: following commands
                   1508: 
                   1509: $ id
                   1510: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
                   1511: $ mkdir $HOME/packages
                   1512: $ cd $PKGSRCDIR/foo/bar
                   1513: 
                   1514: Verify DESTDIR full support, no root privileges should be needed
                   1515: 
1.66      asau     1516: $ make stage-install
1.17      imil     1517: 
                   1518: Create a package without root privileges
                   1519: 
1.66      asau     1520: $ make PACKAGES=$HOME/packages package
1.17      imil     1521: 
                   1522: For the following command, you must be able to gain root privileges using su(1)
                   1523: 
1.66      asau     1524: $ make PACKAGES=$HOME/packages install
1.17      imil     1525: 
                   1526: Then, as a simple user
                   1527: 
                   1528: $ make clean
                   1529: 
1.154     rillig   1530: 6.4. Selecting and configuring the compiler
1.4       rillig   1531: 
1.154     rillig   1532: 6.4.1. Selecting the compiler
1.1       dsieger  1533: 
                   1534: By default, pkgsrc will use GCC to build packages. This may be overridden by
                   1535: setting the following variables in /etc/mk.conf:
                   1536: 
                   1537: PKGSRC_COMPILER:
                   1538: 
                   1539:     This is a list of values specifying the chain of compilers to invoke when
                   1540:     building packages. Valid values are:
                   1541: 
1.66      asau     1542:       + ccc: Compaq C Compilers (Tru64)
                   1543: 
                   1544:       + ccache: compiler cache (chainable)
                   1545: 
                   1546:       + clang: Clang C and Objective-C compiler
                   1547: 
1.42      asau     1548:       + distcc: distributed C/C++ (chainable)
1.1       dsieger  1549: 
1.66      asau     1550:       + f2c: Fortran 77 to C compiler (chainable)
                   1551: 
                   1552:       + icc: Intel C++ Compiler (Linux)
                   1553: 
                   1554:       + ido: SGI IRIS Development Option cc (IRIX 5)
1.1       dsieger  1555: 
1.42      asau     1556:       + gcc: GNU C/C++ Compiler
1.1       dsieger  1557: 
1.66      asau     1558:       + hp: HP-UX C/aC++ compilers
                   1559: 
1.42      asau     1560:       + mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1       dsieger  1561: 
1.66      asau     1562:       + mipspro-ucode: Silicon Graphics, Inc. MIPSpro (o32)
1.1       dsieger  1563: 
1.42      asau     1564:       + sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1       dsieger  1565: 
1.118     sevan    1566:       + xlc: IBM's XL C/C++ compiler suite
1.66      asau     1567: 
1.1       dsieger  1568:     The default is "gcc". You can use ccache and/or distcc with an appropriate
                   1569:     PKGSRC_COMPILER setting, e.g. "ccache gcc". This variable should always be
                   1570:     terminated with a value for a real compiler. Note that only one real
                   1571:     compiler should be listed (e.g. "sunpro gcc" is not allowed).
                   1572: 
                   1573: GCC_REQD:
                   1574: 
                   1575:     This specifies the minimum version of GCC to use when building packages. If
                   1576:     the system GCC doesn't satisfy this requirement, then pkgsrc will build and
                   1577:     install one of the GCC packages to use instead.
                   1578: 
1.153     leot     1579: PYTHON_VERSION_DEFAULT:
1.114     maya     1580: 
                   1581:     Specifies which version of python to use when several options are
                   1582:     available.
                   1583: 
                   1584: PKGSRC_FORTRAN:
                   1585: 
1.176     gutterid 1586:     Specifies the Fortran compiler to use. The default is gfortran.
1.114     maya     1587: 
                   1588: GFORTRAN_VERSION:
                   1589: 
                   1590:     If PKGSRC_FORTRAN= gfortran is used, this option specifies which version to
                   1591:     use.
                   1592: 
1.154     rillig   1593: 6.4.2. Additional flags to the compiler (CFLAGS)
1.1       dsieger  1594: 
                   1595: If you wish to set the CFLAGS variable, please make sure to use the += operator
                   1596: instead of the = operator:
                   1597: 
                   1598: CFLAGS+=        -your -flags
                   1599: 
                   1600: Using CFLAGS= (i.e. without the "+") may lead to problems with packages that
1.16      jnemeth  1601: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24      wiz      1602: package if you're interested in optimization specifically for the current CPU.
1.1       dsieger  1603: 
1.154     rillig   1604: 6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger  1605: 
                   1606: If you want to pass flags to the linker, both in the configure step and the
                   1607: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
                   1608: difference between the two is that LIBS will be appended to the command line,
                   1609: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
                   1610: machines depending on the setting of USE_IMAKE or the inclusion of mk/
                   1611: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
                   1612: settings, use the += operator:
                   1613: 
                   1614: LDFLAGS+=        -your -linkerflags
                   1615: 
1.154     rillig   1616: 6.5. Developer/advanced settings
1.1       dsieger  1617: 
                   1618:   * PKG_DEVELOPER: Run some sanity checks that package developers want:
                   1619: 
1.42      asau     1620:       + make sure patches apply with zero fuzz
1.1       dsieger  1621: 
1.42      asau     1622:       + run check-shlibs to see that all binaries will find their shared libs.
1.1       dsieger  1623: 
                   1624:   * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
                   1625:     making and installing the package. The default value for this is 0, which
                   1626:     will not display the commands as they are executed (normal, default, quiet
                   1627:     operation); the value 1 will display all shell commands before their
                   1628:     invocation, and the value 2 will display both the shell commands before
1.112     rillig   1629:     their invocation, as well as their actual execution progress with set -x.
1.1       dsieger  1630: 
1.154     rillig   1631: 6.6. Selecting Build Options
1.1       dsieger  1632: 
                   1633: Some packages have build time options, usually to select between different
                   1634: dependencies, enable optional support for big dependencies or enable
                   1635: experimental features.
                   1636: 
                   1637: To see which options, if any, a package supports, and which options are
                   1638: mutually exclusive, run make show-options, for example:
                   1639: 
                   1640:     The following options are supported by this package:
                   1641:         ssl      Enable SSL support.
                   1642:     Exactly one of the following gecko options is required:
                   1643:         firefox  Use firefox as gecko rendering engine.
                   1644:         mozilla  Use mozilla as gecko rendering engine.
                   1645:     At most one of the following database options may be selected:
                   1646:         mysql    Enable support for MySQL database.
                   1647:         pgsql    Enable support for PostgreSQL database.
                   1648: 
                   1649:     These options are enabled by default: firefox
                   1650:     These options are currently enabled: mozilla ssl
                   1651: 
1.4       rillig   1652: The following variables can be defined in mk.conf to select which options to
                   1653: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1       dsieger  1654: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
                   1655: which can be used to select or disable options specifically for package pkgbase
                   1656: . Options listed in these variables are selected, options preceded by "-" are
                   1657: disabled. A few examples:
                   1658: 
1.4       rillig   1659: $ grep "PKG.*OPTION" mk.conf
1.1       dsieger  1660: PKG_DEFAULT_OPTIONS=    -arts -dvdread -esound
                   1661: PKG_OPTIONS.kdebase=    debug -sasl
                   1662: PKG_OPTIONS.apache=     suexec
                   1663: 
1.11      rillig   1664: It is important to note that options that were specifically suggested by the
1.19      snj      1665: package maintainer must be explicitly removed if you do not wish to include the
                   1666: option. If you are unsure you can view the current state with make show-options
                   1667: .
1.11      rillig   1668: 
1.1       dsieger  1669: The following settings are consulted in the order given, and the last setting
                   1670: that selects or disables an option is used:
                   1671: 
                   1672:  1. the default options as suggested by the package maintainer
                   1673: 
                   1674:  2. the options implied by the settings of legacy variables (see below)
                   1675: 
                   1676:  3. PKG_DEFAULT_OPTIONS
                   1677: 
                   1678:  4. PKG_OPTIONS.pkgbase
                   1679: 
                   1680: For groups of mutually exclusive options, the last option selected is used, all
                   1681: others are automatically disabled. If an option of the group is explicitly
                   1682: disabled, the previously selected option, if any, is used. It is an error if no
                   1683: option from a required group of options is selected, and building the package
                   1684: will fail.
                   1685: 
                   1686: Before the options framework was introduced, build options were selected by
1.4       rillig   1687: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
                   1688: transition to the options framework for the user, these legacy variables are
                   1689: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
                   1690: automatically. A warning is issued to prompt the user to update mk.conf to use
                   1691: the options framework directly. Support for the legacy variables will be
1.1       dsieger  1692: removed eventually.
                   1693: 
1.154     rillig   1694: Chapter 7. Creating binary packages
1.1       dsieger  1695: 
                   1696: Table of Contents
                   1697: 
1.154     rillig   1698: 7.1. Building a single binary package
                   1699: 7.2. Settings for creation of binary packages
1.1       dsieger  1700: 
1.154     rillig   1701: 7.1. Building a single binary package
1.1       dsieger  1702: 
                   1703: Once you have built and installed a package, you can create a binary package
                   1704: which can be installed on another system with pkg_add(1). This saves having to
                   1705: build the same package on a group of hosts and wasting CPU time. It also
                   1706: provides a simple means for others to install your package, should you
                   1707: distribute it.
                   1708: 
                   1709: To create a binary package, change into the appropriate directory in pkgsrc,
                   1710: and run make package:
                   1711: 
1.112     rillig   1712: $ cd misc/figlet
                   1713: $ make package
1.1       dsieger  1714: 
                   1715: This will build and install your package (if not already done), and then build
                   1716: a binary package from what was installed. You can then use the pkg_* tools to
                   1717: manipulate it. Binary packages are created by default in /usr/pkgsrc/packages,
                   1718: in the form of a gzipped tar file. See Section B.2, "Packaging figlet" for a
                   1719: continuation of the above misc/figlet example.
                   1720: 
1.154     rillig   1721: See Chapter 23, Submitting and Committing for information on how to submit such
1.1       dsieger  1722: a binary package.
                   1723: 
1.154     rillig   1724: 7.2. Settings for creation of binary packages
1.1       dsieger  1725: 
1.154     rillig   1726: See Section 19.17, "Other helpful targets".
1.6       rillig   1727: 
1.154     rillig   1728: Chapter 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig   1729: 
                   1730: Table of Contents
                   1731: 
1.154     rillig   1732: 8.1. Preparations
                   1733: 8.2. Running a pbulk-style bulk build
1.6       rillig   1734: 
1.154     rillig   1735:     8.2.1. Configuration
1.6       rillig   1736: 
1.154     rillig   1737: 8.3. Requirements of a full bulk build
1.178   ! rillig   1738: 8.4. Bulk build variants
        !          1739: 
        !          1740:     8.4.1. Strict SUBST blocks
        !          1741:     8.4.2. Detect unknown configure options
        !          1742:     8.4.3. Detect classes of bugs by forcing compiler warnings
        !          1743:     8.4.4. Use custom directories
        !          1744:     8.4.5. Turn warnings into errors
        !          1745:     8.4.6. Reject packages for which pkglint reports errors
        !          1746:     8.4.7. Reject packages that contain forbidden strings
        !          1747:     8.4.8. Reject packages whose self-test fails
        !          1748:     8.4.9. Reject packages that use undefined shell variables
        !          1749:     8.4.10. Turn off verbose logging
        !          1750:     8.4.11. Select random sets of options
        !          1751:     8.4.12. Select random configurations of BUILD_DEFS
1.6       rillig   1752: 
1.178   ! rillig   1753: 8.5. Creating a multiple CD-ROM packages collection
        !          1754: 
        !          1755:     8.5.1. Example of cdpack
1.6       rillig   1756: 
1.175     gutterid 1757: For a number of reasons, you may want to build binary packages for a large
                   1758: selected set of packages in pkgsrc, or even for all pkgsrc packages. For
1.71      wiz      1759: instance, when you have multiple machines that should run the same software, it
                   1760: is wasted time if they all build their packages themselves from source. Or you
                   1761: may want to build a list of packages you want and check them before deploying
1.175     gutterid 1762: onto production systems. There is a way of getting a set of binary packages:
                   1763: the bulk build system, or pbulk ("p" stands for "parallel"). This chapter
                   1764: describes how to set it up.
1.71      wiz      1765: 
1.154     rillig   1766: 8.1. Preparations
1.71      wiz      1767: 
                   1768: First of all, you have to decide whether you build all packages or a limited
                   1769: set of them. Full bulk builds usually consume a lot more resources, both space
1.175     gutterid 1770: and time, than builds for some practical sets of packages. A number of
                   1771: particularly heavy packages exist that are not actually interesting to a wide
                   1772: audience. (The approximate resource consumption for a full bulk build is given
                   1773: in section Section 8.3, "Requirements of a full bulk build".) For limited bulk
                   1774: builds you need to make a list of packages you want to build. Note that all
                   1775: their dependencies will be built, so you don't need to track them manually.
1.71      wiz      1776: 
                   1777: During bulk builds various packages are installed and deinstalled in /usr/pkg
                   1778: (or whatever LOCALBASE is), so make sure that you don't need any package during
1.112     rillig   1779: the builds. Essentially, you should provide a fresh system, either a chroot
1.71      wiz      1780: environment or something even more restrictive, depending on what the operating
                   1781: system provides, or dedicate the whole physical machine. As a useful side
                   1782: effect this makes sure that bulk builds cannot break anything in your system.
                   1783: There have been numerous cases where certain packages tried to install files
                   1784: outside the LOCALBASE or wanted to edit some files in /etc.
1.6       rillig   1785: 
1.154     rillig   1786: 8.2. Running a pbulk-style bulk build
1.6       rillig   1787: 
1.15      rillig   1788: Running a pbulk-style bulk build works roughly as follows:
                   1789: 
                   1790:   * First, build the pbulk infrastructure in a fresh pkgsrc location.
                   1791: 
                   1792:   * Then, build each of the packages from a clean installation directory using
                   1793:     the infrastructure.
                   1794: 
1.154     rillig   1795: 8.2.1. Configuration
1.6       rillig   1796: 
1.112     rillig   1797: To simplify configuration, we provide the helper script mk/pbulk/pbulk.sh.
1.6       rillig   1798: 
1.68      asau     1799: In order to use it, prepare a clear system (real one, chroot environment, jail,
                   1800: zone, virtual machine). Configure network access to fetch distribution files.
1.112     rillig   1801: Create a user with name "pbulk".
1.68      asau     1802: 
                   1803: Fetch and extract pkgsrc. Use a command like one of these:
                   1804: 
1.151     sevan    1805: # (cd /usr && ftp -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
                   1806: # (cd /usr && fetch -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1.72      wiz      1807: # (cd /usr && cvs -Q -z3 -d anoncvs@anoncvs.NetBSD.org:/cvsroot get -P pkgsrc)
1.68      asau     1808: 
                   1809: Or any other way that fits (e.g., curl, wget).
                   1810: 
                   1811: Deploy and configure pbulk tools, e.g.:
                   1812: 
1.118     sevan    1813: # sh pbulk.sh -n # use native make, no bootstrap kit needed (for use on NetBSD)
1.68      asau     1814: # sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment
                   1815: # sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build
                   1816: 
                   1817: Note
                   1818: 
                   1819: mk.conf.frag is a fragment of mk.conf that contains settings you want to apply
                   1820: to packages you build. For instance,
                   1821: 
1.112     rillig   1822: PKG_DEVELOPER=          yes     # perform more checks
                   1823: X11_TYPE=               modular # use pkgsrc X11
                   1824: SKIP_LICENSE_CHECK=     yes     # accept all licences (useful
                   1825:                                 # when building all packages)
1.68      asau     1826: 
                   1827: If configured for limited list, replace the list in /usr/pbulk/etc/pbulk.list
1.112     rillig   1828: with your list of packages, one per line without empty lines or comments. E.g.:
1.68      asau     1829: 
                   1830: www/firefox
                   1831: mail/thunderbird
                   1832: misc/libreoffice4
                   1833: 
1.69      asau     1834: At this point you can also review configuration in /usr/pbulk/etc and make
                   1835: final amendments, if wanted.
                   1836: 
1.68      asau     1837: Start it:
                   1838: 
                   1839: # /usr/pbulk/bin/bulkbuild
                   1840: 
                   1841: After it finishes, you'll have /mnt filled with distribution files, binary
                   1842: packages, and reports, plain text summary in /mnt/bulklog/meta/report.txt
                   1843: 
                   1844: Note
                   1845: 
                   1846: The pbulk.sh script does not cover all possible use cases. While being ready to
                   1847: run, it serves as a good starting point to understand and build more complex
                   1848: setups. The script is kept small enough for better understanding.
                   1849: 
                   1850: Note
                   1851: 
                   1852: The pbulk.sh script supports running unprivileged bulk build and helps
                   1853: configuring distributed bulk builds.
1.15      rillig   1854: 
1.154     rillig   1855: 8.3. Requirements of a full bulk build
1.71      wiz      1856: 
                   1857: A complete bulk build requires lots of disk space. Some of the disk space can
                   1858: be read-only, some other must be writable. Some can be on remote filesystems
                   1859: (such as NFS) and some should be local. Some can be temporary filesystems,
                   1860: others must survive a sudden reboot.
                   1861: 
                   1862:   * 40 GB for the distfiles (read-write, remote, temporary)
                   1863: 
                   1864:   * 30 GB for the binary packages (read-write, remote, permanent)
                   1865: 
                   1866:   * 1 GB for the pkgsrc tree (read-only, remote, permanent)
                   1867: 
                   1868:   * 5 GB for LOCALBASE (read-write, local, temporary)
                   1869: 
                   1870:   * 10 GB for the log files (read-write, remote, permanent)
                   1871: 
                   1872:   * 5 GB for temporary files (read-write, local, temporary)
                   1873: 
1.178   ! rillig   1874: 8.4. Bulk build variants
        !          1875: 
        !          1876: To ensure that pkgsrc packages work in different configurations, it makes sense
        !          1877: to run non-default bulk builds from time to time. This section lists some ideas
        !          1878: for bulk builds that intentionally let packages fail if they don't follow the
        !          1879: pkgsrc style.
        !          1880: 
        !          1881: 8.4.1. Strict SUBST blocks
        !          1882: 
        !          1883: Up to May 2020, the SUBST blocks ignored files that didn't exist, as well as
        !          1884: substitutions that didn't have any effect. There were quite a few SUBST blocks
        !          1885: that were redundant, and these have been removed already.
        !          1886: 
        !          1887: The next step would be to not only check that each filename pattern has an
        !          1888: effect but also that each substitution in SUBST_SED or SUBST_VARS applies to at
        !          1889: least one file.
        !          1890: 
        !          1891: To do this, mk/subst.mk would have to be adjusted, in a similar way as the
        !          1892: check for no-op SUBST_FILES. There are several regression tests in regress/
        !          1893: infra-unittests that help to get all edge cases correct.
        !          1894: 
        !          1895: When a package fails this additional check, there are various possible causes
        !          1896: why the SUBST_SED became a no-op.
        !          1897: 
        !          1898:  1. The pattern used to be found in a former version of the package, but is not
        !          1899:     needed anymore. In that case, just remove it.
        !          1900: 
        !          1901:  2. The pattern contains a typo. In that case, fix the typo and bump
        !          1902:     PKGREVISION, since the fixed typo will probably modify the resulting binary
        !          1903:     package.
        !          1904: 
        !          1905:  3. There is a patch that is applied before the SUBST block, and the patch
        !          1906:     accidentally contains the change that was intended for the SUBST block. In
        !          1907:     that case, remove the respective hunk from the patch.
        !          1908: 
        !          1909: 8.4.2. Detect unknown configure options
        !          1910: 
        !          1911: Add the following line to mk.conf.
        !          1912: 
        !          1913: GNU_CONFIGURE_STRICT=   yes
        !          1914: 
        !          1915: When a package fails this additional check, the most common cause is that the
        !          1916: configure option was valid for an older version of the package but does not
        !          1917: apply anymore. In that case, just remove it.
        !          1918: 
        !          1919: 8.4.3. Detect classes of bugs by forcing compiler warnings
        !          1920: 
        !          1921: The job of a compiler is not restricted to producing executable code, most
        !          1922: compilers also detects typical mistakes.
        !          1923: 
        !          1924: Add the following line to mk.conf.
        !          1925: 
        !          1926: CFLAGS+=        -Werror=char-subscripts
        !          1927: 
        !          1928: When a package fails this additional check, first document the circumstances in
        !          1929: which the compiler produced the error message. This includes:
        !          1930: 
        !          1931:   * The platform (MACHINE_PLATFORM)
        !          1932: 
        !          1933:   * The source file
        !          1934: 
        !          1935:   * An excerpt of the code. GCC and Clang already do this as part of the
        !          1936:     diagnostic.
        !          1937: 
        !          1938:   * The error message from the compiler.
        !          1939: 
        !          1940: If a package produces these error messages, but the package is fine, document
        !          1941: this in the package Makefile, like this:
        !          1942: 
        !          1943: # Version ${VERSION} failed on ${MACHINE_PLATFORM}:
        !          1944: # error message
        !          1945: # code
        !          1946: # reason why the code does not need to be fixed
        !          1947: BUILDLINK_TRANSFORM+=   rm:-Werror=char-subscripts
        !          1948: 
        !          1949: If the error messages from the compiler are valid and the code needs to be
        !          1950: fixed, prepare a patch for a single source file, or if it's a one-liner fix,
        !          1951: add a SUBST block to the package Makefile. In any case, report it to the
        !          1952: upstream authors of the package.
        !          1953: 
        !          1954: 8.4.4. Use custom directories
        !          1955: 
        !          1956: Some directories like PREFIX, VARBASE, PKG_SYSCONFDIR, PKGMANDIR, PKG_INFODIR
        !          1957: can be configured in pkgsrc. Set these to arbitrary paths during bootstrap or
        !          1958: afterwards in mk.conf.
        !          1959: 
        !          1960: PREFIX=         /a-random-uuid
        !          1961: PKG_SYSCONFDIR= /a-random-uuid
        !          1962: VARBASE=        /a-random-uuid
        !          1963: PKGMANDIR=      a-random-uuid
        !          1964: PKG_INFODIR=    a-random-uuid
        !          1965: 
        !          1966: 8.4.5. Turn warnings into errors
        !          1967: 
        !          1968: When building a package, warnings are typically ignored since they just flow by
        !          1969: and do not cause the build to fail immediately. To find these warnings,
        !          1970: redefine them to errors in mk.conf.
        !          1971: 
        !          1972: DELAYED_WARNING_MSG=    ${DELAYED_ERROR_MSG} "(was warning)"
        !          1973: WARNING_MSG=            ${FAIL_MSG} "(was warning)"
        !          1974: 
        !          1975: (There are many more classes of warnings in pkgsrc, and most of them can be
        !          1976: redefined with a simple definition like above.
        !          1977: 
        !          1978: If a package suggest to add USE_TOOLS+=perl to the package Makefile, research
        !          1979: whether the package actually needs Perl. If it does, add USE_TOOLS+=perl to the
        !          1980: package Makefile, and if it doesn't, add TOOLS_BROKEN+=perl.
        !          1981: 
        !          1982: 8.4.6. Reject packages for which pkglint reports errors
        !          1983: 
        !          1984: Using pkglint as part of the regular build process is mostly a waste of time.
        !          1985: If you want to fix some of the warnings, just run pkglint recursively on the
        !          1986: whole pkgsrc tree. This will take a few minutes (up to 10), which is much
        !          1987: faster than a complete bulk build.
        !          1988: 
        !          1989: 8.4.7. Reject packages that contain forbidden strings
        !          1990: 
        !          1991: To ensure that the binary packages don't contain references to the build
        !          1992: directory, there is already CHECK_WRKREF. If that variable includes the item
        !          1993: extra, it is possible to define additional patterns that must not appear in any
        !          1994: installed file. This is specified in mk.conf.
        !          1995: 
        !          1996: CHECK_WRKREF=                   extra
        !          1997: CHECK_WRKREF_EXTRA_DIRS+=       /usr/local
        !          1998: CHECK_WRKREF_EXTRA_DIRS+=       /usr/pkg
        !          1999: CHECK_WRKREF_EXTRA_DIRS+=       @[A-Z][A-Z]*@
        !          2000: 
        !          2001: The above patterns will probably generate many false positives, therefore the
        !          2002: results need to be taken with a grain of salt.
        !          2003: 
        !          2004: 8.4.8. Reject packages whose self-test fails
        !          2005: 
        !          2006: To run the test suites that come with each package, add this line to mk.conf.
        !          2007: 
        !          2008: PKGSRC_RUN_TEST=        yes
        !          2009: 
        !          2010: Be prepared that even the most basic packages fail this test. When doing a bulk
        !          2011: build with this, it will often abort in the early phase where the packages are
        !          2012: scanned for their dependencies since there are cyclic dependencies. There is
        !          2013: still a lot to do in this area.
        !          2014: 
        !          2015: 8.4.9. Reject packages that use undefined shell variables
        !          2016: 
        !          2017: To catch typos in the shell snippets from the Makefile fragments, add the -u
        !          2018: flag to most of the commands by adding this line to mk.conf.
        !          2019: 
        !          2020: RUN=    @set -eu;
        !          2021: 
        !          2022: See mk/misc/common.mk for the existing definition.
        !          2023: 
        !          2024: 8.4.10. Turn off verbose logging
        !          2025: 
        !          2026: The build logs of a package are often quite long. This allows error messages or
        !          2027: other interesting details to hide between the noise. To make the actual error
        !          2028: message stand out more, add these lines to mk.conf.
        !          2029: 
        !          2030: GNU_CONFIGURE_QUIET=    yes
        !          2031: MAKE_FLAGS+=            -s
        !          2032: 
        !          2033: The -s option works for both GNU Make and BSD Make. On exotic platforms with
        !          2034: their own make, it may be a little different.
        !          2035: 
        !          2036: 8.4.11. Select random sets of options
        !          2037: 
        !          2038: Most bulk builds run with the default package options. This means that other
        !          2039: combinations of options are not regularly tested. To do this, run a bulk build
        !          2040: with these configurations.
        !          2041: 
        !          2042:   * no options enabled
        !          2043: 
        !          2044:   * all options enabled
        !          2045: 
        !          2046:   * 2n + 0
        !          2047: 
        !          2048:   * 2n + 1
        !          2049: 
        !          2050:   * 4n + 0..1
        !          2051: 
        !          2052:   * 4n + 2..3
        !          2053: 
        !          2054:   * 8n + 0..3
        !          2055: 
        !          2056:   * 8n + 4..7
        !          2057: 
        !          2058:   * 2048n + 0..1023
        !          2059: 
        !          2060:   * 2048n + 1024..2047
        !          2061: 
        !          2062: Open questions are:
        !          2063: 
        !          2064:   * how to collect all options from the entire pkgsrc
        !          2065: 
        !          2066:   * how to handle mutually exclusive options
        !          2067: 
        !          2068:   * the sets of mutually exclusive options are defined per-package
        !          2069: 
        !          2070:   * the sets of nonempty sets are defined per-package
        !          2071: 
        !          2072: 8.4.12. Select random configurations of BUILD_DEFS
        !          2073: 
        !          2074: Just like the PKG_OPTIONS, the BUILD_DEFS also allow different variants of
        !          2075: pkgsrc to be created. The same ideas as in Section 8.4.11, "Select random sets
        !          2076: of options" apply.
        !          2077: 
        !          2078: 8.5. Creating a multiple CD-ROM packages collection
1.1       dsieger  2079: 
                   2080: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
                   2081: of the resulting binary packages to assist in installing packages on other
                   2082: machines. The pkgtools/cdpack package provides a simple tool for creating the
                   2083: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
                   2084: keeps all the dependencies for a given package on the same CD as that package.
                   2085: 
1.178   ! rillig   2086: 8.5.1. Example of cdpack
1.1       dsieger  2087: 
                   2088: Complete documentation for cdpack is found in the cdpack(1) man page. The
                   2089: following short example assumes that the binary packages are left in /usr/
                   2090: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
                   2091: ISO 9660 images.
                   2092: 
                   2093: # mkdir /u2/images
                   2094: # pkg_add /usr/pkgsrc/packages/All/cdpack
                   2095: # cdpack /usr/pkgsrc/packages/All /u2/images
                   2096: 
                   2097: 
                   2098: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
                   2099: CD in the collection, then you need to create a directory which contains these
1.175     gutterid 2100: files, e.g.:
1.1       dsieger  2101: 
                   2102: # mkdir /tmp/common
                   2103: # echo "This is a README" > /tmp/common/README
                   2104: # echo "Another file" > /tmp/common/COPYING
                   2105: # mkdir /tmp/common/bin
                   2106: # echo "#!/bin/sh" > /tmp/common/bin/myscript
                   2107: # echo "echo Hello world" >> /tmp/common/bin/myscript
                   2108: # chmod 755 /tmp/common/bin/myscript
                   2109: 
                   2110: 
                   2111: Now create the images:
                   2112: 
                   2113: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
                   2114: 
                   2115: Each image will contain README, COPYING, and bin/myscript in their root
                   2116: directories.
                   2117: 
1.154     rillig   2118: Chapter 9. Directory layout of the installed files
1.1       dsieger  2119: 
                   2120: Table of Contents
                   2121: 
1.154     rillig   2122: 9.1. File system layout in ${LOCALBASE}
                   2123: 9.2. File system layout in ${VARBASE}
1.1       dsieger  2124: 
                   2125: The files that are installed by pkgsrc are organized in a way that is similar
                   2126: to what you find in the /usr directory of the base system. But some details are
                   2127: different. This is because pkgsrc initially came from FreeBSD and had adopted
                   2128: its file system hierarchy. Later it was largely influenced by NetBSD. But no
                   2129: matter which operating system you are using pkgsrc with, you can expect the
                   2130: same layout for pkgsrc.
                   2131: 
                   2132: There are mainly four root directories for pkgsrc, which are all configurable
                   2133: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
                   2134: default locations are:
                   2135: 
                   2136: LOCALBASE=              /usr/pkg
                   2137: PKG_SYSCONFBASE=        /usr/pkg/etc
                   2138: VARBASE=                /var
1.119     sevan    2139: PKG_DBDIR=              /usr/pkg/pkgdb
1.1       dsieger  2140: 
                   2141: In unprivileged mode (when pkgsrc has been installed as any other user), the
                   2142: default locations are:
                   2143: 
                   2144: LOCALBASE=              ${HOME}/pkg
                   2145: PKG_SYSCONFBASE=        ${HOME}/pkg/etc
                   2146: VARBASE=                ${HOME}/pkg/var
1.119     sevan    2147: PKG_DBDIR=              ${HOME}/pkg/pkgdb
1.1       dsieger  2148: 
                   2149: What these four directories are for, and what they look like is explained
                   2150: below.
                   2151: 
1.25      wiz      2152:   * LOCALBASE corresponds to the /usr directory in the base system. It is the "
                   2153:     main" directory where the files are installed and contains the well-known
1.1       dsieger  2154:     subdirectories like bin, include, lib, share and sbin.
                   2155: 
                   2156:   * VARBASE corresponds to /var in the base system. Some programs (especially
                   2157:     games, network daemons) need write access to it during normal operation.
                   2158: 
                   2159:   * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
                   2160:     configuration files of the packages, as well as pkgsrc's mk.conf itself.
                   2161: 
1.154     rillig   2162: 9.1. File system layout in ${LOCALBASE}
1.1       dsieger  2163: 
                   2164: The following directories exist in a typical pkgsrc installation in $
                   2165: {LOCALBASE}.
                   2166: 
                   2167: bin
                   2168: 
                   2169:     Contains executable programs that are intended to be directly used by the
                   2170:     end user.
                   2171: 
                   2172: emul
                   2173: 
                   2174:     Contains files for the emulation layers of various other operating systems,
                   2175:     especially for NetBSD.
                   2176: 
                   2177: etc (the usual location of ${PKG_SYSCONFDIR})
                   2178: 
                   2179:     Contains the configuration files.
                   2180: 
                   2181: include
                   2182: 
                   2183:     Contains headers for the C and C++ programming languages.
                   2184: 
                   2185: info
                   2186: 
                   2187:     Contains GNU info files of various packages.
                   2188: 
                   2189: lib
                   2190: 
                   2191:     Contains shared and static libraries.
                   2192: 
                   2193: libdata
                   2194: 
                   2195:     Contains data files that don't change after installation. Other data files
                   2196:     belong into ${VARBASE}.
                   2197: 
                   2198: libexec
                   2199: 
                   2200:     Contains programs that are not intended to be used by end users, such as
                   2201:     helper programs or network daemons.
                   2202: 
                   2203: libexec/cgi-bin
                   2204: 
                   2205:     Contains programs that are intended to be executed as CGI scripts by a web
                   2206:     server.
                   2207: 
                   2208: man (the usual value of ${PKGMANDIR})
                   2209: 
                   2210:     Contains brief documentation in form of manual pages.
                   2211: 
                   2212: sbin
                   2213: 
                   2214:     Contains programs that are intended to be used only by the super-user.
                   2215: 
                   2216: share
                   2217: 
                   2218:     Contains platform-independent data files that don't change after
                   2219:     installation.
                   2220: 
                   2221: share/doc
                   2222: 
                   2223:     Contains documentation files provided by the packages.
                   2224: 
                   2225: share/examples
                   2226: 
                   2227:     Contains example files provided by the packages. Among others, the original
                   2228:     configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
                   2229:     installation.
                   2230: 
                   2231: share/examples/rc.d
                   2232: 
                   2233:     Contains the original files for rc.d scripts.
                   2234: 
                   2235: var (the usual location of ${VARBASE})
                   2236: 
                   2237:     Contains files that may be modified after installation.
                   2238: 
1.154     rillig   2239: 9.2. File system layout in ${VARBASE}
1.1       dsieger  2240: 
                   2241: db/pkg (the usual location of ${PKG_DBDIR})
                   2242: 
                   2243:     Contains information about the currently installed packages.
                   2244: 
                   2245: games
                   2246: 
                   2247:     Contains highscore files.
                   2248: 
                   2249: log
                   2250: 
                   2251:     Contains log files.
                   2252: 
                   2253: run
                   2254: 
                   2255:     Contains informational files about daemons that are currently running.
                   2256: 
1.154     rillig   2257: Chapter 10. Frequently Asked Questions
1.1       dsieger  2258: 
                   2259: Table of Contents
                   2260: 
1.154     rillig   2261: 10.1. Are there any mailing lists for pkg-related discussion?
                   2262: 10.2. Utilities for package management (pkgtools)
                   2263: 10.3. How to use pkgsrc as non-root
                   2264: 10.4. How to resume transfers when fetching distfiles?
                   2265: 10.5. How can I install/use modular X.org from pkgsrc?
                   2266: 10.6. How to fetch files from behind a firewall
                   2267: 10.7. How to fetch files from HTTPS sites
                   2268: 10.8. How do I tell make fetch to do passive FTP?
                   2269: 10.9. How to fetch all distfiles at once
                   2270: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
                   2271: 10.11. What does "Could not find bsd.own.mk" mean?
                   2272: 10.12. Using 'sudo' with pkgsrc
                   2273: 10.13. How do I change the location of configuration files?
                   2274: 10.14. Automated security checks
                   2275: 10.15. Why do some packages ignore my CFLAGS?
                   2276: 10.16. A package does not build. What shall I do?
                   2277: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24      wiz      2278:     conflicts" mean?
1.1       dsieger  2279: 
                   2280: This section contains hints, tips & tricks on special things in pkgsrc that we
                   2281: didn't find a better place for in the previous chapters, and it contains items
                   2282: for both pkgsrc users and developers.
                   2283: 
1.154     rillig   2284: 10.1. Are there any mailing lists for pkg-related discussion?
1.1       dsieger  2285: 
                   2286: The following mailing lists may be of interest to pkgsrc users:
                   2287: 
                   2288:   * pkgsrc-users: This is a general purpose list for most issues regarding
                   2289:     pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
                   2290:     configuration, unexpected build failures, using particular packages,
                   2291:     upgrading pkgsrc installations, questions regarding the pkgsrc release
                   2292:     branches, etc. General announcements or proposals for changes that impact
                   2293:     the pkgsrc user community, e.g. major infrastructure changes, new features,
                   2294:     package removals, etc., may also be posted.
                   2295: 
                   2296:   * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
                   2297:     discussed.
                   2298: 
                   2299:   * pkgsrc-changes: This list is for those who are interested in getting a
                   2300:     commit message for every change committed to pkgsrc. It is also available
                   2301:     in digest form, meaning one daily message containing all commit messages
                   2302:     for changes to the package source tree in that 24 hour period.
                   2303: 
                   2304: To subscribe, do:
                   2305: 
                   2306: % echo subscribe listname | mail majordomo@NetBSD.org
                   2307: 
1.174     leot     2308: Archives for all these mailing lists are available from https://
1.1       dsieger  2309: mail-index.NetBSD.org/.
                   2310: 
1.154     rillig   2311: 10.2. Utilities for package management (pkgtools)
1.1       dsieger  2312: 
                   2313: The directory pkgsrc/pkgtools contains a number of useful utilities for both
                   2314: users and developers of pkgsrc. This section attempts only to make the reader
1.121     sevan    2315: aware of some of the utilities and when they might be useful, and not to
                   2316: duplicate the documentation that comes with each package.
1.1       dsieger  2317: 
                   2318: Utilities used by pkgsrc (automatically installed when needed):
                   2319: 
                   2320:   * pkgtools/x11-links: Symlinks for use by buildlink.
                   2321: 
                   2322: OS tool augmentation (automatically installed when needed):
                   2323: 
1.121     sevan    2324:   * pkgtools/digest: Calculates various kinds of checksums (including SHA3).
1.1       dsieger  2325: 
                   2326:   * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
                   2327: 
                   2328:   * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
                   2329: 
                   2330:   * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
                   2331:     for use on operating systems where pkg_install is not present.
                   2332: 
                   2333: Utilities used by pkgsrc (not automatically installed):
                   2334: 
                   2335:   * pkgtools/pkg_tarup: Create a binary package from an already-installed
                   2336:     package. Used by make replace to save the old package.
                   2337: 
                   2338:   * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
                   2339:     distfiles from multiple locations. It currently supports the following
                   2340:     methods: multiple CD-ROMs and network FTP/HTTP connections.
                   2341: 
                   2342:   * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24      wiz      2343:     current CPU and compiler.
1.1       dsieger  2344: 
                   2345: Utilities for keeping track of installed packages, being up to date, etc:
                   2346: 
1.65      wiz      2347:   * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
                   2348:     and upgrade binary packages easily.
                   2349: 
1.1       dsieger  2350:   * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
                   2351:     the latest pkgsrc entries.
                   2352: 
                   2353:   * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
                   2354:     strategy for updating.
                   2355: 
                   2356:   * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
                   2357:     graphviz).
                   2358: 
1.12      weinem   2359:   * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
                   2360: 
                   2361:   * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
                   2362:     complete pkgsrc system.
1.1       dsieger  2363: 
                   2364:   * pkgtools/pkgsurvey: Report what packages you have installed.
                   2365: 
                   2366: Utilities for people maintaining or creating individual packages:
                   2367: 
                   2368:   * pkgtools/pkgdiff: Automate making and maintaining patches for a package
                   2369:     (includes pkgdiff, pkgvi, mkpatches, etc.).
                   2370: 
1.65      wiz      2371:   * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1       dsieger  2372: 
                   2373: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
                   2374: 
                   2375:   * pkgtools/pkg_comp: Build packages in a chrooted area.
                   2376: 
                   2377:   * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
                   2378: 
1.154     rillig   2379: 10.3. How to use pkgsrc as non-root
1.1       dsieger  2380: 
1.108     rillig   2381: To install packages from source as a non-root user, download pkgsrc as
1.154     rillig   2382: described in Chapter 3, Where to get pkgsrc and how to keep it up-to-date, cd
1.108     rillig   2383: into that directory and run the command ./bootstrap/bootstrap --unprivileged.
                   2384: 
                   2385: This will install the binary part of pkgsrc to ~/pkg and put the pkgsrc
                   2386: configuration mk.conf into ~/pkg/etc.
                   2387: 
                   2388: For more details, see mk/unprivileged.mk.
1.1       dsieger  2389: 
1.154     rillig   2390: 10.4. How to resume transfers when fetching distfiles?
1.1       dsieger  2391: 
                   2392: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4       rillig   2393: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
                   2394: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1       dsieger  2395: 
1.61      wiz      2396: You can also use a different program than the platform default program by
                   2397: changing the FETCH_USING variable. You can specify the program by using of ftp,
                   2398: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
                   2399: manual. A value of custom disables the system defaults and dependency tracking
                   2400: for the fetch program. In that case you have to provide FETCH_CMD,
                   2401: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1       dsieger  2402: 
1.16      jnemeth  2403: For example, if you want to use wget to download, you'll have to use something
                   2404: like:
1.1       dsieger  2405: 
1.16      jnemeth  2406: FETCH_USING=    wget
1.1       dsieger  2407: 
1.154     rillig   2408: 10.5. How can I install/use modular X.org from pkgsrc?
1.1       dsieger  2409: 
1.4       rillig   2410: If you want to use modular X.org from pkgsrc instead of your system's own X11
                   2411: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1       dsieger  2412: mk.conf:
                   2413: 
1.4       rillig   2414: X11_TYPE=modular
1.1       dsieger  2415: 
1.154     rillig   2416: 10.6. How to fetch files from behind a firewall
1.1       dsieger  2417: 
                   2418: If you are sitting behind a firewall which does not allow direct connections to
                   2419: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
                   2420: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
                   2421: machine "orpheus.amdahl.com" is one of the firewalls, and it uses port 80 as
                   2422: the proxy port number. So the proxy environment variables are:
                   2423: 
                   2424: ftp_proxy=ftp://orpheus.amdahl.com:80/
                   2425: http_proxy=http://orpheus.amdahl.com:80/
                   2426: 
1.154     rillig   2427: 10.7. How to fetch files from HTTPS sites
1.65      wiz      2428: 
                   2429: Some fetch tools are not prepared to support HTTPS by default (for example, the
                   2430: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
                   2431: openssl dependency that low in the dependency graph).
                   2432: 
                   2433: Usually you won't notice, because distribution files are mirrored weekly to "
                   2434: ftp.NetBSD.org", but that might not be often enough if you are following
                   2435: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to "curl" or
                   2436: "wget", which are both compiled with HTTPS support by default. Of course, these
                   2437: tools need to be installed before you can use them this way.
                   2438: 
1.154     rillig   2439: 10.8. How do I tell make fetch to do passive FTP?
1.1       dsieger  2440: 
                   2441: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
                   2442: FETCH_CMD is assigned the first available command from the following list:
                   2443: 
                   2444:   * ${LOCALBASE}/bin/ftp
                   2445: 
                   2446:   * /usr/bin/ftp
                   2447: 
                   2448: On a default NetBSD installation, this will be /usr/bin/ftp, which
                   2449: automatically tries passive connections first, and falls back to active
                   2450: connections if the server refuses to do passive. For the other tools, add the
1.4       rillig   2451: following to your mk.conf file: PASSIVE_FETCH=1.
1.1       dsieger  2452: 
                   2453: Having that option present will prevent /usr/bin/ftp from falling back to
                   2454: active transfers.
                   2455: 
1.154     rillig   2456: 10.9. How to fetch all distfiles at once
1.1       dsieger  2457: 
                   2458: You would like to download all the distfiles in a single batch from work or
                   2459: university, where you can't run a make fetch. There is an archive of distfiles
                   2460: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
                   2461: 
                   2462: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
                   2463: subdirectories, carry the resulting list to your machine at work/school and use
                   2464: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
                   2465: don't forget to set FETCH_CMD to something that fetches a URL:
                   2466: 
                   2467: At home:
                   2468: 
                   2469: % cd /usr/pkgsrc
                   2470: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
                   2471: % scp /tmp/fetch.sh work:/tmp
                   2472: 
                   2473: At work:
                   2474: 
                   2475: % sh /tmp/fetch.sh
                   2476: 
                   2477: then tar up /tmp/distfiles and take it home.
                   2478: 
                   2479: If you have a machine running NetBSD, and you want to get all distfiles (even
                   2480: ones that aren't for your machine architecture), you can do so by using the
                   2481: above-mentioned make fetch-list approach, or fetch the distfiles directly by
                   2482: running:
                   2483: 
                   2484: % make mirror-distfiles
                   2485: 
                   2486: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
                   2487: everything by running:
                   2488: 
                   2489: % make fetch NO_SKIP=yes
                   2490: 
1.154     rillig   2491: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
1.1       dsieger  2492: 
                   2493: When compiling the pkgtools/pkg_install package, you get the error from make
                   2494: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
                   2495: that you don't have installed the "text" set (nroff, ...) from the NetBSD base
                   2496: distribution on your machine. It is recommended to do that to format man pages.
                   2497: 
                   2498: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4       rillig   2499: NOMAN=YES either in the environment or in mk.conf.
1.1       dsieger  2500: 
1.154     rillig   2501: 10.11. What does "Could not find bsd.own.mk" mean?
1.1       dsieger  2502: 
                   2503: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
                   2504: machine. Please get and install it, by extracting it in /:
                   2505: 
                   2506: # cd /
                   2507: # tar --unlink -zxvpf .../comp.tgz
                   2508: 
                   2509: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
                   2510: release (determine via uname -r).
                   2511: 
1.154     rillig   2512: 10.12. Using 'sudo' with pkgsrc
1.1       dsieger  2513: 
                   2514: When installing packages as non-root user and using the just-in-time su(1)
                   2515: feature of pkgsrc, it can become annoying to type in the root password for each
                   2516: required package installed. To avoid this, the sudo package can be used, which
                   2517: does password caching over a limited time. To use it, install sudo (either as
1.4       rillig   2518: binary package or from security/sudo) and then put the following into your
                   2519: mk.conf, somewhere after the definition of the LOCALBASE variable:
1.1       dsieger  2520: 
                   2521: .if exists(${LOCALBASE}/bin/sudo)
                   2522: SU_CMD=        ${LOCALBASE}/bin/sudo /bin/sh -c
                   2523: .endif
                   2524: 
1.154     rillig   2525: 10.13. How do I change the location of configuration files?
1.1       dsieger  2526: 
                   2527: As the system administrator, you can choose where configuration files are
                   2528: installed. The default settings make all these files go into ${PREFIX}/etc or
                   2529: some of its subdirectories; this may be suboptimal depending on your
                   2530: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
                   2531: configuration of the provided packages).
                   2532: 
                   2533: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4       rillig   2534: (in mk.conf) to point to your preferred configuration directory; some common
                   2535: examples include /etc or /etc/pkg.
1.1       dsieger  2536: 
                   2537: Furthermore, you can change this value on a per-package basis by setting the
                   2538: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
                   2539: matches the name of the package you would like to modify, that is, the contents
                   2540: of PKGBASE.
                   2541: 
                   2542: Note that after changing these settings, you must rebuild and reinstall any
                   2543: affected packages.
                   2544: 
1.154     rillig   2545: 10.14. Automated security checks
1.1       dsieger  2546: 
                   2547: Please be aware that there can often be bugs in third-party software, and some
                   2548: of these bugs can leave a machine vulnerable to exploitation by attackers. In
                   2549: an effort to lessen the exposure, the NetBSD packages team maintains a database
                   2550: of known-exploits to packages which have at one time been included in pkgsrc.
                   2551: The database can be downloaded automatically, and a security audit of all
1.14      jmcneill 2552: packages installed on a system can take place. To do this, refer to the
                   2553: following two tools (installed as part of the pkgtools/pkg_install package):
1.1       dsieger  2554: 
1.21      snj      2555:  1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
                   2556:     security vulnerabilities information. This list is kept up to date by the
1.26      spz      2557:     pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1       dsieger  2558: 
1.177     leot     2559:     https://ftp.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities
1.1       dsieger  2560: 
1.21      snj      2561:  2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24      wiz      2562:     known vulnerability. If a vulnerable package is installed, it will be shown
                   2563:     by output to stdout, including a description of the type of vulnerability,
                   2564:     and a URL containing more information.
1.1       dsieger  2565: 
1.154     rillig   2566: Use of these tools is strongly recommended! See Section 5.1.5, "Checking for
1.121     sevan    2567: security vulnerabilities in installed packages" for instructions on how to
                   2568: automate checking and reporting.
                   2569: 
                   2570: If this database is installed, pkgsrc builds will use it to perform a security
                   2571: check before building any package.
1.1       dsieger  2572: 
1.154     rillig   2573: 10.15. Why do some packages ignore my CFLAGS?
1.1       dsieger  2574: 
                   2575: When you add your own preferences to the CFLAGS variable in your mk.conf, these
                   2576: flags are passed in environment variables to the ./configure scripts and to
                   2577: make(1). Some package authors ignore the CFLAGS from the environment variable
                   2578: by overriding them in the Makefiles of their package.
                   2579: 
                   2580: Currently there is no solution to this problem. If you really need the package
                   2581: to use your CFLAGS you should run make patch in the package directory and then
                   2582: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
                   2583: Usually you can remove these lines. But be aware that some "smart" programmers
                   2584: write so bad code that it only works for the specific combination of CFLAGS
                   2585: they have chosen.
                   2586: 
1.172     rillig   2587: To find out where the CFLAGS are ignored, add the following lines to mk.conf:
                   2588: 
                   2589: CPPFLAGS+=              -Dpkgsrc___CPPFLAGS
                   2590: CFLAGS+=                -Dpkgsrc___CFLAGS
                   2591: CXXFLAGS+=              -Dpkgsrc___CXXFLAGS
                   2592: 
                   2593: Then run bmake show-all-configure show-all-build to see whether the above flags
                   2594: are passed to the actual build commands in general.
                   2595: 
                   2596: To find out whether the flags are passed to individual compiler commands, have
                   2597: a look at the file work/.work.log. In most cases, the flags from the original
                   2598: command lines (the lines starting with [*]) are passed unmodified to the actual
                   2599: compiler (the lines starting with <.>). If the flag is missing from the actual
                   2600: compiler command, it must have been removed by the pkgsrc compiler wrappers.
                   2601: 
1.154     rillig   2602: 10.16. A package does not build. What shall I do?
1.1       dsieger  2603: 
                   2604:  1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
                   2605:     is that people only update pkgsrc in parts, because of performance reasons.
                   2606:     Since pkgsrc is one large system, not a collection of many small systems,
                   2607:     there are sometimes changes that only work when the whole pkgsrc tree is
                   2608:     updated.
                   2609: 
1.25      wiz      2610:  2. Make sure that you don't have any CVS conflicts. Search for "<<<<<<" or "
                   2611:     >>>>>>" in all your pkgsrc files.
1.1       dsieger  2612: 
1.25      wiz      2613:  3. Make sure that you don't have old copies of the packages extracted. Run 
1.1       dsieger  2614:     make clean clean-depends to verify this.
                   2615: 
1.108     rillig   2616:  4. If you are a package developer who wants to invest some work, have a look
1.154     rillig   2617:     at Chapter 21, Making your package work.
1.108     rillig   2618: 
                   2619:  5. If the problem still exists, write a mail to the pkgsrc-users mailing list.
1.1       dsieger  2620: 
1.154     rillig   2621: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.1       dsieger  2622: conflicts" mean?
                   2623: 
                   2624: You have modified a file from pkgsrc, and someone else has modified that same
                   2625: file afterwards in the CVS repository. Both changes are in the same region of
                   2626: the file, so when you updated pkgsrc, the cvs command marked the conflicting
                   2627: changes in the file. Because of these markers, the file is no longer a valid
                   2628: Makefile.
                   2629: 
                   2630: Have a look at that file, and if you don't need your local changes anymore, you
                   2631: can remove that file and run cvs -q update -dP in that directory to download
                   2632: the current version.
                   2633: 
                   2634: Part II. The pkgsrc developer's guide
                   2635: 
                   2636: This part of the book deals with creating and modifying packages. It starts
                   2637: with a "HOWTO"-like guide on creating a new package. The remaining chapters are
                   2638: more like a reference manual for pkgsrc.
                   2639: 
                   2640: Table of Contents
                   2641: 
1.154     rillig   2642: 11. Getting help
                   2643: 12. Creating a new pkgsrc package from scratch
1.1       dsieger  2644: 
1.154     rillig   2645:     12.1. Common types of packages
1.1       dsieger  2646: 
1.154     rillig   2647:         12.1.1. Perl modules
                   2648:         12.1.2. Python modules and programs
1.160     brook    2649:         12.1.3. R packages
                   2650:         12.1.4. TeXlive packages
1.1       dsieger  2651: 
1.154     rillig   2652:     12.2. Examples
1.1       dsieger  2653: 
1.154     rillig   2654:         12.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  2655: 
1.154     rillig   2656: 13. Package components - files, directories and contents
1.1       dsieger  2657: 
1.154     rillig   2658:     13.1. Makefile
                   2659:     13.2. distinfo
                   2660:     13.3. patches/*
1.1       dsieger  2661: 
1.154     rillig   2662:         13.3.1. Structure of a single patch file
                   2663:         13.3.2. Creating patch files
                   2664:         13.3.3. Sources where the patch files come from
                   2665:         13.3.4. Patching guidelines
                   2666:         13.3.5. Feedback to the author
1.1       dsieger  2667: 
1.154     rillig   2668:     13.4. Other mandatory files
                   2669:     13.5. Optional files
1.1       dsieger  2670: 
1.154     rillig   2671:         13.5.1. Files affecting the binary package
                   2672:         13.5.2. Files affecting the build process
                   2673:         13.5.3. Files affecting nothing at all
1.1       dsieger  2674: 
1.154     rillig   2675:     13.6. work*
                   2676:     13.7. files/*
1.1       dsieger  2677: 
1.154     rillig   2678: 14. Programming in Makefiles
1.1       dsieger  2679: 
1.154     rillig   2680:     14.1. Caveats
                   2681:     14.2. Makefile variables
1.1       dsieger  2682: 
1.154     rillig   2683:         14.2.1. Naming conventions
1.1       dsieger  2684: 
1.154     rillig   2685:     14.3. Code snippets
1.1       dsieger  2686: 
1.154     rillig   2687:         14.3.1. Adding things to a list
                   2688:         14.3.2. Echoing a string exactly as-is
                   2689:         14.3.3. Passing CFLAGS to GNU configure scripts
                   2690:         14.3.4. Handling possibly empty variables
1.1       dsieger  2691: 
1.154     rillig   2692: 15. PLIST issues
1.1       dsieger  2693: 
1.154     rillig   2694:     15.1. RCS ID
                   2695:     15.2. Semi-automatic PLIST generation
                   2696:     15.3. Tweaking output of make print-PLIST
                   2697:     15.4. Variable substitution in PLIST
                   2698:     15.5. Man page compression
                   2699:     15.6. Changing PLIST source with PLIST_SRC
                   2700:     15.7. Platform-specific and differing PLISTs
                   2701:     15.8. Build-specific PLISTs
                   2702:     15.9. Sharing directories between packages
1.1       dsieger  2703: 
1.154     rillig   2704: 16. Buildlink methodology
1.1       dsieger  2705: 
1.154     rillig   2706:     16.1. Converting packages to use buildlink3
                   2707:     16.2. Writing buildlink3.mk files
1.1       dsieger  2708: 
1.154     rillig   2709:         16.2.1. Anatomy of a buildlink3.mk file
                   2710:         16.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
1.27      wiz      2711:             pkg in buildlink3.mk files
1.1       dsieger  2712: 
1.154     rillig   2713:     16.3. Writing builtin.mk files
1.1       dsieger  2714: 
1.154     rillig   2715:         16.3.1. Anatomy of a builtin.mk file
                   2716:         16.3.2. Global preferences for native or pkgsrc software
1.1       dsieger  2717: 
1.154     rillig   2718: 17. The pkginstall framework
1.1       dsieger  2719: 
1.154     rillig   2720:     17.1. Files and directories outside the installation prefix
1.1       dsieger  2721: 
1.154     rillig   2722:         17.1.1. Directory manipulation
                   2723:         17.1.2. File manipulation
1.1       dsieger  2724: 
1.154     rillig   2725:     17.2. Configuration files
1.1       dsieger  2726: 
1.154     rillig   2727:         17.2.1. How PKG_SYSCONFDIR is set
                   2728:         17.2.2. Telling the software where configuration files are
                   2729:         17.2.3. Patching installations
                   2730:         17.2.4. Disabling handling of configuration files
1.1       dsieger  2731: 
1.154     rillig   2732:     17.3. System startup scripts
1.1       dsieger  2733: 
1.154     rillig   2734:         17.3.1. Disabling handling of system startup scripts
1.1       dsieger  2735: 
1.154     rillig   2736:     17.4. System users and groups
                   2737:     17.5. System shells
1.1       dsieger  2738: 
1.154     rillig   2739:         17.5.1. Disabling shell registration
1.1       dsieger  2740: 
1.154     rillig   2741:     17.6. Fonts
1.1       dsieger  2742: 
1.154     rillig   2743:         17.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  2744: 
1.154     rillig   2745: 18. Options handling
1.1       dsieger  2746: 
1.154     rillig   2747:     18.1. Global default options
                   2748:     18.2. Converting packages to use bsd.options.mk
                   2749:     18.3. Option Names
                   2750:     18.4. Determining the options of dependencies
1.1       dsieger  2751: 
1.154     rillig   2752: 19. The build process
1.1       dsieger  2753: 
1.154     rillig   2754:     19.1. Introduction
                   2755:     19.2. Program location
                   2756:     19.3. Directories used during the build process
                   2757:     19.4. Running a phase
                   2758:     19.5. The fetch phase
1.1       dsieger  2759: 
1.154     rillig   2760:         19.5.1. What to fetch and where to get it from
                   2761:         19.5.2. How are the files fetched?
1.1       dsieger  2762: 
1.154     rillig   2763:     19.6. The checksum phase
                   2764:     19.7. The extract phase
                   2765:     19.8. The patch phase
                   2766:     19.9. The tools phase
                   2767:     19.10. The wrapper phase
                   2768:     19.11. The configure phase
                   2769:     19.12. The build phase
                   2770:     19.13. The test phase
                   2771:     19.14. The install phase
                   2772:     19.15. The package phase
                   2773:     19.16. Cleaning up
                   2774:     19.17. Other helpful targets
1.1       dsieger  2775: 
1.154     rillig   2776: 20. Tools needed for building or running
1.1       dsieger  2777: 
1.154     rillig   2778:     20.1. Tools for pkgsrc builds
                   2779:     20.2. Tools needed by packages
                   2780:     20.3. Tools provided by platforms
1.1       dsieger  2781: 
1.154     rillig   2782: 21. Making your package work
1.1       dsieger  2783: 
1.154     rillig   2784:     21.1. General operation
1.1       dsieger  2785: 
1.154     rillig   2786:         21.1.1. How to pull in user-settable variables from mk.conf
                   2787:         21.1.2. User interaction
                   2788:         21.1.3. Handling licenses
                   2789:         21.1.4. Restricted packages
                   2790:         21.1.5. Handling dependencies
                   2791:         21.1.6. Handling conflicts with other packages
                   2792:         21.1.7. Packages that cannot or should not be built
                   2793:         21.1.8. Packages which should not be deleted, once installed
                   2794:         21.1.9. Handling packages with security problems
                   2795:         21.1.10. How to handle incrementing versions when fixing an existing
1.1       dsieger  2796:             package
1.154     rillig   2797:         21.1.11. Substituting variable text in the package files (the SUBST
1.1       dsieger  2798:             framework)
                   2799: 
1.154     rillig   2800:     21.2. The fetch phase
1.1       dsieger  2801: 
1.154     rillig   2802:         21.2.1. Packages whose distfiles aren't available for plain downloading
                   2803:         21.2.2. How to handle modified distfiles with the 'old' name
                   2804:         21.2.3. Packages hosted on github.com
                   2805: 
                   2806:     21.3. The configure phase
                   2807: 
                   2808:         21.3.1. Shared libraries - libtool
                   2809:         21.3.2. Using libtool on GNU packages that already support libtool
                   2810:         21.3.3. GNU Autoconf/Automake
                   2811: 
                   2812:     21.4. Programming languages
                   2813: 
                   2814:         21.4.1. C, C++, and Fortran
                   2815:         21.4.2. Java
                   2816:         21.4.3. Packages containing perl scripts
                   2817:         21.4.4. Packages containing shell scripts
                   2818:         21.4.5. Other programming languages
                   2819: 
                   2820:     21.5. The build phase
                   2821: 
                   2822:         21.5.1. Compiling C and C++ code conditionally
                   2823:         21.5.2. How to handle compiler bugs
1.172     rillig   2824:         21.5.3. No such file or directory
                   2825:         21.5.4. Undefined reference to "..."
                   2826:         21.5.5. Running out of memory
1.154     rillig   2827: 
                   2828:     21.6. The install phase
                   2829: 
                   2830:         21.6.1. Creating needed directories
                   2831:         21.6.2. Where to install documentation
                   2832:         21.6.3. Installing highscore files
                   2833:         21.6.4. Adding DESTDIR support to packages
                   2834:         21.6.5. Packages with hardcoded paths to other interpreters
                   2835:         21.6.6. Packages installing perl modules
                   2836:         21.6.7. Packages installing info files
                   2837:         21.6.8. Packages installing man pages
                   2838:         21.6.9. Packages installing GConf data files
                   2839:         21.6.10. Packages installing scrollkeeper/rarian data files
                   2840:         21.6.11. Packages installing X11 fonts
                   2841:         21.6.12. Packages installing GTK2 modules
                   2842:         21.6.13. Packages installing SGML or XML data
                   2843:         21.6.14. Packages installing extensions to the MIME database
                   2844:         21.6.15. Packages using intltool
                   2845:         21.6.16. Packages installing startup scripts
                   2846:         21.6.17. Packages installing TeX modules
                   2847:         21.6.18. Packages supporting running binaries in emulation
                   2848:         21.6.19. Packages installing hicolor theme icons
                   2849:         21.6.20. Packages installing desktop files
                   2850: 
                   2851:     21.7. Marking packages as having problems
                   2852: 
                   2853: 22. Debugging
                   2854: 23. Submitting and Committing
                   2855: 
                   2856:     23.1. Submitting binary packages
                   2857:     23.2. Submitting source packages (for non-NetBSD-developers)
                   2858:     23.3. General notes when adding, updating, or removing packages
                   2859:     23.4. Commit Messages
                   2860:     23.5. Committing: Adding a package to CVS
                   2861:     23.6. Updating a package to a newer version
                   2862:     23.7. Renaming a package in pkgsrc
                   2863:     23.8. Moving a package in pkgsrc
                   2864: 
                   2865: 24. Frequently Asked Questions
                   2866: 25. GNOME packaging and porting
                   2867: 
                   2868:     25.1. Meta packages
                   2869:     25.2. Packaging a GNOME application
                   2870:     25.3. Updating GNOME to a newer version
                   2871:     25.4. Patching guidelines
                   2872: 
                   2873: Chapter 11. Getting help
                   2874: 
                   2875: To get help when developing pkgsrc, the definitive source is this document, the
                   2876: pkgsrc guide. If you don't find anything here, there are alternatives:
                   2877: 
                   2878:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
                   2879:     Run bmake help topic=? to get help for any topic, such as a variable name
                   2880:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                   2881:     like strcasecmp or any other topic.
                   2882: 
                   2883:     The available help topics are listed in Appendix D, Help topics.
                   2884: 
1.163     rillig   2885:   * To see the value of a single variable, run bmake show-var VARNAME=X.
                   2886: 
                   2887:   * To see the values of the most common variables, run bmake show-all. These
                   2888:     variables are grouped by topic. To see the variables for a single topic,
                   2889:     run bmake show-all-topic, for example bmake show-all-fetch.
                   2890: 
1.154     rillig   2891:   * The tech-pkg mailing list, to which you can subscribe and then ask your
                   2892:     questions.
                   2893: 
                   2894:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                   2895:     a specialized chat program such as XChat. Pick any user name and join the
                   2896:     channel #pkgsrc.
1.1       dsieger  2897: 
1.154     rillig   2898: Chapter 12. Creating a new pkgsrc package from scratch
1.1       dsieger  2899: 
                   2900: Table of Contents
                   2901: 
1.154     rillig   2902: 12.1. Common types of packages
1.1       dsieger  2903: 
1.154     rillig   2904:     12.1.1. Perl modules
                   2905:     12.1.2. Python modules and programs
1.160     brook    2906:     12.1.3. R packages
                   2907:     12.1.4. TeXlive packages
1.1       dsieger  2908: 
1.154     rillig   2909: 12.2. Examples
1.1       dsieger  2910: 
1.154     rillig   2911:     12.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  2912: 
                   2913: When you find a package that is not yet in pkgsrc, you most likely have a URL
                   2914: from where you can download the source code. Starting with this URL, creating a
                   2915: package involves only a few steps.
                   2916: 
                   2917:  1. First, install the packages pkgtools/url2pkg and pkgtools/pkglint.
                   2918: 
                   2919:  2. Then, choose one of the top-level directories as the category in which you
                   2920:     want to place your package. You can also create a directory of your own
                   2921:     (maybe called local). In that category directory, create another directory
                   2922:     for your package and change into it.
                   2923: 
                   2924:  3. Run the program url2pkg, which will ask you for a URL. Enter the URL of the
                   2925:     distribution file (in most cases a .tar.gz file) and watch how the basic
                   2926:     ingredients of your package are created automatically. The distribution
                   2927:     file is extracted automatically to fill in some details in the Makefile
                   2928:     that would otherwise have to be done manually.
                   2929: 
                   2930:  4. Examine the extracted files to determine the dependencies of your package.
                   2931:     Ideally, this is mentioned in some README file, but things may differ. For
                   2932:     each of these dependencies, look where it exists in pkgsrc, and if there is
                   2933:     a file called buildlink3.mk in that directory, add a line to your package
                   2934:     Makefile which includes that file just before the last line. If the
1.26      spz      2935:     buildlink3.mk file does not exist, it must be created first. The
                   2936:     buildlink3.mk file makes sure that the package's include files and
                   2937:     libraries are provided.
                   2938: 
                   2939:     If you just need binaries from a package, add a DEPENDS line to the
                   2940:     Makefile, which specifies the version of the dependency and where it can be
                   2941:     found in pkgsrc. This line should be placed in the third paragraph. If the
1.1       dsieger  2942:     dependency is only needed for building the package, but not when using it,
1.156     leot     2943:     use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The difference
                   2944:     between TOOL_DEPENDS and BUILD_DEPENDS occurs when cross-compiling:
                   2945:     TOOL_DEPENDS are native packages, i.e. packages for the architecture where
                   2946:     the package is built; BUILD_DEPENDS are target packages, i.e. packages for
1.175     gutterid 2947:     the architecture for which the package is built. There is also
                   2948:     TEST_DEPENDS, which is used to specify a dependency used only for testing
                   2949:     the resulting package built, using the upstream project's included test
                   2950:     suite. Your package may then look like this:
1.1       dsieger  2951: 
                   2952:     [...]
                   2953: 
1.156     leot     2954:     TOOL_DEPENDS+=  libxslt-[0-9]*:../../textproc/libxslt
1.1       dsieger  2955:     DEPENDS+=       screen-[0-9]*:../../misc/screen
                   2956:     DEPENDS+=       screen>=4.0:../../misc/screen
                   2957: 
                   2958:     [...]
                   2959: 
                   2960:     .include "../../category/package/buildlink3.mk"
                   2961:     .include "../../devel/glib2/buildlink3.mk"
                   2962:     .include "../../mk/bsd.pkg.mk"
                   2963: 
                   2964:  5. Run pkglint to see what things still need to be done to make your package a
                   2965:     "good" one. If you don't know what pkglint's warnings want to tell you, try
                   2966:     pkglint --explain or pkglint -e, which outputs additional explanations.
                   2967: 
                   2968:  6. In many cases the package is not yet ready to build. You can find
1.154     rillig   2969:     instructions for the most common cases in the next section, Section 12.1,
1.1       dsieger  2970:     "Common types of packages". After you have followed the instructions over
                   2971:     there, you can hopefully continue here.
                   2972: 
                   2973:  7. Run bmake clean to clean the working directory from the extracted files.
                   2974:     Besides these files, a lot of cache files and other system information has
                   2975:     been saved in the working directory, which may become wrong after you
                   2976:     edited the Makefile.
                   2977: 
                   2978:  8. Now, run bmake to build the package. For the various things that can go
1.154     rillig   2979:     wrong in this phase, consult Chapter 21, Making your package work.
1.1       dsieger  2980: 
1.25      wiz      2981:  9. When the package builds fine, the next step is to install the package. Run 
1.1       dsieger  2982:     bmake install and hope that everything works.
                   2983: 
                   2984: 10. Up to now, the file PLIST, which contains a list of the files that are
                   2985:     installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
                   2986:     generate a probably correct list. Check the file using your preferred text
                   2987:     editor to see if the list of files looks plausible.
                   2988: 
                   2989: 11. Run pkglint again to see if the generated PLIST contains garbage or not.
                   2990: 
                   2991: 12. When you ran bmake install, the package has been registered in the database
                   2992:     of installed files, but with an empty list of files. To fix this, run bmake
                   2993:     deinstall and bmake install again. Now the package is registered with the
                   2994:     list of files from PLIST.
                   2995: 
                   2996: 13. Run bmake package to create a binary package from the set of installed
                   2997:     files.
                   2998: 
1.154     rillig   2999: 12.1. Common types of packages
1.1       dsieger  3000: 
1.154     rillig   3001: 12.1.1. Perl modules
1.1       dsieger  3002: 
                   3003: Simple Perl modules are handled automatically by url2pkg, including
                   3004: dependencies.
                   3005: 
1.154     rillig   3006: 12.1.2. Python modules and programs
1.17      imil     3007: 
                   3008: Python modules and programs packages are easily created using a set of
                   3009: predefined variables.
                   3010: 
1.63      wiz      3011: If some Python versions are not supported by the software, set the
                   3012: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
                   3013: supported, e.g.
1.17      imil     3014: 
1.93      sevan    3015: PYTHON_VERSIONS_INCOMPATIBLE=       27
1.17      imil     3016: 
1.103     wiz      3017: If the packaged software is a Python module, include one of ../../lang/python/
                   3018: egg.mk, ../../lang/python/distutils.mk, or ../../lang/python/extension.mk.
                   3019: 
                   3020: Most Python packages use either "distutils" or easy-setup/setuptools ("eggs").
1.175     gutterid 3021: If the packaged software is using setuptools, you only need to include "../../
1.103     wiz      3022: lang/python/egg.mk". Otherwise, if the software uses "distutils", include "..
1.175     gutterid 3023: /../lang/python/distutils.mk", so pkgsrc will use this framework. "distutils"
                   3024: uses a script called setup.py; if the "distutils" driver is not called
1.103     wiz      3025: setup.py, set the PYSETUP variable to the name of the script.
                   3026: 
                   3027: Either way, the package directory should be called "py-software" and PKGNAME
                   3028: should be set to "${PYPKGPREFIX}-${DISTNAME}", e.g.
1.17      imil     3029: 
                   3030: DISTNAME=   foopymodule-1.2.10
                   3031: PKGNAME=    ${PYPKGPREFIX}-${DISTNAME}
                   3032: 
1.63      wiz      3033: If it is an application, include "../../lang/python/application.mk". In order
                   3034: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
                   3035: variable and set it to the list of files (paths relative to WRKSRC) that must
                   3036: be corrected. For example:
1.17      imil     3037: 
1.63      wiz      3038: REPLACE_PYTHON=   *.py
1.17      imil     3039: 
1.63      wiz      3040: Some Python modules have separate distributions for Python-2.x and Python-3.x
                   3041: support. In pkgsrc this is handled by the versioned_dependencies.mk file. Set
                   3042: PYTHON_VERSIONED_DEPENDENCIES to the list of packages that should be depended
                   3043: upon and include "../../lang/python/versioned_dependencies.mk", then the pkgsrc
                   3044: infrastructure will depend on the appropriate package version. For example:
1.17      imil     3045: 
1.135     wiz      3046: PYTHON_VERSIONED_DEPENDENCIES=dialog
1.63      wiz      3047: 
                   3048: Look inside versioned_dependencies.mk for a list of supported packages.
1.17      imil     3049: 
1.160     brook    3050: 12.1.3. R packages
                   3051: 
                   3052: Simple R packages from CRAN are handled automatically by R2pkg, which is
                   3053: available in pkgtools/R2pkg. Individual packages (and optionally their
                   3054: dependencies) may be created and updated. R packages generally follow the same
                   3055: form, and most of the relevant information needed is contained in a DESCRIPTION
                   3056: file as part of each R package on CRAN. Consequently, R2pkg downloads that
                   3057: information and creates or updates a package in the canonical form. The
                   3058: resulting package should be reviewed for correctness.
                   3059: 
                   3060: 12.1.4. TeXlive packages
                   3061: 
                   3062: TeXlive packages from CTAN are handled automatically by texlive2pkg, which is
                   3063: available in pkgtools/texlive2pkg.
                   3064: 
                   3065: If the TeXlive package name is not known, it may be useful to search CTAN. A "
                   3066: Contained in" field on the package page typically identifies the basename of
                   3067: the package file in the TeXlive archive.
                   3068: 
                   3069: If the TeXlive package name is known, download the files from the TeXlive
                   3070: archive. For package foo, you will need to download foo.tar.xz. Most TeXlive
                   3071: packages also have associated documentation packages, so download
                   3072: foo.doc.tar.xz at the same time. These files should be placed in the
                   3073: appropriate category directory, which is often but not always print. Then run
                   3074: the following command in the category directory.
                   3075: 
                   3076: texlive2pkg foo.tar.xz foo.doc.tar.xz
                   3077: 
                   3078: This will create two packages, tex-foo and tex-foo-doc. Be sure to check that
                   3079: both packages are correct.
                   3080: 
                   3081: Finally, CTAN currently does not include version information in package
                   3082: filenames and changes their contents periodically when updates occur.
                   3083: Consequently, pkgsrc avoids downloading distfiles directly from CTAN and
                   3084: instead relies on the pkgsrc archives. For each new or updated TeXlive package,
                   3085: e.g., the main one and the corresponding documentation, upload the distfiles
                   3086: with the following command in each package directory.
                   3087: 
                   3088: make upload-distfiles
                   3089: 
1.154     rillig   3090: 12.2. Examples
1.1       dsieger  3091: 
1.154     rillig   3092: 12.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  3093: 
1.154     rillig   3094: 12.2.1.1. The initial package
1.1       dsieger  3095: 
                   3096: Looking at the file pkgsrc/doc/TODO, I saw that the "nvu" package has not yet
                   3097: been imported into pkgsrc. As the description says it has to do with the web,
                   3098: the obvious choice for the category is "www".
                   3099: 
                   3100: $ mkdir www/nvu
                   3101: $ cd www/nvu
                   3102: 
                   3103: The web site says that the sources are available as a tar file, so I fed that
                   3104: URL to the url2pkg program:
                   3105: 
                   3106: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
                   3107: 
                   3108: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
                   3109: package name should not have the word "sources" in it. I also filled in the
                   3110: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
                   3111: that:
                   3112: 
1.121     sevan    3113: # $NetBSD $
1.1       dsieger  3114: #
                   3115: 
                   3116: DISTNAME=       nvu-1.0-sources
                   3117: PKGNAME=        nvu-1.0
                   3118: CATEGORIES=     www
                   3119: MASTER_SITES=   http://cvs.nvu.com/download/
                   3120: EXTRACT_SUFX=   .tar.bz2
                   3121: 
                   3122: MAINTAINER=     rillig@NetBSD.org
                   3123: HOMEPAGE=       http://cvs.nvu.com/
                   3124: COMMENT=        Web Authoring System
                   3125: 
                   3126: # url2pkg-marker (please do not remove this line.)
                   3127: .include "../../mk/bsd.pkg.mk"
                   3128: 
1.124     wiz      3129: On the first line of output above, an artificial space has been added between
1.121     sevan    3130: NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
                   3131: the guide.
                   3132: 
1.1       dsieger  3133: Then, I quit the editor and watched pkgsrc downloading a large source archive:
                   3134: 
                   3135: url2pkg> Running "make makesum" ...
                   3136: => Required installed package digest>=20010302: digest-20060826 found
                   3137: => Fetching nvu-1.0-sources.tar.bz2
                   3138: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
                   3139: 100% |*************************************| 28992 KB  150.77 KB/s00:00 ETA
                   3140: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
                   3141: url2pkg> Running "make extract" ...
                   3142: => Required installed package digest>=20010302: digest-20060826 found
                   3143: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   3144: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   3145: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
                   3146: ===> Installing dependencies for nvu-1.0
                   3147: ===> Overriding tools for nvu-1.0
                   3148: ===> Extracting for nvu-1.0
                   3149: url2pkg> Adjusting the Makefile.
                   3150: 
                   3151: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
                   3152: 
                   3153: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
                   3154: 
1.154     rillig   3155: 12.2.1.2. Fixing all kinds of problems to make the package work
1.1       dsieger  3156: 
                   3157: Now that the package has been extracted, let's see what's inside it. The
                   3158: package has a README.txt, but that only says something about mozilla, so it's
                   3159: probably useless for seeing what dependencies this package has. But since there
                   3160: is a GNU configure script in the package, let's hope that it will complain
                   3161: about everything it needs.
                   3162: 
                   3163: $ bmake
                   3164: => Required installed package digest>=20010302: digest-20060826 found
                   3165: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   3166: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   3167: ===> Patching for nvu-1.0
                   3168: ===> Creating toolchain wrappers for nvu-1.0
                   3169: ===> Configuring for nvu-1.0
                   3170: [...]
                   3171: configure: error: Perl 5.004 or higher is required.
                   3172: [...]
                   3173: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
                   3174: [...]
                   3175: 
                   3176: That worked quite well. So I opened the package Makefile in my editor, and
                   3177: since it already has a USE_TOOLS line, I just appended "perl" to it. Since the
                   3178: dependencies of the package have changed now, and since a perl wrapper is
                   3179: automatically installed in the "tools" phase, I need to build the package from
                   3180: scratch.
                   3181: 
                   3182: $ bmake clean
                   3183: ===> Cleaning for nvu-1.0
                   3184: $ bmake
                   3185: [...]
                   3186: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
                   3187: GNU Make.  You will not be able to build Mozilla without GNU Make.
                   3188: [...]
                   3189: 
                   3190: So I added "gmake" to the USE_TOOLS line and tried again (from scratch).
                   3191: 
                   3192: [...]
                   3193: checking for GTK - version >= 1.2.0... no
                   3194: *** Could not run GTK test program, checking why...
                   3195: [...]
                   3196: 
                   3197: Now to the other dependencies. The first question is: Where is the GTK package
                   3198: hidden in pkgsrc?
                   3199: 
                   3200: $ echo ../../*/gtk*
                   3201: [many packages ...]
                   3202: $ echo ../../*/gtk
                   3203: ../../x11/gtk
                   3204: $ echo ../../*/gtk2
                   3205: ../../x11/gtk2
                   3206: $ echo ../../*/gtk2/bui*
                   3207: ../../x11/gtk2/buildlink3.mk
                   3208: 
                   3209: The first try was definitely too broad. The second one had exactly one result,
                   3210: which is very good. But there is one pitfall with GNOME packages. Before GNOME
                   3211: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
                   3212: able to continue to use these packages, the GNOME 2 packages were imported as
                   3213: separate packages, and their names usually have a "2" appended. So I checked
                   3214: whether this was the case here, and indeed it was.
                   3215: 
                   3216: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
                   3217: easy. I just inserted an .include line before the last line of the package
                   3218: Makefile, so that it now looks like this:
                   3219: 
                   3220: [...]
                   3221: .include "../../x11/gtk2/buildlink3.mk"
                   3222: .include "../../mk/bsd.pkg.mk
                   3223: 
                   3224: After another bmake clean && bmake, the answer was:
                   3225: 
                   3226: [...]
                   3227: checking for gtk-config... /home/roland/pkg/bin/gtk-config
                   3228: checking for GTK - version >= 1.2.0... no
                   3229: *** Could not run GTK test program, checking why...
                   3230: *** The test program failed to compile or link. See the file config.log for the
                   3231: *** exact error that occured. This usually means GTK was incorrectly installed
                   3232: *** or that you have moved GTK since it was installed. In the latter case, you
                   3233: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
                   3234: configure: error: Test for GTK failed.
                   3235: [...]
                   3236: 
                   3237: In this particular case, the assumption that "every package prefers GNOME 2"
                   3238: had been wrong. The first of the lines above told me that this package really
                   3239: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
                   3240: it would have looked for pkg-config instead of gtk-config. So I changed the x11
                   3241: /gtk2 to x11/gtk in the package Makefile, and tried again.
                   3242: 
                   3243: [...]
1.59      jnemeth  3244: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\"  [...]
1.1       dsieger  3245: In file included from xpidl.c:42:
                   3246: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
                   3247: In file included from xpidl.c:42:
                   3248: xpidl.h:132: error: parse error before "IDL_ns"
                   3249: [...]
                   3250: 
                   3251: The package still does not find all of its dependencies. Now the question is:
                   3252: Which package provides the libIDL/IDL.h header file?
                   3253: 
                   3254: $ echo ../../*/*idl*
                   3255: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
                   3256: $ echo ../../*/*IDL*
                   3257: ../../net/libIDL
                   3258: 
                   3259: Let's take the one from the second try. So I included the ../../net/libIDL/
                   3260: buildlink3.mk file and tried again. But the error didn't change. After digging
                   3261: through some of the code, I concluded that the build process of the package was
                   3262: broken and couldn't have ever worked, but since the Mozilla source tree is
                   3263: quite large, I didn't want to fix it. So I added the following to the package
                   3264: Makefile and tried again:
                   3265: 
                   3266: CPPFLAGS+=              -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
1.139     leot     3267: BUILDLINK_TRANSFORM+=   l:IDL:IDL-2
1.1       dsieger  3268: 
                   3269: The latter line is needed because the package expects the library libIDL.so,
                   3270: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
                   3271: that on the fly.
                   3272: 
                   3273: The next problem was related to a recent change of the FreeType interface. I
                   3274: looked up in www/seamonkey which patch files were relevant for this issue and
                   3275: copied them to the patches directory. Then I retried, fixed the patches so that
                   3276: they applied cleanly and retried again. This time, everything worked.
                   3277: 
1.154     rillig   3278: 12.2.1.3. Installing the package
1.1       dsieger  3279: 
                   3280: $ bmake CHECK_FILES=no install
                   3281: [...]
                   3282: $ bmake print-PLIST >PLIST
                   3283: $ bmake deinstall
                   3284: $ bmake install
                   3285: 
1.154     rillig   3286: Chapter 13. Package components - files, directories and contents
1.1       dsieger  3287: 
                   3288: Table of Contents
                   3289: 
1.154     rillig   3290: 13.1. Makefile
                   3291: 13.2. distinfo
                   3292: 13.3. patches/*
                   3293: 
                   3294:     13.3.1. Structure of a single patch file
                   3295:     13.3.2. Creating patch files
                   3296:     13.3.3. Sources where the patch files come from
                   3297:     13.3.4. Patching guidelines
                   3298:     13.3.5. Feedback to the author
                   3299: 
                   3300: 13.4. Other mandatory files
                   3301: 13.5. Optional files
                   3302: 
                   3303:     13.5.1. Files affecting the binary package
                   3304:     13.5.2. Files affecting the build process
                   3305:     13.5.3. Files affecting nothing at all
1.1       dsieger  3306: 
1.154     rillig   3307: 13.6. work*
                   3308: 13.7. files/*
1.1       dsieger  3309: 
                   3310: Whenever you're preparing a package, there are a number of files involved which
                   3311: are described in the following sections.
                   3312: 
1.154     rillig   3313: 13.1. Makefile
1.1       dsieger  3314: 
                   3315: Building, installation and creation of a binary package are all controlled by
                   3316: the package's Makefile. The Makefile describes various things about a package,
                   3317: for example from where to get it, how to configure, build, and install it.
                   3318: 
                   3319: A package Makefile contains several sections that describe the package.
                   3320: 
                   3321: In the first section there are the following variables, which should appear
                   3322: exactly in the order given here. The order and grouping of the variables is
                   3323: mostly historical and has no further meaning.
                   3324: 
                   3325:   * DISTNAME is the basename of the distribution file to be downloaded from the
                   3326:     package's website.
                   3327: 
1.66      asau     3328:   * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
                   3329:     it if DISTNAME (which is the default) is not a good name for the package in
                   3330:     pkgsrc or DISTNAME is not provided (no distribution file is required).
                   3331:     Usually it is the pkgsrc directory name together with the version number.
                   3332:     It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
                   3333:     is, it starts with a letter or digit, and contains only letters, digits,
                   3334:     dashes, underscores, dots and plus signs.
1.1       dsieger  3335: 
                   3336:   * CATEGORIES is a list of categories which the package fits in. You can
                   3337:     choose any of the top-level directories of pkgsrc for it.
                   3338: 
                   3339:     Currently the following values are available for CATEGORIES. If more than
                   3340:     one is used, they need to be separated by spaces:
                   3341: 
                   3342:     archivers     cross         geography     meta-pkgs     security
                   3343:     audio         databases     graphics      misc          shells
                   3344:     benchmarks    devel         ham           multimedia    sysutils
                   3345:     biology       editors       inputmethod   net           textproc
                   3346:     cad           emulators     lang          news          time
                   3347:     chat          finance       mail          parallel      wm
                   3348:     comms         fonts         math          pkgtools      www
                   3349:     converters    games         mbone         print         x11
                   3350: 
                   3351:   * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
1.154     rillig   3352:     are discussed in detail in Section 19.5, "The fetch phase".
1.1       dsieger  3353: 
                   3354: The second section contains information about separately downloaded patches, if
                   3355: any.
                   3356: 
                   3357:   * PATCHFILES: Name(s) of additional files that contain distribution patches.
                   3358:     There is no default. pkgsrc will look for them at PATCH_SITES. They will
                   3359:     automatically be uncompressed before patching if the names end with .gz or
                   3360:     .Z.
                   3361: 
                   3362:   * PATCH_SITES: Primary location(s) for distribution patch files (see
1.80      wiz      3363:     PATCHFILES above) if not found locally.
                   3364: 
                   3365:   * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
                   3366:     count to help find the correct files to patch. It defaults to -p0.
1.1       dsieger  3367: 
                   3368: The third section contains the following variables.
                   3369: 
                   3370:   * MAINTAINER is the email address of the person who feels responsible for
                   3371:     this package, and who is most likely to look at problems or questions
                   3372:     regarding this package which have been reported with send-pr(1). Other
1.14      jmcneill 3373:     developers may contact the MAINTAINER before making changes to the package,
                   3374:     but are not required to do so. When packaging a new program, set MAINTAINER
                   3375:     to yourself. If you really can't maintain the package for future updates,
                   3376:     set it to <pkgsrc-users@NetBSD.org>.
                   3377: 
                   3378:   * OWNER should be used instead of MAINTAINER when you do not want other
                   3379:     developers to update or change the package without contacting you first. A
                   3380:     package Makefile should contain one of MAINTAINER or OWNER, but not both.
1.1       dsieger  3381: 
                   3382:   * HOMEPAGE is a URL where users can find more information about the package.
                   3383: 
                   3384:   * COMMENT is a one-line description of the package (should not include the
                   3385:     package name).
                   3386: 
1.122     leot     3387:   * LICENSE indicates the license(s) applicable for the package. See
1.154     rillig   3388:     Section 21.1.3, "Handling licenses" for further details.
1.122     leot     3389: 
1.1       dsieger  3390: Other variables that affect the build:
                   3391: 
                   3392:   * WRKSRC: The directory where the interesting distribution files of the
                   3393:     package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
                   3394:     most packages.
                   3395: 
                   3396:     If a package doesn't create a subdirectory for itself (most GNU software
                   3397:     does, for instance), but extracts itself in the current directory, you
                   3398:     should set WRKSRC=${WRKDIR}.
                   3399: 
                   3400:     If a package doesn't create a subdirectory with the name of DISTNAME but
                   3401:     some different name, set WRKSRC to point to the proper name in ${WRKDIR},
                   3402:     for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
                   3403:     other examples.
                   3404: 
                   3405:     The name of the working directory created by pkgsrc is taken from the
                   3406:     WRKDIR_BASENAME variable. By default, its value is work. If you want to use
                   3407:     the same pkgsrc tree for building different kinds of binary packages, you
                   3408:     can change the variable according to your needs. Two other variables handle
                   3409:     common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
1.4       rillig   3410:     defined in mk.conf, the first component of the host's name is attached to
                   3411:     the directory name. If OBJMACHINE is defined, the platform name is
1.1       dsieger  3412:     attached, which might look like work.i386 or work.sparc.
                   3413: 
                   3414: Please pay attention to the following gotchas:
                   3415: 
                   3416:   * Add MANCOMPRESSED if man pages are installed in compressed form by the
                   3417:     package. For packages using BSD-style makefiles which honor MANZ, there is
                   3418:     MANCOMPRESSED_IF_MANZ.
                   3419: 
                   3420:   * Replace /usr/local with "${PREFIX}" in all files (see patches, below).
                   3421: 
1.154     rillig   3422:   * If the package installs any info files, see Section 21.6.7, "Packages
1.1       dsieger  3423:     installing info files".
                   3424: 
1.154     rillig   3425: 13.2. distinfo
1.1       dsieger  3426: 
                   3427: The distinfo file contains the message digest, or checksum, of each distfile
                   3428: needed for the package. This ensures that the distfiles retrieved from the
                   3429: Internet have not been corrupted during transfer or altered by a malign force
1.108     rillig   3430: to introduce a security hole. To provide maximum security, all distfiles are
                   3431: protected using three different message digest algorithms (SHA1, RMD160,
                   3432: SHA512), as well as the file size.
1.1       dsieger  3433: 
                   3434: The distinfo file also contains the checksums for all the patches found in the
1.154     rillig   3435: patches directory (see Section 13.3, "patches/*"). These checksums ensure that
1.145     leot     3436: patches are only applied intentionally and that they don't accidentally change,
                   3437: e.g. when merging different changes together. They also make sure that new
                   3438: patches are actually added to CVS and old ones are removed. Too see whether the
                   3439: patches and the distinfo file match, run pkglint after changing the patches.
1.1       dsieger  3440: 
1.108     rillig   3441: To regenerate the distinfo file, use the make distinfo command.
1.1       dsieger  3442: 
                   3443: Some packages have different sets of distfiles depending on the platform, for
1.178   ! rillig   3444: example lang/openjdk8. These are kept in the same distinfo file and care should
1.24      wiz      3445: be taken when upgrading such a package to ensure distfile information is not
                   3446: lost.
1.1       dsieger  3447: 
1.154     rillig   3448: 13.3. patches/*
1.1       dsieger  3449: 
1.108     rillig   3450: Some packages don't work out-of-the box on the various platforms that are
                   3451: supported by pkgsrc. These packages need to be patched to make them work. The
                   3452: patch files can be found in the patches/ directory.
1.1       dsieger  3453: 
                   3454: In the patch phase, these patches are applied to the files in WRKSRC directory
1.25      wiz      3455: after extracting them, in alphabetic order.
1.1       dsieger  3456: 
1.154     rillig   3457: 13.3.1. Structure of a single patch file
1.1       dsieger  3458: 
                   3459: The patch-* files should be in diff -bu format, and apply without a fuzz to
                   3460: avoid problems. (To force patches to apply with fuzz you can set
                   3461: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
                   3462: a single file, and no file should be patched by more than one patch file. This
                   3463: helps to keep future modifications simple.
                   3464: 
                   3465: Each patch file is structured as follows: In the first line, there is the RCS
                   3466: Id of the patch itself. The second line should be empty for aesthetic reasons.
                   3467: After that, there should be a comment for each change that the patch does.
                   3468: There are a number of standard cases:
                   3469: 
                   3470:   * Patches for commonly known vulnerabilities should mention the vulnerability
                   3471:     ID (CAN, CVE).
                   3472: 
                   3473:   * Patches that change source code should mention the platform and other
                   3474:     environment (for example, the compiler) that the patch is needed for.
                   3475: 
1.108     rillig   3476: The patch should be commented so that any developer who knows the code of the
                   3477: application can make some use of the patch. Special care should be taken for
                   3478: the upstream developers, since we generally want that they accept our patches,
                   3479: so we have less work in the future.
1.1       dsieger  3480: 
1.154     rillig   3481: 13.3.2. Creating patch files
1.1       dsieger  3482: 
                   3483: One important thing to mention is to pay attention that no RCS IDs get stored
                   3484: in the patch files, as these will cause problems when later checked into the
                   3485: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
                   3486: avoid these problems.
                   3487: 
                   3488: For even more automation, we recommend using mkpatches from the same package to
                   3489: make a whole set of patches. You just have to backup files before you edit them
1.25      wiz      3490: to filename.orig, e.g. with cp -p filename filename.orig or, easier, by using 
1.1       dsieger  3491: pkgvi again from the same package. If you upgrade a package this way, you can
1.25      wiz      3492: easily compare the new set of patches with the previously existing one with 
                   3493: patchdiff. The files in patches are replaced by new files, so carefully check
                   3494: if you want to take all the changes.
1.1       dsieger  3495: 
                   3496: When you have finished a package, remember to generate the checksums for the
1.154     rillig   3497: patch files by using the make makepatchsum command, see Section 13.2,
1.1       dsieger  3498: "distinfo".
                   3499: 
                   3500: When adding a patch that corrects a problem in the distfile (rather than e.g.
                   3501: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
                   3502: report to the maintainer. This benefits non-pkgsrc users of the package, and
                   3503: usually makes it possible to remove the patch in future version.
                   3504: 
1.25      wiz      3505: The file names of the patch files are usually of the form patch-
                   3506: path_to_file__with__underscores.c. Many packages still use the previous
                   3507: convention patch-[a-z][a-z], but new patches should be of the form containing
                   3508: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
                   3509: automatically.
1.2       rillig   3510: 
1.154     rillig   3511: 13.3.3. Sources where the patch files come from
1.1       dsieger  3512: 
                   3513: If you want to share patches between multiple packages in pkgsrc, e.g. because
                   3514: they use the same distfiles, set PATCHDIR to the path where the patch files can
                   3515: be found, e.g.:
                   3516: 
1.159     rillig   3517: PATCHDIR=       ../../editors/xemacs/patches
1.1       dsieger  3518: 
                   3519: Patch files that are distributed by the author or other maintainers can be
                   3520: listed in PATCHFILES.
                   3521: 
                   3522: If it is desired to store any patches that should not be committed into pkgsrc,
                   3523: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
                   3524: directory tree there is expected to have the same "category/package" structure
                   3525: as pkgsrc, and patches are expected to be stored inside these dirs (also known
                   3526: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
                   3527: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
                   3528: files in the named directory are expected to be patch files, and they are
                   3529: applied after pkgsrc patches are applied.
                   3530: 
1.154     rillig   3531: 13.3.4. Patching guidelines
1.1       dsieger  3532: 
                   3533: When fixing a portability issue in the code do not use preprocessor magic to
                   3534: check for the current operating system nor platform. Doing so hurts portability
                   3535: to other platforms because the OS-specific details are not abstracted
                   3536: appropriately.
                   3537: 
                   3538: The general rule to follow is: instead of checking for the operating system the
                   3539: application is being built on, check for the specific features you need. For
                   3540: example, instead of assuming that kqueue is available under NetBSD and using
                   3541: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
                   3542: kqueue itself ? yes, this generally involves patching the configure script.
                   3543: There is absolutely nothing that prevents some OSes from adopting interfaces
                   3544: from other OSes (e.g. Linux implementing kqueue), something that the above
                   3545: checks cannot take into account.
                   3546: 
                   3547: Of course, checking for features generally involves more work on the
                   3548: developer's side, but the resulting changes are cleaner and there are chances
                   3549: they will work on many other platforms. Not to mention that there are higher
                   3550: chances of being later integrated into the mainstream sources. Remember: It
                   3551: doesn't work unless it is right!
                   3552: 
                   3553: Some typical examples:
                   3554: 
1.154     rillig   3555: Table 13.1. Patching examples
1.1       dsieger  3556: 
                   3557: +-------------------------------------------------------------------------------------------+
                   3558: |  Where  |        Incorrect         |                       Correct                        |
                   3559: |---------+--------------------------+------------------------------------------------------|
                   3560: |         |case ${target_os} in      |                                                      |
                   3561: |configure|netbsd*) have_kvm=yes ;;  |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
                   3562: |script   |*)       have_kvm=no  ;;  |                                                      |
                   3563: |         |esac                      |                                                      |
                   3564: |---------+--------------------------+------------------------------------------------------|
1.2       rillig   3565: |C source |#if defined(__NetBSD__)   |#if defined(HAVE_SYS_EVENT_H)                         |
                   3566: |file     |#  include <sys/event.h>  |#  include <sys/event.h>                              |
                   3567: |         |#endif                    |#endif                                                |
1.1       dsieger  3568: |---------+--------------------------+------------------------------------------------------|
                   3569: |         |int                       |int                                                   |
                   3570: |         |monitor_file(...)         |monitor_file(...)                                     |
                   3571: |         |{                         |{                                                     |
                   3572: |         |#if defined(__NetBSD__)   |#if defined(HAVE_KQUEUE)                              |
                   3573: |C source |        int fd = kqueue();|        int fd = kqueue();                            |
                   3574: |file     |        ...               |        ...                                           |
                   3575: |         |#else                     |#else                                                 |
                   3576: |         |        ...               |        ...                                           |
                   3577: |         |#endif                    |#endif                                                |
                   3578: |         |}                         |}                                                     |
                   3579: +-------------------------------------------------------------------------------------------+
                   3580: 
                   3581: 
1.154     rillig   3582: 13.3.5. Feedback to the author
1.1       dsieger  3583: 
                   3584: Always, always, always feed back any portability fixes or improvements you do
                   3585: to a package to the mainstream developers. This is the only way to get their
                   3586: attention on portability issues and to ensure that future versions can be built
                   3587: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
                   3588: get the fixes straight from the packaged code.
                   3589: 
                   3590: This generally involves cleaning up the patches (because sometimes the patches
1.41      wiz      3591: that are added to pkgsrc are quick hacks), filing bug reports in the
1.1       dsieger  3592: appropriate trackers for the projects and working with the mainstream authors
                   3593: to accept your changes. It is extremely important that you do it so that the
                   3594: packages in pkgsrc are kept simple and thus further changes can be done without
                   3595: much hassle.
                   3596: 
1.25      wiz      3597: When you have done this, please add a URL to the upstream bug report to the
                   3598: patch comment.
                   3599: 
1.1       dsieger  3600: Support the idea of free software!
                   3601: 
1.154     rillig   3602: 13.4. Other mandatory files
1.1       dsieger  3603: 
                   3604: DESCR
                   3605: 
                   3606:     A multi-line description of the piece of software. This should include any
                   3607:     credits where they are due. Please bear in mind that others do not share
                   3608:     your sense of humour (or spelling idiosyncrasies), and that others will
                   3609:     read everything that you write here.
                   3610: 
                   3611: PLIST
                   3612: 
                   3613:     This file governs the files that are installed on your system: all the
                   3614:     binaries, manual pages, etc. There are other directives which may be
                   3615:     entered in this file, to control the creation and deletion of directories,
1.154     rillig   3616:     and the location of inserted files. See Chapter 15, PLIST issues for more
1.1       dsieger  3617:     information.
                   3618: 
1.154     rillig   3619: 13.5. Optional files
1.1       dsieger  3620: 
1.154     rillig   3621: 13.5.1. Files affecting the binary package
1.1       dsieger  3622: 
                   3623: INSTALL
                   3624: 
                   3625:     This shell script is invoked twice by pkg_add(1). First time after package
                   3626:     extraction and before files are moved in place, the second time after the
                   3627:     files to install are moved in place. This can be used to do any custom
                   3628:     procedures not possible with @exec commands in PLIST. See pkg_add(1) and
1.154     rillig   3629:     pkg_create(1) for more information. See also Section 17.1, "Files and
1.29      wiz      3630:     directories outside the installation prefix". Please note that you can
                   3631:     modify variables in it easily by using FILES_SUBST in the package's
                   3632:     Makefile:
                   3633: 
                   3634:     FILES_SUBST+=  SOMEVAR="somevalue"
                   3635: 
                   3636:     replaces "@SOMEVAR@" with "somevalue" in the INSTALL. By default,
                   3637:     substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
                   3638:     few others, type make help topic=FILES_SUBST for a complete list.
1.1       dsieger  3639: 
                   3640: DEINSTALL
                   3641: 
                   3642:     This script is executed before and after any files are removed. It is this
                   3643:     script's responsibility to clean up any additional messy details around the
                   3644:     package's installation, since all pkg_delete knows is how to delete the
                   3645:     files created in the original distribution. See pkg_delete(1) and
1.29      wiz      3646:     pkg_create(1) for more information. The same methods to replace variables
                   3647:     can be used as for the INSTALL file.
1.1       dsieger  3648: 
                   3649: MESSAGE
                   3650: 
                   3651:     This file is displayed after installation of the package. Useful for things
                   3652:     like legal notices on almost-free software and hints for updating config
                   3653:     files after installing modules for apache, PHP etc. Please note that you
                   3654:     can modify variables in it easily by using MESSAGE_SUBST in the package's
                   3655:     Makefile:
                   3656: 
                   3657:     MESSAGE_SUBST+=  SOMEVAR="somevalue"
                   3658: 
                   3659:     replaces "${SOMEVAR}" with "somevalue" in MESSAGE. By default, substitution
1.99      sevan    3660:     is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11BASE,
1.16      jnemeth  3661:     PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1       dsieger  3662: 
                   3663:     You can display a different or additional files by setting the MESSAGE_SRC
                   3664:     variable. Its default is MESSAGE, if the file exists.
                   3665: 
                   3666: ALTERNATIVES
                   3667: 
1.66      asau     3668:     This file is used by the alternatives framework. It creates, configures,
                   3669:     and destroys generic wrappers used to run programs with similar interfaces.
                   3670:     See pkg_alternatives(8) from pkgtools/pkg_alternatives for more
                   3671:     information.
                   3672: 
                   3673:     Each line of the file contains two filenames, first the wrapper and then
                   3674:     the alternative provided by the package. Both paths are relative to PREFIX.
1.1       dsieger  3675: 
1.154     rillig   3676: 13.5.2. Files affecting the build process
1.1       dsieger  3677: 
                   3678: Makefile.common
                   3679: 
                   3680:     This file contains arbitrary things that could also go into a Makefile, but
                   3681:     its purpose is to be used by more than one package. This file should only
                   3682:     be used when the packages that will use the file are known in advance. For
                   3683:     other purposes it is often better to write a *.mk file and give it a good
                   3684:     name that describes what it does.
                   3685: 
                   3686: buildlink3.mk
                   3687: 
                   3688:     This file contains the dependency information for the buildlink3 framework
1.154     rillig   3689:     (see Chapter 16, Buildlink methodology).
1.1       dsieger  3690: 
                   3691: hacks.mk
                   3692: 
                   3693:     This file contains workarounds for compiler bugs and similar things. It is
                   3694:     included automatically by the pkgsrc infrastructure, so you don't need an
                   3695:     extra .include line for it.
                   3696: 
                   3697: options.mk
                   3698: 
                   3699:     This file contains the code for the package-specific options (see
1.154     rillig   3700:     Chapter 18, Options handling) that can be selected by the user. If a
1.1       dsieger  3701:     package has only one or two options, it is equally acceptable to put the
                   3702:     code directly into the Makefile.
                   3703: 
1.154     rillig   3704: 13.5.3. Files affecting nothing at all
1.1       dsieger  3705: 
                   3706: README*
                   3707: 
                   3708:     These files do not take place in the creation of a package and thus are
                   3709:     purely informative to the package developer.
                   3710: 
                   3711: TODO
                   3712: 
                   3713:     This file contains things that need to be done to make the package even
                   3714:     better.
                   3715: 
1.154     rillig   3716: 13.6. work*
1.1       dsieger  3717: 
                   3718: When you type make, the distribution files are unpacked into the directory
                   3719: denoted by WRKDIR. It can be removed by running make clean. Besides the
                   3720: sources, this directory is also used to keep various timestamp files. The
                   3721: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
                   3722: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
                   3723: 
1.154     rillig   3724: 13.7. files/*
1.1       dsieger  3725: 
                   3726: If you have any files that you wish to be placed in the package prior to
1.172     rillig   3727: configuration or building, you can place these files here and use a ${CP}
                   3728: command in the "post-extract" target to achieve this.
1.1       dsieger  3729: 
                   3730: If you want to share files in this way with other packages, set the FILESDIR
                   3731: variable to point to the other package's files directory, e.g.:
                   3732: 
1.159     rillig   3733: FILESDIR=       ../../editors/xemacs/files
1.1       dsieger  3734: 
1.154     rillig   3735: Chapter 14. Programming in Makefiles
1.1       dsieger  3736: 
                   3737: Table of Contents
                   3738: 
1.154     rillig   3739: 14.1. Caveats
                   3740: 14.2. Makefile variables
1.1       dsieger  3741: 
1.154     rillig   3742:     14.2.1. Naming conventions
1.1       dsieger  3743: 
1.154     rillig   3744: 14.3. Code snippets
1.1       dsieger  3745: 
1.154     rillig   3746:     14.3.1. Adding things to a list
                   3747:     14.3.2. Echoing a string exactly as-is
                   3748:     14.3.3. Passing CFLAGS to GNU configure scripts
                   3749:     14.3.4. Handling possibly empty variables
1.1       dsieger  3750: 
                   3751: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
                   3752: part of the pkgsrc system. Using the make(1) system as a programming language
                   3753: for a big system like pkgsrc requires some discipline to keep the code correct
                   3754: and understandable.
                   3755: 
1.154     rillig   3756: The basic ingredients for Makefile programming are variables and shell
                   3757: commands. Among these shell commands may even be more complex ones like awk(1)
                   3758: programs. To make sure that every shell command runs as intended it is
                   3759: necessary to quote all variables correctly when they are used.
1.1       dsieger  3760: 
1.154     rillig   3761: This chapter describes some patterns that appear quite often in Makefiles,
1.1       dsieger  3762: including the pitfalls that come along with them.
                   3763: 
1.154     rillig   3764: 14.1. Caveats
1.1       dsieger  3765: 
                   3766:   * When you are creating a file as a target of a rule, always write the data
                   3767:     to a temporary file first and finally rename that file. Otherwise there
                   3768:     might occur an error in the middle of generating the file, and when the
                   3769:     user runs make(1) for the second time, the file exists and will not be
                   3770:     regenerated properly. Example:
                   3771: 
                   3772:     wrong:
                   3773:             @echo "line 1" > ${.TARGET}
                   3774:             @echo "line 2" >> ${.TARGET}
                   3775:             @false
                   3776: 
                   3777:     correct:
                   3778:             @echo "line 1" > ${.TARGET}.tmp
                   3779:             @echo "line 2" >> ${.TARGET}.tmp
                   3780:             @false
                   3781:             @mv ${.TARGET}.tmp ${.TARGET}
                   3782: 
                   3783:     When you run make wrong twice, the file wrong will exist, although there
                   3784:     was an error message in the first run. On the other hand, running make
                   3785:     correct gives an error message twice, as expected.
                   3786: 
                   3787:     You might remember that make(1) sometimes removes ${.TARGET} in case of
                   3788:     error, but this only happens when it is interrupted, for example by
1.154     rillig   3789:     pressing Ctrl+C. This does not happen when one of the commands fails (like
1.1       dsieger  3790:     false(1) above).
                   3791: 
1.154     rillig   3792: 14.2. Makefile variables
1.1       dsieger  3793: 
                   3794: Makefile variables contain strings that can be processed using the five
1.154     rillig   3795: operators =, +=, ?=, := and !=, which are described in the make(1) man page.
1.1       dsieger  3796: 
1.154     rillig   3797: When a variable's value is parsed from a Makefile, the hash character # and the
                   3798: backslash character \ are handled specially. If a backslash is the last
                   3799: character in a line, that backslash is removed from the line and the line
                   3800: continues with the next line of the file.
                   3801: 
                   3802: The # character starts a comment that reaches until the end of the line. To get
                   3803: an actual # character, such as in a URL, write \# instead.
1.1       dsieger  3804: 
1.108     rillig   3805: The evaluation of variables either happens immediately or lazy. It happens
1.154     rillig   3806: immediately when the variable occurs on the right-hand side of the := or the !=
                   3807: operator, in a .if condition or a .for loop. In the other cases, it is
                   3808: evaluated lazily.
1.1       dsieger  3809: 
                   3810: Some of the modifiers split the string into words and then operate on the
                   3811: words, others operate on the string as a whole. When a string is split into
1.154     rillig   3812: words, double quotes and single quotes are interpreted as delimiters, just like
                   3813: in sh(1).
1.1       dsieger  3814: 
1.154     rillig   3815: 14.2.1. Naming conventions
1.1       dsieger  3816: 
                   3817:   * All variable names starting with an underscore are reserved for use by the
1.154     rillig   3818:     pkgsrc infrastructure. They shall not be used by packages.
1.1       dsieger  3819: 
                   3820:   * In .for loops you should use lowercase variable names for the iteration
                   3821:     variables.
                   3822: 
1.154     rillig   3823:   * All list variables should have a plural name, such as PKG_OPTIONS or
1.1       dsieger  3824:     DISTFILES.
                   3825: 
1.154     rillig   3826: 14.3. Code snippets
1.1       dsieger  3827: 
1.154     rillig   3828: 14.3.1. Adding things to a list
1.108     rillig   3829: 
                   3830: When adding a string that possibly contains whitespace or quotes to a list
                   3831: (example 1), it must be quoted using the :Q modifier.
1.1       dsieger  3832: 
1.108     rillig   3833: When adding another list to a list (example 2), it must not be quoted, since
                   3834: its elements are already quoted.
1.1       dsieger  3835: 
1.108     rillig   3836: STRING=         foo * bar `date`
                   3837: LIST=           # empty
                   3838: ANOTHER_LIST=   a=b c=d
1.1       dsieger  3839: 
1.108     rillig   3840: LIST+=          ${STRING:Q}       # 1
                   3841: LIST+=          ${ANOTHER_LIST}   # 2
1.1       dsieger  3842: 
1.154     rillig   3843: 14.3.2. Echoing a string exactly as-is
1.1       dsieger  3844: 
1.108     rillig   3845: Echoing a string containing special characters needs special work.
1.1       dsieger  3846: 
                   3847: STRING=         foo bar <    > * `date` $$HOME ' "
1.108     rillig   3848: EXAMPLE_ENV=    string=${STRING:Q} x=multiple\ quoted\ words
1.1       dsieger  3849: 
                   3850: all:
                   3851:         echo ${STRING}                  # 1
1.108     rillig   3852:         echo ${STRING:Q}                # 2
                   3853:         printf '%s\n' ${STRING:Q}''     # 3
                   3854:         env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"'   # 4
1.1       dsieger  3855: 
                   3856: Example 1 leads to a syntax error in the shell, as the characters are just
                   3857: copied.
                   3858: 
1.108     rillig   3859: Example 2 quotes the string so that the shell interprets it correctly. But the
                   3860: echo command may additionally interpret strings with a leading dash or those
                   3861: containing backslashes.
                   3862: 
                   3863: Example 3 can handle arbitrary strings, since printf(1) only interprets the
1.139     leot     3864: format string, but not the next argument. The trailing single quotes handle the
                   3865: case when the string is empty. In that case, the :Q modifier would result in an
                   3866: empty string too, which would then be skipped by the shell. For printf(1) this
                   3867: doesn't make a difference, but other programs may care.
1.108     rillig   3868: 
                   3869: In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
                   3870: has already been done when adding elements to the list.
                   3871: 
1.154     rillig   3872: 14.3.3. Passing CFLAGS to GNU configure scripts
1.108     rillig   3873: 
                   3874: When passing CFLAGS or similar variables to a GNU-style configure script
                   3875: (especially those that call other configure scripts), it must not have leading
                   3876: or trailing whitespace, since otherwise the configure script gets confused. To
                   3877: trim leading and trailing whitespace, use the :M modifier, as in the following
                   3878: example:
                   3879: 
                   3880: CPPFLAGS=               # empty
                   3881: CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX}\"
                   3882: CPPFLAGS+=              ${MY_CPPFLAGS}
                   3883: 
                   3884: CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
                   3885: 
                   3886: all:
                   3887:         echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
                   3888:         echo x${CONFIGURE_ARGS:Q}x      # properly trimmed
                   3889: 
                   3890: In this example, CPPFLAGS has both leading and trailing whitespace because the
                   3891: += operator always adds a space.
                   3892: 
1.154     rillig   3893: 14.3.4. Handling possibly empty variables
1.108     rillig   3894: 
                   3895: When a possibly empty variable is used in a shell program, it may lead to a
                   3896: syntax error.
                   3897: 
                   3898: EGFILES=        # empty
                   3899: 
                   3900: install-examples:   # produces a syntax error in the shell
                   3901:         for egfile in ${EGFILES}; do            \
                   3902:                 echo "Installing $$egfile";     \
                   3903:         done
                   3904: 
                   3905: The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
                   3906: with an empty string by make(1). To fix this syntax error, use one of the
                   3907: snippets below.
                   3908: 
                   3909: EMPTY=          # empty
                   3910: 
                   3911: install-examples:
                   3912:         for egfile in ${EGFILES} ""; do         \
                   3913:                 [ -n "$$egfile" ] || continue;  \
                   3914:                 echo "Installing $$egfile";     \
                   3915:         done
                   3916: 
                   3917: In this case, an empty string is appended to the iteration list (to prevent the
                   3918: syntax error) and filtered out later.
1.1       dsieger  3919: 
1.108     rillig   3920: EGFILES=        # empty
1.1       dsieger  3921: 
1.108     rillig   3922: install-examples:
                   3923: .for egfile in ${EGFILES}
                   3924:         echo "Installing ${egfile}"
                   3925: .endfor
                   3926: 
1.154     rillig   3927: If one of the filenames contains special characters, it should be enclosed in
                   3928: single or double quotes.
1.108     rillig   3929: 
                   3930: To have a shell command test whether a make variable is empty, use the
                   3931: following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
1.1       dsieger  3932: 
1.154     rillig   3933: Chapter 15. PLIST issues
1.1       dsieger  3934: 
                   3935: Table of Contents
                   3936: 
1.154     rillig   3937: 15.1. RCS ID
                   3938: 15.2. Semi-automatic PLIST generation
                   3939: 15.3. Tweaking output of make print-PLIST
                   3940: 15.4. Variable substitution in PLIST
                   3941: 15.5. Man page compression
                   3942: 15.6. Changing PLIST source with PLIST_SRC
                   3943: 15.7. Platform-specific and differing PLISTs
                   3944: 15.8. Build-specific PLISTs
                   3945: 15.9. Sharing directories between packages
1.1       dsieger  3946: 
                   3947: The PLIST file contains a package's "packing list", i.e. a list of files that
                   3948: belong to the package (relative to the ${PREFIX} directory it's been installed
                   3949: in) plus some additional statements - see the pkg_create(1) man page for a full
                   3950: list. This chapter addresses some issues that need attention when dealing with
                   3951: the PLIST file (or files, see below!).
                   3952: 
1.154     rillig   3953: 15.1. RCS ID
1.1       dsieger  3954: 
                   3955: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
                   3956: 
1.121     sevan    3957: @comment $NetBSD $
                   3958: 
1.123     wiz      3959: An artificial space has been added between NetBSD and $, this is a workaround
1.121     sevan    3960: here to prevent CVS expanding to the filename of the guide. When adding the RCS
1.125     leot     3961: ID the space should be omitted.
1.1       dsieger  3962: 
1.154     rillig   3963: 15.2. Semi-automatic PLIST generation
1.1       dsieger  3964: 
                   3965: You can use the make print-PLIST command to output a PLIST that matches any new
1.154     rillig   3966: files since the package was extracted. See Section 19.17, "Other helpful
1.1       dsieger  3967: targets" for more information on this target.
                   3968: 
1.154     rillig   3969: 15.3. Tweaking output of make print-PLIST
1.1       dsieger  3970: 
                   3971: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
                   3972: used to filter the output of print-PLIST. You can append any chunk of AWK
                   3973: scripting you like to it, but be careful with quoting.
                   3974: 
                   3975: For example, to get all files inside the libdata/foo directory removed from the
                   3976: resulting PLIST:
                   3977: 
                   3978: PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
                   3979: 
1.154     rillig   3980: 15.4. Variable substitution in PLIST
1.1       dsieger  3981: 
                   3982: A number of variables are substituted automatically in PLISTs when a package is
                   3983: installed on a system. This includes the following variables:
                   3984: 
                   3985: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
                   3986: 
                   3987:     Some packages like emacs and perl embed information about which
                   3988:     architecture they were built on into the pathnames where they install their
                   3989:     files. To handle this case, PLIST will be preprocessed before actually
                   3990:     used, and the symbol "${MACHINE_ARCH}" will be replaced by what uname -p
                   3991:     gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
                   3992:     PLIST somewhere - use this on packages that have GNU autoconf-created
                   3993:     configure scripts.
                   3994: 
                   3995:     Legacy note
                   3996: 
                   3997:     There used to be a symbol "$ARCH" that was replaced by the output of uname
                   3998:     -m, but that's no longer supported and has been removed.
                   3999: 
                   4000: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
                   4001: 
                   4002:     Some packages want to embed the OS name and version into some paths. To do
                   4003:     this, use these variables in the PLIST:
                   4004: 
1.42      asau     4005:       + ${OPSYS} - output of "uname -s"
1.1       dsieger  4006: 
1.42      asau     4007:       + ${LOWER_OPSYS} - lowercase common name (eg. "solaris")
1.1       dsieger  4008: 
1.42      asau     4009:       + ${OS_VERSION} - "uname -r"
1.1       dsieger  4010: 
1.88      tnn      4011: For a list of values which are replaced by default, the output of make help
                   4012: topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
                   4013: PLIST_SUBST should help.
1.1       dsieger  4014: 
                   4015: If you want to change other variables not listed above, you can add variables
                   4016: and their expansions to this variable in the following way, similar to
1.154     rillig   4017: MESSAGE_SUBST (see Section 13.5, "Optional files"):
1.1       dsieger  4018: 
                   4019: PLIST_SUBST+=   SOMEVAR="somevalue"
                   4020: 
                   4021: This replaces all occurrences of "${SOMEVAR}" in the PLIST with "somevalue".
                   4022: 
1.19      snj      4023: The PLIST_VARS variable can be used to simplify the common case of
                   4024: conditionally including some PLIST entries. It can be done by adding
                   4025: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
                   4026: entry should be included. This will substitute "${PLIST.foo}" in the PLIST with
                   4027: either """" or ""@comment "". For example, in Makefile:
1.18      mishka   4028: 
                   4029: PLIST_VARS+=    foo
                   4030: .if condition
                   4031: PLIST.foo=      yes
                   4032: .else
                   4033: 
                   4034: And then in PLIST:
                   4035: 
1.121     sevan    4036: @comment $NetBSD $
1.18      mishka   4037: bin/bar
                   4038: man/man1/bar.1
                   4039: ${PLIST.foo}bin/foo
                   4040: ${PLIST.foo}man/man1/foo.1
                   4041: ${PLIST.foo}share/bar/foo.data
                   4042: 
1.123     wiz      4043: An artificial space has been added between NetBSD and $, this is a workaround
1.121     sevan    4044: here to prevent CVS expanding to the filename of the guide. When adding the RCS
                   4045: ID the space should be ommited.
                   4046: 
1.154     rillig   4047: 15.5. Man page compression
1.1       dsieger  4048: 
                   4049: Man pages should be installed in compressed form if MANZ is set (in
                   4050: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
                   4051: suffix ".gz" is appended/removed automatically for man pages according to MANZ
                   4052: and MANCOMPRESSED being set or not, see above for details. This modification of
                   4053: the PLIST file is done on a copy of it, not PLIST itself.
                   4054: 
1.154     rillig   4055: 15.6. Changing PLIST source with PLIST_SRC
1.1       dsieger  4056: 
                   4057: To use one or more files as source for the PLIST used in generating the binary
                   4058: package, set the variable PLIST_SRC to the names of that file(s). The files are
                   4059: later concatenated using cat(1), and the order of things is important. The
                   4060: default for PLIST_SRC is ${PKGDIR}/PLIST.
                   4061: 
1.154     rillig   4062: 15.7. Platform-specific and differing PLISTs
1.1       dsieger  4063: 
                   4064: Some packages decide to install a different set of files based on the operating
                   4065: system being used. These differences can be automatically handled by using the
                   4066: following files:
                   4067: 
                   4068:   * PLIST.common
                   4069: 
                   4070:   * PLIST.${OPSYS}
                   4071: 
                   4072:   * PLIST.${MACHINE_ARCH}
                   4073: 
                   4074:   * PLIST.${OPSYS}-${MACHINE_ARCH}
                   4075: 
                   4076:   * PLIST.common_end
                   4077: 
1.154     rillig   4078: 15.8. Build-specific PLISTs
1.86      wiz      4079: 
                   4080: Some packages decide to generate hard-to-guess file names during installation
                   4081: that are hard to wire down.
                   4082: 
                   4083: In such cases, you can set the GENERATE_PLIST variable to shell code terminated
                   4084: (with a semicolon) that will output PLIST entries which will be appended to the
                   4085: PLIST
                   4086: 
                   4087: You can find one example in editors/xemacs:
                   4088: 
1.111     sevan    4089: GENERATE_PLIST+=        ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
1.86      wiz      4090: 
                   4091: which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
                   4092: 
1.154     rillig   4093: 15.9. Sharing directories between packages
1.1       dsieger  4094: 
                   4095: A "shared directory" is a directory where multiple (and unrelated) packages
1.23      jakllsch 4096: install files. These directories were problematic because you had to add
1.1       dsieger  4097: special tricks in the PLIST to conditionally remove them, or have some
                   4098: centralized package handle them.
                   4099: 
1.23      jakllsch 4100: In pkgsrc, it is now easy: Each package should create directories and install
                   4101: files as needed; pkg_delete will remove any directories left empty after
                   4102: uninstalling a package.
1.1       dsieger  4103: 
1.23      jakllsch 4104: If a package needs an empty directory to work, create the directory during
                   4105: installation as usual, and also add an entry to the PLIST:
1.1       dsieger  4106: 
1.23      jakllsch 4107: @pkgdir path/to/empty/directory
1.1       dsieger  4108: 
1.86      wiz      4109: or take a look at MAKE_DIRS and OWN_DIRS.
                   4110: 
1.154     rillig   4111: Chapter 16. Buildlink methodology
1.1       dsieger  4112: 
                   4113: Table of Contents
                   4114: 
1.154     rillig   4115: 16.1. Converting packages to use buildlink3
                   4116: 16.2. Writing buildlink3.mk files
1.1       dsieger  4117: 
1.154     rillig   4118:     16.2.1. Anatomy of a buildlink3.mk file
                   4119:     16.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.27      wiz      4120:         buildlink3.mk files
1.1       dsieger  4121: 
1.154     rillig   4122: 16.3. Writing builtin.mk files
1.1       dsieger  4123: 
1.154     rillig   4124:     16.3.1. Anatomy of a builtin.mk file
                   4125:     16.3.2. Global preferences for native or pkgsrc software
1.1       dsieger  4126: 
                   4127: Buildlink is a framework in pkgsrc that controls what headers and libraries are
                   4128: seen by a package's configure and build processes. This is implemented in a two
                   4129: step process:
                   4130: 
                   4131:  1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
                   4132:     default is a subdirectory of WRKDIR.
                   4133: 
                   4134:  2. Create wrapper scripts that are used in place of the normal compiler tools
                   4135:     that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
                   4136:     references to BUILDLINK_DIR. The wrapper scripts also make native compiler
                   4137:     on some operating systems look like GCC, so that packages that expect GCC
                   4138:     won't require modifications to build with those native compilers.
                   4139: 
                   4140: This normalizes the environment in which a package is built so that the package
                   4141: may be built consistently despite what other software may be installed. Please
                   4142: note that the normal system header and library paths, e.g. /usr/include, /usr/
                   4143: lib, etc., are always searched -- buildlink3 is designed to insulate the
                   4144: package build from non-system-supplied software.
                   4145: 
1.154     rillig   4146: 16.1. Converting packages to use buildlink3
1.1       dsieger  4147: 
1.25      wiz      4148: The process of converting packages to use the buildlink3 framework ("bl3ifying"
                   4149: ) is fairly straightforward. The things to keep in mind are:
1.1       dsieger  4150: 
                   4151:  1. Ensure that the build always calls the wrapper scripts instead of the
                   4152:     actual toolchain. Some packages are tricky, and the only way to know for
                   4153:     sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
                   4154:     invoked.
                   4155: 
                   4156:  2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
                   4157:     standalone shells, etc., because the code to symlink files into $
                   4158:     {BUILDLINK_DIR} looks for files relative to "pkg_info -qp pkgname".
                   4159: 
                   4160:  3. Remember that only the buildlink3.mk files that you list in a package's
                   4161:     Makefile are added as dependencies for that package.
                   4162: 
                   4163: If a dependency on a particular package is required for its libraries and
                   4164: headers, then we replace:
                   4165: 
                   4166: DEPENDS+=       foo>=1.1.0:../../category/foo
                   4167: 
                   4168: with
                   4169: 
                   4170: .include "../../category/foo/buildlink3.mk"
                   4171: 
                   4172: The buildlink3.mk files usually define the required dependencies. If you need a
                   4173: newer version of the dependency when using buildlink3.mk files, then you can
                   4174: define it in your Makefile; for example:
                   4175: 
                   4176: BUILDLINK_API_DEPENDS.foo+=   foo>=1.1.0
                   4177: .include "../../category/foo/buildlink3.mk"
                   4178: 
                   4179: There are several buildlink3.mk files in pkgsrc/mk that handle special package
                   4180: issues:
                   4181: 
                   4182:   * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
                   4183:     implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
                   4184: 
                   4185:   * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
                   4186:     this will take care to install the devel/ncurses package.
                   4187: 
                   4188:   * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
                   4189:     a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
                   4190:     implementation.
                   4191: 
                   4192:   * motif.buildlink3.mk checks for a system-provided Motif installation or adds
1.126     leot     4193:     a dependency on x11/lesstif or x11/motif. The user can set MOTIF_TYPE to "
                   4194:     dt", "lesstif" or "motif" to choose which Motif version will be used.
1.1       dsieger  4195: 
1.57      wiz      4196:   * readline.buildlink3.mk checks for a system-provided GNU readline or
                   4197:     editline (libedit) installation, or adds a dependency on devel/readline,
                   4198:     devel/editline. The user can set READLINE_DEFAULT to choose readline
1.56      ryoon    4199:     implementation. If your package really needs GNU readline library, its
                   4200:     Makefile should include devel/readline/buildlink3.mk instead of
                   4201:     readline.buildlink3.mk.
                   4202: 
1.1       dsieger  4203:   * oss.buildlink3.mk defines several variables that may be used by packages
                   4204:     that use the Open Sound System (OSS) API.
                   4205: 
1.36      wiz      4206:   * pgsql.buildlink3.mk will accept any of the Postgres versions in the
                   4207:     variable PGSQL_VERSIONS_ACCEPTED and default to the version
                   4208:     PGSQL_VERSION_DEFAULT. See the file for more information.
1.1       dsieger  4209: 
                   4210:   * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
                   4211:     pthreads or adds a dependency on devel/pth as needed.
                   4212: 
                   4213:   * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
                   4214:     widgets library.
                   4215: 
                   4216: The comments in those buildlink3.mk files provide a more complete description
                   4217: of how to use them properly.
                   4218: 
1.154     rillig   4219: 16.2. Writing buildlink3.mk files
1.1       dsieger  4220: 
                   4221: A package's buildlink3.mk file is included by Makefiles to indicate the need to
                   4222: compile and link against header files and libraries provided by the package. A
                   4223: buildlink3.mk file should always provide enough information to add the correct
                   4224: type of dependency relationship and include any other buildlink3.mk files that
                   4225: it needs to find headers and libraries that it needs in turn.
                   4226: 
                   4227: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
                   4228: pkgtools/createbuildlink package is highly recommended. For most packages, the
                   4229: following command will generate a good starting point for buildlink3.mk files:
                   4230: 
                   4231: % cd pkgsrc/category/pkgdir
                   4232: % createbuildlink >buildlink3.mk
                   4233: 
                   4234: 
1.154     rillig   4235: 16.2.1. Anatomy of a buildlink3.mk file
1.1       dsieger  4236: 
                   4237: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
                   4238: tiff:
                   4239: 
1.19      snj      4240: # $NetBSD: buildlink3.mk,v 1.16 2009/03/20 19:24:45 joerg Exp $
1.1       dsieger  4241: 
1.19      snj      4242: BUILDLINK_TREE+=        tiff
1.1       dsieger  4243: 
1.19      snj      4244: .if !defined(TIFF_BUILDLINK3_MK)
                   4245: TIFF_BUILDLINK3_MK:=
1.1       dsieger  4246: 
1.19      snj      4247: BUILDLINK_API_DEPENDS.tiff+=    tiff>=3.6.1
                   4248: BUILDLINK_ABI_DEPENDS.tiff+=    tiff>=3.7.2nb1
1.1       dsieger  4249: BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
                   4250: 
                   4251: .include "../../devel/zlib/buildlink3.mk"
                   4252: .include "../../graphics/jpeg/buildlink3.mk"
1.19      snj      4253: .endif # TIFF_BUILDLINK3_MK
1.1       dsieger  4254: 
1.19      snj      4255: BUILDLINK_TREE+=        -tiff
1.1       dsieger  4256: 
1.19      snj      4257: The header and footer manipulate BUILDLINK_TREE, which is common across all
                   4258: buildlink3.mk files and is used to track the dependency tree.
1.1       dsieger  4259: 
1.19      snj      4260: The main section is protected from multiple inclusion and controls how the
1.1       dsieger  4261: dependency on pkg is added. Several important variables are set in the section:
                   4262: 
                   4263:   * BUILDLINK_API_DEPENDS.pkg is the actual dependency recorded in the
                   4264:     installed package; this should always be set using += to ensure that we're
                   4265:     appending to any pre-existing list of values. This variable should be set
1.27      wiz      4266:     to the first version of the package that had an backwards-incompatible API
                   4267:     change.
1.1       dsieger  4268: 
                   4269:   * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
                   4270: 
                   4271:   * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
                   4272:     BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
                   4273:     is selected by setting BUILDLINK_DEPMETHOD.pkg to "build". By default, the
                   4274:     full dependency is used.
                   4275: 
                   4276:   * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
                   4277:     of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
                   4278:     library search paths. These default to "include" and "lib" respectively.
                   4279: 
                   4280:   * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
                   4281:     to add to CPPFLAGS, which are passed on to the configure and build phases.
                   4282:     The "-I" option should be avoided and instead be handled using
                   4283:     BUILDLINK_INCDIRS.pkg as above.
                   4284: 
                   4285: The following variables are all optionally defined within this second section
                   4286: (protected against multiple inclusion) and control which package files are
                   4287: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
                   4288: symlinking:
                   4289: 
                   4290:   * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
                   4291:     {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
                   4292:     *.h.
                   4293: 
                   4294:   * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
                   4295:     to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
                   4296:     resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
                   4297:     takes the +CONTENTS of a pkg and filters it through $
                   4298:     {BUILDLINK_CONTENTS_FILTER.pkg}.
                   4299: 
                   4300:   * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
                   4301:     filters +CONTENTS input into a list of files relative to $
1.84      wiz      4302:     {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
                   4303:     outputs the contents of the include and lib directories in the package
                   4304:     +CONTENTS.
1.1       dsieger  4305: 
                   4306:   * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
                   4307:     used to transform the name of the source filename into a destination
                   4308:     filename, e.g. -e "s|/curses.h|/ncurses.h|g".
                   4309: 
1.19      snj      4310: This section can additionally include any buildlink3.mk needed for pkg's
                   4311: library dependencies. Including these buildlink3.mk files means that the
                   4312: headers and libraries for these dependencies are also symlinked into $
                   4313: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
                   4314: are only added for directly include buildlink3.mk files.
1.1       dsieger  4315: 
1.48      wiz      4316: When providing a buildlink3.mk and including other buildlink3.mk files in it,
1.51      wiz      4317: please only add necessary ones, i.e., those whose libraries or header files are
1.48      wiz      4318: automatically exposed when the package is use.
                   4319: 
                   4320: In particular, if only an executable (bin/foo) is linked against a library,
                   4321: that library does not need to be propagated in the buildlink3.mk file.
                   4322: 
                   4323: The following steps should help you decide if a buildlink3.mk file needs to be
                   4324: included:
                   4325: 
                   4326:   * Look at the installed header files: What headers do they include? The
                   4327:     packages providing these files must be buildlinked.
                   4328: 
1.50      wiz      4329:   * Run ldd on all installed libraries and look against what other libraries
                   4330:     they link. Some of the packages providing these probably need to be
                   4331:     buildlinked; however, it's not automatic, since e.g. GTK on some systems
                   4332:     pulls in the X libraries, so they will show up in the ldd output, while on
1.51      wiz      4333:     others (like OS X) it won't. ldd output can thus only be used as a hint.
1.50      wiz      4334: 
1.154     rillig   4335: 16.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.27      wiz      4336: buildlink3.mk files
1.1       dsieger  4337: 
1.27      wiz      4338: These two variables differ in that one describes source compatibility (API) and
                   4339: the other binary compatibility (ABI). The difference is that a change in the
                   4340: API breaks compilation of programs while changes in the ABI stop compiled
                   4341: programs from running.
                   4342: 
1.28      wiz      4343: Changes to the BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk file
                   4344: happen very rarely. One possible reason is that all packages depending on this
                   4345: already need a newer version. In case it is bumped see the description below.
1.27      wiz      4346: 
                   4347: The most common example of an ABI change is that the major version of a shared
                   4348: library is increased. In this case, BUILDLINK_ABI_DEPENDS.pkg should be
                   4349: adjusted to require at least the new package version. Then the packages that
                   4350: depend on this package need their PKGREVISIONs increased and, if they have
                   4351: buildlink3.mk files, their BUILDLINK_ABI_DEPENDS.pkg adjusted, too. This is
                   4352: needed so pkgsrc will require the correct package dependency and not settle for
                   4353: an older one when building the source.
1.1       dsieger  4354: 
1.154     rillig   4355: See Section 21.1.5, "Handling dependencies" for more information about
1.1       dsieger  4356: dependencies on other packages, including the BUILDLINK_ABI_DEPENDS and
                   4357: ABI_DEPENDS definitions.
                   4358: 
                   4359: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
                   4360: BUILDLINK_ABI_DEPENDS.pkg as we don't want to cause unneeded package deletions
                   4361: and rebuilds. In many cases, new versions of packages work just fine with older
                   4362: dependencies.
                   4363: 
                   4364: Also it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
                   4365: BUILDLINK_API_DEPENDS.pkg.
                   4366: 
1.154     rillig   4367: 16.3. Writing builtin.mk files
1.1       dsieger  4368: 
                   4369: Some packages in pkgsrc install headers and libraries that coincide with
                   4370: headers and libraries present in the base system. Aside from a buildlink3.mk
                   4371: file, these packages should also include a builtin.mk file that includes the
                   4372: necessary checks to decide whether using the built-in software or the pkgsrc
                   4373: software is appropriate.
                   4374: 
                   4375: The only requirements of a builtin.mk file for pkg are:
                   4376: 
                   4377:  1. It should set USE_BUILTIN.pkg to either "yes" or "no" after it is included.
                   4378: 
                   4379:  2. It should not override any USE_BUILTIN.pkg which is already set before the
                   4380:     builtin.mk file is included.
                   4381: 
                   4382:  3. It should be written to allow multiple inclusion. This is very important
                   4383:     and takes careful attention to Makefile coding.
                   4384: 
1.154     rillig   4385: 16.3.1. Anatomy of a builtin.mk file
1.1       dsieger  4386: 
                   4387: The following is the recommended template for builtin.mk files:
                   4388: 
                   4389: .if !defined(IS_BUILTIN.foo)
                   4390: #
                   4391: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
                   4392: # genuinely exists in the system or not.
                   4393: #
                   4394: IS_BUILTIN.foo?=        no
                   4395: 
                   4396: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
                   4397: # version can be determined.
                   4398: #
                   4399: .  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
                   4400: BUILTIN_PKG.foo?=       foo-1.0
                   4401: .  endif
                   4402: .endif  # IS_BUILTIN.foo
                   4403: 
                   4404: .if !defined(USE_BUILTIN.foo)
                   4405: USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
                   4406: .  if defined(BUILTIN_PKG.foo)
                   4407: .    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
                   4408: .      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
                   4409: USE_BUILTIN.foo!=                                                       \
                   4410:         ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}            \
                   4411:         && ${ECHO} "yes" || ${ECHO} "no"
                   4412: .      endif
                   4413: .    endfor
                   4414: .  endif
                   4415: .endif  # USE_BUILTIN.foo
                   4416: 
                   4417: CHECK_BUILTIN.foo?=     no
                   4418: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
                   4419: #
                   4420: # Here we place code that depends on whether USE_BUILTIN.foo is set to
                   4421: # "yes" or "no".
                   4422: #
                   4423: .endif  # CHECK_BUILTIN.foo
                   4424: 
                   4425: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
                   4426: base system. This should not be a base system software with similar
                   4427: functionality to pkg; it should only be "yes" if the actual package is included
                   4428: as part of the base system. This variable is only used internally within the
                   4429: builtin.mk file.
                   4430: 
                   4431: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
                   4432: system if it exists (if IS_BUILTIN.pkg is "yes"). This variable is only used
                   4433: internally within the builtin.mk file.
                   4434: 
                   4435: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
                   4436: The code in this section must make the determination whether the built-in
                   4437: software is adequate to satisfy the dependencies listed in
                   4438: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
1.25      wiz      4439: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg 
1.1       dsieger  4440: must be set to the correct value by the end of the builtin.mk file. Note that
                   4441: USE_BUILTIN.pkg may be "yes" even if IS_BUILTIN.pkg is "no" because we may make
                   4442: the determination that the built-in version of the software is similar enough
                   4443: to be used as a replacement.
                   4444: 
                   4445: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
                   4446: the value of USE_BUILTIN.pkg set in the previous section. This typically
                   4447: includes, e.g., adding additional dependency restrictions and listing
                   4448: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
                   4449: 
1.154     rillig   4450: 16.3.2. Global preferences for native or pkgsrc software
1.1       dsieger  4451: 
                   4452: When building packages, it's possible to choose whether to set a global
                   4453: preference for using either the built-in (native) version or the pkgsrc version
                   4454: of software to satisfy a dependency. This is controlled by setting
1.25      wiz      4455: PREFER_PKGSRC and PREFER_NATIVE. These variables take values of either "yes", "
                   4456: no", or a list of packages. PREFER_PKGSRC tells pkgsrc to use the pkgsrc
1.1       dsieger  4457: versions of software, while PREFER_NATIVE tells pkgsrc to use the built-in
                   4458: versions. Preferences are determined by the most specific instance of the
                   4459: package in either PREFER_PKGSRC or PREFER_NATIVE. If a package is specified in
                   4460: neither or in both variables, then PREFER_PKGSRC has precedence over
                   4461: PREFER_NATIVE. For example, to require using pkgsrc versions of software for
                   4462: all but the most basic bits on a NetBSD system, you can set:
                   4463: 
                   4464: PREFER_PKGSRC=  yes
                   4465: PREFER_NATIVE=  getopt skey tcp_wrappers
                   4466: 
                   4467: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
                   4468: it is simply ignored in that list.
                   4469: 
1.117     sevan    4470: Setting PREFER_NATIVE should be performed straight after bootstrap and
                   4471: PREFER_PKGSRC during bootstrap. Switching between settings globally at a later
                   4472: date can introduce complications with dependency resolution. This is caused by
                   4473: packages built with the opposite preference being installed alongside each
                   4474: other.
                   4475: 
                   4476: # ./bootstrap --prefer-pkgsrc yes
                   4477: 
1.154     rillig   4478: Chapter 17. The pkginstall framework
1.1       dsieger  4479: 
                   4480: Table of Contents
                   4481: 
1.154     rillig   4482: 17.1. Files and directories outside the installation prefix
1.1       dsieger  4483: 
1.154     rillig   4484:     17.1.1. Directory manipulation
                   4485:     17.1.2. File manipulation
1.1       dsieger  4486: 
1.154     rillig   4487: 17.2. Configuration files
1.1       dsieger  4488: 
1.154     rillig   4489:     17.2.1. How PKG_SYSCONFDIR is set
                   4490:     17.2.2. Telling the software where configuration files are
                   4491:     17.2.3. Patching installations
                   4492:     17.2.4. Disabling handling of configuration files
1.1       dsieger  4493: 
1.154     rillig   4494: 17.3. System startup scripts
1.1       dsieger  4495: 
1.154     rillig   4496:     17.3.1. Disabling handling of system startup scripts
1.1       dsieger  4497: 
1.154     rillig   4498: 17.4. System users and groups
                   4499: 17.5. System shells
1.1       dsieger  4500: 
1.154     rillig   4501:     17.5.1. Disabling shell registration
1.1       dsieger  4502: 
1.154     rillig   4503: 17.6. Fonts
1.1       dsieger  4504: 
1.154     rillig   4505:     17.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  4506: 
                   4507: This chapter describes the framework known as pkginstall, whose key features
                   4508: are:
                   4509: 
                   4510:   * Generic installation and manipulation of directories and files outside the
                   4511:     pkgsrc-handled tree, LOCALBASE.
                   4512: 
                   4513:   * Automatic handling of configuration files during installation, provided
                   4514:     that packages are correctly designed.
                   4515: 
                   4516:   * Generation and installation of system startup scripts.
                   4517: 
                   4518:   * Registration of system users and groups.
                   4519: 
                   4520:   * Registration of system shells.
                   4521: 
                   4522:   * Automatic updating of fonts databases.
                   4523: 
                   4524: The following sections inspect each of the above points in detail.
                   4525: 
                   4526: You may be thinking that many of the things described here could be easily done
                   4527: with simple code in the package's post-installation target (post-install). This
                   4528: is incorrect, as the code in them is only executed when building from source.
                   4529: Machines using binary packages could not benefit from it at all (as the code
                   4530: itself could be unavailable). Therefore, the only way to achieve any of the
                   4531: items described above is by means of the installation scripts, which are
                   4532: automatically generated by pkginstall.
                   4533: 
1.154     rillig   4534: 17.1. Files and directories outside the installation prefix
1.1       dsieger  4535: 
                   4536: As you already know, the PLIST file holds a list of files and directories that
                   4537: belong to a package. The names used in it are relative to the installation
                   4538: prefix (${PREFIX}), which means that it cannot register files outside this
                   4539: directory (absolute path names are not allowed). Despite this restriction, some
                   4540: packages need to install files outside this location; e.g., under ${VARBASE} or
                   4541: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
                   4542: installation time by using installation scripts.
                   4543: 
                   4544: The generic installation scripts are shell scripts that can contain arbitrary
                   4545: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
                   4546: which defaults to INSTALL. A similar variable exists for package removal
                   4547: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
                   4548: commands, so they have the potential to create and manage files anywhere in the
                   4549: file system.
                   4550: 
                   4551: Using these general installation files is not recommended, but may be needed in
                   4552: some special cases. One reason for avoiding them is that the user has to trust
                   4553: the packager that there is no unwanted or simply erroneous code included in the
                   4554: installation script. Also, previously there were many similar scripts for the
                   4555: same functionality, and fixing a common error involved finding and changing all
                   4556: of them.
                   4557: 
                   4558: The pkginstall framework offers another, standardized way. It provides generic
                   4559: scripts to abstract the manipulation of such files and directories based on
                   4560: variables set in the package's Makefile. The rest of this section describes
                   4561: these variables.
                   4562: 
1.154     rillig   4563: 17.1.1. Directory manipulation
1.1       dsieger  4564: 
                   4565: The following variables can be set to request the creation of directories
                   4566: anywhere in the file system:
                   4567: 
                   4568:   * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
                   4569:     and should attempt to be destroyed by the installation scripts. The
                   4570:     difference between the two is that the latter prompts the administrator to
                   4571:     remove any directories that may be left after deinstallation (because they
1.108     rillig   4572:     were not empty), while the former does not. Example:
                   4573: 
                   4574:     MAKE_DIRS+=             ${VARBASE}/foo/private
1.1       dsieger  4575: 
                   4576:   * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
                   4577:     which directories should be created and should attempt to be destroyed by
                   4578:     the installation scripts. Each tuple holds the following values, separated
                   4579:     by spaces: the directory name, its owner, its group and its numerical mode.
                   4580:     For example:
                   4581: 
1.108     rillig   4582:     MAKE_DIRS_PERMS+=       ${VARBASE}/foo/private \
                   4583:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  4584: 
                   4585:     The difference between the two is exactly the same as their non-PERMS
                   4586:     counterparts.
                   4587: 
1.154     rillig   4588: 17.1.2. File manipulation
1.1       dsieger  4589: 
                   4590: Creating non-empty files outside the installation prefix is tricky because the
                   4591: PLIST forces all files to be inside it. To overcome this problem, the only
                   4592: solution is to extract the file in the known place (i.e., inside the
                   4593: installation prefix) and copy it to the appropriate location during
                   4594: installation (done by the installation scripts generated by pkginstall). We
                   4595: will call the former the master file in the following paragraphs, which
                   4596: describe the variables that can be used to automatically and consistently
                   4597: handle files outside the installation prefix:
                   4598: 
1.31      wiz      4599:   * CONF_FILES and REQD_FILES are pairs of master and target files. During
1.1       dsieger  4600:     installation time, the master file is copied to the target one if and only
                   4601:     if the latter does not exist. Upon deinstallation, the target file is
                   4602:     removed provided that it was not modified by the installation.
                   4603: 
                   4604:     The difference between the two is that the latter prompts the administrator
                   4605:     to remove any files that may be left after deinstallation (because they
                   4606:     were not empty), while the former does not.
                   4607: 
1.31      wiz      4608:   * CONF_FILES_PERMS and REQD_FILES_PERMS contain tuples describing master
1.1       dsieger  4609:     files as well as their target locations. For each of them, it also
                   4610:     specifies their owner, their group and their numeric permissions, in this
                   4611:     order. For example:
                   4612: 
1.108     rillig   4613:     REQD_FILES_PERMS+=      ${PREFIX}/share/somefile ${VARBASE}/somefile \
                   4614:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  4615: 
                   4616:     The difference between the two is exactly the same as their non-PERMS
                   4617:     counterparts.
                   4618: 
1.154     rillig   4619: 17.2. Configuration files
1.1       dsieger  4620: 
                   4621: Configuration files are special in the sense that they are installed in their
                   4622: own specific directory, PKG_SYSCONFDIR, and need special treatment during
                   4623: installation (most of which is automated by pkginstall). The main concept you
                   4624: must bear in mind is that files marked as configuration files are automatically
                   4625: copied to the right place (somewhere inside PKG_SYSCONFDIR) during installation
                   4626: if and only if they didn't exist before. Similarly, they will not be removed if
                   4627: they have local modifications. This ensures that administrators never lose any
                   4628: custom changes they may have made.
                   4629: 
1.154     rillig   4630: 17.2.1. How PKG_SYSCONFDIR is set
1.1       dsieger  4631: 
                   4632: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
                   4633: shall be installed. Its contents are set based upon the following variables:
                   4634: 
                   4635:   * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
                   4636:     etc although it may be overridden by the user to point to his preferred
                   4637:     location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
                   4638: 
                   4639:   * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
                   4640:     configuration files for the package being built shall be installed. The
                   4641:     definition of this variable only makes sense in the package's Makefile
                   4642:     (i.e., it is not user-customizable).
                   4643: 
1.68      asau     4644:     As an example, consider the Apache package, www/apache24, which places its
1.1       dsieger  4645:     configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
                   4646:     should be set in the package Makefile.
                   4647: 
                   4648:   * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
                   4649:     package's configuration directory (if different from PKG_SYSCONFBASE). It
                   4650:     defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
                   4651: 
                   4652:   * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
                   4653:     configuration files for the package identified by PKG_SYSCONFVAR's shall be
                   4654:     placed.
                   4655: 
                   4656: Based on the above variables, pkginstall determines the value of
                   4657: PKG_SYSCONFDIR, which is the only variable that can be used within a package to
                   4658: refer to its configuration directory. The algorithm used to set its value is
                   4659: basically the following:
                   4660: 
                   4661:  1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
                   4662: 
                   4663:  2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
                   4664:     package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
                   4665:     {PKG_SYSCONFSUBDIR}.
                   4666: 
                   4667:  3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
                   4668: 
                   4669: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
1.154     rillig   4670: OWN_DIRS. See Section 17.1.1, "Directory manipulation" what this means. This
1.16      jnemeth  4671: does not apply to subdirectories of ${PKG_SYSCONFDIR}, they still have to be
                   4672: created with OWN_DIRS or MAKE_DIRS.
1.1       dsieger  4673: 
1.154     rillig   4674: 17.2.2. Telling the software where configuration files are
1.1       dsieger  4675: 
                   4676: Given that pkgsrc (and users!) expect configuration files to be in a known
                   4677: place, you need to teach each package where it shall install its files. In some
                   4678: cases you will have to patch the package Makefiles to achieve it. If you are
                   4679: lucky, though, it may be as easy as passing an extra flag to the configuration
                   4680: script; this is the case of GNU Autoconf- generated files:
                   4681: 
                   4682: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
                   4683: 
                   4684: Note that this specifies where the package has to look for its configuration
                   4685: files, not where they will be originally installed (although the difference is
                   4686: never explicit, unfortunately).
                   4687: 
1.154     rillig   4688: 17.2.3. Patching installations
1.1       dsieger  4689: 
                   4690: As said before, pkginstall automatically handles configuration files. This
                   4691: means that the packages themselves must not touch the contents of $
                   4692: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
                   4693: will, out of the box, mess with the contents of that directory. So what is the
                   4694: correct procedure to fix this issue?
                   4695: 
                   4696: You must teach the package (usually by manually patching it) to install any
                   4697: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
                   4698: This way, the PLIST registers them and the administrator always has the
                   4699: original copies available.
                   4700: 
                   4701: Once the required configuration files are in place (i.e., under the examples
                   4702: hierarchy), the pkginstall framework can use them as master copies during the
                   4703: package installation to update what is in ${PKG_SYSCONFDIR}. To achieve this,
                   4704: the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
1.154     rillig   4705: Section 17.1.2, "File manipulation" for information about their syntax and
1.1       dsieger  4706: their purpose. Here is an example, taken from the mail/mutt package:
                   4707: 
                   4708: EGDIR=        ${PREFIX}/share/doc/mutt/samples
                   4709: CONF_FILES=   ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
                   4710: 
                   4711: Note that the EGDIR variable is specific to that package and has no meaning
                   4712: outside it.
                   4713: 
1.154     rillig   4714: 17.2.4. Disabling handling of configuration files
1.1       dsieger  4715: 
                   4716: The automatic copying of config files can be toggled by setting the environment
                   4717: variable PKG_CONFIG prior to package installation.
                   4718: 
1.154     rillig   4719: 17.3. System startup scripts
1.1       dsieger  4720: 
                   4721: System startup scripts are special files because they must be installed in a
                   4722: place known by the underlying OS, usually outside the installation prefix.
1.154     rillig   4723: Therefore, the same rules described in Section 17.1, "Files and directories
1.1       dsieger  4724: outside the installation prefix" apply, and the same solutions can be used.
                   4725: However, pkginstall provides a special mechanism to handle these files.
                   4726: 
                   4727: In order to provide system startup scripts, the package has to:
                   4728: 
                   4729:  1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
                   4730:     Considering the print/cups package as an example, it has a cupsd.sh in its
                   4731:     files directory.
                   4732: 
                   4733:  2. Tell pkginstall to handle it, appending the name of the script, without its
                   4734:     extension, to the RCD_SCRIPTS variable. Continuing the previous example:
                   4735: 
                   4736:     RCD_SCRIPTS+=   cupsd
                   4737: 
                   4738: Once this is done, pkginstall will do the following steps for each script in an
                   4739: automated fashion:
                   4740: 
                   4741:  1. Process the file found in the files directory applying all the
                   4742:     substitutions described in the FILES_SUBST variable.
                   4743: 
                   4744:  2. Copy the script from the files directory to the examples hierarchy, $
                   4745:     {PREFIX}/share/examples/rc.d/. Note that this master file must be
                   4746:     explicitly registered in the PLIST.
                   4747: 
                   4748:  3. Add code to the installation scripts to copy the startup script from the
                   4749:     examples hierarchy into the system-wide startup scripts directory.
                   4750: 
1.154     rillig   4751: 17.3.1. Disabling handling of system startup scripts
1.1       dsieger  4752: 
                   4753: The automatic copying of config files can be toggled by setting the environment
                   4754: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
                   4755: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
                   4756: rc.d/, no matter what the value of this variable is.
                   4757: 
1.154     rillig   4758: 17.4. System users and groups
1.1       dsieger  4759: 
                   4760: If a package needs to create special users and/or groups during installation,
                   4761: it can do so by using the pkginstall framework.
                   4762: 
                   4763: Users can be created by adding entries to the PKG_USERS variable. Each entry
                   4764: has the following syntax:
                   4765: 
                   4766: user:group
                   4767: 
                   4768: Further specification of user details may be done by setting per-user
                   4769: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
                   4770: user's description or comment. PKG_HOME.user is the user's home directory, and
                   4771: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
                   4772: and defaults to /sbin/nologin if not specified.
                   4773: 
                   4774: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
                   4775: whose syntax is:
                   4776: 
                   4777: group
                   4778: 
                   4779: The numeric GID of the group may be set by defining PKG_GID.group.
                   4780: 
                   4781: If a package needs to create the users and groups at an earlier stage, then it
1.116     wiz      4782: can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
                   4783: the phase before which the users and groups are created. In this case, the
                   4784: numeric UIDs and GIDs of the created users and groups are automatically
                   4785: hardcoded into the final installation scripts.
1.1       dsieger  4786: 
1.154     rillig   4787: 17.5. System shells
1.1       dsieger  4788: 
                   4789: Packages that install system shells should register them in the shell database,
                   4790: /etc/shells, to make things easier to the administrator. This must be done from
                   4791: the installation scripts to keep binary packages working on any system.
                   4792: pkginstall provides an easy way to accomplish this task.
                   4793: 
                   4794: When a package provides a shell interpreter, it has to set the PKG_SHELL
                   4795: variable to its absolute file name. This will add some hooks to the
                   4796: installation scripts to handle it. Consider the following example, taken from
                   4797: shells/zsh:
                   4798: 
                   4799: PKG_SHELL=      ${PREFIX}/bin/zsh
                   4800: 
1.154     rillig   4801: 17.5.1. Disabling shell registration
1.1       dsieger  4802: 
                   4803: The automatic registration of shell interpreters can be disabled by the
                   4804: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
                   4805: 
1.154     rillig   4806: 17.6. Fonts
1.1       dsieger  4807: 
                   4808: Packages that install X11 fonts should update the database files that index the
                   4809: fonts within each fonts directory. This can easily be accomplished within the
                   4810: pkginstall framework.
                   4811: 
                   4812: When a package installs X11 fonts, it must list the directories in which fonts
                   4813: are installed in the FONTS_DIRS.type variables, where type can be one of "ttf",
                   4814: "type1" or "x11". This will add hooks to the installation scripts to run the
                   4815: appropriate commands to update the fonts database files within each of those
                   4816: directories. For convenience, if the directory path is relative, it is taken to
                   4817: be relative to the package's installation prefix. Consider the following
                   4818: example, taken from fonts/dbz-ttf:
                   4819: 
1.67      wiz      4820: FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
1.1       dsieger  4821: 
1.154     rillig   4822: 17.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  4823: 
                   4824: The automatic update of fonts databases can be disabled by the administrator by
                   4825: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
                   4826: 
1.154     rillig   4827: Chapter 18. Options handling
1.1       dsieger  4828: 
                   4829: Table of Contents
                   4830: 
1.154     rillig   4831: 18.1. Global default options
                   4832: 18.2. Converting packages to use bsd.options.mk
                   4833: 18.3. Option Names
                   4834: 18.4. Determining the options of dependencies
1.1       dsieger  4835: 
                   4836: Many packages have the ability to be built to support different sets of
                   4837: features. bsd.options.mk is a framework in pkgsrc that provides generic
                   4838: handling of those options that determine different ways in which the packages
                   4839: can be built. It's possible for the user to specify exactly which sets of
                   4840: options will be built into a package or to allow a set of global default
                   4841: options apply.
                   4842: 
1.7       rillig   4843: There are two broad classes of behaviors that one might want to control via
                   4844: options. One is whether some particular feature is enabled in a program that
                   4845: will be built anyway, often by including or not including a dependency on some
                   4846: other package. The other is whether or not an additional program will be built
                   4847: as part of the package. Generally, it is better to make a split package for
                   4848: such additional programs instead of using options, because it enables binary
                   4849: packages to be built which can then be added separately. For example, the foo
                   4850: package might have minimal dependencies (those packages without which foo
                   4851: doesn't make sense), and then the foo-gfoo package might include the GTK
                   4852: frontend program gfoo. This is better than including a gtk option to foo that
                   4853: adds gfoo, because either that option is default, in which case binary users
                   4854: can't get foo without gfoo, or not default, in which case they can't get gfoo.
                   4855: With split packages, they can install foo without having GTK, and later decide
                   4856: to install gfoo (pulling in GTK at that time). This is an advantage to source
                   4857: users too, avoiding the need for rebuilds.
                   4858: 
                   4859: Plugins with widely varying dependencies should usually be split instead of
                   4860: options.
                   4861: 
                   4862: It is often more work to maintain split packages, especially if the upstream
                   4863: package does not support this. The decision of split vs. option should be made
                   4864: based on the likelihood that users will want or object to the various pieces,
                   4865: the size of the dependencies that are included, and the amount of work.
                   4866: 
                   4867: A further consideration is licensing. Non-free parts, or parts that depend on
                   4868: non-free dependencies (especially plugins) should almost always be split if
                   4869: feasible.
                   4870: 
1.154     rillig   4871: 18.1. Global default options
1.1       dsieger  4872: 
                   4873: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
                   4874: the options that should be built into every package if that option is
1.4       rillig   4875: supported. This variable should be set in mk.conf.
1.1       dsieger  4876: 
1.154     rillig   4877: 18.2. Converting packages to use bsd.options.mk
1.1       dsieger  4878: 
                   4879: The following example shows how bsd.options.mk should be used by the
                   4880: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
                   4881: e.g. options.mk, that is included by the main package Makefile.
                   4882: 
                   4883: PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
                   4884: PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
                   4885: PKG_OPTIONS_OPTIONAL_GROUPS=    database
                   4886: PKG_OPTIONS_GROUP.database=     mysql pgsql
                   4887: PKG_SUGGESTED_OPTIONS=          wibble-foo
                   4888: PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
                   4889: PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
                   4890: 
                   4891: .include "../../mk/bsd.prefs.mk"
                   4892: 
                   4893: # this package was previously named wibble2
                   4894: .if defined(PKG_OPTIONS.wibble2)
                   4895: PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
                   4896: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
                   4897:         "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
                   4898: .endif
                   4899: 
                   4900: .include "../../mk/bsd.options.mk"
                   4901: 
                   4902: # Package-specific option-handling
                   4903: 
                   4904: ###
                   4905: ### FOO support
                   4906: ###
                   4907: .if !empty(PKG_OPTIONS:Mwibble-foo)
                   4908: CONFIGURE_ARGS+=    --enable-foo
                   4909: .endif
                   4910: 
                   4911: ###
                   4912: ### LDAP support
                   4913: ###
                   4914: .if !empty(PKG_OPTIONS:Mldap)
                   4915: .  include "../../databases/openldap-client/buildlink3.mk"
                   4916: CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
                   4917: .endif
                   4918: 
                   4919: ###
                   4920: ### database support
                   4921: ###
                   4922: .if !empty(PKG_OPTIONS:Mmysql)
                   4923: .  include "../../mk/mysql.buildlink3.mk"
                   4924: .endif
                   4925: .if !empty(PKG_OPTIONS:Mpgsql)
                   4926: .  include "../../mk/pgsql.buildlink3.mk"
                   4927: .endif
                   4928: 
                   4929: The first section contains the information about which build options are
                   4930: supported by the package, and any default options settings if needed.
                   4931: 
                   4932:  1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
                   4933:     to override the default options. It should be set to PKG_OPTIONS.pkgbase.
                   4934:     Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
                   4935:     the point where the options are processed.
                   4936: 
                   4937:  2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
                   4938: 
                   4939:  3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
                   4940:     exclusive options. The options in each group are listed in
                   4941:     PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
                   4942:     the group takes precedence over all other options in the group. Options
                   4943:     from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
                   4944: 
                   4945:  4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
                   4946:     building the packages will fail if no option from the group is selected.
                   4947: 
                   4948:  5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
                   4949:     one option from each set must be selected. The options in each set are
                   4950:     listed in PKG_OPTIONS_SET.setname. Options from the sets will be
                   4951:     automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
                   4952:     fail if no option from the set is selected.
                   4953: 
                   4954:  6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
                   4955:     default.
                   4956: 
                   4957:  7. PKG_OPTIONS_LEGACY_VARS is a list of "USE_VARIABLE:option" pairs that map
1.4       rillig   4958:     legacy mk.conf variables to their option counterparts. Pairs should be
1.1       dsieger  4959:     added with "+=" to keep the listing of global legacy variables. A warning
                   4960:     will be issued if the user uses a legacy variable.
                   4961: 
                   4962:  8. PKG_OPTIONS_LEGACY_OPTS is a list of "old-option:new-option" pairs that map
                   4963:     options that have been renamed to their new counterparts. Pairs should be
                   4964:     added with "+=" to keep the listing of global legacy options. A warning
                   4965:     will be issued if the user uses a legacy option.
                   4966: 
                   4967:  9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
                   4968:     used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
                   4969:     PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
                   4970: 
                   4971: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
                   4972:     variables or options used, and what to use instead.
                   4973: 
                   4974: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
                   4975: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
                   4976: options, use PKG_SUGGESTED_OPTIONS.
                   4977: 
                   4978: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
                   4979: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
                   4980: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
                   4981: options if none of them is supported on the current platform), PKG_OPTIONS is
                   4982: set to the empty list and the package is otherwise treated as not using the
                   4983: options framework.
                   4984: 
                   4985: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
                   4986: list of selected build options, properly filtered to remove unsupported and
                   4987: duplicate options.
                   4988: 
                   4989: The remaining sections contain the logic that is specific to each option. The
                   4990: correct way to check for an option is to check whether it is listed in
                   4991: PKG_OPTIONS:
                   4992: 
                   4993: .if !empty(PKG_OPTIONS:Moption)
                   4994: 
1.154     rillig   4995: 18.3. Option Names
1.1       dsieger  4996: 
                   4997: Options that enable similar features in different packages (like optional
                   4998: support for a library) should use a common name in all packages that support it
                   4999: (like the name of the library). If another package already has an option with
                   5000: the same meaning, use the same name.
                   5001: 
                   5002: Options that enable features specific to one package, where it's unlikely that
                   5003: another (unrelated) package has the same (or a similar) optional feature,
                   5004: should use a name prefixed with pkgname-.
                   5005: 
                   5006: If a group of related packages share an optional feature specific to that
                   5007: group, prefix it with the name of the "main" package (e. g.
                   5008: djbware-errno-hack).
                   5009: 
                   5010: For new options, add a line to mk/defaults/options.description. Lines have two
                   5011: fields, separated by tab. The first field is the option name, the second its
                   5012: description. The description should be a whole sentence (starting with an
                   5013: uppercase letter and ending with a period) that describes what enabling the
                   5014: option does. E. g. "Enable ispell support." The file is sorted by option names.
                   5015: 
1.154     rillig   5016: 18.4. Determining the options of dependencies
1.7       rillig   5017: 
                   5018: When writing buildlink3.mk files, it is often necessary to list different
                   5019: dependencies based on the options with which the package was built. For
                   5020: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
                   5021: A typical example looks like this:
                   5022: 
                   5023: pkgbase := libpurple
                   5024: .include "../../mk/pkg-build-options.mk"
                   5025: 
                   5026: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
                   5027: ...
                   5028: .endif
                   5029: 
                   5030: Including pkg-build-options.mk here will set the variable
                   5031: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
                   5032: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
                   5033: pkg-build-options.mk for more details.
                   5034: 
1.154     rillig   5035: Chapter 19. The build process
1.1       dsieger  5036: 
                   5037: Table of Contents
                   5038: 
1.154     rillig   5039: 19.1. Introduction
                   5040: 19.2. Program location
                   5041: 19.3. Directories used during the build process
                   5042: 19.4. Running a phase
                   5043: 19.5. The fetch phase
                   5044: 
                   5045:     19.5.1. What to fetch and where to get it from
                   5046:     19.5.2. How are the files fetched?
                   5047: 
                   5048: 19.6. The checksum phase
                   5049: 19.7. The extract phase
                   5050: 19.8. The patch phase
                   5051: 19.9. The tools phase
                   5052: 19.10. The wrapper phase
                   5053: 19.11. The configure phase
                   5054: 19.12. The build phase
                   5055: 19.13. The test phase
                   5056: 19.14. The install phase
                   5057: 19.15. The package phase
                   5058: 19.16. Cleaning up
                   5059: 19.17. Other helpful targets
1.1       dsieger  5060: 
1.154     rillig   5061: 19.1. Introduction
1.1       dsieger  5062: 
                   5063: This chapter gives a detailed description on how a package is built. Building a
                   5064: package is separated into different phases (for example fetch, build, install),
1.19      snj      5065: all of which are described in the following sections. Each phase is split into
                   5066: so-called stages, which take the name of the containing phase, prefixed by one
                   5067: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
                   5068: actual work is done in the do-* stages.
1.1       dsieger  5069: 
                   5070: Never override the regular targets (like fetch), if you have to, override the
                   5071: do-* ones instead.
                   5072: 
                   5073: The basic steps for building a program are always the same. First the program's
                   5074: source (distfile) must be brought to the local system and then extracted. After
                   5075: any pkgsrc-specific patches to compile properly are applied, the software can
                   5076: be configured, then built (usually by compiling), and finally the generated
                   5077: binaries, etc. can be put into place on the system.
                   5078: 
                   5079: To get more details about what is happening at each step, you can set the
                   5080: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
                   5081: more details about the patch step.
                   5082: 
1.154     rillig   5083: 19.2. Program location
1.1       dsieger  5084: 
                   5085: Before outlining the process performed by the NetBSD package system in the next
                   5086: section, here's a brief discussion on where programs are installed, and which
                   5087: variables influence this.
                   5088: 
                   5089: The automatic variable PREFIX indicates where all files of the final program
                   5090: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
                   5091: pkgs in the cross category. The value of PREFIX needs to be put into the
                   5092: various places in the program's source where paths to these files are encoded.
1.154     rillig   5093: See Section 13.3, "patches/*" and Section 21.3.1, "Shared libraries - libtool"
1.1       dsieger  5094: for more details.
                   5095: 
                   5096: When choosing which of these variables to use, follow the following rules:
                   5097: 
                   5098:   * PREFIX always points to the location where the current pkg will be
1.25      wiz      5099:     installed. When referring to a pkg's own installation path, use "${PREFIX}"
                   5100:     .
1.1       dsieger  5101: 
                   5102:   * LOCALBASE is where all non-X11 pkgs are installed. If you need to construct
                   5103:     a -I or -L argument to the compiler to find includes and libraries
                   5104:     installed by another non-X11 pkg, use "${LOCALBASE}". The name LOCALBASE
                   5105:     stems from FreeBSD, which installed all packages in /usr/local. As pkgsrc
                   5106:     leaves /usr/local for the system administrator, this variable is a
                   5107:     misnomer.
                   5108: 
                   5109:   * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
                   5110:     installed. When looking for standard X11 includes (not those installed by a
                   5111:     package), use "${X11BASE}".
                   5112: 
1.99      sevan    5113:   * X11-based packages using imake must set USE_IMAKE to be installed correctly
                   5114:     under LOCALBASE.
1.1       dsieger  5115: 
                   5116:   * Within ${PREFIX}, packages should install files according to hier(7), with
                   5117:     the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
                   5118:     man.
                   5119: 
1.154     rillig   5120: 19.3. Directories used during the build process
1.1       dsieger  5121: 
1.14      jmcneill 5122: When building a package, various directories are used to store source files,
1.1       dsieger  5123: temporary files, pkgsrc-internal files, and so on. These directories are
                   5124: explained here.
                   5125: 
                   5126: Some of the directory variables contain relative pathnames. There are two
                   5127: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
                   5128: used for directories that are pkgsrc-specific. WRKSRC is used for directories
                   5129: inside the package itself.
                   5130: 
                   5131: PKGSRCDIR
                   5132: 
                   5133:     This is an absolute pathname that points to the pkgsrc root directory.
                   5134:     Generally, you don't need it.
                   5135: 
                   5136: PKGDIR
                   5137: 
                   5138:     This is an absolute pathname that points to the current package.
                   5139: 
                   5140: PKGPATH
                   5141: 
                   5142:     This is a pathname relative to PKGSRCDIR that points to the current
                   5143:     package.
                   5144: 
                   5145: WRKDIR
                   5146: 
                   5147:     This is an absolute pathname pointing to the directory where all work takes
                   5148:     place. The distfiles are extracted to this directory. It also contains
                   5149:     temporary directories and log files used by the various pkgsrc frameworks,
                   5150:     like buildlink or the wrappers.
                   5151: 
                   5152: WRKSRC
                   5153: 
                   5154:     This is an absolute pathname pointing to the directory where the distfiles
                   5155:     are extracted. It is usually a direct subdirectory of WRKDIR, and often
                   5156:     it's the only directory entry that isn't hidden. This variable may be
                   5157:     changed by a package Makefile.
                   5158: 
1.14      jmcneill 5159: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
1.15      rillig   5160: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
1.14      jmcneill 5161: created in the pkgsrc entry's directory. If users would like to have their
                   5162: pkgsrc trees behave in a read-only manner, then the value of
                   5163: CREATE_WRKDIR_SYMLINK should be set to no.
                   5164: 
1.154     rillig   5165: 19.4. Running a phase
1.1       dsieger  5166: 
                   5167: You can run a particular phase by typing make phase, where phase is the name of
                   5168: the phase. This will automatically run all phases that are required for this
                   5169: phase. The default phase is build, that is, when you run make without
                   5170: parameters in a package directory, the package will be built, but not
                   5171: installed.
                   5172: 
1.154     rillig   5173: 19.5. The fetch phase
1.1       dsieger  5174: 
                   5175: The first step in building a package is to fetch the distribution files
1.25      wiz      5176: (distfiles) from the sites that are providing them. This is the task of the 
1.1       dsieger  5177: fetch phase.
                   5178: 
1.154     rillig   5179: 19.5.1. What to fetch and where to get it from
1.1       dsieger  5180: 
                   5181: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
                   5182: name is derived from the DISTNAME variable, is fetched. The more complicated
                   5183: cases are described below.
                   5184: 
                   5185: The variable DISTFILES specifies the list of distfiles that have to be fetched.
1.66      asau     5186: Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
                   5187: {EXTRACT_SUFX}, so that most packages don't need to define it at all.
                   5188: EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
                   5189: your package requires additional distfiles to the default one, you cannot just
                   5190: append the additional filenames using the += operator, but you have write for
                   5191: example:
1.1       dsieger  5192: 
1.66      asau     5193: DISTFILES=      ${DEFAULT_DISTFILES} additional-files.tar.gz
1.1       dsieger  5194: 
                   5195: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
                   5196: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
                   5197: can set SITES.distfile to the list of URLs where the file distfile (including
                   5198: the suffix) can be found.
                   5199: 
                   5200: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
                   5201: DISTFILES+=     foo-file.tar.gz
                   5202: SITES.foo-file.tar.gz= \
1.174     leot     5203: https://www.somewhere.com/somehow/ \
                   5204: https://www.somewhereelse.com/mirror/somehow/
1.1       dsieger  5205: 
                   5206: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
                   5207: gets the name of each distfile appended to it, without an intermediate slash.
                   5208: Therefore, all site values have to end with a slash or other separator
                   5209: character. This allows for example to set MASTER_SITES to a URL of a CGI script
                   5210: that gets the name of the distfile as a parameter. In this case, the definition
                   5211: would look like:
                   5212: 
1.174     leot     5213: MASTER_SITES=   https://www.example.com/download.cgi?file=
1.1       dsieger  5214: 
1.23      jakllsch 5215: The exception to this rule are URLs starting with a dash. In that case the URL
                   5216: is taken as is, fetched and the result stored under the name of the distfile.
1.66      asau     5217: You can use this style for the case when the download URL style does not match
                   5218: the above common case. For example, if permanent download URL is a redirector
                   5219: to the real download URL, or the download file name is offered by an HTTP
                   5220: Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
                   5221: created instead of the default v1.0.0.tar.gz.
                   5222: 
                   5223: DISTNAME=       foo-1.0.0
1.174     leot     5224: MASTER_SITES=   -https://www.example.com/archive/v1.0.0.tar.gz
1.23      jakllsch 5225: 
1.1       dsieger  5226: There are some predefined values for MASTER_SITES, which can be used in
                   5227: packages. The names of the variables should speak for themselves.
                   5228: 
1.156     leot     5229: MASTER_SITE_APACHE          MASTER_SITE_BACKUP
                   5230: MASTER_SITE_CRATESIO        MASTER_SITE_CYGWIN
                   5231: MASTER_SITE_DEBIAN          MASTER_SITE_FREEBSD
                   5232: MASTER_SITE_FREEBSD_LOCAL   MASTER_SITE_GENTOO
                   5233: MASTER_SITE_GITHUB          MASTER_SITE_GNOME
                   5234: MASTER_SITE_GNU             MASTER_SITE_GNUSTEP
                   5235: MASTER_SITE_HASKELL_HACKAGE MASTER_SITE_IFARCHIVE
                   5236: MASTER_SITE_KDE             MASTER_SITE_MOZILLA
                   5237: MASTER_SITE_MOZILLA_ALL     MASTER_SITE_MYSQL
                   5238: MASTER_SITE_NETLIB          MASTER_SITE_OPENBSD
                   5239: MASTER_SITE_OPENOFFICE      MASTER_SITE_OSDN
                   5240: MASTER_SITE_PERL_CPAN       MASTER_SITE_PGSQL
                   5241: MASTER_SITE_PYPI            MASTER_SITE_RUBYGEMS
                   5242: MASTER_SITE_R_CRAN          MASTER_SITE_SOURCEFORGE
                   5243: MASTER_SITE_SUNSITE         MASTER_SITE_SUSE
                   5244: MASTER_SITE_TEX_CTAN        MASTER_SITE_XCONTRIB
                   5245: MASTER_SITE_XEMACS          MASTER_SITE_XORG
1.1       dsieger  5246: 
                   5247: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
                   5248: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
1.27      wiz      5249: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
1.26      spz      5250: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
                   5251: distfiles/LOCAL_PORTS/.
1.1       dsieger  5252: 
                   5253: If you choose one of these predefined sites, you may want to specify a
                   5254: subdirectory of that site. Since these macros may expand to more than one
                   5255: actual site, you must use the following construct to specify a subdirectory:
                   5256: 
                   5257: MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
                   5258: MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
                   5259: 
                   5260: Note the trailing slash after the subdirectory name.
                   5261: 
1.154     rillig   5262: 19.5.2. How are the files fetched?
1.1       dsieger  5263: 
                   5264: The fetch phase makes sure that all the distfiles exist in a local directory
                   5265: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
                   5266: are fetched using commands of the form
                   5267: 
                   5268: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
                   5269: 
                   5270: where ${site} varies through several possibilities in turn: first,
                   5271: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
                   5272: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
                   5273: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
                   5274: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
                   5275: MASTER_SORT_AWK or MASTER_SORT_REGEX.
                   5276: 
1.16      jnemeth  5277: The specific command and arguments used depend on the FETCH_USING parameter.
                   5278: The example above is for FETCH_USING=custom.
                   5279: 
1.1       dsieger  5280: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
                   5281: target to mirror the distfiles, if they are freely distributable. Packages
                   5282: setting NO_SRC_ON_FTP (usually to "${RESTRICTED}") will not have their
                   5283: distfiles mirrored.
                   5284: 
1.154     rillig   5285: 19.6. The checksum phase
1.1       dsieger  5286: 
                   5287: After the distfile(s) are fetched, their checksum is generated and compared
                   5288: with the checksums stored in the distinfo file. If the checksums don't match,
                   5289: the build is aborted. This is to ensure the same distfile is used for building,
                   5290: and that the distfile wasn't changed, e.g. by some malign force, deliberately
                   5291: changed distfiles on the master distribution site or network lossage.
                   5292: 
1.154     rillig   5293: 19.7. The extract phase
1.1       dsieger  5294: 
                   5295: When the distfiles are present on the local system, they need to be extracted,
                   5296: as they usually come in the form of some compressed archive format.
                   5297: 
                   5298: By default, all DISTFILES are extracted. If you only need some of them, you can
                   5299: set the EXTRACT_ONLY variable to the list of those files.
                   5300: 
                   5301: Extracting the files is usually done by a little program, mk/extract/extract,
                   5302: which already knows how to extract various archive formats, so most likely you
                   5303: will not need to change anything here. But if you need, the following variables
                   5304: may help you:
                   5305: 
                   5306: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
                   5307: 
                   5308:     Use these variables to override the default options for an extract command,
                   5309:     which are defined in mk/extract/extract.
                   5310: 
                   5311: EXTRACT_USING
                   5312: 
1.14      jmcneill 5313:     This variable can be set to bsdtar, gtar, nbtar (which is the default
                   5314:     value), pax, or an absolute pathname pointing to the command with which tar
                   5315:     archives should be extracted. It is preferred to choose bsdtar over gtar if
                   5316:     NetBSD's pax-as-tar is not good enough.
1.1       dsieger  5317: 
                   5318: If the extract program doesn't serve your needs, you can also override the
                   5319: EXTRACT_CMD variable, which holds the command used for extracting the files.
                   5320: This command is executed in the ${WRKSRC} directory. During execution of this
                   5321: command, the shell variable extract_file holds the absolute pathname of the
                   5322: file that is going to be extracted.
                   5323: 
                   5324: And if that still does not suffice, you can override the do-extract target in
                   5325: the package Makefile.
                   5326: 
1.154     rillig   5327: 19.8. The patch phase
1.1       dsieger  5328: 
                   5329: After extraction, all the patches named by the PATCHFILES, those present in the
                   5330: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
                   5331: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
                   5332: are uncompressed before they are applied, files ending in .orig or .rej are
                   5333: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
1.154     rillig   5334: Section 13.3, "patches/*" for more details.
1.1       dsieger  5335: 
                   5336: By default patch(1) is given special args to make it fail if the patches apply
                   5337: with some lines of fuzz. Please fix (regen) the patches so that they apply
                   5338: cleanly. The rationale behind this is that patches that don't apply cleanly may
                   5339: end up being applied in the wrong place, and cause severe harm there.
                   5340: 
1.154     rillig   5341: 19.9. The tools phase
1.1       dsieger  5342: 
1.154     rillig   5343: This is covered in Chapter 20, Tools needed for building or running.
1.1       dsieger  5344: 
1.154     rillig   5345: 19.10. The wrapper phase
1.1       dsieger  5346: 
                   5347: This phase creates wrapper programs for the compilers and linkers. The
                   5348: following variables can be used to tweak the wrappers.
                   5349: 
                   5350: ECHO_WRAPPER_MSG
                   5351: 
                   5352:     The command used to print progress messages. Does nothing by default. Set
                   5353:     to ${ECHO} to see the progress messages.
                   5354: 
                   5355: WRAPPER_DEBUG
                   5356: 
                   5357:     This variable can be set to yes (default) or no, depending on whether you
                   5358:     want additional information in the wrapper log file.
                   5359: 
                   5360: WRAPPER_UPDATE_CACHE
                   5361: 
                   5362:     This variable can be set to yes or no, depending on whether the wrapper
                   5363:     should use its cache, which will improve the speed. The default value is
                   5364:     yes, but is forced to no if the platform does not support it.
                   5365: 
                   5366: WRAPPER_REORDER_CMDS
                   5367: 
                   5368:     A list of reordering commands. A reordering command has the form reorder:l:
                   5369:     lib1:lib2. It ensures that that -llib1 occurs before -llib2.
                   5370: 
1.154     rillig   5371: 19.11. The configure phase
1.1       dsieger  5372: 
                   5373: Most pieces of software need information on the header files, system calls, and
                   5374: library routines which are available on the platform they run on. The process
                   5375: of determining this information is known as configuration, and is usually
                   5376: automated. In most cases, a script is supplied with the distfiles, and its
                   5377: invocation results in generation of header files, Makefiles, etc.
                   5378: 
                   5379: If the package contains a configure script, this can be invoked by setting
                   5380: HAS_CONFIGURE to "yes". If the configure script is a GNU autoconf script, you
                   5381: should set GNU_CONFIGURE to "yes" instead. What happens in the configure phase
                   5382: is roughly:
                   5383: 
                   5384: .for d in ${CONFIGURE_DIRS}
                   5385:         cd ${WRKSRC} \
                   5386:         && cd ${d} \
                   5387:         && env ${CONFIGURE_ENV} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
                   5388: .endfor
                   5389: 
                   5390: CONFIGURE_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In
                   5391: each of these directories, the configure script is run with the environment
                   5392: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
                   5393: CONFIGURE_SCRIPT (default: "./configure") and CONFIGURE_ARGS may all be changed
                   5394: by the package.
                   5395: 
1.38      wiz      5396: If the program uses the Perl way of configuration (mainly Perl modules, but not
                   5397: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
                   5398: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
                   5399: (e.g., MAKE_PARAMS+=foo=bar
                   5400: 
1.1       dsieger  5401: If the program uses an Imakefile for configuration, the appropriate steps can
1.99      sevan    5402: be invoked by setting USE_IMAKE to "yes". If you only need xmkmf, add it to
                   5403: USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
                   5404: SCRIPTS_ENV variable.
1.1       dsieger  5405: 
1.11      rillig   5406: If the program uses cmake for configuration, the appropriate steps can be
                   5407: invoked by setting USE_CMAKE to "yes". You can add variables to cmake's
                   5408: environment by adding them to the CONFIGURE_ENV variable and arguments to cmake
                   5409: by adding them to the CMAKE_ARGS variable. The top directory argument is given
                   5410: by the CMAKE_ARG_PATH variable, that defaults to "." (relative to
                   5411: CONFIGURE_DIRS)
                   5412: 
1.1       dsieger  5413: If there is no configure step at all, set NO_CONFIGURE to "yes".
                   5414: 
1.154     rillig   5415: 19.12. The build phase
1.1       dsieger  5416: 
                   5417: For building a package, a rough equivalent of the following code is executed.
                   5418: 
                   5419: .for d in ${BUILD_DIRS}
                   5420:         cd ${WRKSRC} \
                   5421:         && cd ${d} \
                   5422:         && env ${MAKE_ENV} \
                   5423:             ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
                   5424:                 -f ${MAKE_FILE} \
                   5425:                 ${BUILD_TARGET}
                   5426: .endfor
                   5427: 
                   5428: BUILD_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In each of
                   5429: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
                   5430: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
                   5431: and BUILD_TARGET may all be changed by the package.
                   5432: 
1.25      wiz      5433: The default value of MAKE_PROGRAM is "gmake" if USE_TOOLS contains "gmake", "
                   5434: make" otherwise. The default value of MAKE_FILE is "Makefile", and BUILD_TARGET
                   5435: defaults to "all".
1.1       dsieger  5436: 
                   5437: If there is no build step at all, set NO_BUILD to "yes".
                   5438: 
1.154     rillig   5439: 19.13. The test phase
1.1       dsieger  5440: 
                   5441: [TODO]
                   5442: 
1.154     rillig   5443: 19.14. The install phase
1.1       dsieger  5444: 
                   5445: Once the build stage has completed, the final step is to install the software
                   5446: in public directories, so users can access the programs and files.
                   5447: 
                   5448: In the install phase, a rough equivalent of the following code is executed.
                   5449: Additionally, before and after this code, much magic is performed to do
                   5450: consistency checks, registering the package, and so on.
                   5451: 
                   5452: .for d in ${INSTALL_DIRS}
                   5453:         cd ${WRKSRC} \
                   5454:         && cd ${d} \
                   5455:         && env ${MAKE_ENV} \
                   5456:             ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
                   5457:                 -f ${MAKE_FILE} \
                   5458:                 ${INSTALL_TARGET}
                   5459: .endfor
                   5460: 
                   5461: The variable's meanings are analogous to the ones in the build phase.
                   5462: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is "install" by default,
                   5463: plus "install.man" if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
                   5464: defined.
                   5465: 
                   5466: In the install phase, the following variables are useful. They are all
                   5467: variations of the install(1) command that have the owner, group and permissions
                   5468: preset. INSTALL is the plain install command. The specialized variants,
                   5469: together with their intended use, are:
                   5470: 
                   5471: INSTALL_PROGRAM_DIR
                   5472: 
                   5473:     directories that contain binaries
                   5474: 
                   5475: INSTALL_SCRIPT_DIR
                   5476: 
                   5477:     directories that contain scripts
                   5478: 
                   5479: INSTALL_LIB_DIR
                   5480: 
                   5481:     directories that contain shared and static libraries
                   5482: 
                   5483: INSTALL_DATA_DIR
                   5484: 
                   5485:     directories that contain data files
                   5486: 
                   5487: INSTALL_MAN_DIR
                   5488: 
                   5489:     directories that contain man pages
                   5490: 
1.100     leot     5491: INSTALL_GAME_DIR
                   5492: 
                   5493:     directories that contain data files for games
                   5494: 
1.1       dsieger  5495: INSTALL_PROGRAM
                   5496: 
                   5497:     binaries that can be stripped from debugging symbols
                   5498: 
                   5499: INSTALL_SCRIPT
                   5500: 
                   5501:     binaries that cannot be stripped
                   5502: 
                   5503: INSTALL_GAME
                   5504: 
                   5505:     game binaries
                   5506: 
                   5507: INSTALL_LIB
                   5508: 
                   5509:     shared and static libraries
                   5510: 
                   5511: INSTALL_DATA
                   5512: 
                   5513:     data files
                   5514: 
                   5515: INSTALL_GAME_DATA
                   5516: 
                   5517:     data files for games
                   5518: 
                   5519: INSTALL_MAN
                   5520: 
                   5521:     man pages
                   5522: 
                   5523: Some other variables are:
                   5524: 
1.106     tnn      5525: INSTALL_UNSTRIPPED
                   5526: 
                   5527:     If set to yes, do not run strip(1) when installing binaries. Any debugging
                   5528:     sections and symbols present in binaries will be preserved.
                   5529: 
1.1       dsieger  5530: INSTALLATION_DIRS
                   5531: 
                   5532:     A list of directories relative to PREFIX that are created by pkgsrc at the
                   5533:     beginning of the install phase. The package is supposed to create all
                   5534:     needed directories itself before installing files to it and list all other
                   5535:     directories here.
                   5536: 
1.25      wiz      5537: In the rare cases that a package shouldn't install anything, set NO_INSTALL to 
1.1       dsieger  5538: "yes". This is mostly relevant for packages in the regress category.
                   5539: 
1.154     rillig   5540: 19.15. The package phase
1.1       dsieger  5541: 
                   5542: Once the install stage has completed, a binary package of the installed files
                   5543: can be built. These binary packages can be used for quick installation without
                   5544: previous compilation, e.g. by the make bin-install or by using pkg_add.
                   5545: 
                   5546: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
                   5547: created in ${PACKAGES}/category, one for each category in the CATEGORIES
                   5548: variable. PACKAGES defaults to pkgsrc/packages.
                   5549: 
1.154     rillig   5550: 19.16. Cleaning up
1.1       dsieger  5551: 
                   5552: Once you're finished with a package, you can clean the work directory by
                   5553: running make clean. If you want to clean the work directories of all
                   5554: dependencies too, use make clean-depends.
                   5555: 
1.154     rillig   5556: 19.17. Other helpful targets
1.1       dsieger  5557: 
                   5558: pre/post-*
                   5559: 
                   5560:     For any of the main targets described in the previous section, two
                   5561:     auxiliary targets exist with "pre-" and "post-" used as a prefix for the
                   5562:     main target's name. These targets are invoked before and after the main
                   5563:     target is called, allowing extra configuration or installation steps be
                   5564:     performed from a package's Makefile, for example, which a program's
                   5565:     configure script or install target omitted.
                   5566: 
                   5567: do-*
                   5568: 
                   5569:     Should one of the main targets do the wrong thing, and should there be no
                   5570:     variable to fix this, you can redefine it with the do-* target. (Note that
                   5571:     redefining the target itself instead of the do-* target is a bad idea, as
                   5572:     the pre-* and post-* targets won't be called anymore, etc.) You will not
                   5573:     usually need to do this.
                   5574: 
                   5575: reinstall
                   5576: 
                   5577:     If you did a make install and you noticed some file was not installed
                   5578:     properly, you can repeat the installation with this target, which will
                   5579:     ignore the "already installed" flag.
                   5580: 
                   5581:     This is the default value of DEPENDS_TARGET except in the case of make
                   5582:     update and make package, where the defaults are "package" and "update",
                   5583:     respectively.
                   5584: 
                   5585: deinstall
                   5586: 
                   5587:     This target does a pkg_delete(1) in the current directory, effectively
                   5588:     de-installing the package. The following variables can be used to tune the
                   5589:     behaviour:
                   5590: 
                   5591:     PKG_VERBOSE
                   5592: 
                   5593:         Add a "-v" to the pkg_delete(1) command.
                   5594: 
                   5595:     DEINSTALLDEPENDS
                   5596: 
                   5597:         Remove all packages that require (depend on) the given package. This
                   5598:         can be used to remove any packages that may have been pulled in by a
                   5599:         given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
1.25      wiz      5600:         pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding "-R
                   5601:         " to the pkg_delete(1) command line.
1.1       dsieger  5602: 
                   5603: bin-install
                   5604: 
                   5605:     Install a binary package from local disk and via FTP from a list of sites
                   5606:     (see the BINPKG_SITES variable), and do a make package if no binary package
                   5607:     is available anywhere. The arguments given to pkg_add can be set via
                   5608:     BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
                   5609: 
1.95      wiz      5610: install-clean
                   5611: 
                   5612:     This target removes the state files for the "install" and later phases so
                   5613:     that the "install" target may be re-invoked. This can be used after editing
                   5614:     the PLIST to install the package without rebuilding it.
                   5615: 
                   5616: build-clean
                   5617: 
                   5618:     This target removes the state files for the "build" and later phases so
                   5619:     that the "build" target may be re-invoked.
                   5620: 
1.1       dsieger  5621: update
                   5622: 
                   5623:     This target causes the current package to be updated to the latest version.
                   5624:     The package and all depending packages first get de-installed, then current
                   5625:     versions of the corresponding packages get compiled and installed. This is
                   5626:     similar to manually noting which packages are currently installed, then
                   5627:     performing a series of make deinstall and make install (or whatever
                   5628:     UPDATE_TARGET is set to) for these packages.
                   5629: 
                   5630:     You can use the "update" target to resume package updating in case a
                   5631:     previous make update was interrupted for some reason. However, in this
                   5632:     case, make sure you don't call make clean or otherwise remove the list of
                   5633:     dependent packages in WRKDIR. Otherwise, you lose the ability to
                   5634:     automatically update the current package along with the dependent packages
                   5635:     you have installed.
                   5636: 
                   5637:     Resuming an interrupted make update will only work as long as the package
                   5638:     tree remains unchanged. If the source code for one of the packages to be
                   5639:     updated has been changed, resuming make update will most certainly fail!
                   5640: 
1.4       rillig   5641:     The following variables can be used either on the command line or in
1.1       dsieger  5642:     mk.conf to alter the behaviour of make update:
                   5643: 
                   5644:     UPDATE_TARGET
                   5645: 
                   5646:         Install target to recursively use for the updated package and the
                   5647:         dependent packages. Defaults to DEPENDS_TARGET if set, "install"
1.25      wiz      5648:         otherwise for make update. Other good targets are "package" or "
                   5649:         bin-install". Do not set this to "update" or you will get stuck in an
1.1       dsieger  5650:         endless loop!
                   5651: 
                   5652:     NOCLEAN
                   5653: 
                   5654:         Don't clean up after updating. Useful if you want to leave the work
                   5655:         sources of the updated packages around for inspection or other
1.25      wiz      5656:         purposes. Be sure you eventually clean up the source tree (see the "
                   5657:         clean-update" target below) or you may run into troubles with old
1.1       dsieger  5658:         source code still lying around on your next make or make update.
                   5659: 
                   5660:     REINSTALL
                   5661: 
                   5662:         Deinstall each package before installing (making DEPENDS_TARGET). This
                   5663:         may be necessary if the "clean-update" target (see below) was called
                   5664:         after interrupting a running make update.
                   5665: 
                   5666:     DEPENDS_TARGET
                   5667: 
                   5668:         Allows you to disable recursion and hardcode the target for packages.
                   5669:         The default is "update" for the update target, facilitating a recursive
                   5670:         update of prerequisite packages. Only set DEPENDS_TARGET if you want to
                   5671:         disable recursive updates. Use UPDATE_TARGET instead to just set a
                   5672:         specific target for each package to be installed during make update
                   5673:         (see above).
                   5674: 
                   5675: clean-update
                   5676: 
                   5677:     Clean the source tree for all packages that would get updated if make
                   5678:     update was called from the current directory. This target should not be
                   5679:     used if the current package (or any of its depending packages) have already
                   5680:     been de-installed (e.g., after calling make update) or you may lose some
1.25      wiz      5681:     packages you intended to update. As a rule of thumb: only use this target 
1.1       dsieger  5682:     before the first time you run make update and only if you have a dirty
                   5683:     package tree (e.g., if you used NOCLEAN).
                   5684: 
                   5685:     If you are unsure about whether your tree is clean, you can either perform
                   5686:     a make clean at the top of the tree, or use the following sequence of
                   5687:     commands from the directory of the package you want to update (before
                   5688:     running make update for the first time, otherwise you lose all the packages
                   5689:     you wanted to update!):
                   5690: 
                   5691:     # make clean-update
                   5692:     # make clean CLEANDEPENDS=YES
                   5693:     # make update
                   5694: 
                   5695: 
1.4       rillig   5696:     The following variables can be used either on the command line or in
1.1       dsieger  5697:     mk.conf to alter the behaviour of make clean-update:
                   5698: 
                   5699:     CLEAR_DIRLIST
                   5700: 
                   5701:         After make clean, do not reconstruct the list of directories to update
                   5702:         for this package. Only use this if make update successfully installed
                   5703:         all packages you wanted to update. Normally, this is done automatically
                   5704:         on make update, but may have been suppressed by the NOCLEAN variable
                   5705:         (see above).
                   5706: 
                   5707: replace
                   5708: 
                   5709:     Update the installation of the current package. This differs from update in
                   5710:     that it does not replace dependent packages. You will need to install
                   5711:     pkgtools/pkg_tarup for this target to work.
                   5712: 
                   5713:     Be careful when using this target! There are no guarantees that dependent
                   5714:     packages will still work, in particular they will most certainly break if
                   5715:     you make replace a library package whose shared library major version
                   5716:     changed between your installed version and the new one. For this reason,
                   5717:     this target is not officially supported and only recommended for advanced
                   5718:     users.
                   5719: 
                   5720: info
                   5721: 
                   5722:     This target invokes pkg_info(1) for the current package. You can use this
                   5723:     to check which version of a package is installed.
                   5724: 
                   5725: index
                   5726: 
                   5727:     This is a top-level command, i.e. it should be used in the pkgsrc
                   5728:     directory. It creates a database of all packages in the local pkgsrc tree,
                   5729:     including dependencies, comment, maintainer, and some other useful
                   5730:     information. Individual entries are created by running make describe in the
                   5731:     packages' directories. This index file is saved as pkgsrc/INDEX. It can be
                   5732:     displayed in verbose format by running make print-index. You can search in
                   5733:     it with make search key=something. You can extract a list of all packages
                   5734:     that depend on a particular one by running make show-deps PKG=somepackage.
                   5735: 
                   5736:     Running this command takes a very long time, some hours even on fast
                   5737:     machines!
                   5738: 
                   5739: readme
                   5740: 
                   5741:     This target generates a README.html file, which can be viewed using a
                   5742:     browser such as www/firefox or www/links. The generated files contain
                   5743:     references to any packages which are in the PACKAGES directory on the local
                   5744:     host. The generated files can be made to refer to URLs based on
                   5745:     FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
                   5746:     README.html files which pointed to binary packages on the local machine, in
                   5747:     the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
                   5748:     FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
                   5749:     subdirectories will be searched for all the binary packages.
                   5750: 
                   5751:     The target can be run at the toplevel or in category directories, in which
                   5752:     case it descends recursively.
                   5753: 
                   5754: readme-all
                   5755: 
                   5756:     This is a top-level command, run it in pkgsrc. Use this target to create a
                   5757:     file README-all.html which contains a list of all packages currently
                   5758:     available in the NetBSD Packages Collection, together with the category
                   5759:     they belong to and a short description. This file is compiled from the
                   5760:     pkgsrc/*/README.html files, so be sure to run this after a make readme.
                   5761: 
                   5762: cdrom-readme
                   5763: 
                   5764:     This is very much the same as the "readme" target (see above), but is to be
                   5765:     used when generating a pkgsrc tree to be written to a CD-ROM. This target
                   5766:     also produces README.html files, and can be made to refer to URLs based on
                   5767:     CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
                   5768: 
                   5769: show-distfiles
                   5770: 
                   5771:     This target shows which distfiles and patchfiles are needed to build the
                   5772:     package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
                   5773:     patches/*).
                   5774: 
                   5775: show-downlevel
                   5776: 
                   5777:     This target shows nothing if the package is not installed. If a version of
                   5778:     this package is installed, but is not the version provided in this version
                   5779:     of pkgsrc, then a warning message is displayed. This target can be used to
                   5780:     show which of your installed packages are downlevel, and so the old
                   5781:     versions can be deleted, and the current ones added.
                   5782: 
                   5783: show-pkgsrc-dir
                   5784: 
                   5785:     This target shows the directory in the pkgsrc hierarchy from which the
                   5786:     package can be built and installed. This may not be the same directory as
                   5787:     the one from which the package was installed. This target is intended to be
                   5788:     used by people who may wish to upgrade many packages on a single host, and
1.25      wiz      5789:     can be invoked from the top-level pkgsrc Makefile by using the "
                   5790:     show-host-specific-pkgs" target.
1.1       dsieger  5791: 
                   5792: show-installed-depends
                   5793: 
                   5794:     This target shows which installed packages match the current package's
                   5795:     DEPENDS. Useful if out of date dependencies are causing build problems.
                   5796: 
1.95      wiz      5797: print-build-depends-list
                   5798: 
                   5799:     This target shows the list of packages that the current package depends on
                   5800:     for building.
                   5801: 
                   5802: print-run-depends-list
                   5803: 
                   5804:     This target shows the list of packages that the current package depends on
                   5805:     for running.
                   5806: 
1.1       dsieger  5807: check-shlibs
                   5808: 
                   5809:     After a package is installed, check all its binaries and (on ELF platforms)
                   5810:     shared libraries to see if they find the shared libs they need. Run by
1.4       rillig   5811:     default if PKG_DEVELOPER is set in mk.conf.
1.1       dsieger  5812: 
                   5813: print-PLIST
                   5814: 
                   5815:     After a "make install" from a new or upgraded pkg, this prints out an
                   5816:     attempt to generate a new PLIST from a find -newer work/.extract_done. An
                   5817:     attempt is made to care for shared libs etc., but it is strongly
                   5818:     recommended to review the result before putting it into PLIST. On upgrades,
                   5819:     it's useful to diff the output of this command against an already existing
                   5820:     PLIST file.
                   5821: 
                   5822:     If the package installs files via tar(1) or other methods that don't update
                   5823:     file access times, be sure to add these files manually to your PLIST, as
                   5824:     the "find -newer" command used by this target won't catch them!
                   5825: 
1.154     rillig   5826:     See Section 15.3, "Tweaking output of make print-PLIST" for more
1.1       dsieger  5827:     information on this target.
                   5828: 
                   5829: bulk-package
                   5830: 
                   5831:     Used to do bulk builds. If an appropriate binary package already exists, no
                   5832:     action is taken. If not, this target will compile, install and package it
1.154     rillig   5833:     (and its depends, if PKG_DEPENDS is set properly. See Chapter 8, Creating
1.66      asau     5834:     binary packages for everything in pkgsrc (bulk builds)). After creating the
                   5835:     binary package, the sources, the just-installed package and its required
                   5836:     packages are removed, preserving free disk space.
1.1       dsieger  5837: 
                   5838:     Beware that this target may deinstall all packages installed on a system!
                   5839: 
                   5840: bulk-install
                   5841: 
                   5842:     Used during bulk-installs to install required packages. If an up-to-date
1.25      wiz      5843:     binary package is available, it will be installed via pkg_add(1). If not, 
1.1       dsieger  5844:     make bulk-package will be executed, but the installed binary won't be
                   5845:     removed.
                   5846: 
                   5847:     A binary package is considered "up-to-date" to be installed via pkg_add(1)
                   5848:     if:
                   5849: 
1.42      asau     5850:       + None of the package's files (Makefile, ...) were modified since it was
1.1       dsieger  5851:         built.
                   5852: 
1.42      asau     5853:       + None of the package's required (binary) packages were modified since it
1.1       dsieger  5854:         was built.
                   5855: 
                   5856:     Beware that this target may deinstall all packages installed on a system!
                   5857: 
1.154     rillig   5858: Chapter 20. Tools needed for building or running
1.1       dsieger  5859: 
                   5860: Table of Contents
                   5861: 
1.154     rillig   5862: 20.1. Tools for pkgsrc builds
                   5863: 20.2. Tools needed by packages
                   5864: 20.3. Tools provided by platforms
1.1       dsieger  5865: 
                   5866: The USE_TOOLS definition is used both internally by pkgsrc and also for
                   5867: individual packages to define what commands are needed for building a package
1.156     leot     5868: (like TOOL_DEPENDS) or for later run-time of an installed packaged (such as
1.1       dsieger  5869: DEPENDS). If the native system provides an adequate tool, then in many cases, a
                   5870: pkgsrc package will not be used.
                   5871: 
                   5872: When building a package, the replacement tools are made available in a
                   5873: directory (as symlinks or wrapper scripts) that is early in the executable
                   5874: search path. Just like the buildlink system, this helps with consistent builds.
                   5875: 
                   5876: A tool may be needed to help build a specific package. For example, perl, GNU
                   5877: make (gmake) or yacc may be needed.
                   5878: 
                   5879: Also a tool may be needed, for example, because the native system's supplied
                   5880: tool may be inefficient for building a package with pkgsrc. For example, a
                   5881: package may need GNU awk, bison (instead of yacc) or a better sed.
                   5882: 
                   5883: The tools used by a package can be listed by running make show-tools.
                   5884: 
1.154     rillig   5885: 20.1. Tools for pkgsrc builds
1.1       dsieger  5886: 
                   5887: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
                   5888: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
                   5889: seen by running: make show-var VARNAME=USE_TOOLS.
                   5890: 
                   5891: If a package needs a specific program to build then the USE_TOOLS variable can
                   5892: be used to define the tools needed.
                   5893: 
1.154     rillig   5894: 20.2. Tools needed by packages
1.1       dsieger  5895: 
1.29      wiz      5896: In the following examples, the :run means that it is needed at run-time (and
                   5897: becomes a DEPENDS). The default is a build dependency which can be set with
                   5898: :build. (So in this example, it is the same as gmake:build and
                   5899: pkg-config:build.)
1.1       dsieger  5900: 
                   5901: USE_TOOLS+=     gmake perl:run pkg-config
                   5902: 
                   5903: When using the tools framework, a TOOLS_PATH.foo variable is defined which
                   5904: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
                   5905: could be "/bin/bash" on Linux systems.
                   5906: 
                   5907: If you always need a pkgsrc version of the tool at run-time, then just use
                   5908: DEPENDS instead.
                   5909: 
1.154     rillig   5910: 20.3. Tools provided by platforms
1.1       dsieger  5911: 
                   5912: When improving or porting pkgsrc to a new platform, have a look at (or create)
                   5913: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
                   5914: tools.${OPSYS}.mk which defines the name of the common tools. For example:
                   5915: 
                   5916: .if exists(/usr/bin/bzcat)
                   5917: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
                   5918: .elif exists(/usr/bin/bzip2)
                   5919: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
                   5920: .endif
                   5921: 
                   5922: TOOLS_PLATFORM.true?=           true                    # shell builtin
                   5923: 
1.154     rillig   5924: Chapter 21. Making your package work
1.1       dsieger  5925: 
                   5926: Table of Contents
                   5927: 
1.154     rillig   5928: 21.1. General operation
1.1       dsieger  5929: 
1.154     rillig   5930:     21.1.1. How to pull in user-settable variables from mk.conf
                   5931:     21.1.2. User interaction
                   5932:     21.1.3. Handling licenses
                   5933:     21.1.4. Restricted packages
                   5934:     21.1.5. Handling dependencies
                   5935:     21.1.6. Handling conflicts with other packages
                   5936:     21.1.7. Packages that cannot or should not be built
                   5937:     21.1.8. Packages which should not be deleted, once installed
                   5938:     21.1.9. Handling packages with security problems
                   5939:     21.1.10. How to handle incrementing versions when fixing an existing
1.1       dsieger  5940:         package
1.154     rillig   5941:     21.1.11. Substituting variable text in the package files (the SUBST
1.1       dsieger  5942:         framework)
                   5943: 
1.154     rillig   5944: 21.2. The fetch phase
1.1       dsieger  5945: 
1.154     rillig   5946:     21.2.1. Packages whose distfiles aren't available for plain downloading
                   5947:     21.2.2. How to handle modified distfiles with the 'old' name
                   5948:     21.2.3. Packages hosted on github.com
                   5949: 
                   5950: 21.3. The configure phase
                   5951: 
                   5952:     21.3.1. Shared libraries - libtool
                   5953:     21.3.2. Using libtool on GNU packages that already support libtool
                   5954:     21.3.3. GNU Autoconf/Automake
                   5955: 
                   5956: 21.4. Programming languages
                   5957: 
                   5958:     21.4.1. C, C++, and Fortran
                   5959:     21.4.2. Java
                   5960:     21.4.3. Packages containing perl scripts
                   5961:     21.4.4. Packages containing shell scripts
                   5962:     21.4.5. Other programming languages
                   5963: 
                   5964: 21.5. The build phase
                   5965: 
                   5966:     21.5.1. Compiling C and C++ code conditionally
                   5967:     21.5.2. How to handle compiler bugs
1.172     rillig   5968:     21.5.3. No such file or directory
                   5969:     21.5.4. Undefined reference to "..."
                   5970:     21.5.5. Running out of memory
1.154     rillig   5971: 
                   5972: 21.6. The install phase
                   5973: 
                   5974:     21.6.1. Creating needed directories
                   5975:     21.6.2. Where to install documentation
                   5976:     21.6.3. Installing highscore files
                   5977:     21.6.4. Adding DESTDIR support to packages
                   5978:     21.6.5. Packages with hardcoded paths to other interpreters
                   5979:     21.6.6. Packages installing perl modules
                   5980:     21.6.7. Packages installing info files
                   5981:     21.6.8. Packages installing man pages
                   5982:     21.6.9. Packages installing GConf data files
                   5983:     21.6.10. Packages installing scrollkeeper/rarian data files
                   5984:     21.6.11. Packages installing X11 fonts
                   5985:     21.6.12. Packages installing GTK2 modules
                   5986:     21.6.13. Packages installing SGML or XML data
                   5987:     21.6.14. Packages installing extensions to the MIME database
                   5988:     21.6.15. Packages using intltool
                   5989:     21.6.16. Packages installing startup scripts
                   5990:     21.6.17. Packages installing TeX modules
                   5991:     21.6.18. Packages supporting running binaries in emulation
                   5992:     21.6.19. Packages installing hicolor theme icons
                   5993:     21.6.20. Packages installing desktop files
1.1       dsieger  5994: 
1.154     rillig   5995: 21.7. Marking packages as having problems
1.1       dsieger  5996: 
1.154     rillig   5997: 21.1. General operation
1.1       dsieger  5998: 
                   5999: One appealing feature of pkgsrc is that it runs on many different platforms. As
                   6000: a result, it is important to ensure, where possible, that packages in pkgsrc
                   6001: are portable. This chapter mentions some particular details you should pay
                   6002: attention to while working on pkgsrc.
                   6003: 
1.154     rillig   6004: 21.1.1. How to pull in user-settable variables from mk.conf
1.1       dsieger  6005: 
                   6006: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4       rillig   6007: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
                   6008: those variables in the preprocessor directives of make(1) (for example .if or
                   6009: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
                   6010: loads the user preferences.
1.1       dsieger  6011: 
                   6012: But note that some variables may not be completely defined after ../../mk/
                   6013: bsd.prefs.mk has been included, as they may contain references to variables
1.108     rillig   6014: that are not yet defined. In shell commands (the lines in Makefile that are
                   6015: indented with a tab) this is no problem, since variables are only expanded when
                   6016: they are used. But in the preprocessor directives mentioned above and in
                   6017: dependency lines (of the form target: dependencies) the variables are expanded
                   6018: at load time.
1.1       dsieger  6019: 
                   6020: Note
                   6021: 
1.108     rillig   6022: To check whether a variable can be used at load time, run pkglint -Wall on your
                   6023: package.
1.1       dsieger  6024: 
1.154     rillig   6025: 21.1.2. User interaction
1.1       dsieger  6026: 
                   6027: Occasionally, packages require interaction from the user, and this can be in a
                   6028: number of ways:
                   6029: 
                   6030:   * When fetching the distfiles, some packages require user interaction such as
                   6031:     entering username/password or accepting a license on a web page.
                   6032: 
                   6033:   * When extracting the distfiles, some packages may ask for passwords.
                   6034: 
                   6035:   * help to configure the package before it is built
                   6036: 
                   6037:   * help during the build process
                   6038: 
                   6039:   * help during the installation of a package
                   6040: 
1.108     rillig   6041: A package can set the INTERACTIVE_STAGE variable to define which stages need
                   6042: interaction. This should be done in the package's Makefile, e.g.:
1.1       dsieger  6043: 
                   6044: INTERACTIVE_STAGE=      configure install
                   6045: 
                   6046: The user can then decide to skip this package by setting the BATCH variable.
1.108     rillig   6047: Packages that require interaction are also excluded from bulk builds.
1.1       dsieger  6048: 
1.154     rillig   6049: 21.1.3. Handling licenses
1.1       dsieger  6050: 
                   6051: Authors of software can choose the licence under which software can be copied.
1.111     sevan    6052: The Free Software Foundation has declared some licenses "Free", and the Open
                   6053: Source Initiative has a definition of "Open Source".
                   6054: 
                   6055: By default, pkgsrc allows packages with Free or Open Source licenses to be
                   6056: built. To allow packages with other licenses to be built as well, the pkgsrc
                   6057: user needs to add these licenses to the ACCEPTABLE_LICENSES variable in mk.conf
                   6058: . Note that this variable only affects which packages may be built, while the
                   6059: license terms often also restrict the actual use of the package and its
                   6060: redistribution.
1.1       dsieger  6061: 
                   6062: One might want to only install packages with a BSD license, or the GPL, and not
1.20      jnemeth  6063: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
1.111     sevan    6064: variable. The pkgsrc user can override the default by setting the
                   6065: ACCEPTABLE_LICENSES variable with "=" instead of "+=". The licenses accepted by
                   6066: default are defined in the DEFAULT_ACCEPTABLE_LICENSES variable in the file
                   6067: pkgsrc/mk/license.mk.
1.1       dsieger  6068: 
                   6069: The license tag mechanism is intended to address copyright-related issues
                   6070: surrounding building, installing and using a package, and not to address
1.20      jnemeth  6071: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
                   6072: redistribution restrictions should set these tags.
1.1       dsieger  6073: 
                   6074: Denoting that a package may be copied according to a particular license is done
                   6075: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
                   6076: string identifying the license, e.g. in graphics/xv:
                   6077: 
                   6078: LICENSE=        xv-license
                   6079: 
                   6080: When trying to build, the user will get a notice that the package is covered by
                   6081: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
                   6082: 
                   6083: % make
                   6084: ===> xv-3.10anb9 has an unacceptable license: xv-license.
                   6085: ===>     To view the license, enter "/usr/bin/make show-license".
                   6086: ===>     To indicate acceptance, add this line to your /etc/mk.conf:
                   6087: ===>     ACCEPTABLE_LICENSES+=xv-license
                   6088: *** Error code 1
                   6089: 
                   6090: The license can be viewed with make show-license, and if the user so chooses,
1.4       rillig   6091: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1       dsieger  6092: should not in the future fail because of that license:
                   6093: 
                   6094: ACCEPTABLE_LICENSES+=xv-license
                   6095: 
1.111     sevan    6096: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
                   6097: is deprecated because it does not crisply refer to a particular license text.
                   6098: Another problem with such usage is that it does not enable a user to tell
                   6099: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
                   6100: for all packages with that tag.
                   6101: 
1.154     rillig   6102: 21.1.3.1. Adding a package with a new license
1.1       dsieger  6103: 
1.49      rodent   6104: When adding a package with a new license, the following steps are required:
                   6105: 
1.111     sevan    6106:  1. Check whether the license qualifies as Free or Open Source by referencing
                   6107:     Various Licenses and Comments about Them and Licenses by Name | Open Source
                   6108:     Initiative. If this is the case, the filename in pkgsrc/licenses/ does not
                   6109:     need the -license suffix, and the license name should be added to:
1.49      rodent   6110: 
                   6111:       + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
                   6112: 
                   6113:       + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
                   6114:         license.c
                   6115: 
                   6116:  2. The license text should be added to pkgsrc/licenses for displaying. A list
                   6117:     of known licenses can be seen in this directory.
1.1       dsieger  6118: 
1.154     rillig   6119: 21.1.3.2. Change to the license
1.1       dsieger  6120: 
1.111     sevan    6121: When the license changes (in a way other than formatting), make sure that the
                   6122: new license has a different name (e.g., append the version number if it exists,
                   6123: or the date). Just because a user told pkgsrc to build programs under a
                   6124: previous version of a license does not mean that pkgsrc should build programs
                   6125: under the new licenses. The higher-level point is that pkgsrc does not evaluate
                   6126: licenses for reasonableness; the only test is a mechanistic test of whether a
                   6127: particular text has been approved by either of two bodies (FSF or OSI).
1.1       dsieger  6128: 
1.154     rillig   6129: 21.1.4. Restricted packages
1.1       dsieger  6130: 
1.111     sevan    6131: Some licenses restrict how software may be re-distributed. By declaring the
                   6132: restrictions, package tools can automatically refrain from e.g. placing binary
                   6133: packages on FTP sites.
                   6134: 
                   6135: There are four possible restrictions, which are the cross product of sources
                   6136: (distfiles) and binaries not being placed on FTP sites and CD-ROMs. Because
                   6137: this is rarely the exact language in any license, and because non-Free licenses
                   6138: tend to be different from each other, pkgsrc adopts a definition of FTP and
                   6139: CD-ROM. "FTP" means making the source or binary file available over the
                   6140: Internet at no charge. "CD-ROM" means making the source or binary available on
                   6141: some kind of media, together with other source and binary packages, which is
                   6142: sold for a distribution charge.
1.1       dsieger  6143: 
                   6144: In order to encode these restrictions, the package system defines five make
                   6145: variables that can be set to note these restrictions:
                   6146: 
                   6147:   * RESTRICTED
                   6148: 
                   6149:     This variable should be set whenever a restriction exists (regardless of
                   6150:     its kind). Set this variable to a string containing the reason for the
                   6151:     restriction. It should be understood that those wanting to understand the
                   6152:     restriction will have to read the license, and perhaps seek advice of
                   6153:     counsel.
                   6154: 
                   6155:   * NO_BIN_ON_CDROM
                   6156: 
                   6157:     Binaries may not be placed on CD-ROM containing other binary packages, for
                   6158:     which a distribution charge may be made. In this case, set this variable to
                   6159:     ${RESTRICTED}.
                   6160: 
                   6161:   * NO_BIN_ON_FTP
                   6162: 
                   6163:     Binaries may not made available on the Internet without charge. In this
                   6164:     case, set this variable to ${RESTRICTED}. If this variable is set, binary
                   6165:     packages will not be included on ftp.NetBSD.org.
                   6166: 
                   6167:   * NO_SRC_ON_CDROM
                   6168: 
                   6169:     Distfiles may not be placed on CD-ROM, together with other distfiles, for
                   6170:     which a fee may be charged. In this case, set this variable to $
                   6171:     {RESTRICTED}.
                   6172: 
                   6173:   * NO_SRC_ON_FTP
                   6174: 
                   6175:     Distfiles may not made available via FTP at no charge. In this case, set
                   6176:     this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
                   6177:     will not be mirrored on ftp.NetBSD.org.
                   6178: 
1.111     sevan    6179: Please note that packages will be removed from pkgsrc when the distfiles are
1.33      wiz      6180: not distributable and cannot be obtained for a period of one full quarter
1.111     sevan    6181: branch. Packages with manual/interactive fetch must have a maintainer and it is
                   6182: his/her responsibility to ensure this.
1.33      wiz      6183: 
1.154     rillig   6184: 21.1.5. Handling dependencies
1.1       dsieger  6185: 
1.175     gutterid 6186: Your package may depend on some other package being present, and there are
                   6187: various ways of expressing this dependency. pkgsrc supports the DEPENDS,
                   6188: BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS definitions, the USE_TOOLS
                   6189: definition, as well as dependencies via buildlink3.mk, which is the preferred
                   6190: way to handle dependencies, and which uses the variables named above. See
                   6191: Chapter 16, Buildlink methodology for more information.
                   6192: 
                   6193: The basic difference is that the DEPENDS definition registers that
                   6194: pre-requisite in the binary package so it will be pulled in when the binary
                   6195: package is later installed, whilst the BUILD_DEPENDS, TOOL_DEPENDS, and
                   6196: TEST_DEPENDS definitions do not, marking a dependency that is only needed for
                   6197: building or testing the resulting package. See also Chapter 12, Creating a new
                   6198: pkgsrc package from scratch for more information.
                   6199: 
                   6200: This means that if you only need a package present whilst you are building or
                   6201: testing, it should be noted as a TOOL_DEPENDS, BUILD_DEPENDS, or TEST_DEPENDS.
                   6202: When cross-compiling, TOOL_DEPENDS are native packages, i.e. packages for the
                   6203: architecture where the package is built; BUILD_DEPENDS are target packages,
                   6204: i.e., packages for the architecture for which the package is built.
1.1       dsieger  6205: 
1.175     gutterid 6206: The format for a DEPENDS, BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS
                   6207: definition is:
1.1       dsieger  6208: 
                   6209: <pre-req-package-name>:../../<category>/<pre-req-package>
                   6210: 
                   6211: Please note that the "pre-req-package-name" may include any of the wildcard
                   6212: version numbers recognized by pkg_info(1).
                   6213: 
1.55      wiz      6214:  1. If your package needs another package's binaries or libraries to build and
1.1       dsieger  6215:     run, and if that package has a buildlink3.mk file available, use it:
                   6216: 
                   6217:     .include "../../graphics/jpeg/buildlink3.mk"
                   6218: 
1.55      wiz      6219:  2. If your package needs another package's binaries or libraries only for
                   6220:     building, and if that package has a buildlink3.mk file available, use it:
                   6221: 
                   6222:     .include "../../graphics/jpeg/buildlink3.mk"
                   6223: 
                   6224:     but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
                   6225:     This case is rather rare.
                   6226: 
                   6227:  3. If your package needs binaries from another package to build, use the
1.156     leot     6228:     TOOL_DEPENDS definition:
                   6229: 
                   6230:     TOOL_DEPENDS+= itstool-[0-9]*:../../textproc/itstool
1.1       dsieger  6231: 
1.156     leot     6232:  4. If your package needs static libraries to link against, header files to
                   6233:     include, etc. from another package to build, use the BUILD_DEPENDS
                   6234:     definition.
1.1       dsieger  6235: 
1.156     leot     6236:  5. If your package needs a library with which to link and there is no
1.26      spz      6237:     buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
                   6238:     because the include files and libraries will be hidden from the compiler.
1.1       dsieger  6239: 
1.156     leot     6240:  6. If your package needs some executable to be able to run correctly and if
1.26      spz      6241:     there's no buildlink3.mk file, this is specified using the DEPENDS
                   6242:     variable. The print/lyx package needs to be able to execute the latex
1.129     wiz      6243:     binary from the tex-latex-bin package when it runs, and that is specified:
1.1       dsieger  6244: 
1.129     wiz      6245:     DEPENDS+=        tex-latex-bin-[0-9]*:../../print/tex-latex-bin
1.1       dsieger  6246: 
1.175     gutterid 6247:  7. If your package includes a test suite that has extra dependencies only
                   6248:     required for this purpose (frequently this can be run as a "make test"
                   6249:     target), use the TEST_DEPENDS variable.
                   6250: 
                   6251:  8. You can use wildcards in package dependencies. Note that such wildcard
1.26      spz      6252:     dependencies are retained when creating binary packages. The dependency is
                   6253:     checked when installing the binary package and any package which matches
                   6254:     the pattern will be used. Wildcard dependencies should be used with care.
1.1       dsieger  6255: 
                   6256:     The "-[0-9]*" should be used instead of "-*" to avoid potentially ambiguous
                   6257:     matches such as "tk-postgresql" matching a "tk-*" DEPENDS.
                   6258: 
                   6259:     Wildcards can also be used to specify that a package will only build
                   6260:     against a certain minimum version of a pre-requisite:
                   6261: 
1.26      spz      6262:     DEPENDS+=       ImageMagick>=6.0:../../graphics/ImageMagick
1.1       dsieger  6263: 
1.26      spz      6264:     This means that the package will build using version 6.0 of ImageMagick or
                   6265:     newer. Such a dependency may be warranted if, for example, the command line
                   6266:     options of an executable have changed.
                   6267: 
                   6268:     If you need to depend on minimum versions of libraries, see the buildlink
                   6269:     section of the pkgsrc guide.
1.1       dsieger  6270: 
                   6271:     For security fixes, please update the package vulnerabilities file. See
1.154     rillig   6272:     Section 21.1.9, "Handling packages with security problems" for more
1.1       dsieger  6273:     information.
                   6274: 
                   6275: If your package needs files from another package to build, add the relevant
                   6276: distribution files to DISTFILES, so they will be extracted automatically. See
                   6277: the print/ghostscript package for an example. (It relies on the jpeg sources
                   6278: being present in source form during the build.)
                   6279: 
1.154     rillig   6280: 21.1.6. Handling conflicts with other packages
1.1       dsieger  6281: 
                   6282: Your package may conflict with other packages a user might already have
                   6283: installed on his system, e.g. if your package installs the same set of files as
1.80      wiz      6284: another package in the pkgsrc tree or has the same PKGNAME.
1.1       dsieger  6285: 
1.142     leot     6286: For example, x11/libXaw3d and x11/Xaw-Xpm install the same shared library, thus
                   6287: you set in pkgsrc/x11/libXaw3d/Makefile:
1.1       dsieger  6288: 
1.142     leot     6289: CONFLICTS=      Xaw-Xpm-[0-9]*
1.1       dsieger  6290: 
                   6291: 
1.142     leot     6292: and in pkgsrc/x11/Xaw-Xpm/Makefile:
1.1       dsieger  6293: 
1.142     leot     6294: CONFLICTS=      libXaw3d-[0-9]*
1.1       dsieger  6295: 
1.142     leot     6296: 
                   6297: pkg_add(1) is able to detect attempts to install packages that conflict with
                   6298: existing packages and abort. However, in many situations this is too late in
                   6299: the process. Binary package managers will not know about the conflict until
                   6300: they attempt to install the package after already downloading it and all its
                   6301: dependencies. Users may also waste time building a package and its dependencies
                   6302: only to find out at the end that it conflicts with another package they have
                   6303: installed.
                   6304: 
                   6305: To avoid these issues CONFLICTS entries should be added in all cases where it
                   6306: is known that packages conflict with each other. These CONFLICTS entries are
                   6307: exported in pkg_summary(5) files and consumed by binary package managers to
                   6308: inform users that packages cannot be installed onto the target system.
1.1       dsieger  6309: 
1.154     rillig   6310: 21.1.7. Packages that cannot or should not be built
1.1       dsieger  6311: 
                   6312: There are several reasons why a package might be instructed to not build under
                   6313: certain circumstances. If the package builds and runs on most platforms, the
1.83      dholland 6314: exceptions should be noted with BROKEN_ON_PLATFORM. If the package builds and
                   6315: runs on a small handful of platforms, set BROKEN_EXCEPT_ON_PLATFORM instead.
                   6316: Both BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM are OS triples
                   6317: (OS-version-platform) that can use glob-style wildcards.
                   6318: 
1.114     maya     6319: If a package is not appropriate for some platforms (as opposed to merely
1.83      dholland 6320: broken), a different set of variables should be used as this affects failure
                   6321: reporting and statistics. If the package is appropriate for most platforms, the
                   6322: exceptions should be noted with NOT_FOR_PLATFORM. If the package is appropriate
                   6323: for only a small handful of platforms (often exactly one), set
                   6324: ONLY_FOR_PLATFORM instead. Both ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS
                   6325: triples (OS-version-platform) that can use glob-style wildcards.
1.1       dsieger  6326: 
                   6327: Some packages are tightly bound to a specific version of an operating system,
                   6328: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
                   6329: with other versions of the OS, and should be uploaded to a version specific
                   6330: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
                   6331: to "yes". This variable is not currently used by any of the package system
                   6332: internals, but may be used in the future.
                   6333: 
                   6334: If the package should be skipped (for example, because it provides
                   6335: functionality already provided by the system), set PKG_SKIP_REASON to a
                   6336: descriptive message. If the package should fail because some preconditions are
                   6337: not met, set PKG_FAIL_REASON to a descriptive message.
                   6338: 
1.154     rillig   6339: 21.1.8. Packages which should not be deleted, once installed
1.1       dsieger  6340: 
                   6341: To ensure that a package may not be deleted, once it has been installed, the
                   6342: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.25      wiz      6343: carried into any binary package that is made from this pkgsrc entry. A "
                   6344: preserved" package will not be deleted using pkg_delete(1) unless the "-f"
1.1       dsieger  6345: option is used.
                   6346: 
1.154     rillig   6347: 21.1.9. Handling packages with security problems
1.1       dsieger  6348: 
                   6349: When a vulnerability is found, this should be noted in localsrc/security/
1.32      wiz      6350: advisories/pkg-vulnerabilities, and after committing that file, ask
                   6351: pkgsrc-security@NetBSD.org to update the file on ftp.NetBSD.org.
1.1       dsieger  6352: 
                   6353: After fixing the vulnerability by a patch, its PKGREVISION should be increased
                   6354: (this is of course not necessary if the problem is fixed by using a newer
1.32      wiz      6355: release of the software), and the pattern in the pkg-vulnerabilities file must
                   6356: be updated.
1.1       dsieger  6357: 
                   6358: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
                   6359: submit a pullup request!
                   6360: 
                   6361: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
                   6362: a weekly cron job.
                   6363: 
1.154     rillig   6364: 21.1.10. How to handle incrementing versions when fixing an existing package
1.1       dsieger  6365: 
                   6366: When making fixes to an existing package it can be useful to change the version
                   6367: number in PKGNAME. To avoid conflicting with future versions by the original
                   6368: author, a "nb1", "nb2", ... suffix can be used on package versions by setting
                   6369: PKGREVISION=1 (2, ...). The "nb" is treated like a "." by the package tools.
                   6370: e.g.
                   6371: 
                   6372: DISTNAME=       foo-17.42
                   6373: PKGREVISION=    9
                   6374: 
                   6375: will result in a PKGNAME of "foo-17.42nb9". If you want to use the original
                   6376: value of PKGNAME without the "nbX" suffix, e.g. for setting DIST_SUBDIR, use
                   6377: PKGNAME_NOREV.
                   6378: 
                   6379: When a new release of the package is released, the PKGREVISION should be
                   6380: removed, e.g. on a new minor release of the above package, things should be
                   6381: like:
                   6382: 
                   6383: DISTNAME=       foo-17.43
                   6384: 
                   6385: PKGREVISION should be incremented for any non-trivial change in the resulting
                   6386: binary package. Without a PKGREVISION bump, someone with the previous version
                   6387: installed has no way of knowing that their package is out of date. Thus,
                   6388: changes without increasing PKGREVISION are essentially labeled "this is so
                   6389: trivial that no reasonable person would want to upgrade", and this is the rough
                   6390: test for when increasing PKGREVISION is appropriate. Examples of changes that
                   6391: do not merit increasing PKGREVISION are:
                   6392: 
1.14      jmcneill 6393:   * Changing HOMEPAGE, MAINTAINER, OWNER, or comments in Makefile.
1.1       dsieger  6394: 
                   6395:   * Changing build variables if the resulting binary package is the same.
                   6396: 
                   6397:   * Changing DESCR.
                   6398: 
                   6399:   * Adding PKG_OPTIONS if the default options don't change.
                   6400: 
                   6401: Examples of changes that do merit an increase to PKGREVISION include:
                   6402: 
                   6403:   * Security fixes
                   6404: 
                   6405:   * Changes or additions to a patch file
                   6406: 
                   6407:   * Changes to the PLIST
                   6408: 
1.12      weinem   6409:   * A dependency is changed or renamed.
                   6410: 
1.1       dsieger  6411: PKGREVISION must also be incremented when dependencies have ABI changes.
                   6412: 
1.154     rillig   6413: 21.1.11. Substituting variable text in the package files (the SUBST framework)
1.1       dsieger  6414: 
                   6415: When you want to replace the same text in multiple files or when the
                   6416: replacement text varies, patches alone cannot help. This is where the SUBST
                   6417: framework comes in. It provides an easy-to-use interface for replacing text in
1.172     rillig   6418: files. It just needs the following information:
                   6419: 
                   6420:   * When should the replacement happen?
                   6421: 
                   6422:   * Where should the replacement happen, i.e. in which files?
                   6423: 
                   6424:   * Which text should be replaced with what?
                   6425: 
                   6426: This information is encoded in a block of SUBST variables, like in this
                   6427: example:
1.1       dsieger  6428: 
                   6429: SUBST_CLASSES+=                 fix-paths
                   6430: SUBST_STAGE.fix-paths=          pre-configure
                   6431: SUBST_MESSAGE.fix-paths=        Fixing absolute paths.
                   6432: SUBST_FILES.fix-paths=          src/*.c
                   6433: SUBST_FILES.fix-paths+=         scripts/*.sh
                   6434: SUBST_SED.fix-paths=            -e 's,"/usr/local,"${PREFIX},g'
                   6435: SUBST_SED.fix-paths+=           -e 's,"/var/log,"${VARBASE}/log,g'
                   6436: 
                   6437: SUBST_CLASSES is a list of identifiers that are used to identify the different
                   6438: SUBST blocks that are defined. The SUBST framework is heavily used by pkgsrc,
                   6439: so it is important to always use the += operator with this variable. Otherwise
                   6440: some substitutions may be skipped.
                   6441: 
                   6442: The remaining variables of each SUBST block are parameterized with the
                   6443: identifier from the first line (fix-paths in this case.) They can be seen as
                   6444: parameters to a function call.
                   6445: 
                   6446: SUBST_STAGE.* specifies the stage at which the replacement will take place. All
                   6447: combinations of pre-, do- and post- together with a phase name are possible,
                   6448: though only few are actually used. Most commonly used are post-patch and
                   6449: pre-configure. Of these two, pre-configure should be preferred because then it
                   6450: is possible to run bmake patch and have the state after applying the patches
                   6451: but before making any other changes. This is especially useful when you are
                   6452: debugging a package in order to create new patches for it. Similarly,
                   6453: post-build is preferred over pre-install, because the install phase should
                   6454: generally be kept as simple as possible. When you use post-build, you have the
                   6455: same files in the working directory that will be installed later, so you can
                   6456: check if the substitution has succeeded.
                   6457: 
                   6458: SUBST_MESSAGE.* is an optional text that is printed just before the
                   6459: substitution is done.
                   6460: 
                   6461: SUBST_FILES.* is the list of shell globbing patterns that specifies the files
                   6462: in which the substitution will take place. The patterns are interpreted
                   6463: relatively to the WRKSRC directory.
                   6464: 
                   6465: SUBST_SED.* is a list of arguments to sed(1) that specify the actual
                   6466: substitution. Every sed command should be prefixed with -e, so that all SUBST
                   6467: blocks look uniform.
                   6468: 
1.172     rillig   6469: SUBST_VARS.* is a list of variable names. For each of these variables, the text
                   6470: @VAR@ is replaced with the value of the variable VAR.
                   6471: 
1.1       dsieger  6472: There are some more variables, but they are so seldomly used that they are only
                   6473: documented in the mk/subst.mk file.
                   6474: 
1.154     rillig   6475: 21.2. The fetch phase
1.1       dsieger  6476: 
1.154     rillig   6477: 21.2.1. Packages whose distfiles aren't available for plain downloading
1.1       dsieger  6478: 
                   6479: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
                   6480: a make fetch will call files/getsite.sh with the name of each file to download
                   6481: as an argument, expecting it to output the URL of the directory from which to
                   6482: download it. graphics/ns-cult3d is an example of this usage.
                   6483: 
                   6484: If the download can't be automated, because the user must submit personal
                   6485: information to apply for a password, or must pay for the source, or whatever,
                   6486: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
                   6487: before aborting the build. Example:
                   6488: 
                   6489: FETCH_MESSAGE=  "Please download the files"
                   6490: FETCH_MESSAGE+= "    "${DISTFILES:Q}
                   6491: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
                   6492: 
1.154     rillig   6493: 21.2.2. How to handle modified distfiles with the 'old' name
1.1       dsieger  6494: 
                   6495: Sometimes authors of a software package make some modifications after the
                   6496: software was released, and they put up a new distfile without changing the
                   6497: package's version number. If a package is already in pkgsrc at that time, the
                   6498: checksum will no longer match. The contents of the new distfile should be
                   6499: compared against the old one before changing anything, to make sure the
                   6500: distfile was really updated on purpose, and that no trojan horse or so crept
                   6501: in. Please mention that the distfiles were compared and what was found in your
1.54      rodent   6502: commit message.
                   6503: 
                   6504: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
1.109     wiz      6505: directory name, usually based on PKGNAME_NOREV (but take care with python or
                   6506: ruby packages, where PKGNAME includes a variable prefix). All DISTFILES and
                   6507: PATCHFILES for this package will be put in that subdirectory of the local
1.154     rillig   6508: distfiles directory. (See Section 21.1.10, "How to handle incrementing versions
1.109     wiz      6509: when fixing an existing package" for more details.) In case this happens more
                   6510: often, PKGNAME can be used (thus including the nbX suffix) or a date stamp can
                   6511: be appended, like ${PKGNAME_NOREV}-YYYYMMDD.
1.54      rodent   6512: 
                   6513: DIST_SUBDIR is also used when a distfile's name does not contain a version and
                   6514: the distfile is apt to change. In cases where the likelihood of this is very
                   6515: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
                   6516: removed unless the distfile name changes, even if a package is being moved or
                   6517: renamed.
                   6518: 
                   6519: Do not forget regenerating the distinfo file after that, since it contains the
                   6520: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
                   6521: installed package is different. Furthermore, a mail to the package's authors
                   6522: seems appropriate telling them that changing distfiles after releases without
                   6523: changing the file names is not good practice.
1.1       dsieger  6524: 
1.154     rillig   6525: 21.2.3. Packages hosted on github.com
1.88      tnn      6526: 
1.90      tnn      6527: Helper methods exist for packages hosted on github.com which will often have
                   6528: distfile names that clash with other packages, for example 1.0.tar.gz. Use one
                   6529: of the three recipes from below:
1.88      tnn      6530: 
1.154     rillig   6531: 21.2.3.1. Fetch based on a tagged release
1.88      tnn      6532: 
1.174     leot     6533: If your distfile URL looks similar to https://github.com/username/
                   6534: exampleproject/archive/v1.0.zip, then you are packaging a tagged release.
1.88      tnn      6535: 
                   6536: DISTNAME=       exampleproject-1.0
1.90      tnn      6537: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6538: #GITHUB_PROJECT=        # can be omitted if same as DISTNAME
                   6539: GITHUB_TAG=     v${PKGVERSION_NOREV}
1.88      tnn      6540: EXTRACT_SUFX=   .zip
                   6541: 
1.154     rillig   6542: 21.2.3.2. Fetch based on a specific commit
1.88      tnn      6543: 
1.174     leot     6544: If your distfile URL looks similar to https://github.com?/example?/example?/
1.169     rillig   6545: archive?/988881adc9fc3655077dc2d4d757d480b5ea0e11.tar.gz, then you are
                   6546: packaging a specific commit not tied to a release.
1.88      tnn      6547: 
                   6548: DISTNAME=       example-1.0
1.107     jnemeth  6549: MASTER_SITES=   ${MASTER_SITE_GITHUB:=example/}
1.90      tnn      6550: #GITHUB_PROJECT=        # can be omitted if same as DISTNAME
                   6551: GITHUB_TAG=     988881adc9fc3655077dc2d4d757d480b5ea0e11
1.88      tnn      6552: 
1.154     rillig   6553: 21.2.3.3. Fetch based on release
1.88      tnn      6554: 
1.174     leot     6555: If your distfile URL looks similar to https://github.com?/username/
1.169     rillig   6556: exampleproject?/releases?/download?/rel-1.6?/offensive-1.6.zip, then you are
                   6557: packaging a release.
1.88      tnn      6558: 
1.90      tnn      6559: DISTNAME=       offensive-1.6
1.88      tnn      6560: PKGNAME=        ${DISTNAME:S/offensive/proper/}
1.90      tnn      6561: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6562: GITHUB_PROJECT= exampleproject
                   6563: GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
                   6564: EXTRACT_SUFX=   .zip
1.88      tnn      6565: 
1.154     rillig   6566: 21.3. The configure phase
1.1       dsieger  6567: 
1.154     rillig   6568: 21.3.1. Shared libraries - libtool
1.1       dsieger  6569: 
                   6570: pkgsrc supports many different machines, with different object formats like
                   6571: a.out and ELF, and varying abilities to do shared library and dynamic loading
                   6572: at all. To accompany this, varying commands and options have to be passed to
                   6573: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
                   6574: especially if you don't have all the machines at your hand to test things. The
                   6575: devel/libtool pkg can help here, as it just "knows" how to build both static
                   6576: and dynamic libraries from a set of source files, thus being
                   6577: platform-independent.
                   6578: 
                   6579: Here's how to use libtool in a package in seven simple steps:
                   6580: 
                   6581:  1. Add USE_LIBTOOL=yes to the package Makefile.
                   6582: 
                   6583:  2. For library objects, use "${LIBTOOL} --mode=compile ${CC}" in place of "$
                   6584:     {CC}". You could even add it to the definition of CC, if only libraries are
                   6585:     being built in a given Makefile. This one command will build both PIC and
                   6586:     non-PIC library objects, so you need not have separate shared and
                   6587:     non-shared library rules.
                   6588: 
                   6589:  3. For the linking of the library, remove any "ar", "ranlib", and "ld
                   6590:     -Bshareable" commands, and instead use:
                   6591: 
                   6592:     ${LIBTOOL} --mode=link \
                   6593:         ${CC} -o ${.TARGET:.a=.la} \
                   6594:             ${OBJS:.o=.lo} \
                   6595:             -rpath ${PREFIX}/lib \
                   6596:             -version-info major:minor
                   6597: 
                   6598:     Note that the library is changed to have a .la extension, and the objects
                   6599:     are changed to have a .lo extension. Change OBJS as necessary. This
                   6600:     automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
                   6601:     necessary) in the build directory. Be sure to include "-version-info",
                   6602:     especially when major and minor are zero, as libtool will otherwise strip
                   6603:     off the shared library version.
                   6604: 
                   6605:     From the libtool manual:
                   6606: 
                   6607:     So, libtool library versions are described by three integers:
                   6608: 
                   6609:     CURRENT
                   6610:     The most recent interface number that this library implements.
                   6611: 
                   6612:     REVISION
                   6613:     The implementation number of the CURRENT interface.
                   6614: 
                   6615:     AGE
                   6616:     The difference between the newest and oldest interfaces that
                   6617:     this library implements.  In other words, the library implements
                   6618:     all the interface numbers in the range from number `CURRENT -
                   6619:     AGE' to `CURRENT'.
                   6620: 
                   6621:     If two libraries have identical CURRENT and AGE numbers, then the
                   6622:     dynamic linker chooses the library with the greater REVISION number.
                   6623: 
                   6624:     The "-release" option will produce different results for a.out and ELF
1.25      wiz      6625:     (excluding symlinks) in only one case. An ELF library of the form "
                   6626:     libfoo-release.so.x.y" will have a symlink of "libfoo.so.x.y" on an a.out
1.1       dsieger  6627:     platform. This is handled automatically.
                   6628: 
                   6629:     The "-rpath argument" is the install directory of the library being built.
                   6630: 
                   6631:     In the PLIST, include only the .la file, the other files will be added
                   6632:     automatically.
                   6633: 
                   6634:  4. When linking shared object (.so) files, i.e. files that are loaded via
                   6635:     dlopen(3), NOT shared libraries, use "-module -avoid-version" to prevent
                   6636:     them getting version tacked on.
                   6637: 
                   6638:     The PLIST file gets the foo.so entry.
                   6639: 
                   6640:  5. When linking programs that depend on these libraries before they are
                   6641:     installed, preface the cc(1) or ld(1) line with "${LIBTOOL} --mode=link",
                   6642:     and it will find the correct libraries (static or shared), but please be
                   6643:     aware that libtool will not allow you to specify a relative path in -L
                   6644:     (such as "-L../somelib"), because it expects you to change that argument to
                   6645:     be the .la file. e.g.
                   6646: 
                   6647:     ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
                   6648: 
                   6649:     should be changed to:
                   6650: 
                   6651:     ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
                   6652: 
                   6653:     and it will do the right thing with the libraries.
                   6654: 
                   6655:  6. When installing libraries, preface the install(1) or cp(1) command with "$
                   6656:     {LIBTOOL} --mode=install", and change the library name to .la. e.g.
                   6657: 
1.23      jakllsch 6658:     ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1       dsieger  6659: 
                   6660:     This will install the static .a, shared library, any needed symlinks, and
                   6661:     run ldconfig(8).
                   6662: 
                   6663:  7. In your PLIST, include only the .la file (this is a change from previous
                   6664:     behaviour).
                   6665: 
1.154     rillig   6666: 21.3.2. Using libtool on GNU packages that already support libtool
1.1       dsieger  6667: 
                   6668: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
                   6669: own libtool in most cases. For older libtool using packages, libtool is made by
                   6670: ltconfig script during the do-configure step; you can check the libtool script
                   6671: location by doing make configure; find work*/ -name libtool.
                   6672: 
                   6673: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
                   6674: override. By default, it is set to "libtool */libtool */*/libtool". If this
                   6675: does not match the location of the package's libtool script(s), set it as
                   6676: appropriate.
                   6677: 
                   6678: If you do not need *.a static libraries built and installed, then use
                   6679: SHLIBTOOL_OVERRIDE instead.
                   6680: 
                   6681: If your package makes use of the platform-independent library for loading
                   6682: dynamic shared objects, that comes with libtool (libltdl), you should include
                   6683: devel/libltdl/buildlink3.mk.
                   6684: 
                   6685: Some packages use libtool incorrectly so that the package may not work or build
                   6686: in some circumstances. Some of the more common errors are:
                   6687: 
                   6688:   * The inclusion of a shared object (-module) as a dependent library in an
                   6689:     executable or library. This in itself isn't a problem if one of two things
                   6690:     has been done:
                   6691: 
                   6692:      1. The shared object is named correctly, i.e. libfoo.la, not foo.la
                   6693: 
                   6694:      2. The -dlopen option is used when linking an executable.
                   6695: 
                   6696:   * The use of libltdl without the correct calls to initialisation routines.
                   6697:     The function lt_dlinit() should be called and the macro
                   6698:     LTDL_SET_PRELOADED_SYMBOLS included in executables.
                   6699: 
1.154     rillig   6700: 21.3.3. GNU Autoconf/Automake
1.1       dsieger  6701: 
                   6702: If a package needs GNU autoconf or automake to be executed to regenerate the
                   6703: configure script and Makefile.in makefile templates, then they should be
                   6704: executed in a pre-configure target.
                   6705: 
                   6706: For packages that need only autoconf:
                   6707: 
                   6708: AUTOCONF_REQD=  2.50            # if default version is not good enough
                   6709: USE_TOOLS+=     autoconf        # use "autoconf213" for autoconf-2.13
                   6710: ...
                   6711: 
                   6712: pre-configure:
                   6713:         cd ${WRKSRC} && autoconf
                   6714: 
                   6715: ...
                   6716: 
                   6717: and for packages that need automake and autoconf:
                   6718: 
                   6719: AUTOMAKE_REQD=  1.7.1           # if default version is not good enough
                   6720: USE_TOOLS+=     automake        # use "automake14" for automake-1.4
                   6721: ...
                   6722: 
                   6723: pre-configure:
                   6724:         set -e; cd ${WRKSRC}; \
                   6725:         aclocal; autoheader; automake -a --foreign -i; autoconf
                   6726: 
                   6727: ...
                   6728: 
                   6729: Packages which use GNU Automake will almost certainly require GNU Make.
                   6730: 
                   6731: There are times when the configure process makes additional changes to the
                   6732: generated files, which then causes the build process to try to re-execute the
                   6733: automake sequence. This is prevented by touching various files in the configure
                   6734: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
                   6735: NO in the package Makefile.
                   6736: 
1.154     rillig   6737: 21.4. Programming languages
1.1       dsieger  6738: 
1.154     rillig   6739: 21.4.1. C, C++, and Fortran
1.1       dsieger  6740: 
                   6741: Compilers for the C, C++, and Fortran languages comes with the NetBSD base
                   6742: system. By default, pkgsrc assumes that a package is written in C and will hide
1.154     rillig   6743: all other compilers (via the wrapper framework, see Chapter 16, Buildlink
1.1       dsieger  6744: methodology).
                   6745: 
                   6746: To declare which language's compiler a package needs, set the USE_LANGUAGES
                   6747: variable. Allowed values currently are "c", "c++", and "fortran" (and any
                   6748: combination). The default is "c". Packages using GNU configure scripts, even if
                   6749: written in C++, usually need a C compiler for the configure phase.
                   6750: 
1.154     rillig   6751: 21.4.2. Java
1.1       dsieger  6752: 
                   6753: If a program is written in Java, use the Java framework in pkgsrc. The package
                   6754: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
                   6755: variables:
                   6756: 
                   6757:   * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
                   6758:     set to "run", then there is only a runtime dependency on the JDK. The
                   6759:     default is "yes", which also adds a build dependency on the JDK.
                   6760: 
                   6761:   * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
                   6762:     supported values are "yes", "1.4", and "1.5". "yes" accepts any Java2
                   6763:     implementation, "1.4" insists on versions 1.4 or above, and "1.5" only
                   6764:     accepts versions 1.5 or above. This variable is not set by default.
                   6765: 
1.25      wiz      6766:   * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
                   6767:     implementation dependency. It may be used to set JAVA_HOME to a good value
                   6768:     if the program needs this variable to be defined.
                   6769: 
1.154     rillig   6770: 21.4.3. Packages containing perl scripts
1.1       dsieger  6771: 
                   6772: If your package contains interpreted perl scripts, add "perl" to the USE_TOOLS
                   6773: variable and set REPLACE_PERL to ensure that the proper interpreter path is
                   6774: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
1.74      wiz      6775: you want adjusted. Every occurrence of */bin/perl in a she-bang line will be
                   6776: replaced with the full path to the perl executable.
1.1       dsieger  6777: 
                   6778: If a particular version of perl is needed, set the PERL5_REQD variable to the
                   6779: version number. The default is "5.0".
                   6780: 
1.154     rillig   6781: See Section 21.6.6, "Packages installing perl modules" for information about
1.1       dsieger  6782: handling perl modules.
                   6783: 
1.154     rillig   6784: 21.4.4. Packages containing shell scripts
1.41      wiz      6785: 
                   6786: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
                   6787: shell hash bangs in files. Please use the appropriate one, prefering REPLACE_SH
1.74      wiz      6788: in case this shell is sufficient. Each should contain a list of scripts,
                   6789: relative to WRKSRC, that you want adjusted. Every occurrence of the matching
                   6790: shell in a she-bang line will be replaced with the full path to the shell
                   6791: executable. When using REPLACE_BASH, don't forget to add bash to USE_TOOLS.
1.41      wiz      6792: 
1.154     rillig   6793: 21.4.5. Other programming languages
1.1       dsieger  6794: 
                   6795: Currently, there is no special handling for other languages in pkgsrc. If a
                   6796: compiler package provides a buildlink3.mk file, include that, otherwise just
                   6797: add a (build) dependency on the appropriate compiler package.
                   6798: 
1.154     rillig   6799: 21.5. The build phase
1.1       dsieger  6800: 
                   6801: The most common failures when building a package are that some platforms do not
                   6802: provide certain header files, functions or libraries, or they provide the
                   6803: functions in a library that the original package author didn't know. To work
                   6804: around this, you can rewrite the source code in most cases so that it does not
                   6805: use the missing functions or provides a replacement function.
                   6806: 
1.154     rillig   6807: 21.5.1. Compiling C and C++ code conditionally
1.1       dsieger  6808: 
                   6809: If a package already comes with a GNU configure script, the preferred way to
                   6810: fix the build failure is to change the configure script, not the code. In the
                   6811: other cases, you can utilize the C preprocessor, which defines certain macros
                   6812: depending on the operating system and hardware architecture it compiles for.
                   6813: These macros can be queried using for example #if defined(__i386). Almost every
                   6814: operating system, hardware architecture and compiler has its own macro. For
                   6815: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
                   6816: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
                   6817: GCC.
                   6818: 
                   6819: The list of the following macros for hardware and operating system depends on
                   6820: the compiler that is used. For example, if you want to conditionally compile
                   6821: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
                   6822: Use __sun instead.
                   6823: 
1.154     rillig   6824: 21.5.1.1. C preprocessor macros to identify the operating system
1.1       dsieger  6825: 
                   6826: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
                   6827: should use the following code.
                   6828: 
                   6829: #include <sys/param.h>
                   6830: #if (defined(BSD) && BSD >= 199306)
                   6831: /* BSD-specific code goes here */
                   6832: #else
                   6833: /* non-BSD-specific code goes here */
                   6834: #endif
                   6835: 
                   6836: If this distinction is not fine enough, you can also test for the following
                   6837: macros.
                   6838: 
1.46      obache   6839: Cygwin      __CYGWIN__
                   6840: DragonFly   __DragonFly__
1.1       dsieger  6841: FreeBSD     __FreeBSD__
1.46      obache   6842: Haiku       __HAIKU__
1.1       dsieger  6843: Interix     __INTERIX
                   6844: IRIX        __sgi (TODO: get a definite source for this)
                   6845: Linux       linux, __linux, __linux__
1.83      dholland 6846: Mac OS X    __APPLE__
1.46      obache   6847: MirBSD      __MirBSD__ (__OpenBSD__ is also defined)
                   6848: Minix3      __minix
1.1       dsieger  6849: NetBSD      __NetBSD__
                   6850: OpenBSD     __OpenBSD__
                   6851: Solaris     sun, __sun
                   6852: 
1.154     rillig   6853: 21.5.1.2. C preprocessor macros to identify the hardware architecture
1.1       dsieger  6854: 
                   6855: i386        i386, __i386, __i386__
                   6856: MIPS        __mips
                   6857: SPARC       sparc, __sparc
                   6858: 
1.154     rillig   6859: 21.5.1.3. C preprocessor macros to identify the compiler
1.1       dsieger  6860: 
                   6861: GCC         __GNUC__ (major version), __GNUC_MINOR__
                   6862: MIPSpro     _COMPILER_VERSION (0x741 for MIPSpro 7.41)
                   6863: SunPro      __SUNPRO_C (0x570 for Sun C 5.7)
                   6864: SunPro C++  __SUNPRO_CC (0x580 for Sun C++ 5.8)
                   6865: 
1.154     rillig   6866: 21.5.2. How to handle compiler bugs
1.1       dsieger  6867: 
                   6868: Some source files trigger bugs in the compiler, based on combinations of
                   6869: compiler version and architecture and almost always relation to optimisation
                   6870: being enabled. Common symptoms are gcc internal errors or never finishing
                   6871: compiling a file.
                   6872: 
                   6873: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
1.87      tnn      6874: disabling optimisation for that combination of file, MACHINE_ARCH and compiler.
                   6875: 
                   6876: This used to be a big problem in the past, but is rarely needed now as compiler
                   6877: technology has matured. If you still need to add a compiler specific
                   6878: workaround, please do so in the file hacks.mk and describe the symptom and
                   6879: compiler version as detailed as possible.
1.1       dsieger  6880: 
1.172     rillig   6881: 21.5.3. No such file or directory
                   6882: 
                   6883: Compilation sometimes fails with an error message like this:
                   6884: 
                   6885: .../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10:
                   6886:     fatal error: pango/pango.h: No such file or directory
                   6887: 
                   6888: The proper way to fix this problem depends on the type of the header, which is
                   6889: described in the following sections.
                   6890: 
                   6891: 21.5.3.1. Headers from other packages
                   6892: 
                   6893: If the header name looks like it comes from a different package, that other
                   6894: package should be included via the buildlink3 framework.
                   6895: 
                   6896: First, look whether the header is somewhere in the buildlink3 directory below
                   6897: WRKDIR. In the above case of the missing Pango header:
                   6898: 
                   6899: $ find work/.buildlink/ -print | grep -F pango/pango.h
                   6900: 
                   6901: In the case of Pango, the output is:
                   6902: 
                   6903: work/.buildlink/include/pango-1.0/pango/pango.h
                   6904: 
                   6905: If the pango/pango.h file were placed directly in the .buildlink directory, it
                   6906: would have been found automatically. There is an extra pango-1.0 path component
                   6907: though, which means that the compiler command line must contain an option of
                   6908: the form -I${BUILDLINK3_PREFIX.pango}/include/pango-1.0. In most cases this
                   6909: option is generated by the configure script, which can be examined using:
                   6910: 
                   6911: $ $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile
                   6912: -I/usr/pkg/include/pango-1.0
                   6913: -I/usr/pkg/include/pango-1.0
                   6914: -I/usr/pkg/include/pango-1.0
                   6915: -I/usr/pkg/include/pango-1.0
                   6916: -I/usr/pkg/include/pango-1.0
                   6917: 
                   6918: This looks good. These options are transformed by the buildlink wrapper to
                   6919: refer to the correct path inside work/.buildlink.
                   6920: 
                   6921: Since the compilation fails though, examine the compiler command lines in work
                   6922: /.work.log to see whether the -I option is included in the particular command
                   6923: line.
                   6924: 
                   6925: To further analyze the situation, run bmake build-env, which sets up an
                   6926: interactive, realistic environment including all the pkgsrc wrapper commands
                   6927: and environment variables. From there, try to compile some simple example
                   6928: programs that use the header.
                   6929: 
                   6930: 21.5.3.2. Headers generated during the build
                   6931: 
                   6932: If the name of the header seems to come from the package itself, and if the
                   6933: build is run with parallel jobs, the package may have some undeclared
                   6934: dependencies between the .c and the .h files, and a C file is compiled before
                   6935: its required header is generated.
                   6936: 
                   6937: To see whether the build runs with parallel jobs, run bmake show-all-build |
                   6938: grep JOBS. Its output looks like this:
                   6939: 
                   6940:   usr   MAKE_JOBS=              7
                   6941:   pkg   MAKE_JOBS_SAFE          # undefined
                   6942:   def   _MAKE_JOBS_N=           7
                   6943: 
                   6944: In this case the pkgsrc user has asked pkgsrc to build packages with 7 jobs in
                   6945: parallel (MAKE_JOBS). The package could have disabled parallel builds by
                   6946: setting MAKE_JOBS_SAFE to no, but in this case it hasn't.
                   6947: 
                   6948: To see whether the build failure is caused by parallel builds, first save the
                   6949: exact error message and a bit of context, maybe you need it later for reporting
                   6950: a bug. Next, run:
                   6951: 
                   6952: MAKE_JOBS_SAFE=no bmake clean build
                   6953: 
                   6954: If that succeeds, file a bug report against the pkgsrc package, including the
                   6955: exact error message and the contents of your mk.conf file.
                   6956: 
1.173     rillig   6957: 21.5.3.3. Symlinks
                   6958: 
                   6959: Pkgsrc does not work reliably if any of LOCALBASE, VARBASE or WRKDIR contains a
                   6960: symlink. Since 2019Q2, the pkgsrc bootstrap program prevents installing pkgsrc
                   6961: in symlink-based directories. Existing pkgsrc installations are not checked for
                   6962: symlinks though.
                   6963: 
                   6964: The "No such file or directory" error messages are a typical symptom of
                   6965: symlinks, and it's quite difficult to find out that this is the actual cause.
                   6966: 
                   6967: 21.5.3.4. Stale working directories
                   6968: 
                   6969: When building a hierarchy of packages, it may happen that one package is built
                   6970: and then pkgsrc is updated. This situation can provoke various hard to diagnose
                   6971: build errors. To clean up the situation:
                   6972: 
                   6973: $ (cd ../../ && test -f mk/bsd.pkg.mk && rm -rf */*/work)
                   6974: 
                   6975: (The test for bsd.pkg.mk just prevents running this command in the wrong
                   6976: directory.)
                   6977: 
                   6978: If you have set WRKOBJDIR in mk.conf, remove that directory as well.
                   6979: 
                   6980: 21.5.3.5. Other possible reasons
                   6981: 
                   6982: On platforms other than BSD, third-party packages are installed in /usr/
                   6983: include, together with the base system. This means that pkgsrc cannot
                   6984: distinguish between headers provided by the base system (which it needs) and
                   6985: headers from third-party packages (which are often included in pkgsrc as well).
                   6986: This can lead to subtle version mismatches.
                   6987: 
                   6988: In pkgsrc installations that have been active for several years, it may happen
                   6989: that some files are manually deleted. To exclude this unlikely reason, run 
                   6990: pkg_admin check.
                   6991: 
                   6992: It may help to run pkg_admin rebuild-tree to check/fix dependencies.
                   6993: 
                   6994: If all of the above doesn't help, see Chapter 2, Getting help for contact
                   6995: information. Be prepared to describe what you have tried so far and what any
                   6996: error messages were.
                   6997: 
1.172     rillig   6998: 21.5.4. Undefined reference to "..."
1.1       dsieger  6999: 
                   7000: This error message often means that a package did not link to a shared library
                   7001: it needs. The following functions are known to cause this error message over
                   7002: and over.
                   7003: 
                   7004: +-----------------------------------------------------+
                   7005: |        Function         |Library |Affected platforms|
                   7006: |-------------------------+--------+------------------|
                   7007: |accept, bind, connect    |-lsocket|Solaris           |
                   7008: |-------------------------+--------+------------------|
                   7009: |crypt                    |-lcrypt |DragonFly, NetBSD |
                   7010: |-------------------------+--------+------------------|
                   7011: |dlopen, dlsym            |-ldl    |Linux             |
                   7012: |-------------------------+--------+------------------|
                   7013: |gethost*                 |-lnsl   |Solaris           |
                   7014: |-------------------------+--------+------------------|
                   7015: |inet_aton                |-lresolv|Solaris           |
                   7016: |-------------------------+--------+------------------|
                   7017: |nanosleep, sem_*, timer_*|-lrt    |Solaris           |
                   7018: |-------------------------+--------+------------------|
                   7019: |openpty                  |-lutil  |Linux             |
                   7020: +-----------------------------------------------------+
                   7021: 
                   7022: To fix these linker errors, it is often sufficient to say LIBS.OperatingSystem+
                   7023: = -lfoo to the package Makefile and then say bmake clean; bmake.
                   7024: 
1.172     rillig   7025: 21.5.4.1. Special issue: The SunPro compiler
1.1       dsieger  7026: 
                   7027: When you are using the SunPro compiler, there is another possibility. That
                   7028: compiler cannot handle the following code:
                   7029: 
                   7030: extern int extern_func(int);
                   7031: 
                   7032: static inline int
                   7033: inline_func(int x)
                   7034: {
                   7035:         return extern_func(x);
                   7036: }
                   7037: 
                   7038: int main(void)
                   7039: {
                   7040:         return 0;
                   7041: }
                   7042: 
                   7043: It generates the code for inline_func even if that function is never used. This
                   7044: code then refers to extern_func, which can usually not be resolved. To solve
                   7045: this problem you can try to tell the package to disable inlining of functions.
                   7046: 
1.172     rillig   7047: 21.5.5. Running out of memory
1.1       dsieger  7048: 
                   7049: Sometimes packages fail to build because the compiler runs into an operating
                   7050: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
1.94      wiz      7051: told to unlimit the resources. Currently, the allowed values are any
                   7052: combination of "cputime", "datasize", "memorysize", and "stacksize". Setting
                   7053: this variable is similar to running the shell builtin ulimit command to raise
                   7054: the maximum data segment size or maximum stack size of a process, respectively,
                   7055: to their hard limits.
1.1       dsieger  7056: 
1.154     rillig   7057: 21.6. The install phase
1.1       dsieger  7058: 
1.154     rillig   7059: 21.6.1. Creating needed directories
1.1       dsieger  7060: 
                   7061: The BSD-compatible install supplied with some operating systems cannot create
                   7062: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
                   7063: like this:
                   7064: 
                   7065: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
                   7066: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
                   7067: 
                   7068: You can also just append "dir1 dir2" to the INSTALLATION_DIRS variable, which
                   7069: will automatically do the right thing.
                   7070: 
1.154     rillig   7071: 21.6.2. Where to install documentation
1.1       dsieger  7072: 
                   7073: In general, documentation should be installed into ${PREFIX}/share/doc/$
                   7074: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME} (the latter includes the version
                   7075: number of the package).
                   7076: 
                   7077: Many modern packages using GNU autoconf allow to set the directory where HTML
                   7078: documentation is installed with the "--with-html-dir" option. Sometimes using
                   7079: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
                   7080: share/doc/html or other places.
                   7081: 
                   7082: An exception to the above is that library API documentation generated with the
                   7083: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
                   7084: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
                   7085: can be recognized from files ending in .devhelp or .devhelp2. (It is also
                   7086: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
                   7087: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
                   7088: then, no additional subdirectory level is allowed in this case. This is usually
                   7089: achieved by using "--with-html-dir=${PREFIX}/share/doc". ${PREFIX}/share/
                   7090: gtk-doc is preferred though.)
                   7091: 
1.154     rillig   7092: 21.6.3. Installing highscore files
1.1       dsieger  7093: 
                   7094: Certain packages, most of them in the games category, install a score file that
                   7095: allows all users on the system to record their highscores. In order for this to
                   7096: work, the binaries need to be installed setgid and the score files owned by the
1.36      wiz      7097: appropriate group and/or owner (traditionally the "games" user/group). Set
                   7098: USE_GAMESGROUP to yes to support this. The following variables, documented in
                   7099: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
1.100     leot     7100: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER. Other useful variables are:
                   7101: GAMEDIR_PERMS, GAMEDATA_PERMS and SETGID_GAMES_PERMS.
                   7102: 
                   7103: An example that illustrates some of the variables described above is games/
                   7104: moon-buggy. OWN_DIRS_PERMS is used to properly set directory permissions of the
                   7105: directory where the scorefile is saved, REQD_FILES_PERMS is used to create a
                   7106: dummy scorefile (mbscore) with the proper permissions and SPECIAL_PERMS is used
                   7107: to install setgid the game binary:
                   7108: 
                   7109: USE_GAMESGROUP=         yes
                   7110: 
                   7111: BUILD_DEFS+=            VARBASE
                   7112: 
                   7113: OWN_DIRS_PERMS+=        ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
                   7114: REQD_FILES_PERMS+=      /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
                   7115: SPECIAL_PERMS+=         ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
                   7116: 
                   7117: Various INSTALL_* variables are also available: INSTALL_GAME to install setgid
                   7118: game binaries, INSTALL_GAME_DIR to install game directories that are needed to
                   7119: be accessed by setgid games and INSTALL_GAME_DATA to install scorefiles.
1.1       dsieger  7120: 
1.14      jmcneill 7121: A package should therefore never hard code file ownership or access permissions
1.100     leot     7122: but rely on *_PERMS as described above or alternatively on INSTALL_GAME,
                   7123: INSTALL_GAME_DATA and INSTALL_GAME_DIR to set these correctly.
1.1       dsieger  7124: 
1.154     rillig   7125: 21.6.4. Adding DESTDIR support to packages
1.4       rillig   7126: 
1.14      jmcneill 7127: DESTDIR support means that a package installs into a staging directory, not the
                   7128: final location of the files. Then a binary package is created which can be used
                   7129: for installation as usual. There are two ways: Either the package must install
1.25      wiz      7130: as root ("destdir") or the package can install as non-root user ("user-destdir"
                   7131: ).
1.14      jmcneill 7132: 
1.113     leot     7133:   * PKG_DESTDIR_SUPPORT has to be set to "destdir" or "user-destdir". By
                   7134:     default PKG_DESTDIR_SUPPORT is set to "user-destdir" to help catching more
                   7135:     potential packaging problems. If bsd.prefs.mk is included in the Makefile,
                   7136:     PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14      jmcneill 7137: 
1.4       rillig   7138:   * All installation operations have to be prefixed with ${DESTDIR}.
                   7139: 
                   7140:   * automake gets this DESTDIR mostly right automatically. Many manual rules
                   7141:     and pre/post-install often are incorrect; fix them.
                   7142: 
1.17      imil     7143:   * If files are installed with special owner/group use SPECIAL_PERMS.
1.4       rillig   7144: 
                   7145:   * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
                   7146: 
1.154     rillig   7147: 21.6.5. Packages with hardcoded paths to other interpreters
1.1       dsieger  7148: 
                   7149: Your package may also contain scripts with hardcoded paths to other
                   7150: interpreters besides (or as well as) perl. To correct the full pathname to the
                   7151: script interpreter, you need to set the following definitions in your Makefile
                   7152: (we shall use tclsh in this example):
                   7153: 
                   7154: REPLACE_INTERPRETER+=   tcl
                   7155: REPLACE.tcl.old=        .*/bin/tclsh
                   7156: REPLACE.tcl.new=        ${PREFIX}/bin/tclsh
                   7157: REPLACE_FILES.tcl=      # list of tcl scripts which need to be fixed,
                   7158: # relative to ${WRKSRC}, just as in REPLACE_PERL
                   7159: 
                   7160: Note
                   7161: 
                   7162: Before March 2006, these variables were called _REPLACE.* and _REPLACE_FILES.*.
                   7163: 
1.154     rillig   7164: 21.6.6. Packages installing perl modules
1.1       dsieger  7165: 
                   7166: Makefiles of packages providing perl5 modules should include the Makefile
                   7167: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
                   7168: standard perl configuration for such modules as well as various hooks to tune
                   7169: this configuration. See comments in this file for details.
                   7170: 
                   7171: Perl5 modules will install into different places depending on the version of
                   7172: perl used during the build process. To address this, pkgsrc will append lines
                   7173: to the PLIST corresponding to the files listed in the installed .packlist file
                   7174: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48      wiz      7175: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
                   7176: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1       dsieger  7177: 
1.48      wiz      7178: PERL5_PACKLIST= auto/Pg/.packlist
1.1       dsieger  7179: 
1.48      wiz      7180: The perl5 config variables installarchlib, installscript, installvendorbin,
                   7181: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
                   7182: and installvendorman3dir represent those locations in which components of perl5
                   7183: modules may be installed, provided as variable with uppercase and prefixed with
                   7184: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
                   7185: have a packlist. These variables are also substituted for in the PLIST as
                   7186: uppercase prefixed with PERL5_SUB_.
1.1       dsieger  7187: 
1.154     rillig   7188: 21.6.7. Packages installing info files
1.1       dsieger  7189: 
                   7190: Some packages install info files or use the "makeinfo" or "install-info"
                   7191: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
                   7192: and DEINSTALL scripts will be generated to handle registration of the info
                   7193: files in the Info directory file. The "install-info" command used for the info
                   7194: files registration is either provided by the system, or by a special purpose
                   7195: package automatically added as dependency if needed.
                   7196: 
                   7197: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
                   7198: located. PKGINFODIR defaults to "info" and can be overridden by the user.
                   7199: 
                   7200: The info files for the package should be listed in the package PLIST; however
                   7201: any split info files need not be listed.
                   7202: 
                   7203: A package which needs the "makeinfo" command at build time must add "makeinfo"
                   7204: to USE_TOOLS in its Makefile. If a minimum version of the "makeinfo" command is
                   7205: needed it should be noted with the TEXINFO_REQD variable in the package
                   7206: Makefile. By default, a minimum version of 3.12 is required. If the system does
                   7207: not provide a makeinfo command or if it does not match the required minimum, a
                   7208: build dependency on the devel/gtexinfo package will be added automatically.
                   7209: 
                   7210: The build and installation process of the software provided by the package
                   7211: should not use the install-info command as the registration of info files is
1.25      wiz      7212: the task of the package INSTALL script, and it must use the appropriate 
1.1       dsieger  7213: makeinfo command.
                   7214: 
                   7215: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
                   7216: the install-info and makeinfo commands in a directory listed early in PATH.
                   7217: 
                   7218: The script overriding install-info has no effect except the logging of a
                   7219: message. The script overriding makeinfo logs a message and according to the
                   7220: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
                   7221: error.
                   7222: 
1.154     rillig   7223: 21.6.8. Packages installing man pages
1.1       dsieger  7224: 
                   7225: All packages that install manual pages should install them into the same
                   7226: directory, so that there is one common place to look for them. In pkgsrc, this
                   7227: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.25      wiz      7228: packages. The default for PKGMANDIR is "man". Another often-used value is "
                   7229: share/man".
1.1       dsieger  7230: 
                   7231: Note
                   7232: 
                   7233: The support for a custom PKGMANDIR is far from complete.
                   7234: 
                   7235: The PLIST files can just use man/ as the top level directory for the man page
                   7236: file entries, and the pkgsrc framework will convert as needed. In all other
                   7237: places, the correct PKGMANDIR must be used.
                   7238: 
                   7239: Packages that are configured with GNU_CONFIGURE set as "yes", by default will
                   7240: use the ./configure --mandir switch to set where the man pages should be
                   7241: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
                   7242: {PKGMANDIR}.
                   7243: 
                   7244: Packages that use GNU_CONFIGURE but do not use --mandir, can set
                   7245: CONFIGURE_HAS_MANDIR to "no". Or if the ./configure script uses a non-standard
                   7246: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
                   7247: 
1.154     rillig   7248: See Section 15.5, "Man page compression" for information on installation of
1.1       dsieger  7249: compressed manual pages.
                   7250: 
1.154     rillig   7251: 21.6.9. Packages installing GConf data files
1.1       dsieger  7252: 
1.7       rillig   7253: If a package installs .schemas or .entries files, used by GConf, you need to
1.1       dsieger  7254: take some extra steps to make sure they get registered in the database:
                   7255: 
1.7       rillig   7256:  1. Include ../../devel/GConf/schemas.mk instead of its buildlink3.mk file.
                   7257:     This takes care of rebuilding the GConf database at installation and
                   7258:     deinstallation time, and tells the package where to install GConf data
1.1       dsieger  7259:     files using some standard configure arguments. It also disallows any access
                   7260:     to the database directly from the package.
                   7261: 
                   7262:  2. Ensure that the package installs its .schemas files under ${PREFIX}/share/
                   7263:     gconf/schemas. If they get installed under ${PREFIX}/etc, you will need to
                   7264:     manually patch the package.
                   7265: 
                   7266:  3. Check the PLIST and remove any entries under the etc/gconf directory, as
1.154     rillig   7267:     they will be handled automatically. See Section 10.13, "How do I change the
1.1       dsieger  7268:     location of configuration files?" for more information.
                   7269: 
1.7       rillig   7270:  4. Define the GCONF_SCHEMAS variable in your Makefile with a list of all
1.1       dsieger  7271:     .schemas files installed by the package, if any. Names must not contain any
                   7272:     directories in them.
                   7273: 
1.7       rillig   7274:  5. Define the GCONF_ENTRIES variable in your Makefile with a list of all
1.1       dsieger  7275:     .entries files installed by the package, if any. Names must not contain any
                   7276:     directories in them.
                   7277: 
1.154     rillig   7278: 21.6.10. Packages installing scrollkeeper/rarian data files
1.1       dsieger  7279: 
1.18      mishka   7280: If a package installs .omf files, used by scrollkeeper/rarian, you need to take
                   7281: some extra steps to make sure they get registered in the database:
1.1       dsieger  7282: 
1.18      mishka   7283:  1. Include ../../mk/omf-scrollkeeper.mk instead of rarian's buildlink3.mk
                   7284:     file. This takes care of rebuilding the scrollkeeper database at
                   7285:     installation and deinstallation time, and disallows any access to it
                   7286:     directly from the package.
1.1       dsieger  7287: 
                   7288:  2. Check the PLIST and remove any entries under the libdata/scrollkeeper
                   7289:     directory, as they will be handled automatically.
                   7290: 
                   7291:  3. Remove the share/omf directory from the PLIST. It will be handled by
1.18      mishka   7292:     rarian. (make print-PLIST does this automatically.)
1.1       dsieger  7293: 
1.154     rillig   7294: 21.6.11. Packages installing X11 fonts
1.1       dsieger  7295: 
                   7296: If a package installs font files, you will need to rebuild the fonts database
                   7297: in the directory where they get installed at installation and deinstallation
                   7298: time. This can be automatically done by using the pkginstall framework.
                   7299: 
                   7300: You can list the directories where fonts are installed in the FONTS_DIRS.type
                   7301: variables, where type can be one of "ttf", "type1" or "x11". Also make sure
                   7302: that the database file fonts.dir is not listed in the PLIST.
                   7303: 
                   7304: Note that you should not create new directories for fonts; instead use the
                   7305: standard ones to avoid that the user needs to manually configure his X server
                   7306: to find them.
                   7307: 
1.154     rillig   7308: 21.6.12. Packages installing GTK2 modules
1.1       dsieger  7309: 
                   7310: If a package installs GTK2 immodules or loaders, you need to take some extra
                   7311: steps to get them registered in the GTK2 database properly:
                   7312: 
                   7313:  1. Include ../../x11/gtk2/modules.mk instead of its buildlink3.mk file. This
                   7314:     takes care of rebuilding the database at installation and deinstallation
                   7315:     time.
                   7316: 
                   7317:  2. Set GTK2_IMMODULES=YES if your package installs GTK2 immodules.
                   7318: 
                   7319:  3. Set GTK2_LOADERS=YES if your package installs GTK2 loaders.
                   7320: 
                   7321:  4. Patch the package to not touch any of the GTK2 databases directly. These
                   7322:     are:
                   7323: 
1.42      asau     7324:       + libdata/gtk-2.0/gdk-pixbuf.loaders
1.1       dsieger  7325: 
1.42      asau     7326:       + libdata/gtk-2.0/gtk.immodules
1.1       dsieger  7327: 
                   7328:  5. Check the PLIST and remove any entries under the libdata/gtk-2.0 directory,
                   7329:     as they will be handled automatically.
                   7330: 
1.154     rillig   7331: 21.6.13. Packages installing SGML or XML data
1.1       dsieger  7332: 
                   7333: If a package installs SGML or XML data files that need to be registered in
                   7334: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
                   7335: extra steps:
                   7336: 
                   7337:  1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
                   7338:     care of registering those files in system-wide catalogs at installation and
                   7339:     deinstallation time.
                   7340: 
                   7341:  2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
                   7342:     package.
                   7343: 
                   7344:  3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
                   7345:     package.
                   7346: 
                   7347:  4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
                   7348:     These come in groups of three strings; see xmlcatmgr(1) for more
                   7349:     information (specifically, arguments recognized by the 'add' action). Note
                   7350:     that you will normally not use this variable.
                   7351: 
                   7352:  5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
                   7353:     come in groups of three strings; see xmlcatmgr(1) for more information
                   7354:     (specifically, arguments recognized by the 'add' action). Note that you
                   7355:     will normally not use this variable.
                   7356: 
1.154     rillig   7357: 21.6.14. Packages installing extensions to the MIME database
1.1       dsieger  7358: 
                   7359: If a package provides extensions to the MIME database by installing .xml files
                   7360: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
                   7361: ensure that the database is kept consistent with respect to these new files:
                   7362: 
                   7363:  1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
                   7364:     buildlink3.mk file from this same directory, which is reserved for
                   7365:     inclusion from other buildlink3.mk files). It takes care of rebuilding the
                   7366:     MIME database at installation and deinstallation time, and disallows any
                   7367:     access to it directly from the package.
                   7368: 
1.25      wiz      7369:  2. Check the PLIST and remove any entries under the share/mime directory, 
1.1       dsieger  7370:     except for files saved under share/mime/packages. The former are handled
                   7371:     automatically by the update-mime-database program, but the latter are
                   7372:     package-dependent and must be removed by the package that installed them in
                   7373:     the first place.
                   7374: 
                   7375:  3. Remove any share/mime/* directories from the PLIST. They will be handled by
                   7376:     the shared-mime-info package.
                   7377: 
1.154     rillig   7378: 21.6.15. Packages using intltool
1.1       dsieger  7379: 
                   7380: If a package uses intltool during its build, add intltool to the USE_TOOLS,
                   7381: which forces it to use the intltool package provided by pkgsrc, instead of the
                   7382: one bundled with the distribution file.
                   7383: 
                   7384: This tracks intltool's build-time dependencies and uses the latest available
                   7385: version; this way, the package benefits of any bug fixes that may have appeared
                   7386: since it was released.
                   7387: 
1.154     rillig   7388: 21.6.16. Packages installing startup scripts
1.1       dsieger  7389: 
                   7390: If a package contains a rc.d script, it won't be copied into the startup
                   7391: directory by default, but you can enable it, by adding the option
1.4       rillig   7392: PKG_RCD_SCRIPTS=YES in mk.conf. This option will copy the scripts into /etc/
                   7393: rc.d when a package is installed, and it will automatically remove the scripts
                   7394: when the package is deinstalled.
1.1       dsieger  7395: 
1.154     rillig   7396: 21.6.17. Packages installing TeX modules
1.1       dsieger  7397: 
                   7398: If a package installs TeX packages into the texmf tree, the ls-R database of
                   7399: the tree needs to be updated.
                   7400: 
                   7401: Note
                   7402: 
1.23      jakllsch 7403: Except the main TeX packages such as kpathsea, packages should install files
                   7404: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1       dsieger  7405: 
1.23      jakllsch 7406:  1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
                   7407:     ls-R database at installation and deinstallation time.
1.1       dsieger  7408: 
1.23      jakllsch 7409:  2. If your package installs files into a texmf tree other than the one at $
                   7410:     {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
                   7411:     trees that need database update.
1.1       dsieger  7412: 
                   7413:     If your package also installs font map files that need to be registered
1.30      dholland 7414:     using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
                   7415:     and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then 
                   7416:     updmap will be run automatically at installation/deinstallation to enable/
                   7417:     disable font map files for TeX output drivers.
1.1       dsieger  7418: 
                   7419:  3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30      dholland 7420:     be removed only by the kpathsea package.
1.1       dsieger  7421: 
1.154     rillig   7422: 21.6.18. Packages supporting running binaries in emulation
1.1       dsieger  7423: 
                   7424: There are some packages that provide libraries and executables for running
                   7425: binaries from a one operating system on a different one (if the latter supports
                   7426: it). One example is running Linux binaries on NetBSD.
                   7427: 
                   7428: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
                   7429: 
                   7430: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
                   7431: if all libraries for each installed executable can be found by the dynamic
                   7432: linker. Since the standard dynamic linker is run, this fails for emulation
                   7433: packages, because the libraries used by the emulation are not in the standard
                   7434: directories.
                   7435: 
1.154     rillig   7436: 21.6.19. Packages installing hicolor theme icons
1.1       dsieger  7437: 
                   7438: If a package installs images under the share/icons/hicolor and/or updates the
                   7439: share/icons/hicolor/icon-theme.cache database, you need to take some extra
                   7440: steps to make sure that the shared theme directory is handled appropriately and
                   7441: that the cache database is rebuilt:
                   7442: 
                   7443:  1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
                   7444: 
                   7445:  2. Check the PLIST and remove the entry that refers to the theme cache.
                   7446: 
                   7447:  3. Ensure that the PLIST does not remove the shared icon directories from the
                   7448:     share/icons/hicolor hierarchy because they will be handled automatically.
                   7449: 
                   7450: The best way to verify that the PLIST is correct with respect to the last two
                   7451: points is to regenerate it using make print-PLIST.
                   7452: 
1.154     rillig   7453: 21.6.20. Packages installing desktop files
1.1       dsieger  7454: 
                   7455: If a package installs .desktop files under share/applications and these include
1.54      rodent   7456: MIME information (MimeType key), you need to take extra steps to ensure that
                   7457: they are registered into the MIME database:
1.1       dsieger  7458: 
                   7459:  1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
                   7460: 
                   7461:  2. Check the PLIST and remove the entry that refers to the share/applications/
                   7462:     mimeinfo.cache file. It will be handled automatically.
                   7463: 
                   7464: The best way to verify that the PLIST is correct with respect to the last point
                   7465: is to regenerate it using make print-PLIST.
                   7466: 
1.154     rillig   7467: 21.7. Marking packages as having problems
1.1       dsieger  7468: 
1.23      jakllsch 7469: In some cases one does not have the time to solve a problem immediately. In
                   7470: this case, one can plainly mark a package as broken. For this, one just sets
                   7471: the variable BROKEN to the reason why the package is broken (similar to the
1.162     rillig   7472: PKG_FAIL_REASON variable). A user trying to build the package will immediately
                   7473: be shown this message, and the build will not be even tried.
1.1       dsieger  7474: 
1.23      jakllsch 7475: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1       dsieger  7476: 
1.154     rillig   7477: Chapter 22. Debugging
1.1       dsieger  7478: 
                   7479: To check out all the gotchas when building a package, here are the steps that I
                   7480: do in order to get a package working. Please note this is basically the same as
                   7481: what was explained in the previous sections, only with some debugging aids.
                   7482: 
1.4       rillig   7483:   * Be sure to set PKG_DEVELOPER=yes in mk.conf.
1.1       dsieger  7484: 
                   7485:   * Install pkgtools/url2pkg, create a directory for a new package, change into
                   7486:     it, then run url2pkg:
                   7487: 
                   7488:     % mkdir /usr/pkgsrc/category/examplepkg
                   7489:     % cd /usr/pkgsrc/category/examplepkg
1.174     leot     7490:     % url2pkg https://www.example.com/path/to/distfile.tar.gz
1.1       dsieger  7491: 
                   7492:   * Edit the Makefile as requested.
                   7493: 
                   7494:   * Fill in the DESCR file
                   7495: 
                   7496:   * Run make configure
                   7497: 
                   7498:   * Add any dependencies glimpsed from documentation and the configure step to
                   7499:     the package's Makefile.
                   7500: 
                   7501:   * Make the package compile, doing multiple rounds of
                   7502: 
                   7503:     % make
                   7504:     % pkgvi ${WRKSRC}/some/file/that/does/not/compile
                   7505:     % mkpatches
                   7506:     % patchdiff
                   7507:     % mv ${WRKDIR}/.newpatches/* patches
                   7508:     % make mps
                   7509:     % make clean
                   7510: 
                   7511:     Doing this step as non-root user will ensure that no files are modified
                   7512:     that shouldn't be, especially during the build phase. mkpatches, patchdiff
                   7513:     and pkgvi are from the pkgtools/pkgdiff package.
                   7514: 
1.154     rillig   7515:   * Look at the Makefile, fix if necessary; see Section 13.1, "Makefile".
1.1       dsieger  7516: 
                   7517:   * Generate a PLIST:
                   7518: 
                   7519:     # make install
                   7520:     # make print-PLIST >PLIST
                   7521:     # make deinstall
                   7522:     # make install
                   7523:     # make deinstall
                   7524: 
                   7525:     You usually need to be root to do this. Look if there are any files left:
                   7526: 
                   7527:     # make print-PLIST
                   7528: 
                   7529:     If this reveals any files that are missing in PLIST, add them.
                   7530: 
                   7531:   * Now that the PLIST is OK, install the package again and make a binary
                   7532:     package:
                   7533: 
                   7534:     # make reinstall
                   7535:     # make package
                   7536: 
                   7537:   * Delete the installed package:
                   7538: 
                   7539:     # pkg_delete examplepkg
                   7540: 
                   7541:   * Repeat the above make print-PLIST command, which shouldn't find anything
                   7542:     now:
                   7543: 
                   7544:     # make print-PLIST
                   7545: 
                   7546:   * Reinstall the binary package:
                   7547: 
                   7548:     # pkg_add .../examplepkg.tgz
                   7549: 
                   7550:   * Play with it. Make sure everything works.
                   7551: 
                   7552:   * Run pkglint from pkgtools/pkglint, and fix the problems it reports:
                   7553: 
                   7554:     # pkglint
                   7555: 
1.154     rillig   7556:   * Submit (or commit, if you have cvs access); see Chapter 23, Submitting and
1.1       dsieger  7557:     Committing.
                   7558: 
1.154     rillig   7559: Chapter 23. Submitting and Committing
1.1       dsieger  7560: 
                   7561: Table of Contents
                   7562: 
1.154     rillig   7563: 23.1. Submitting binary packages
                   7564: 23.2. Submitting source packages (for non-NetBSD-developers)
                   7565: 23.3. General notes when adding, updating, or removing packages
                   7566: 23.4. Commit Messages
                   7567: 23.5. Committing: Adding a package to CVS
                   7568: 23.6. Updating a package to a newer version
                   7569: 23.7. Renaming a package in pkgsrc
                   7570: 23.8. Moving a package in pkgsrc
1.1       dsieger  7571: 
1.154     rillig   7572: 23.1. Submitting binary packages
1.1       dsieger  7573: 
                   7574: Our policy is that we accept binaries only from pkgsrc developers to guarantee
                   7575: that the packages don't contain any trojan horses etc. This is not to annoy
                   7576: anyone but rather to protect our users! You're still free to put up your
                   7577: home-made binary packages and tell the world where to get them. NetBSD
1.154     rillig   7578: developers doing bulk builds and wanting to upload them please see Chapter 8, 
1.66      asau     7579: Creating binary packages for everything in pkgsrc (bulk builds).
1.1       dsieger  7580: 
1.154     rillig   7581: 23.2. Submitting source packages (for non-NetBSD-developers)
1.1       dsieger  7582: 
                   7583: First, check that your package is complete, compiles and runs well; see
1.154     rillig   7584: Chapter 22, Debugging and the rest of this document. Next, generate an
1.1       dsieger  7585: uuencoded gzipped tar(1) archive that contains all files that make up the
                   7586: package. Finally, send this package to the pkgsrc bug tracking system, either
                   7587: with the send-pr(1) command, or if you don't have that, go to the web page
1.174     leot     7588: https://www.NetBSD.org/support/send-pr.html, which contains some instructions
1.22      snj      7589: and a link to a form where you can submit packages. The sysutils/gtk-send-pr
                   7590: package is also available as a substitute for either of the above two tools.
1.1       dsieger  7591: 
                   7592: In the form of the problem report, the category should be "pkg", the synopsis
                   7593: should include the package name and version number, and the description field
                   7594: should contain a short description of your package (contents of the COMMENT
1.25      wiz      7595: variable or DESCR file are OK). The uuencoded package data should go into the "
                   7596: fix" field.
1.1       dsieger  7597: 
                   7598: If you want to submit several packages, please send a separate PR for each one,
                   7599: it's easier for us to track things that way.
                   7600: 
                   7601: Alternatively, you can also import new packages into pkgsrc-wip ("pkgsrc
1.174     leot     7602: work-in-progress"); see the homepage at https://pkgsrc.org/wip/ for details.
1.1       dsieger  7603: 
1.154     rillig   7604: 23.3. General notes when adding, updating, or removing packages
1.1       dsieger  7605: 
                   7606: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
                   7607: CHANGES-YYYY. It's very important to keep this file up to date and conforming
                   7608: to the existing format, because it will be used by scripts to automatically
                   7609: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
                   7610: doc/TODO file and remove the entry for the package you updated or removed, in
                   7611: case it was mentioned there.
                   7612: 
                   7613: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
                   7614: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
                   7615: that result from a dependency being updated should not be mentioned. In all
                   7616: other cases it's the developer's decision.
                   7617: 
                   7618: There is a make target that helps in creating proper CHANGES-YYYY entries: make
                   7619: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
                   7620: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
                   7621: (to avoid having to resolve conflicts later-on) and then to cd to the package
                   7622: directory. For package updates, make changes-entry is enough. For new packages,
                   7623: or package moves or removals, set the CTYPE variable on the command line to
1.4       rillig   7624: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23      jakllsch 7625: your local login name is not the same as your NetBSD login name. The target
                   7626: also automatically removes possibly existing entries for the package in the
                   7627: TODO file. Don't forget to commit the changes, e.g. by using make
1.66      asau     7628: commit-changes-entry! If you are not using a checkout directly from
1.23      jakllsch 7629: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
                   7630: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1       dsieger  7631: 
1.154     rillig   7632: 23.4. Commit Messages
1.130     wiz      7633: 
                   7634: For several years, there have been mirrors of pkgsrc in fossil, git, and hg.
                   7635: Standard practise when using these tools is to make the first line of a commit
                   7636: message function as a summary that can be read without the rest, such as is
                   7637: commonly done with "git log --oneline". For this reason, we have the following
                   7638: guidelines for pkgsrc commit messages:
                   7639: 
1.131     wiz      7640:   * Start the commit message with a line that explains the big picture in 65
1.130     wiz      7641:     characters or less. When a commit is for one package, include the name of
                   7642:     the package. For updates, include the version to which it is updated.
                   7643: 
                   7644:   * Leave the next line empty.
                   7645: 
                   7646:   * Then come the details for the commit (changes in that package, reason for a
                   7647:     change) and any relevant PRs. Wrap this section.
                   7648: 
                   7649: Here is an example:
                   7650: 
                   7651:   libxslt: update to 1.0.30
                   7652: 
                   7653:   Changes since 1.0.29:
                   7654:   ...
                   7655: 
                   7656: 
                   7657: Here is another example:
                   7658: 
                   7659:   mk/bsd.pkg.mk: enable SSP by default on NetBSD
                   7660: 
                   7661:   (rationale)
                   7662: 
                   7663: 
                   7664: Commit messages are final: no "cvs admin" is allowed on the pkgsrc repository
                   7665: to change commit messages.
                   7666: 
1.154     rillig   7667: 23.5. Committing: Adding a package to CVS
1.1       dsieger  7668: 
                   7669: This section is only of interest for pkgsrc developers with write access to the
1.34      wiz      7670: pkgsrc repository.
                   7671: 
                   7672: When the package is finished, "cvs add" the files. Start by adding the
                   7673: directory and then files in the directory. Don't forget to add the new package
                   7674: to the category's Makefile. Make sure you don't forget any files; you can check
                   7675: by running "cvs status". An example:
                   7676: 
                   7677: $ cd .../pkgsrc/category
                   7678: $ cvs add pkgname
                   7679: $ cd pkgname
                   7680: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
                   7681: $ cvs add patches/p*
                   7682: $ cvs status | less
1.35      wiz      7683: $ cvs commit
1.34      wiz      7684: $ cd ..
                   7685: $ vi Makefile # add SUBDIRS+=pkgname line
1.35      wiz      7686: $ cvs commit Makefile
1.66      asau     7687: $ cd pkgname
1.73      jnemeth  7688: $ make CTYPE=Added commit-changes-entry
1.1       dsieger  7689: 
                   7690: The commit message of the initial import should include part of the DESCR file,
                   7691: so people reading the mailing lists know what the package is/does.
                   7692: 
1.34      wiz      7693: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
                   7694: 
                   7695: Previously, "cvs import" was suggested, but it was much easier to get wrong
                   7696: than "cvs add".
1.1       dsieger  7697: 
1.154     rillig   7698: 23.6. Updating a package to a newer version
1.1       dsieger  7699: 
                   7700: Please always put a concise, appropriate and relevant summary of the changes
                   7701: between old and new versions into the commit log when updating a package. There
                   7702: are various reasons for this:
                   7703: 
                   7704:   * A URL is volatile, and can change over time. It may go away completely or
                   7705:     its information may be overwritten by newer information.
                   7706: 
                   7707:   * Having the change information between old and new versions in our CVS
                   7708:     repository is very useful for people who use either cvs or anoncvs.
                   7709: 
                   7710:   * Having the change information between old and new versions in our CVS
                   7711:     repository is very useful for people who read the pkgsrc-changes mailing
                   7712:     list, so that they can make tactical decisions about when to upgrade the
                   7713:     package.
                   7714: 
                   7715: Please also recognize that, just because a new version of a package has been
                   7716: released, it should not automatically be upgraded in the CVS repository. We
                   7717: prefer to be conservative in the packages that are included in pkgsrc -
                   7718: development or beta packages are not really the best thing for most places in
                   7719: which pkgsrc is used. Please use your judgement about what should go into
                   7720: pkgsrc, and bear in mind that stability is to be preferred above new and
                   7721: possibly untested features.
                   7722: 
1.154     rillig   7723: 23.7. Renaming a package in pkgsrc
1.21      snj      7724: 
                   7725: Renaming packages is not recommended.
                   7726: 
1.175     gutterid 7727: When renaming packages, be sure to fix any references to the old name in other
1.21      snj      7728: Makefiles, options, buildlink files, etc.
                   7729: 
1.175     gutterid 7730: Also, when renaming a package, please add the package name and version pattern
1.167     leot     7731: (s) of the previous package to SUPERSEDES. This may be repeated for multiple
                   7732: renames. The new package would be an exact replacement. Example:
                   7733: 
                   7734: SUPERSEDES+=    p5-IO-Compress-Zlib<2.017
                   7735: SUPERSEDES+=    optcomp-[0-9]*
1.21      snj      7736: 
                   7737: Note that "successor" in the CHANGES-YYYY file doesn't necessarily mean that it
                   7738: supersedes, as that successor may not be an exact replacement but is a
                   7739: suggestion for the replaced functionality.
                   7740: 
1.154     rillig   7741: 23.8. Moving a package in pkgsrc
1.21      snj      7742: 
                   7743: It is preferred that packages are not renamed or moved, but if needed please
                   7744: follow these steps.
1.1       dsieger  7745: 
                   7746:  1. Make a copy of the directory somewhere else.
                   7747: 
                   7748:  2. Remove all CVS dirs.
                   7749: 
                   7750:     Alternatively to the first two steps you can also do:
                   7751: 
                   7752:     % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
                   7753: 
                   7754:     and use that for further work.
                   7755: 
1.25      wiz      7756:  3. Fix CATEGORIES and any DEPENDS paths that just did "../package" instead of 
1.1       dsieger  7757:     "../../category/package".
                   7758: 
1.21      snj      7759:  4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
                   7760:     previous category/package pathname. The PREV_PKGPATH can be used by tools
                   7761:     for doing an update using pkgsrc building; for example, it can search the
                   7762:     pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
                   7763:     the corresponding new PKGPATH for that moved package. Note that it may have
                   7764:     multiple matches, so the tool should also check on the PKGBASE too. The
                   7765:     PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
                   7766:     PKGBASE stays the same.
                   7767: 
                   7768:  5. cvs import the modified package in the new place.
1.1       dsieger  7769: 
1.21      snj      7770:  6. Check if any package depends on it:
1.1       dsieger  7771: 
                   7772:     % cd /usr/pkgsrc
                   7773:     % grep /package */*/Makefile* */*/buildlink*
                   7774: 
1.21      snj      7775:  7. Fix paths in packages from step 5 to point to new location.
1.1       dsieger  7776: 
1.21      snj      7777:  8. cvs rm (-f) the package at the old location.
1.1       dsieger  7778: 
1.21      snj      7779:  9. Remove from oldcategory/Makefile.
1.1       dsieger  7780: 
1.21      snj      7781: 10. Add to newcategory/Makefile.
1.1       dsieger  7782: 
1.21      snj      7783: 11. Commit the changed and removed files:
1.1       dsieger  7784: 
                   7785:     % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
                   7786: 
                   7787:     (and any packages from step 5, of course).
                   7788: 
1.154     rillig   7789: Chapter 24. Frequently Asked Questions
1.1       dsieger  7790: 
                   7791: This section contains the answers to questions that may arise when you are
                   7792: writing a package. If you don't find your question answered here, first have a
                   7793: look in the other chapters, and if you still don't have the answer, ask on the
                   7794: pkgsrc-users mailing list.
                   7795: 
1.154     rillig   7796: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
                   7797: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
                   7798: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
                   7799: 24.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1       dsieger  7800:     BUILDLINK_LIBS?
1.154     rillig   7801: 24.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
                   7802: 24.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1       dsieger  7803:     the := inside it.
1.154     rillig   7804: 24.7. Which mailing lists are there for package developers?
                   7805: 24.8. Where is the pkgsrc documentation?
                   7806: 24.9. I have a little time to kill. What shall I do?
1.1       dsieger  7807: 
1.154     rillig   7808: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1       dsieger  7809: 
                   7810:       MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
                   7811:       (1), while MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM
                   7812:       when building the package. [FIXME: What is .MAKEFLAGS for?]
                   7813: 
1.154     rillig   7814: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1       dsieger  7815: 
                   7816:       MAKE is the path to the make(1) program that is used in the pkgsrc
                   7817:       infrastructure. GMAKE is the path to GNU Make, but you need to say
                   7818:       USE_TOOLS+=gmake to use that. MAKE_PROGRAM is the path to the Make
                   7819:       program that is used for building the package.
                   7820: 
1.154     rillig   7821: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1       dsieger  7822: 
                   7823:       CC is the path to the real C compiler, which can be configured by the
                   7824:       pkgsrc user. PKG_CC is the path to the compiler wrapper. PKGSRC_COMPILER
                   7825:       is not a path to a compiler, but the type of compiler that should be
                   7826:       used. See mk/compiler.mk for more information about the latter variable.
                   7827: 
1.154     rillig   7828: 24.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1       dsieger  7829:       BUILDLINK_LIBS?
                   7830: 
                   7831:       [FIXME]
                   7832: 
1.154     rillig   7833: 24.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1       dsieger  7834: 
1.25      wiz      7835:       For optimization reasons, some variables are only available in the "
                   7836:       wrapper" phase and later. To "simulate" the wrapper phase, append 
1.1       dsieger  7837:       PKG_PHASE=wrapper to the above command.
                   7838: 
1.154     rillig   7839: 24.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1       dsieger  7840:       the := inside it.
                   7841: 
1.108     rillig   7842:       The := is not really an assignment operator, although it looks like it.
                   7843:       Instead, it is a degenerate form of ${LIST:old_string=new_string}, which
                   7844:       is documented in the make(1) man page and which is commonly used in the
                   7845:       form ${SRCS:.c=.o}. In the case of MASTER_SITE_*, old_string is the empty
                   7846:       string and new_string is package/. That's where the : and the = fall
                   7847:       together.
1.1       dsieger  7848: 
1.154     rillig   7849: 24.7. Which mailing lists are there for package developers?
1.1       dsieger  7850: 
                   7851:       tech-pkg
                   7852: 
                   7853:           This is a list for technical discussions related to pkgsrc
                   7854:           development, e.g. soliciting feedback for changes to pkgsrc
                   7855:           infrastructure, proposed new features, questions related to porting
                   7856:           pkgsrc to a new platform, advice for maintaining a package, patches
                   7857:           that affect many packages, help requests moved from pkgsrc-users when
                   7858:           an infrastructure bug is found, etc.
                   7859: 
                   7860:       pkgsrc-bugs
                   7861: 
                   7862:           All bug reports in category "pkg" sent with send-pr(1) appear here.
                   7863:           Please do not report your bugs here directly; use one of the other
                   7864:           mailing lists.
                   7865: 
1.154     rillig   7866: 24.8. Where is the pkgsrc documentation?
1.1       dsieger  7867: 
                   7868:       There are many places where you can find documentation about pkgsrc:
                   7869: 
                   7870:         * The pkgsrc guide (this document) is a collection of chapters that
                   7871:           explain large parts of pkgsrc, but some chapters tend to be outdated.
                   7872:           Which ones they are is hard to say.
                   7873: 
1.174     leot     7874:         * On the mailing list archives (see https://mail-index.NetBSD.org/),
                   7875:           you can find discussions about certain features, announcements of new
1.1       dsieger  7876:           parts of the pkgsrc infrastructure and sometimes even announcements
                   7877:           that a certain feature has been marked as obsolete. The benefit here
                   7878:           is that each message has a date appended to it.
                   7879: 
                   7880:         * Many of the files in the mk/ directory start with a comment that
                   7881:           describes the purpose of the file and how it can be used by the
                   7882:           pkgsrc user and package authors. An easy way to find this
                   7883:           documentation is to run bmake help.
                   7884: 
                   7885:         * The CVS log messages are a rich source of information, but they tend
                   7886:           to be highly abbreviated, especially for actions that occur often.
                   7887:           Some contain a detailed description of what has changed, but they are
                   7888:           geared towards the other pkgsrc developers, not towards an average
                   7889:           pkgsrc user. They also only document changes, so if you don't know
                   7890:           what has been before, these messages may not be worth too much to
                   7891:           you.
                   7892: 
                   7893:         * Some parts of pkgsrc are only "implicitly documented", that is the
                   7894:           documentation exists only in the mind of the developer who wrote the
                   7895:           code. To get this information, use the cvs annotate command to see
                   7896:           who has written it and ask on the tech-pkg mailing list, so that
                   7897:           others can find your questions later (see above). To be sure that the
                   7898:           developer in charge reads the mail, you may CC him or her.
                   7899: 
1.154     rillig   7900: 24.9. I have a little time to kill. What shall I do?
1.1       dsieger  7901: 
                   7902:       This is not really an FAQ yet, but here's the answer anyway.
                   7903: 
                   7904:         * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
                   7905:           about newer versions of installed packages that are available, but
                   7906:           not yet updated in pkgsrc.
                   7907: 
                   7908:         * Browse pkgsrc/doc/TODO ? it contains a list of suggested new packages
                   7909:           and a list of cleanups and enhancements for pkgsrc that would be nice
                   7910:           to have.
                   7911: 
1.71      wiz      7912:         * Review packages for which review was requested on the tech-pkg
                   7913:           mailing list.
1.1       dsieger  7914: 
1.154     rillig   7915: Chapter 25. GNOME packaging and porting
1.1       dsieger  7916: 
                   7917: Table of Contents
                   7918: 
1.154     rillig   7919: 25.1. Meta packages
                   7920: 25.2. Packaging a GNOME application
                   7921: 25.3. Updating GNOME to a newer version
                   7922: 25.4. Patching guidelines
1.1       dsieger  7923: 
                   7924: Quoting GNOME's web site:
                   7925: 
                   7926:     The GNOME project provides two things: The GNOME desktop environment, an
                   7927:     intuitive and attractive desktop for users, and the GNOME development
                   7928:     platform, an extensive framework for building applications that integrate
                   7929:     into the rest of the desktop.
                   7930: 
                   7931: pkgsrc provides a seamless way to automatically build and install a complete
                   7932: GNOME environment under many different platforms. We can say with confidence
                   7933: that pkgsrc is one of the most advanced build and packaging systems for GNOME
                   7934: due to its included technologies buildlink3, the wrappers and tools framework
                   7935: and automatic configuration file management. Lots of efforts are put into
                   7936: achieving a completely clean deinstallation of installed software components.
                   7937: 
                   7938: Given that pkgsrc is NetBSD's official packaging system, the above also means
                   7939: that great efforts are put into making GNOME work under this operating system.
                   7940: Recently, DragonFly BSD also adopted pkgsrc as its preferred packaging system,
                   7941: contributing lots of portability fixes to make GNOME build and install under
                   7942: it.
                   7943: 
                   7944: This chapter is aimed at pkgsrc developers and other people interested in
                   7945: helping our GNOME porting and packaging efforts. It provides instructions on
                   7946: how to manage the existing packages and some important information regarding
                   7947: their internals.
                   7948: 
                   7949: We need your help!
                   7950: 
                   7951: Should you have some spare cycles to devote to NetBSD, pkgsrc and GNOME and are
                   7952: willing to learn new exciting stuff, please jump straight to the pending work
                   7953: list! There is still a long way to go to get a fully-functional GNOME desktop
                   7954: under NetBSD and we need your help to achieve it!
                   7955: 
1.154     rillig   7956: 25.1. Meta packages
1.1       dsieger  7957: 
                   7958: pkgsrc includes three GNOME-related meta packages:
                   7959: 
                   7960:   * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
                   7961:     includes the necessary bits to get it to boot correctly, although it may
                   7962:     lack important functionality for daily operation. The idea behind this
                   7963:     package is to let end users build their own configurations on top of this
                   7964:     one, first installing this meta package to achieve a functional setup and
                   7965:     then adding individual applications.
                   7966: 
                   7967:   * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
                   7968:     desktop as defined by the GNOME project; this is based on the components
                   7969:     distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
                   7970:     directories of the official FTP server. Developer-only tools found in those
                   7971:     directories are not installed unless required by some other component to
                   7972:     work properly. Similarly, packages from the bindings set (bindings/x.y/
                   7973:     x.y.z/sources) are not pulled in unless required as a dependency for an
                   7974:     end-user component. This package "extends" meta-pkgs/gnome-base.
                   7975: 
                   7976:   * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
                   7977:     component when fetched from the CVS repository. These are required to let
                   7978:     the autogen.sh scripts work appropriately.
                   7979: 
                   7980: In all these packages, the DEPENDS lines are sorted in a way that eases
                   7981: updates: a package may depend on other packages listed before it but not on any
1.25      wiz      7982: listed after it. It is very important to keep this order to ease updates so... 
1.1       dsieger  7983: do not change it to alphabetical sorting!
                   7984: 
1.154     rillig   7985: 25.2. Packaging a GNOME application
1.1       dsieger  7986: 
                   7987: Almost all GNOME applications are written in C and use a common set of tools as
                   7988: their build system. Things get different with the new bindings to other
                   7989: languages (such as Python), but the following will give you a general idea on
                   7990: the minimum required tools:
                   7991: 
                   7992:   * Almost all GNOME applications use the GNU Autotools as their build system.
                   7993:     As a general rule you will need to tell this to your package:
                   7994: 
                   7995:     GNU_CONFIGURE=yes
                   7996:     USE_LIBTOOL=yes
                   7997:     USE_TOOLS+=gmake
                   7998: 
                   7999:   * If the package uses pkg-config to detect dependencies, add this tool to the
                   8000:     list of required utilities:
                   8001: 
                   8002:     USE_TOOLS+=pkg-config
                   8003: 
                   8004:     Also use pkgtools/verifypc at the end of the build process to ensure that
                   8005:     you did not miss to specify any dependency in your package and that the
                   8006:     version requirements are all correct.
                   8007: 
                   8008:   * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
                   8009:     handle dependencies and to force the package to use the latest available
                   8010:     version.
                   8011: 
                   8012:   * If the package uses gtk-doc (a documentation generation utility), do not
                   8013:     add a dependency on it. The tool is rather big and the distfile should come
                   8014:     with pregenerated documentation anyway; if it does not, it is a bug that
                   8015:     you ought to report. For such packages you should disable gtk-doc (unless
                   8016:     it is the default):
                   8017: 
                   8018:     CONFIGURE_ARGS+=--disable-gtk-doc
                   8019: 
                   8020:     The default location of installed HTML files (share/gtk-doc/<package-name>)
                   8021:     is correct and should not be changed unless the package insists on
                   8022:     installing them somewhere else. Otherwise programs as devhelp will not be
                   8023:     able to open them. You can do that with an entry similar to:
                   8024: 
                   8025:     CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...
                   8026: 
                   8027: GNOME uses multiple shared directories and files under the installation prefix
                   8028: to maintain databases. In this context, shared means that those exact same
                   8029: directories and files are used among several different packages, leading to
                   8030: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
                   8031: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
                   8032: your file lists and omitting shared files from them. If you find yourself doing
                   8033: those, your package is most likely incorrect.
                   8034: 
                   8035: The following table lists the common situations that result in using shared
                   8036: directories or files. For each of them, the appropriate solution is given.
1.25      wiz      8037: After applying the solution be sure to regenerate the package's file list with 
1.1       dsieger  8038: make print-PLIST and ensure it is correct.
                   8039: 
1.154     rillig   8040: Table 25.1. PLIST handling for GNOME packages
1.1       dsieger  8041: 
                   8042: +-----------------------------------------------------------------------------+
                   8043: |             If the package...             |             Then...             |
                   8044: |-------------------------------------------+---------------------------------|
1.154     rillig   8045: |                                           |See Section 21.6.10, "Packages   |
1.18      mishka   8046: |Installs OMF files under share/omf.        |installing scrollkeeper/rarian   |
                   8047: |                                           |data files".                     |
1.1       dsieger  8048: |-------------------------------------------+---------------------------------|
1.154     rillig   8049: |Installs icons under the share/icons/      |See Section 21.6.19, "Packages   |
1.1       dsieger  8050: |hicolor hierarchy or updates share/icons/  |installing hicolor theme icons". |
                   8051: |hicolor/icon-theme.cache.                  |                                 |
                   8052: |-------------------------------------------+---------------------------------|
1.154     rillig   8053: |                                           |See Section 21.6.14, "Packages   |
1.1       dsieger  8054: |Installs files under share/mime/packages.  |installing extensions to the MIME|
                   8055: |                                           |database".                       |
                   8056: |-------------------------------------------+---------------------------------|
1.154     rillig   8057: |Installs .desktop files under share/       |See Section 21.6.20, "Packages   |
1.1       dsieger  8058: |applications and these include MIME        |installing desktop files".       |
                   8059: |information.                               |                                 |
                   8060: +-----------------------------------------------------------------------------+
                   8061: 
                   8062: 
1.154     rillig   8063: 25.3. Updating GNOME to a newer version
1.1       dsieger  8064: 
                   8065: When seeing GNOME as a whole, there are two kinds of updates:
                   8066: 
                   8067: Major update
                   8068: 
                   8069:     Given that there is still a very long way for GNOME 3 (if it ever appears),
                   8070:     we consider a major update one that goes from a 2.X version to a 2.Y one,
                   8071:     where Y is even and greater than X. These are hard to achieve because they
                   8072:     introduce lots of changes in the components' code and almost all GNOME
                   8073:     distfiles are updated to newer versions. Some of them can even break API
                   8074:     and ABI compatibility with the previous major version series. As a result,
                   8075:     the update needs to be done all at once to minimize breakage.
                   8076: 
                   8077:     A major update typically consists of around 80 package updates and the
                   8078:     addition of some new ones.
                   8079: 
                   8080: Minor update
                   8081: 
                   8082:     We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
                   8083:     one where Y is greater than X. These are easy to achieve because they do
                   8084:     not update all GNOME components, can be done in an incremental way and do
                   8085:     not break API nor ABI compatibility.
                   8086: 
                   8087:     A minor update typically consists of around 50 package updates, although
                   8088:     the numbers here may vary a lot.
                   8089: 
                   8090: In order to update the GNOME components in pkgsrc to a new stable release
                   8091: (either major or minor), the following steps should be followed:
                   8092: 
                   8093:  1. Get a list of all the tarballs that form the new release by using the
1.19      snj      8094:     following commands. These will leave the full list of the components'
1.1       dsieger  8095:     distfiles into the list.txt file:
                   8096: 
                   8097:     % echo ls "*.tar.bz2" | \
                   8098:         ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
                   8099:         awk '{ print $9 }' >list.txt
                   8100:     % echo ls "*.tar.bz2" | \
                   8101:         ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
                   8102:         awk '{ print $9 }' >>list.txt
                   8103: 
                   8104:  2. Open each meta package's Makefile and bump their version to the release you
                   8105:     are updating them to. The three meta packages should be always consistent
                   8106:     with versioning. Obviously remove any PKGREVISIONs that might be in them.
                   8107: 
                   8108:  3. For each meta package, update all its DEPENDS lines to match the latest
                   8109:     versions as shown by the above commands. Do not list any newer version
                   8110:     (even if found in the FTP) because the meta packages are supposed to list
                   8111:     the exact versions that form a specific GNOME release. Exceptions are
                   8112:     permitted here if a newer version solves a serious issue in the overall
                   8113:     desktop experience; these typically come in the form of a revision bump in
                   8114:     pkgsrc, not in newer versions from the developers.
                   8115: 
                   8116:     Packages not listed in the list.txt file should be updated to the latest
                   8117:     version available (if found in pkgsrc). This is the case, for example, of
                   8118:     the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
                   8119:     package.
                   8120: 
                   8121:  4. Generate a patch from the modified meta packages and extract the list of
                   8122:     "new" lines. This will provide you an outline on what packages need to be
                   8123:     updated in pkgsrc and in what order:
                   8124: 
                   8125:     % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
                   8126: 
                   8127:  5. For major desktop updates it is recommended to zap all your installed
                   8128:     packages and start over from scratch at this point.
                   8129: 
                   8130:  6. Now comes the longest step by far: iterate over the contents of todo.txt
                   8131:     and update the packages listed in it in order. For major desktop updates
                   8132:     none of these should be committed until the entire set is completed because
                   8133:     there are chances of breaking not-yet-updated packages.
                   8134: 
                   8135:  7. Once the packages are up to date and working, commit them to the tree one
                   8136:     by one with appropriate log messages. At the end, commit the three meta
                   8137:     package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
                   8138:     and pkgsrc/doc/TODO files.
                   8139: 
1.154     rillig   8140: 25.4. Patching guidelines
1.1       dsieger  8141: 
                   8142: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
                   8143: it is very important that you always, always, always feed back any portability
                   8144: fixes you do to a GNOME package to the mainstream developers (see
1.154     rillig   8145: Section 13.3.5, "Feedback to the author"). This is the only way to get their
1.1       dsieger  8146: attention on portability issues and to ensure that future versions can be built
                   8147: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
                   8148: updates are. Those developers in charge of issuing major GNOME updates will be
                   8149: grateful if you do that.
                   8150: 
                   8151: The most common places to report bugs are the GNOME's Bugzilla and the
                   8152: freedesktop.org's Bugzilla. Not all components use these to track bugs, but
                   8153: most of them do. Do not be short on your reports: always provide detailed
                   8154: explanations of the current failure, how it can be improved to achieve maximum
                   8155: portability and, if at all possible, provide a patch against CVS head. The more
                   8156: verbose you are, the higher chances of your patch being accepted.
                   8157: 
                   8158: Also, please avoid using preprocessor magic to fix portability issues. While
                   8159: the FreeBSD GNOME people are doing a great job in porting GNOME to their
                   8160: operating system, the official GNOME sources are now plagued by conditionals
                   8161: that check for __FreeBSD__ and similar macros. This hurts portability. Please
1.154     rillig   8162: see our patching guidelines (Section 13.3.4, "Patching guidelines") for more
1.1       dsieger  8163: details.
                   8164: 
                   8165: Part III. The pkgsrc infrastructure internals
                   8166: 
                   8167: This part of the guide deals with everything from the infrastructure that is
                   8168: behind the interfaces described in the developer's guide. A casual package
                   8169: maintainer should not need anything from this part.
                   8170: 
                   8171: Table of Contents
                   8172: 
1.154     rillig   8173: 26. Design of the pkgsrc infrastructure
1.1       dsieger  8174: 
1.154     rillig   8175:     26.1. The meaning of variable definitions
                   8176:     26.2. Avoiding problems before they arise
                   8177:     26.3. Variable evaluation
1.1       dsieger  8178: 
1.154     rillig   8179:         26.3.1. At load time
                   8180:         26.3.2. At runtime
1.1       dsieger  8181: 
1.154     rillig   8182:     26.4. How can variables be specified?
                   8183:     26.5. Designing interfaces for Makefile fragments
1.1       dsieger  8184: 
1.154     rillig   8185:         26.5.1. Procedures with parameters
                   8186:         26.5.2. Actions taken on behalf of parameters
1.1       dsieger  8187: 
1.154     rillig   8188:     26.6. The order in which files are loaded
1.1       dsieger  8189: 
1.154     rillig   8190:         26.6.1. The order in bsd.prefs.mk
                   8191:         26.6.2. The order in bsd.pkg.mk
1.1       dsieger  8192: 
1.154     rillig   8193: 27. Regression tests
1.1       dsieger  8194: 
1.154     rillig   8195:     27.1. Running the regression tests
                   8196:     27.2. Adding a new regression test
1.1       dsieger  8197: 
1.154     rillig   8198:         27.2.1. Overridable functions
                   8199:         27.2.2. Helper functions
1.1       dsieger  8200: 
1.154     rillig   8201: 28. Porting pkgsrc
1.1       dsieger  8202: 
1.154     rillig   8203:     28.1. Porting pkgsrc to a new operating system
1.1       dsieger  8204: 
1.154     rillig   8205: Chapter 26. Design of the pkgsrc infrastructure
1.1       dsieger  8206: 
                   8207: Table of Contents
                   8208: 
1.154     rillig   8209: 26.1. The meaning of variable definitions
                   8210: 26.2. Avoiding problems before they arise
                   8211: 26.3. Variable evaluation
1.1       dsieger  8212: 
1.154     rillig   8213:     26.3.1. At load time
                   8214:     26.3.2. At runtime
1.1       dsieger  8215: 
1.154     rillig   8216: 26.4. How can variables be specified?
                   8217: 26.5. Designing interfaces for Makefile fragments
1.1       dsieger  8218: 
1.154     rillig   8219:     26.5.1. Procedures with parameters
                   8220:     26.5.2. Actions taken on behalf of parameters
1.1       dsieger  8221: 
1.154     rillig   8222: 26.6. The order in which files are loaded
1.1       dsieger  8223: 
1.154     rillig   8224:     26.6.1. The order in bsd.prefs.mk
                   8225:     26.6.2. The order in bsd.pkg.mk
1.1       dsieger  8226: 
                   8227: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
                   8228: fragment needs a properly specified interface. This chapter explains how such
                   8229: an interface looks like.
                   8230: 
1.154     rillig   8231: 26.1. The meaning of variable definitions
1.1       dsieger  8232: 
                   8233: Whenever a variable is defined in the pkgsrc infrastructure, the location and
                   8234: the way of definition provide much information about the intended use of that
                   8235: variable. Additionally, more documentation may be found in a header comment or
                   8236: in this pkgsrc guide.
                   8237: 
                   8238: A special file is mk/defaults/mk.conf, which lists all variables that are
                   8239: intended to be user-defined. They are either defined using the ?= operator or
                   8240: they are left undefined because defining them to anything would effectively
                   8241: mean "yes". All these variables may be overridden by the pkgsrc user in the
                   8242: MAKECONF file.
                   8243: 
                   8244: Outside this file, the following conventions apply: Variables that are defined
                   8245: using the ?= operator may be overridden by a package.
                   8246: 
                   8247: Variables that are defined using the = operator may be used read-only at
                   8248: run-time.
                   8249: 
                   8250: Variables whose name starts with an underscore must not be accessed outside the
                   8251: pkgsrc infrastructure at all. They may change without further notice.
                   8252: 
                   8253: Note
                   8254: 
                   8255: These conventions are currently not applied consistently to the complete pkgsrc
                   8256: infrastructure.
                   8257: 
1.154     rillig   8258: 26.2. Avoiding problems before they arise
1.1       dsieger  8259: 
                   8260: All variables that contain lists of things should default to being empty. Two
                   8261: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
                   8262: variables cannot simply be modified using the += operator in package Makefiles
                   8263: (or other files included by them), since there is no guarantee whether the
                   8264: variable is already set or not, and what its value is. In the case of
                   8265: DISTFILES, the packages "know" the default value and just define it as in the
                   8266: following example.
                   8267: 
                   8268: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   8269: 
                   8270: Because of the selection of this default value, the same value appears in many
                   8271: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
                   8272: value ("c") is so short that it doesn't stand out. Nevertheless it is mentioned
                   8273: in many files.
                   8274: 
1.154     rillig   8275: 26.3. Variable evaluation
1.1       dsieger  8276: 
1.154     rillig   8277: 26.3.1. At load time
1.1       dsieger  8278: 
                   8279: Variable evaluation takes place either at load time or at runtime, depending on
                   8280: the context in which they occur. The contexts where variables are evaluated at
                   8281: load time are:
                   8282: 
                   8283:   * The right hand side of the := and != operators,
                   8284: 
                   8285:   * Make directives like .if or .for,
                   8286: 
                   8287:   * Dependency lines.
                   8288: 
                   8289: A special exception are references to the iteration variables of .for loops,
                   8290: which are expanded inline, no matter in which context they appear.
                   8291: 
                   8292: As the values of variables may change during load time, care must be taken not
                   8293: to evaluate them by accident. Typical examples for variables that should not be
                   8294: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
                   8295: clear, here is an example:
                   8296: 
                   8297: CONFIGURE_ARGS=         # none
                   8298: CFLAGS=                 -O
                   8299: CONFIGURE_ARGS+=        CFLAGS=${CFLAGS:Q}
                   8300: 
                   8301: CONFIGURE_ARGS:=        ${CONFIGURE_ARGS}
                   8302: 
                   8303: CFLAGS+=                -Wall
                   8304: 
                   8305: This code shows how the use of the := operator can quickly lead to unexpected
                   8306: results. The first paragraph is fairly common code. The second paragraph
                   8307: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
                   8308: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
                   8309: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
                   8310: typically occur in completely unrelated files.
                   8311: 
1.154     rillig   8312: 26.3.2. At runtime
1.1       dsieger  8313: 
                   8314: After all the files have been loaded, the values of the variables cannot be
                   8315: changed anymore. Variables that are used in the shell commands are expanded at
                   8316: this point.
                   8317: 
1.154     rillig   8318: 26.4. How can variables be specified?
1.1       dsieger  8319: 
                   8320: There are many ways in which the definition and use of a variable can be
                   8321: restricted in order to detect bugs and violations of the (mostly unwritten)
1.108     rillig   8322: policies. A package can be checked with pkglint -Wall to see whether it meets
                   8323: these rules.
1.1       dsieger  8324: 
1.154     rillig   8325: 26.5. Designing interfaces for Makefile fragments
1.1       dsieger  8326: 
                   8327: Most of the .mk files fall into one of the following classes. Cases where a
                   8328: file falls into more than one class should be avoided as it often leads to
                   8329: subtle bugs.
                   8330: 
1.154     rillig   8331: 26.5.1. Procedures with parameters
1.1       dsieger  8332: 
                   8333: In a traditional imperative programming language some of the .mk files could be
1.23      jakllsch 8334: described as procedures. They take some input parameters and?after
                   8335: inclusion?provide a result in output parameters. Since all variables in
                   8336: Makefiles have global scope care must be taken not to use parameter names that
                   8337: have already another meaning. For example, PKGNAME is a bad choice for a
                   8338: parameter name.
1.1       dsieger  8339: 
                   8340: Procedures are completely evaluated at preprocessing time. That is, when
                   8341: calling a procedure all input parameters must be completely resolvable. For
                   8342: example, CONFIGURE_ARGS should never be an input parameter since it is very
                   8343: likely that further text will be added after calling the procedure, which would
                   8344: effectively apply the procedure to only a part of the variable. Also,
1.108     rillig   8345: references to other variables will be modified after calling the procedure.
1.1       dsieger  8346: 
                   8347: A procedure can declare its output parameters either as suitable for use in
                   8348: preprocessing directives or as only available at runtime. The latter
                   8349: alternative is for variables that contain references to other runtime
                   8350: variables.
                   8351: 
                   8352: Procedures shall be written such that it is possible to call the procedure more
                   8353: than once. That is, the file must not contain multiple-inclusion guards.
                   8354: 
                   8355: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
                   8356: To express that the parameters are evaluated at load time, they should be
                   8357: assigned using the := operator, which should be used only for this purpose.
                   8358: 
1.154     rillig   8359: 26.5.2. Actions taken on behalf of parameters
1.1       dsieger  8360: 
                   8361: Action files take some input parameters and may define runtime variables. They
                   8362: shall not define loadtime variables. There are action files that are included
                   8363: implicitly by the pkgsrc infrastructure, while other must be included
                   8364: explicitly.
                   8365: 
                   8366: An example for action files is mk/subst.mk.
                   8367: 
1.154     rillig   8368: 26.6. The order in which files are loaded
1.1       dsieger  8369: 
                   8370: Package Makefiles usually consist of a set of variable definitions, and include
                   8371: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
                   8372: include various other *.mk files if they need to query the availability of
                   8373: certain features like the type of compiler or the X11 implementation. Due to
                   8374: the heavy use of preprocessor directives like .if and .for, the order in which
                   8375: the files are loaded matters.
                   8376: 
                   8377: This section describes at which point the various files are loaded and gives
                   8378: reasons for that order.
                   8379: 
1.154     rillig   8380: 26.6.1. The order in bsd.prefs.mk
1.1       dsieger  8381: 
                   8382: The very first action in bsd.prefs.mk is to define some essential variables
                   8383: like OPSYS, OS_VERSION and MACHINE_ARCH.
                   8384: 
1.4       rillig   8385: Then, the user settings are loaded from the file specified in MAKECONF, which
                   8386: is usually mk.conf. After that, those variables that have not been overridden
                   8387: by the user are loaded from mk/defaults/mk.conf.
1.1       dsieger  8388: 
                   8389: After the user settings, the system settings and platform settings are loaded,
                   8390: which may override the user settings.
                   8391: 
                   8392: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
                   8393: This only happens when building a package, so the proper variables must be used
                   8394: instead of the direct tool names.
                   8395: 
                   8396: As the last steps, some essential variables from the wrapper and the package
                   8397: system flavor are loaded, as well as the variables that have been cached in
                   8398: earlier phases of a package build.
                   8399: 
1.154     rillig   8400: 26.6.2. The order in bsd.pkg.mk
1.1       dsieger  8401: 
                   8402: First, bsd.prefs.mk is loaded.
                   8403: 
                   8404: Then, the various *-vars.mk files are loaded, which fill default values for
                   8405: those variables that have not been defined by the package. These variables may
                   8406: later be used even in unrelated files.
                   8407: 
                   8408: Then, the file bsd.pkg.error.mk provides the target error-check that is added
                   8409: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
                   8410: DELAYED_WARNING_MSG.
                   8411: 
                   8412: Then, the package-specific hacks from hacks.mk are included.
                   8413: 
                   8414: Then, various other files follow. Most of them don't have any dependencies on
                   8415: what they need to have included before or after them, though some do.
                   8416: 
                   8417: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
                   8418: restricts the use of these variables to all the files that have been included
                   8419: before. Appearances in later files will be silently ignored.
                   8420: 
                   8421: Then, the files for the main targets are included, in the order of later
                   8422: execution, though the actual order should not matter.
                   8423: 
                   8424: At last, some more files are included that don't set any interesting variables
                   8425: but rather just define make targets to be executed.
                   8426: 
1.154     rillig   8427: Chapter 27. Regression tests
1.1       dsieger  8428: 
                   8429: Table of Contents
                   8430: 
1.154     rillig   8431: 27.1. Running the regression tests
                   8432: 27.2. Adding a new regression test
1.1       dsieger  8433: 
1.154     rillig   8434:     27.2.1. Overridable functions
                   8435:     27.2.2. Helper functions
1.1       dsieger  8436: 
                   8437: The pkgsrc infrastructure consists of a large codebase, and there are many
                   8438: corners where every little bit of a file is well thought out, making pkgsrc
                   8439: likely to fail as soon as anything is changed near those parts. To prevent most
                   8440: changes from breaking anything, a suite of regression tests should go along
                   8441: with every important part of the pkgsrc infrastructure. This chapter describes
                   8442: how regression tests work in pkgsrc and how you can add new tests.
                   8443: 
1.154     rillig   8444: 27.1. Running the regression tests
1.1       dsieger  8445: 
1.25      wiz      8446: You first need to install the pkgtools/pkg_regress package, which provides the 
1.1       dsieger  8447: pkg_regress command. Then you can simply run that command, which will run all
1.168     rillig   8448: tests in the regress/ directory.
1.1       dsieger  8449: 
1.154     rillig   8450: 27.2. Adding a new regression test
1.1       dsieger  8451: 
1.168     rillig   8452: Every directory in the regress/ directory that contains a file called spec is
1.1       dsieger  8453: considered a regression test. This file is a shell program that is included by
                   8454: the pkg_regress command. The following functions can be overridden to suit your
                   8455: needs.
                   8456: 
1.154     rillig   8457: 27.2.1. Overridable functions
1.1       dsieger  8458: 
1.108     rillig   8459: These functions do not take any parameters. Although they are called in "set -e
1.168     rillig   8460: " mode, they don't stop at the first failing command. See this Stack Overflow
1.108     rillig   8461: question for details.
1.1       dsieger  8462: 
1.108     rillig   8463: do_setup
1.1       dsieger  8464: 
                   8465:     This function prepares the environment for the test. By default it does
                   8466:     nothing.
                   8467: 
1.108     rillig   8468: do_test
1.1       dsieger  8469: 
                   8470:     This function runs the actual test. By default, it calls TEST_MAKE with the
                   8471:     arguments MAKEARGS_TEST and writes its output including error messages into
                   8472:     the file TEST_OUTFILE.
                   8473: 
1.108     rillig   8474:     When defining this function, make sure that all output that needs to be
                   8475:     checked is written to the correct output file. Example:
                   8476: 
                   8477:     do_test() {
                   8478:             echo "Example output"
                   8479:     } 1>$TEST_OUTFILE 2>&1
                   8480: 
                   8481: check_result
1.1       dsieger  8482: 
                   8483:     This function is run after the test and is typically used to compare the
                   8484:     actual output from the one that is expected. It can make use of the various
1.108     rillig   8485:     helper functions from the next section. Example:
                   8486: 
                   8487:     check_result() {
                   8488:             exit_status 0
                   8489:             output_require "Example"
                   8490:             output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
                   8491:             output_prohibit "no such file or directory"
1.169     rillig   8492:             regress_fail "expected $expected but got $actual for input $input"
1.108     rillig   8493:     }
1.1       dsieger  8494: 
1.108     rillig   8495: do_cleanup
1.1       dsieger  8496: 
                   8497:     This function cleans everything up after the test has been run. By default
                   8498:     it does nothing.
                   8499: 
1.154     rillig   8500: 27.2.2. Helper functions
1.1       dsieger  8501: 
1.168     rillig   8502: regress_fail message...
                   8503: 
                   8504:     This function makes the test fail with the given error message.
                   8505: 
1.108     rillig   8506: exit_status expected
1.1       dsieger  8507: 
1.108     rillig   8508:     This function compares the exitcode of the do_test function with its first
                   8509:     parameter. If they differ, the test will fail.
1.1       dsieger  8510: 
1.108     rillig   8511: output_require regex...
1.1       dsieger  8512: 
                   8513:     This function checks for each of its parameters if the output from do_test
1.108     rillig   8514:     matches the extended regular expression. If it does not, the test will
                   8515:     fail. Example:
                   8516: 
                   8517:     output_require "looks fine"
                   8518:     output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
1.1       dsieger  8519: 
1.177     leot     8520: output_prohibit regex...
1.1       dsieger  8521: 
                   8522:     This function checks for each of its parameters if the output from do_test
                   8523:     () does not match the extended regular expression. If any of the regular
                   8524:     expressions matches, the test will fail.
                   8525: 
1.154     rillig   8526: Chapter 28. Porting pkgsrc
1.1       dsieger  8527: 
                   8528: Table of Contents
                   8529: 
1.154     rillig   8530: 28.1. Porting pkgsrc to a new operating system
1.1       dsieger  8531: 
                   8532: The pkgsrc system has already been ported to many operating systems, hardware
                   8533: architectures and compilers. This chapter explains the necessary steps to make
                   8534: pkgsrc even more portable.
                   8535: 
1.154     rillig   8536: 28.1. Porting pkgsrc to a new operating system
1.1       dsieger  8537: 
                   8538: To port pkgsrc to a new operating system (called MyOS in this example), you
                   8539: need to touch the following files:
                   8540: 
                   8541: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
                   8542: 
                   8543:     This file contains some basic definitions, for example the name of the C
                   8544:     compiler.
                   8545: 
                   8546: mk/bsd.prefs.mk
                   8547: 
                   8548:     Insert code that defines the variables OPSYS, OS_VERSION, LOWER_OS_VERSION,
                   8549:     LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
                   8550:     that appear in this file.
                   8551: 
                   8552: mk/platform/MyOS.mk
                   8553: 
                   8554:     This file contains the platform-specific definitions that are used by
                   8555:     pkgsrc. Start by copying one of the other files and edit it to your needs.
                   8556: 
                   8557: mk/tools/tools.MyOS.mk
                   8558: 
                   8559:     This file defines the paths to all the tools that are needed by one or the
                   8560:     other package in pkgsrc, as well as by pkgsrc itself. Find out where these
                   8561:     tools are on your platform and add them.
                   8562: 
                   8563: Now, you should be able to build some basic packages, like lang/perl5, shells/
                   8564: bash.
                   8565: 
                   8566: Appendix A. A simple example package: bison
                   8567: 
                   8568: Table of Contents
                   8569: 
                   8570: A.1. files
                   8571: 
                   8572:     A.1.1. Makefile
                   8573:     A.1.2. DESCR
                   8574:     A.1.3. PLIST
                   8575:     A.1.4. Checking a package with pkglint
                   8576: 
                   8577: A.2. Steps for building, installing, packaging
                   8578: 
                   8579: We checked to find a piece of software that wasn't in the packages collection,
1.25      wiz      8580: and picked GNU bison. Quite why someone would want to have bison when Berkeley 
1.1       dsieger  8581: yacc is already present in the tree is beyond us, but it's useful for the
                   8582: purposes of this exercise.
                   8583: 
                   8584: A.1. files
                   8585: 
                   8586: A.1.1. Makefile
                   8587: 
1.2       rillig   8588: # $NetBSD$
1.1       dsieger  8589: #
                   8590: 
                   8591: DISTNAME=       bison-1.25
                   8592: CATEGORIES=     devel
1.171     rillig   8593: MASTER_SITES=   ${MASTER_SITE_GNU:=bison/}
1.1       dsieger  8594: 
1.30      dholland 8595: MAINTAINER=     pkgsrc-users@NetBSD.org
1.174     leot     8596: HOMEPAGE=       https://www.gnu.org/software/bison/bison.html
1.1       dsieger  8597: COMMENT=        GNU yacc clone
                   8598: 
                   8599: GNU_CONFIGURE=  yes
1.47      wiz      8600: INFO_FILES=     yes
1.1       dsieger  8601: 
                   8602: .include "../../mk/bsd.pkg.mk"
                   8603: 
                   8604: A.1.2. DESCR
                   8605: 
                   8606: GNU version of yacc.  Can make re-entrant parsers, and numerous other
                   8607: improvements.  Why you would want this when Berkeley yacc(1) is part
                   8608: of the NetBSD source tree is beyond me.
                   8609: 
                   8610: A.1.3. PLIST
                   8611: 
1.2       rillig   8612: @comment $NetBSD$
1.1       dsieger  8613: bin/bison
                   8614: man/man1/bison.1.gz
                   8615: share/bison.simple
                   8616: share/bison.hairy
                   8617: 
                   8618: A.1.4. Checking a package with pkglint
                   8619: 
                   8620: The NetBSD package system comes with pkgtools/pkglint which helps to check the
                   8621: contents of these files. After installation it is quite easy to use, just
1.171     rillig   8622: change to the directory of the package you wish to examine and run pkglint:
1.1       dsieger  8623: 
                   8624: $ pkglint
1.171     rillig   8625: ERROR: Makefile: Each package must define its LICENSE.
                   8626: WARN: Makefile:9: HOMEPAGE should migrate from http to https.
                   8627: NOTE: PLIST:3: The .gz extension is unnecessary for manual pages.
                   8628: WARN: PLIST:5: "share/bison.hairy" should be sorted before "share/bison.simple".
                   8629: 1 error, 2 warnings and 1 note found.
                   8630: (Run "pkglint -e" to show explanations.)
                   8631: (Run "pkglint -fs" to show what can be fixed automatically.)
1.172     rillig   8632: (Run "pkglint -F" to automatically fix some issues.)
1.1       dsieger  8633: 
                   8634: Depending on the supplied command line arguments (see pkglint(1)), more checks
1.170     rillig   8635: will be performed. Use e.g. pkglint -Wall for a very thorough check.
1.1       dsieger  8636: 
                   8637: A.2. Steps for building, installing, packaging
                   8638: 
                   8639: Create the directory where the package lives, plus any auxiliary directories:
                   8640: 
                   8641: # cd /usr/pkgsrc/lang
                   8642: # mkdir bison
                   8643: # cd bison
                   8644: # mkdir patches
                   8645: 
1.154     rillig   8646: Create Makefile, DESCR and PLIST (see Chapter 13, Package components - files,
1.1       dsieger  8647: directories and contents) then continue with fetching the distfile:
                   8648: 
                   8649: # make fetch
                   8650: >> bison-1.25.tar.gz doesn't seem to exist on this system.
                   8651: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
                   8652: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8653: ftp: Error retrieving file: 500 Internal error
                   8654: 
                   8655: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
                   8656: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8657: ftp: Error retrieving file: 500 Internal error
                   8658: 
                   8659: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
                   8660: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8661: Successfully retrieved file.
                   8662: 
                   8663: Generate the checksum of the distfile into distinfo:
                   8664: 
                   8665: # make makedistinfo
                   8666: 
                   8667: Now compile:
                   8668: 
                   8669: # make
                   8670: >> Checksum OK for bison-1.25.tar.gz.
                   8671: ===>  Extracting for bison-1.25
                   8672: ===>  Patching for bison-1.25
                   8673: ===>   Ignoring empty patch directory
                   8674: ===>  Configuring for bison-1.25
                   8675: creating cache ./config.cache
                   8676: checking for gcc... cc
                   8677: checking whether we are using GNU C... yes
                   8678: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
                   8679: checking how to run the C preprocessor... cc -E
                   8680: checking for minix/config.h... no
                   8681: checking for POSIXized ISC... no
                   8682: checking whether cross-compiling... no
                   8683: checking for ANSI C header files... yes
                   8684: checking for string.h... yes
                   8685: checking for stdlib.h... yes
                   8686: checking for memory.h... yes
                   8687: checking for working const... yes
                   8688: checking for working alloca.h... no
                   8689: checking for alloca... yes
                   8690: checking for strerror... yes
                   8691: updating cache ./config.cache
                   8692: creating ./config.status
                   8693: creating Makefile
                   8694: ===>  Building for bison-1.25
                   8695: 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
                   8696: 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
                   8697: 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
                   8698: 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
                   8699: 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
                   8700: 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
                   8701: 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
                   8702: 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
                   8703: 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
                   8704: 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
                   8705: 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
                   8706: 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
                   8707: 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
                   8708: 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
                   8709: 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
                   8710: 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
                   8711: 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
                   8712: 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
                   8713: 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
                   8714: 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
                   8715: 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
                   8716: 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
                   8717: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
                   8718: rm -f bison.s1
                   8719: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
                   8720: 
                   8721: Everything seems OK, so install the files:
                   8722: 
                   8723: # make install
                   8724: >> Checksum OK for bison-1.25.tar.gz.
                   8725: ===>  Installing for bison-1.25
                   8726: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
                   8727: rm -f /usr/pkg/bin/bison
                   8728: cd /usr/pkg/share; rm -f bison.simple bison.hairy
                   8729: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
                   8730: install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
                   8731: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
                   8732: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
                   8733: cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
                   8734: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
                   8735: ===>  Registering installation for bison-1.25
                   8736: 
                   8737: You can now use bison, and also - if you decide so - remove it with pkg_delete
                   8738: bison. Should you decide that you want a binary package, do this now:
                   8739: 
                   8740: # make package
                   8741: >> Checksum OK for bison-1.25.tar.gz.
                   8742: ===>  Building package for bison-1.25
                   8743: Creating package bison-1.25.tgz
                   8744: Registering depends:.
                   8745: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
                   8746: 
                   8747: Now that you don't need the source and object files any more, clean up:
                   8748: 
                   8749: # make clean
                   8750: ===>  Cleaning for bison-1.25
                   8751: 
                   8752: Appendix B. Build logs
                   8753: 
                   8754: Table of Contents
                   8755: 
                   8756: B.1. Building figlet
                   8757: B.2. Packaging figlet
                   8758: 
                   8759: B.1. Building figlet
                   8760: 
                   8761: # make
                   8762: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   8763: => figlet221.tar.gz doesn't seem to exist on this system.
                   8764: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
                   8765: => [172219 bytes]
                   8766: Connected to ftp.plig.net.
                   8767: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
                   8768: 331 Guest login ok, send your complete e-mail address as password.
                   8769: 230-You are user #5 of 500 simultaneous users allowed.
                   8770: 230-
                   8771: 230-  ___ _             _ _
                   8772: 230- |  _| |_ ___   ___| |_|___   ___ ___ ___
                   8773: 230- |  _|  _| . |_| . | | | . |_| . |  _| . |
                   8774: 230- |_| |_| |  _|_|  _|_|_|_  |_|___|_| |_  |
                   8775: 230-         |_|   |_|     |___|         |___|
                   8776: 230-
                   8777: 230-** Welcome to ftp.plig.org **
                   8778: 230-
                   8779: 230-Please note that all transfers from this FTP site are logged. If you
                   8780: 230-do not like this, please disconnect now.
                   8781: 230-
1.19      snj      8782: 230-This archive is available via
1.1       dsieger  8783: 230-
                   8784: 230-HTTP:  http://ftp.plig.org/
                   8785: 230-FTP:   ftp://ftp.plig.org/     (max 500 connections)
                   8786: 230-RSYNC: rsync://ftp.plig.org/   (max  30 connections)
                   8787: 230-
                   8788: 230-Please email comments, bug reports and requests for packages to be
                   8789: 230-mirrored to ftp-admin@plig.org.
                   8790: 230-
                   8791: 230-
                   8792: 230 Logged in anonymously.
                   8793: Remote system type is UNIX.
                   8794: Using binary mode to transfer files.
                   8795: 200 Type okay.
                   8796: 250 "/pub" is new cwd.
                   8797: 250-"/pub/figlet" is new cwd.
                   8798: 250-
                   8799: 250-Welcome to the figlet archive at ftp.figlet.org
                   8800: 250-
                   8801: 250-    ftp://ftp.figlet.org/pub/figlet/
                   8802: 250-
                   8803: 250-The official FIGlet web page is:
                   8804: 250-    http://www.figlet.org/
                   8805: 250-
                   8806: 250-If you have questions, please mailto:info@figlet.org. If you want to
                   8807: 250-contribute a font or something else, you can email us.
                   8808: 250
                   8809: 250 "/pub/figlet/program" is new cwd.
                   8810: 250 "/pub/figlet/program/unix" is new cwd.
                   8811: local: figlet221.tar.gz remote: figlet221.tar.gz
                   8812: 502 Unimplemented command.
                   8813: 227 Entering Passive Mode (195,40,6,41,246,104)
                   8814: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
                   8815: 38% |**************                       | 65800      64.16 KB/s    00:01 ETA
                   8816: 226 Transfer completed.
                   8817: 172219 bytes received in 00:02 (75.99 KB/s)
                   8818: 221 Goodbye.
                   8819: => Checksum OK for figlet221.tar.gz.
                   8820: ===> Extracting for figlet-2.2.1nb2
                   8821: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
                   8822: ===> Patching for figlet-2.2.1nb2
                   8823: ===> Applying pkgsrc patches for figlet-2.2.1nb2
                   8824: ===> Overriding tools for figlet-2.2.1nb2
                   8825: ===> Creating toolchain wrappers for figlet-2.2.1nb2
                   8826: ===> Configuring for figlet-2.2.1nb2
                   8827: ===> Building for figlet-2.2.1nb2
                   8828: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\"  -DDEFAULTFONTFILE=\"standard.flf\"  figlet.c zipio.c crc.c inflate.c -o figlet
                   8829: chmod a+x figlet
                   8830: gcc -O2 -o chkfont chkfont.c
                   8831: => Unwrapping files-to-be-installed.
                   8832: #
                   8833: # make install
                   8834: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   8835: ===> Installing for figlet-2.2.1nb2
                   8836: install -d -o root -g wheel -m 755 /usr/pkg/bin
                   8837: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
                   8838: mkdir -p /usr/pkg/share/figlet
                   8839: cp figlet /usr/pkg/bin
                   8840: cp chkfont /usr/pkg/bin
                   8841: chmod 555 figlist showfigfonts
                   8842: cp figlist /usr/pkg/bin
                   8843: cp showfigfonts /usr/pkg/bin
                   8844: cp fonts/*.flf /usr/pkg/share/figlet
                   8845: cp fonts/*.flc /usr/pkg/share/figlet
                   8846: cp figlet.6 /usr/pkg/man/man6
                   8847: ===> Registering installation for figlet-2.2.1nb2
                   8848: #
                   8849: 
                   8850: B.2. Packaging figlet
                   8851: 
                   8852: # make package
                   8853: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   8854: ===> Packaging figlet-2.2.1nb2
                   8855: ===> Building binary package for figlet-2.2.1nb2
                   8856: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
                   8857: Using SrcDir value of /usr/pkg
                   8858: Registering depends:.
                   8859: #
                   8860: 
                   8861: Appendix C. Directory layout of the pkgsrc FTP server
                   8862: 
                   8863: Table of Contents
                   8864: 
1.23      jakllsch 8865: C.1. distfiles: The distributed source files
                   8866: C.2. misc: Miscellaneous things
                   8867: C.3. packages: Binary packages
                   8868: C.4. reports: Bulk build reports
1.148     leot     8869: C.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  8870: 
                   8871: As in other big projects, the directory layout of pkgsrc is quite complex for
                   8872: newbies. This chapter explains where you find things on the FTP server. The
                   8873: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
                   8874: different, but inside this directory, everything should look the same, no
                   8875: matter on which server you are. This directory contains some subdirectories,
                   8876: which are explained below.
                   8877: 
1.23      jakllsch 8878: C.1. distfiles: The distributed source files
1.1       dsieger  8879: 
                   8880: The directory distfiles contains lots of archive files from all pkgsrc
                   8881: packages, which are mirrored here. The subdirectories are called after their
                   8882: package names and are used when the distributed files have names that don't
                   8883: explicitly contain a version number or are otherwise too generic (for example
                   8884: release.tar.gz).
                   8885: 
1.23      jakllsch 8886: C.2. misc: Miscellaneous things
1.1       dsieger  8887: 
                   8888: This directory contains things that individual pkgsrc developers find worth
                   8889: publishing.
                   8890: 
1.23      jakllsch 8891: C.3. packages: Binary packages
1.1       dsieger  8892: 
1.3       rillig   8893: This directory contains binary packages for the various platforms that are
                   8894: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
                   8895: The meaning of these variables is:
                   8896: 
                   8897:   * OPSYS is the name of the operating system for which the packages have been
1.9       rillig   8898:     built. The name is taken from the output of the uname command, so it may
                   8899:     differ from the one you are used to hear.
1.3       rillig   8900: 
1.8       rillig   8901:   * ARCH is the hardware architecture of the platform for which the packages
1.10      hubertf  8902:     have been built. It also includes the ABI (Application Binary Interface)
                   8903:     for platforms that have several of them.
1.3       rillig   8904: 
1.8       rillig   8905:   * OSVERSION is the version of the operating system. For version numbers that
                   8906:     change often (for example NetBSD-current), the often-changing part should
                   8907:     be replaced with an x, for example 4.99.x.
1.3       rillig   8908: 
1.23      jakllsch 8909:   * TAG is either 20xxQy for a stable branch, or head for packages built from
1.8       rillig   8910:     the HEAD branch. The latter should only be used when the packages are
                   8911:     updated on a regular basis. Otherwise the date from checking out pkgsrc
                   8912:     should be appended, for example head_20071015.
1.3       rillig   8913: 
                   8914: The rationale for exactly this scheme is that the pkgsrc users looking for
                   8915: binary packages can quickly click through the directories on the server and
                   8916: find the best binary packages for their machines. Since they usually know the
                   8917: operating system and the hardware architecture, OPSYS and ARCH are placed
                   8918: first. After these choices, they can select the best combination of OSVERSION
                   8919: and TAG together, since it is usually the case that packages stay compatible
                   8920: between different version of the operating system.
                   8921: 
                   8922: In each of these directories, there is a whole binary packages collection for a
                   8923: specific platform. It has a directory called All which contains all binary
                   8924: packages. Besides that, there are various category directories that contain
                   8925: symbolic links to the real binary packages.
1.1       dsieger  8926: 
1.23      jakllsch 8927: C.4. reports: Bulk build reports
1.8       rillig   8928: 
                   8929: Here are the reports from bulk builds, for those who want to fix packages that
                   8930: didn't build on some of the platforms. The structure of subdirectories should
1.23      jakllsch 8931: look like the one in Section C.3, "packages: Binary packages".
1.8       rillig   8932: 
1.148     leot     8933: C.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  8934: 
                   8935: These directories contain the "real" pkgsrc, that is the files that define how
                   8936: to create binary packages from source archives.
                   8937: 
1.149     leot     8938: Each of the current, stable and pkgsrc-20xxQy directories share the same
                   8939: structure. They each contain a pkgsrc directory and pkgsrc.tar.{bz,gz,xz} file.
                   8940: 
1.1       dsieger  8941: The directory pkgsrc contains a snapshot of the CVS repository, which is
1.149     leot     8942: updated regularly. The file pkgsrc.tar.{bz,gz,xz} contains the same as the
                   8943: directory, ready to be downloaded as a whole.
1.1       dsieger  8944: 
1.149     leot     8945: The current directory contains files related to the HEAD branch of the CVS
                   8946: repository. In this directory there is an additional file called
                   8947: pkgsrc-readmes.tar.{bz,gz,xz} that contains all pkgsrc READMEs with information
                   8948: about categories and packages.
                   8949: 
                   8950: The stable directory is a symlink to the latest pkgsrc-20xxQy.
                   8951: 
                   8952: The pkgsrc-20xxQy. directories contain files related to the -20xxQy stable
                   8953: branch of the CVS repository. In these directories there is an additional file
                   8954: called pkgsrc-20xxQy.tar.{bz,gz,xz}, which contains the state of pkgsrc when it
                   8955: was branched.
1.148     leot     8956: 
1.154     rillig   8957: Appendix D. Help topics
                   8958: 
                   8959: The following list contains all help topics that are available when running 
                   8960: bmake help topic=:index.
                   8961: 
1.178   ! rillig   8962: #!                                   -lintl
        !          8963: 64bit                                ABI
        !          8964: ACCEPTABLE_LICENSES                  ACROREAD_FONTPATH
        !          8965: ADDITIONAL                           AFAIK
        !          8966: AIX                                  ALLOW_VULNERABLE_PACKAGES
        !          8967: ALL_ENV                              ALSA_PC
        !          8968: ALTERNATIVES_SRC                     AMANDA_TMP
        !          8969: AMANDA_USER                          AMANDA_VAR
        !          8970: APACHE_GROUP                         APACHE_MODULE_NAME
        !          8971: APACHE_MODULE_SRC                    APACHE_MODULE_SRCDIR
        !          8972: APACHE_PKG_PREFIX                    APACHE_SUEXEC_CONFIGURE_ARGS
        !          8973: APACHE_SUEXEC_DOCROOT                APACHE_USER
        !          8974: APPEND_ABI                           APPEND_ELF
        !          8975: ARLA_CACHE                           AUDIT_PACKAGES_FLAGS
        !          8976: AUTOCONF_REQD                        AUTOMAKE_OVERRIDE
        !          8977: AUTOMAKE_REQD                        AUTO_MKDIRS
        !          8978: BDB185_DEFAULT                       BDBBASE
        !          8979: BDB_ACCEPTED                         BDB_DEFAULT
        !          8980: BDB_LIBS                             BDB_TYPE
        !          8981: BIND_DIR                             BIND_GROUP
        !          8982: BIND_USER                            BINPKG_SITES
        !          8983: BIN_INSTALL_FLAGS                    BISON_PKGDATADIR
        !          8984: BLAS_ACCEPTED                        BLAS_LIBS
        !          8985: BLAS_TYPE                            BOOTSTRAP_DEPENDS
        !          8986: BOOTSTRAP_SETUPTOOLS                 BROKEN
        !          8987: BROKEN_EXCEPT_ON_PLATFORM            BROKEN_ON_PLATFORM
        !          8988: BSDSRCDIR                            BSDXSRCDIR
        !          8989: BSD_MAKE_ENV                         BUILDLINK_AUTO_DIRS
        !          8990: BUILDLINK_AUTO_VARS                  BUILDLINK_CFLAGS
        !          8991: BUILDLINK_CONTENTS_FILTER            BUILDLINK_CPPFLAGS
        !          8992: BUILDLINK_DEPMETHOD                  BUILDLINK_FILES
        !          8993: BUILDLINK_FILES_CMD                  BUILDLINK_FNAME_TRANSFORM
        !          8994: BUILDLINK_LDFLAGS                    BUILDLINK_LIBS
        !          8995: BUILDLINK_OPSYS_SUPPORT_PTHREAD      BUILDLINK_PKGNAME
        !          8996: BUILDLINK_PREFIX                     BUILDLINK_RPATHDIRS
        !          8997: BUILDLINK_TREE                       BUILD_DEFS
        !          8998: BUILD_DEFS_EFFECTS                   BUILD_DEPENDS
        !          8999: BUILD_DIRS                           BUILD_ENV_SHELL
        !          9000: BUILD_MAKE_CMD                       BUILD_MAKE_FLAGS
        !          9001: BUILD_TARGET                         BUILTIN_FIND_FILES
        !          9002: BUILTIN_FIND_FILES_VAR               BUILTIN_FIND_GREP
        !          9003: BUILTIN_FIND_HEADERS                 BUILTIN_FIND_HEADERS_VAR
        !          9004: BUILTIN_PKG                          BUILTIN_TEST_CURSES_DEFINES
        !          9005: BUILTIN_TEST_CURSES_FUNCS            BUILTIN_VERSION_SCRIPT
        !          9006: BUILTIN_X11_TYPE                     BUILTIN_X11_VERSION
        !          9007: CACTI_GROUP                          CACTI_USER
        !          9008: CANNA_GROUP                          CANNA_USER
        !          9009: CAT                                  CCACHE_BASE
        !          9010: CCACHE_DIR                           CCACHE_LOGFILE
        !          9011: CC_VERSION                           CC_VERSION_STRING
        !          9012: CDRECORD_CONF                        CDROM_PKG_URL_DIR
        !          9013: CDROM_PKG_URL_HOST                   CHECKOUT_DATE
        !          9014: CHECK_FAKEHOME                       CHECK_FILES
        !          9015: CHECK_FILES_SKIP                     CHECK_FILES_STRICT
        !          9016: CHECK_HEADERS                        CHECK_HEADERS_SKIP
        !          9017: CHECK_INTERPRETER                    CHECK_INTERPRETER_SKIP
        !          9018: CHECK_PERMS                          CHECK_PERMS_AUTOFIX
        !          9019: CHECK_PERMS_SKIP                     CHECK_PORTABILITY
        !          9020: CHECK_PORTABILITY_EXPERIMENTAL       CHECK_PORTABILITY_SKIP
        !          9021: CHECK_RELRO                          CHECK_RELRO_SKIP
        !          9022: CHECK_RELRO_SUPPORTED                CHECK_SHLIBS
        !          9023: CHECK_SHLIBS_BLACKLIST               CHECK_SHLIBS_SKIP
        !          9024: CHECK_SHLIBS_SUPPORTED               CHECK_SSP
        !          9025: CHECK_SSP_SKIP                       CHECK_SSP_SUPPORTED
        !          9026: CHECK_STRIPPED                       CHECK_STRIPPED_SKIP
        !          9027: CHECK_WRKREF                         CHECK_WRKREF_EXTRA_DIRS
        !          9028: CHECK_WRKREF_SKIP                    CLAMAV_DBDIR
        !          9029: CLAMAV_GROUP                         CLAMAV_USER
        !          9030: CLANGBASE                            CLEANDEPENDS
        !          9031: CMAKE_DEPENDENCIES_REWRITE           CMAKE_INSTALL_PREFIX
        !          9032: CMAKE_MODULE_PATH_OVERRIDE           CMAKE_PKGSRC_BUILD_FLAGS
        !          9033: CMAKE_PREFIX_PATH                    CMAKE_USE_GNU_INSTALL_DIRS
        !          9034: COMMON_LISP_DOCFILES                 COMMON_LISP_EXAMPLES
        !          9035: COMMON_LISP_EXTRAFILES               COMMON_LISP_PACKAGES
        !          9036: COMMON_LISP_SYSTEM                   COMPILER_RPATH_FLAG
        !          9037: COMPILER_USE_SYMLINKS                CONFIGURE_ARGS
        !          9038: CONFIGURE_DIRS                       CONFIGURE_ENV
        !          9039: CONFIGURE_ENV_SHELL                  CONFIGURE_HAS_INFODIR
        !          9040: CONFIGURE_HAS_MANDIR                 CONFIGURE_SCRIPT
        !          9041: CONFIG_SHELL                         CONFIG_SHELL_FLAGS
        !          9042: CONF_FILES                           CONF_FILES_MODE
        !          9043: CONF_FILES_PERMS                     CONSERVER_DEFAULTHOST
        !          9044: CONSERVER_DEFAULTPORT                CP
        !          9045: CPP                                  CPP_PRECOMP_FLAGS
        !          9046: CREATE_WRKDIR_SYMLINK                CROSSBASE
        !          9047: CTFCONVERT                           CTF_FILES_SKIP
        !          9048: CTF_SUPPORTED                        CTYPE
        !          9049: CUPS_GROUP                           CUPS_SYSTEM_GROUPS
        !          9050: CUPS_USER                            CURSES_DEFAULT
        !          9051: CURSES_TYPE                          CVS_EXTRACTDIR
        !          9052: CVS_MODULE                           CVS_PROJECT
        !          9053: CVS_REPOSITORIES                     CVS_ROOT
        !          9054: CVS_ROOT_GNU                         CVS_ROOT_NONGNU
        !          9055: CVS_ROOT_SOURCEFORGE                 CVS_TAG
        !          9056: CXX                                  CYRUS_GROUP
        !          9057: CYRUS_IDLE                           CYRUS_USER
        !          9058: DAEMONTOOLS_GROUP                    DAEMONTOOLS_LOG_USER
        !          9059: DBUS_GROUP                           DBUS_USER
        !          9060: DEFANG_GROUP                         DEFANG_USER
        !          9061: DEFAULT_ACCEPTABLE_LICENSES          DEFAULT_DISTFILES
        !          9062: DEFAULT_IRC_SERVER                   DEFAULT_SERIAL_DEVICE
        !          9063: DEF_UMASK                            DEINSTALLDEPENDS
        !          9064: DEINSTALL_SRC                        DEINSTALL_TEMPLATES
        !          9065: DELAYED_ERROR_MSG                    DELAYED_WARNING_MSG
        !          9066: DEPENDS                              DEPENDS_TARGET
        !          9067: DEPENDS_TYPE                         DESTDIR
        !          9068: DESTDIR_VARNAME                      DIALER_GROUP
        !          9069: DIGEST_REQD                          DISTDIR
        !          9070: DISTFILES                            DISTINFO_FILE
        !          9071: DISTNAME                             DIST_PATH
        !          9072: DIST_SUBDIR                          DJBDNS_AXFR_USER
        !          9073: DJBDNS_CACHE_USER                    DJBDNS_DJBDNS_GROUP
        !          9074: DJBDNS_LOG_USER                      DJBDNS_RBL_USER
        !          9075: DJBDNS_TINY_USER                     DLOPEN_REQUIRE_PTHREADS
        !          9076: DL_AUTO_VARS                         DL_CFLAGS
        !          9077: DL_LDFLAGS                           DL_LIBS
        !          9078: DNS                                  DOWNLOADED_DISTFILE
        !          9079: DT_LAYOUT                            DYNAMIC_SITES_CMD
        !          9080: DYNAMIC_SITES_SCRIPT                 ECHO
        !          9081: ECHO_N                               ELK_GUI
        !          9082: EMACS_TYPE                           EMULDIR
        !          9083: EMULSUBDIR                           EMULSUBDIRSLASH
        !          9084: EMUL_ARCH                            EMUL_DISTRO
        !          9085: EMUL_EXEC_FMT                        EMUL_IS_NATIVE
        !          9086: EMUL_MODULES                         EMUL_OPSYS
        !          9087: EMUL_PKG_FMT                         EMUL_PLATFORM
        !          9088: EMUL_PLATFORMS                       EMUL_PREFER
        !          9089: EMUL_REQD                            EMUL_TYPE
        !          9090: ERROR_MSG                            EXIM_GROUP
        !          9091: EXIM_USER                            EXPORT_SYMBOLS_LDFLAGS
        !          9092: EXTRACTOR                            EXTRACT_CMD
        !          9093: EXTRACT_CMD_DEFAULT                  EXTRACT_DIR
        !          9094: EXTRACT_ELEMENTS                     EXTRACT_ENV
        !          9095: EXTRACT_ONLY                         EXTRACT_OPTS
        !          9096: EXTRACT_SUFX                         EXTRACT_USING
        !          9097: FAIL                                 FAILOVER_FETCH
        !          9098: FAIL_MSG                             FAKE_NCURSES
        !          9099: FAM                                  FAM_ACCEPTED
        !          9100: FAM_DEFAULT                          FAM_SERVER
        !          9101: FCPATH                               FEATURE_CPPFLAGS
        !          9102: FEATURE_LDFLAGS                      FEATURE_LIBS
        !          9103: FETCH_AFTER_ARGS                     FETCH_BEFORE_ARGS
        !          9104: FETCH_CMD                            FETCH_OUTPUT_ARGS
        !          9105: FETCH_PROXY                          FETCH_RESUME_ARGS
        !          9106: FETCH_USING                          FILES_SUBST
        !          9107: FILES_SUBST_SED                      FIX_SYSTEM_HEADERS
        !          9108: FLUXBOX_USE_GNOME                    FLUXBOX_USE_KDE
        !          9109: FLUXBOX_USE_XFT                      FLUXBOX_USE_XINERAMA
        !          9110: FONTDIR                              FONTS_DIRS
        !          9111: FONTS_VERBOSE                        FOO_HACKS_MK
        !          9112: FOSSIL_EXTRACTDIR                    FOSSIL_REPO
        !          9113: FOSSIL_REPOSITORIES                  FOSSIL_VERSION
        !          9114: FOX_USE_XUNICODE                     FREEWNN_GROUP
        !          9115: FREEWNN_USER                         FTP_PKG_URL_DIR
        !          9116: FTP_PKG_URL_HOST                     GAMEDATAMODE
        !          9117: GAMEDATA_PERMS                       GAMEDIRMODE
        !          9118: GAMEDIR_PERMS                        GAMEGRP
        !          9119: GAMEMODE                             GAMEOWN
        !          9120: GAMES_GROUP                          GAMES_USER
        !          9121: GCC                                  GCCBASE
        !          9122: GCC_REQD                             GCC_VERSION_SUFFIX
        !          9123: GEM_BUILD                            GEM_CLEANBUILD
        !          9124: GEM_CLEANBUILD_EXTENSIONS            GEM_DOCDIR
        !          9125: GEM_EXTSDIR                          GEM_HOME
        !          9126: GEM_KEEPBUILD                        GEM_LIBDIR
        !          9127: GEM_NAME                             GEM_PATH
        !          9128: GEM_SPECFILE                         GENERATE_PLIST
        !          9129: GHOSTSCRIPT_REQD                     GITHUB_PROJECT
        !          9130: GITHUB_RELEASE                       GITHUB_TAG
        !          9131: GITHUB_TYPE                          GITLAB_PROJECT
        !          9132: GITLAB_TAG                           GITLAB_TYPE
        !          9133: GIT_BRANCH                           GIT_ENV
        !          9134: GIT_EXTRACTDIR                       GIT_REPO
        !          9135: GIT_REPOSITORIES                     GIT_REVISION
        !          9136: GIT_TAG                              GNU
        !          9137: GNU_CONFIGURE                        GNU_CONFIGURE_INFODIR
        !          9138: GNU_CONFIGURE_MANDIR                 GNU_CONFIGURE_QUIET
        !          9139: GNU_CONFIGURE_STRICT                 GODEP_REDIRECTS
        !          9140: GO_BUILD_PATTERN                     GO_DEPS
        !          9141: GO_DIST_BASE                         GO_MODULE_FILES
        !          9142: GO_SRCPATH                           GO_VERSION_DEFAULT
        !          9143: GROUP_SPECIFIC_PKGS                  GRUB_NETWORK_CARDS
        !          9144: GRUB_PRESET_COMMAND                  GRUB_SCAN_ARGS
        !          9145: GZIP                                 HASKELL_COMPILER
        !          9146: HASKELL_ENABLE_HADDOCK_DOCUMENTATION HASKELL_ENABLE_LIBRARY_PROFILING
        !          9147: HASKELL_ENABLE_SHARED_LIBRARY        HASKELL_OPTIMIZATION_LEVEL
        !          9148: HAS_CONFIGURE                        HEADER_TEMPLATES
        !          9149: HG_REPO                              HG_REPOSITORIES
        !          9150: HG_TAG                               HOST_PKGTOOLS_ARGS
        !          9151: HOST_SPECIFIC_PKGS                   HOWL_GROUP
        !          9152: HOWL_USER                            ICCBASE
        !          9153: ICECAST_CHROOTDIR                    ICON_THEMES
        !          9154: IDOBASE                              IGNORE_CCACHE
        !          9155: IGNORE_INFO_DIRS                     IGNORE_INTERACTIVE_FETCH
        !          9156: IMAKE                                IMAKEOPTS
        !          9157: IMAKE_MAKE                           IMAKE_MANINSTALL
        !          9158: IMAP_UW_CCLIENT_MBOX_FMT             IMDICTDIR
        !          9159: INCOMPAT_CURSES                      INFO_DIR
        !          9160: INFO_FILES                           INFO_FILES_VERBOSE
        !          9161: INFO_MSG                             INIT_SYSTEM
        !          9162: INN_DATA_DIR                         INN_GROUP
        !          9163: INN_USER                             INSTALLATION_DIRS
        !          9164: INSTALLATION_DIRS_FROM_PLIST         INSTALL_ENV
        !          9165: INSTALL_SH_OVERRIDE                  INSTALL_SRC
        !          9166: INSTALL_TEMPLATES                    INSTALL_UNSTRIPPED
        !          9167: IRCD_HYBRID_IRC_GROUP                IRCD_HYBRID_IRC_USER
        !          9168: IRCD_HYBRID_MAXCONN                  IRCD_HYBRID_NICLEN
        !          9169: IRCD_HYBRID_SYSLOG_EVENTS            IRCD_HYBRID_SYSLOG_FACILITY
        !          9170: IRCD_HYBRID_TOPICLEN                 IRIX
        !          9171: IRRD_USE_PGP                         JABBERD_GROUP
        !          9172: JABBERD_LOGDIR                       JABBERD_PIDDIR
        !          9173: JABBERD_SPOOLDIR                     JABBERD_USER
        !          9174: JAKARTA_HOME                         JAVA_APP_PATH
        !          9175: JAVA_APP_TARGETS                     JAVA_BINPREFIX
        !          9176: JAVA_CLASSPATH                       JAVA_HOME
        !          9177: JAVA_LD_LIBRARY_PATH                 JAVA_NAME
        !          9178: JAVA_UNLIMIT                         JAVA_WRAPPERS
        !          9179: JPEG_ACCEPTED                        JPEG_DEFAULT
        !          9180: KERBEROS                             KERMIT_SUID_UUCP
        !          9181: KJS_USE_PCRE                         KNEWS_DOMAIN_FILE
        !          9182: KNEWS_DOMAIN_NAME                    KRB5_ACCEPTED
        !          9183: KRB5_DEFAULT                         LANGUAGES
        !          9184: LAPACK_LIBS                          LATEX2HTML_ICONPATH
        !          9185: LDCONFIG_ADD_CMD                     LDCONFIG_REMOVE_CMD
        !          9186: LEAFNODE_DATA_DIR                    LEAFNODE_GROUP
        !          9187: LEAFNODE_USER                        LIBDVDCSS_HOMEPAGE
        !          9188: LIBDVDCSS_MASTER_SITES               LIBRSVG_TYPE
        !          9189: LIBTOOL                              LIBTOOLIZE_PLIST
        !          9190: LIBTOOL_M4_OVERRIDE                  LIBUSB_TYPE
        !          9191: LICENSE                              LINKER_RPATH_FLAG
        !          9192: LINK_RPATH_FLAG                      LINUX_BASE_NODEPS
        !          9193: LINUX_BASE_PREFERRED                 LINUX_BASE_REQUIRED
        !          9194: LINUX_LOCALES                        LOCALBASE
        !          9195: LOCALBASE_LOCKTYPE                   LOCALPATCHES
        !          9196: LOVE_DATA                            LOVE_GAME
        !          9197: LOVE_VERSION                         LP64PLATFORMS
        !          9198: MACHINE_PLATFORM                     MAILAGENT_DOMAIN
        !          9199: MAILAGENT_EMAIL                      MAILAGENT_FQDN
        !          9200: MAILAGENT_ORGANIZATION               MAJORDOMO_HOMEDIR
        !          9201: MAJOR_OS_VERSION                     MAKEINFO_ARGS
        !          9202: MAKE_DIRS                            MAKE_DIRS_PERMS
        !          9203: MAKE_ENV                             MAKE_FILE
        !          9204: MAKE_FLAGS                           MAKE_JOBS
        !          9205: MAKE_JOBS_SAFE                       MAKE_PROGRAM
        !          9206: MANINSTALL                           MANZ
        !          9207: MASTER_SITES                         MASTER_SITE_BACKUP
        !          9208: MASTER_SITE_LOCAL                    MASTER_SITE_MOZILLA
        !          9209: MASTER_SITE_OVERRIDE                 MASTER_SITE_PERL_CPAN
        !          9210: MASTER_SORT                          MASTER_SORT_RANDOM
        !          9211: MASTER_SORT_REGEX                    MECAB_CHARSET
        !          9212: MEDIATOMB_GROUP                      MEDIATOMB_USER
        !          9213: MIPSPROBASE                          MIREDO_GROUP
        !          9214: MIREDO_USER                          MISSING_FEATURES
        !          9215: MKDIR                                MLDONKEY_GROUP
        !          9216: MLDONKEY_HOME                        MLDONKEY_USER
        !          9217: MONOTONE_GROUP                       MONOTONE_USER
        !          9218: MOTIFBASE                            MOTIF_TYPE
        !          9219: MOTIF_TYPE_DEFAULT                   MPI_TYPE
        !          9220: MSGFMT_STRIP_MSGCTXT                 MSGFMT_STRIP_MSGID_PLURAL
        !          9221: MTOOLS_ENABLE_FLOPPYD                MUST
        !          9222: MV                                   MYSQL_CHARSET
        !          9223: MYSQL_DATADIR                        MYSQL_EXTRA_CHARSET
        !          9224: MYSQL_GROUP                          MYSQL_PKGSRCDIR
        !          9225: MYSQL_USER                           MYSQL_VERSIONS_ACCEPTED
        !          9226: MYSQL_VERSION_DEFAULT                NAGIOSCMD_GROUP
        !          9227: NAGIOSDIR                            NAGIOS_GROUP
        !          9228: NAGIOS_USER                          NATIVE_APPEND_ABI
        !          9229: NATIVE_APPEND_ELF                    NATIVE_EXEC_FMT
        !          9230: NATIVE_MACHINE_PLATFORM              NATIVE_OBJECT_FMT
        !          9231: NBPAX_PROGRAM_PREFIX                 NETBSD_LOGIN_NAME
        !          9232: NMH_EDITOR                           NMH_MTA
        !          9233: NMH_PAGER                            NOLOGIN
        !          9234: NOTE                                 NOT_FOR_PLATFORM
        !          9235: NOT_PAX_ASLR_SAFE                    NOT_PAX_MPROTECT_SAFE
        !          9236: NO_BUILD                             NO_CHECKSUM
        !          9237: NO_CONFIGURE                         NO_SKIP
        !          9238: NS_PREFERRED                         NULLMAILER_GROUP
        !          9239: NULLMAILER_USER                      OASIS
        !          9240: OASIS_BUILD_ARGS                     OBJHOSTNAME
        !          9241: OBJMACHINE                           OCAML_FINDLIB_DIRS
        !          9242: OCAML_FINDLIB_REGISTER               OCAML_FINDLIB_REGISTER_VERBOSE
        !          9243: OCAML_SITELIBDIR                     OCAML_TOPKG_DOCDIR
        !          9244: OCAML_USE_DUNE                       OCAML_USE_FINDLIB
        !          9245: OCAML_USE_JBUILDER                   OCAML_USE_OASIS
        !          9246: OCAML_USE_OASIS_DYNRUN               OCAML_USE_OPAM
        !          9247: OCAML_USE_OPT_COMPILER               OCAML_USE_TOPKG
        !          9248: OMF                                  ONLY_FOR_COMPILER
        !          9249: ONLY_FOR_PLATFORM                    OPENSSH_CHROOT
        !          9250: OPENSSH_GROUP                        OPENSSH_USER
        !          9251: OPSYS                                OPSYS_EMULDIR
        !          9252: OSS_TYPE                             OSX
        !          9253: OSX_TOLERATE_SDK_SKEW                OS_HAVE_ALSA
        !          9254: OS_HAVE_RCD                          OS_VARIANT
        !          9255: OS_VERSION                           OTF_FONTS_DIR
        !          9256: OVERRIDE_DIRDEPTH                    OVERRIDE_GEMSPEC
        !          9257: OVERRIDE_GNU_CONFIG_SCRIPTS          OVERRIDE_ROCKSPEC
        !          9258: OWN_DIRS                             OWN_DIRS_PERMS
        !          9259: P4GROUP                              P4PORT
        !          9260: P4ROOT                               P4USER
        !          9261: PACKAGES                             PALMOS_DEFAULT_SDK
        !          9262: PAMBASE                              PAM_DEFAULT
        !          9263: PAPERSIZE                            PASSIVE_FETCH
        !          9264: PATCHDIR                             PATCHFILES
        !          9265: PATCH_ARGS                           PATCH_DEBUG
        !          9266: PATCH_DIST_ARGS                      PATCH_DIST_CAT
        !          9267: PATCH_DIST_STRIP                     PATCH_FUZZ_FACTOR
        !          9268: PATCH_STRIP                          PATH
        !          9269: PCCBASE                              PEAR
        !          9270: PEAR_CHANNEL                         PEAR_CHANNEL_ALIAS
        !          9271: PEAR_CHANNEL_VERSION                 PEAR_CMD
        !          9272: PEAR_LIB                             PEAR_PACKAGE_XML
        !          9273: PERL5                                PERL5_CONFIGURE
        !          9274: PERL5_CONFIGURE_DIRS                 PERL5_LDFLAGS
        !          9275: PERL5_LICENSE                        PERL5_MODULE_TYPE
        !          9276: PERL5_PACKLIST                       PERL5_PACKLIST_DIR
        !          9277: PERL5_PERLBASE                       PERL5_SITEBASE
        !          9278: PERL5_USE_PACKLIST                   PERL5_VENDORBASE
        !          9279: PFCTL                                PFVAR_H
        !          9280: PF_VERSION                           PGGROUP
        !          9281: PGHOME                               PGPKGSRCDIR
        !          9282: PGSQL_TYPE                           PGSQL_VERSIONS_ACCEPTED
        !          9283: PGSQL_VERSION_DEFAULT                PGUSER
        !          9284: PG_LIB_EXT                           PHP
        !          9285: PHPCOMMON_MK                         PHPPKGSRCDIR
        !          9286: PHP_BASE_VERS                        PHP_CHECK_INSTALLED
        !          9287: PHP_EXTENSION_DIR                    PHP_INITIAL_TEENY
        !          9288: PHP_PKG_PREFIX                       PHP_VERSION
        !          9289: PHP_VERSIONS_ACCEPTED                PHP_VERSIONS_INCOMPATIBLE
        !          9290: PHP_VERSION_DEFAULT                  PHP_VERSION_REQD
        !          9291: PILRC_USE_GTK                        PKGCONFIG_BASE
        !          9292: PKGCONFIG_FILE                       PKGCONFIG_OVERRIDE
        !          9293: PKGCONFIG_OVERRIDE_STAGE             PKGDIR
        !          9294: PKGGNUDIR                            PKGINFODIR
        !          9295: PKGLOCALEDIR                         PKGMANDIR
        !          9296: PKGNAME                              PKGNAME_REQD
        !          9297: PKGPATH                              PKGREVISION
        !          9298: PKGSRC_BLAS_TYPES                    PKGSRC_CHANGES
        !          9299: PKGSRC_COMPILER                      PKGSRC_KEEP_BIN_PKGS
        !          9300: PKGSRC_LOCKTYPE                      PKGSRC_MAKE_ENV
        !          9301: PKGSRC_MESSAGE_RECIPIENTS            PKGSRC_MKPIE
        !          9302: PKGSRC_MKREPRO                       PKGSRC_RUN_TEST
        !          9303: PKGSRC_SETENV                        PKGSRC_SLEEPSECS
        !          9304: PKGSRC_TODO                          PKGSRC_USE_CTF
        !          9305: PKGSRC_USE_FORTIFY                   PKGSRC_USE_RELRO
        !          9306: PKGSRC_USE_SSP                       PKGSRC_USE_STACK_CHECK
        !          9307: PKGTASKS_DATAFILE                    PKGTOOLS_ARGS
        !          9308: PKGTOOLS_ENV                         PKG_ALTERNATIVES
        !          9309: PKG_APACHE                           PKG_APACHE_ACCEPTED
        !          9310: PKG_APACHE_DEFAULT                   PKG_BEST_EXISTS
        !          9311: PKG_BUILD_OPTIONS                    PKG_COMPRESSION
        !          9312: PKG_CONFIG                           PKG_CONFIG_PERMS
        !          9313: PKG_CREATE_USERGROUP                 PKG_DB_TMPDIR
        !          9314: PKG_DEBUG_LEVEL                      PKG_DEFAULT_OPTIONS
        !          9315: PKG_DESTDIR_SUPPORT                  PKG_DEVELOPER
        !          9316: PKG_DISABLED_OPTIONS                 PKG_FATAL_ERRORS
        !          9317: PKG_FC                               PKG_FILELIST_CMD
        !          9318: PKG_GECOS                            PKG_GID
        !          9319: PKG_GROUPS                           PKG_GROUPS_VARS
        !          9320: PKG_HOME                             PKG_INIT_SCRIPTS
        !          9321: PKG_JAVA_HOME                        PKG_JVM
        !          9322: PKG_JVMS_ACCEPTED                    PKG_JVM_DEFAULT
        !          9323: PKG_LEGACY_OPTIONS                   PKG_LIBTOOL
        !          9324: PKG_OPTIONS                          PKG_OPTIONS_DEPRECATED_WARNINGS
        !          9325: PKG_OPTIONS_LEGACY_OPTS              PKG_OPTIONS_LEGACY_VARS
        !          9326: PKG_OPTIONS_NONEMPTY_SETS            PKG_OPTIONS_OPTIONAL_GROUPS
        !          9327: PKG_OPTIONS_REQUIRED_GROUPS          PKG_OPTIONS_VAR
        !          9328: PKG_PHP                              PKG_PHP_MAJOR_VERS
        !          9329: PKG_PHP_VERSION                      PKG_RCD_SCRIPTS
        !          9330: PKG_REFCOUNT_DBDIR                   PKG_REGISTER_SHELLS
        !          9331: PKG_RESUME_TRANSFERS                 PKG_SHELL
        !          9332: PKG_SUGGESTED_OPTIONS                PKG_SUPPORTED_OPTIONS
        !          9333: PKG_SYSCONFBASE                      PKG_SYSCONFBASEDIR
        !          9334: PKG_SYSCONFDIR                       PKG_SYSCONFDIR_PERMS
        !          9335: PKG_SYSCONFSUBDIR                    PKG_SYSCONFVAR
        !          9336: PKG_TOOLS_BIN                        PKG_UID
        !          9337: PKG_UPDATE_FONTS_DB                  PKG_USERS
        !          9338: PKG_USERS_VARS                       PKG_VERBOSE
        !          9339: PLIST                                PLIST_AWK
        !          9340: PLIST_AWK_ENV                        PLIST_SRC
        !          9341: PLIST_SUBST                          PLIST_TYPE
        !          9342: PLIST_VARS                           POPTOP_USE_MPPE
        !          9343: POSSIBLE_GFORTRAN_VERSION            POST_FETCH_HOOK
        !          9344: PREFER                               PREFER_NATIVE
        !          9345: PREFER_NATIVE_PTHREADS               PREFER_PKGSRC
        !          9346: PREFIX                               PREPEND_PATH
        !          9347: PRE_ROOT_CMD                         PRIVILEGED_STAGES
        !          9348: PS                                   PTHREAD_AUTO_VARS
        !          9349: PTHREAD_CFLAGS                       PTHREAD_LDFLAGS
        !          9350: PTHREAD_LIBS                         PTHREAD_OPTS
        !          9351: PTHREAD_TYPE                         PVM_SSH
        !          9352: PYPKGPREFIX                          PYTHON_FOR_BUILD_ONLY
        !          9353: PYTHON_SELF_CONFLICT                 PYTHON_VERSIONED_DEPENDENCIES
        !          9354: PYTHON_VERSIONS_ACCEPTED             PYTHON_VERSIONS_INCOMPATIBLE
        !          9355: PYTHON_VERSION_DEFAULT               PYTHON_VERSION_REQD
        !          9356: PYVERSSUFFIX                         PY_NO_EGG
        !          9357: QMAILDIR                             QMAIL_ALIAS_USER
        !          9358: QMAIL_DAEMON_USER                    QMAIL_LOG_USER
        !          9359: QMAIL_NOFILES_GROUP                  QMAIL_PASSWD_USER
        !          9360: QMAIL_QMAIL_GROUP                    QMAIL_QUEUE_DIR
        !          9361: QMAIL_QUEUE_EXTRA                    QMAIL_QUEUE_USER
        !          9362: QMAIL_REMOTE_USER                    QMAIL_ROOT_USER
        !          9363: QMAIL_SEND_USER                      QPOPPER_FAC
        !          9364: QPOPPER_SPOOL_DIR                    QPOPPER_USER
        !          9365: RAKE_NAME                            RASMOL_DEPTH
        !          9366: RCD_DIR                              RCD_ORDER
        !          9367: RCD_SCRIPTS                          RCD_SCRIPTS_DIR
        !          9368: RCD_SCRIPTS_EXAMPLEDIR               RCD_SCRIPTS_MODE
        !          9369: RCD_SCRIPTS_SHELL                    RCD_SCRIPT_SRC
        !          9370: RCD_SUBR                             RDOC
        !          9371: READLINE_DEFAULT                     READLINE_TYPE
        !          9372: REAL_ROOT_GROUP                      REAL_ROOT_USER
        !          9373: RECURSIVE_MAKE                       RELAY_CTRL_DIR
        !          9374: REPLACE_AWK                          REPLACE_BASH
        !          9375: REPLACE_CSH                          REPLACE_KSH
        !          9376: REPLACE_PERL                         REPLACE_PERL6
        !          9377: REPLACE_PHP                          REPLACE_PYTHON
        !          9378: REPLACE_RUBY                         REPLACE_RUBY_DIRS
        !          9379: REPLACE_RUBY_PAT                     REPLACE_SH
        !          9380: REPLACE_TEXLUA                       REQD_DIRS
        !          9381: REQD_DIRS_PERMS                      REQD_FILES
        !          9382: REQD_FILES_MODE                      REQD_FILES_PERMS
        !          9383: RESOLV_AUTO_VARS                     RESOLV_LDFLAGS
        !          9384: RESOLV_LIBS                          RM
        !          9385: ROCKSPEC_NAME                        ROCKSPEC_SPECFILE
        !          9386: ROOT_CMD                             ROOT_GROUP
        !          9387: ROOT_USER                            RPCGEN
        !          9388: RPM                                  RPM2PKG_PLIST
        !          9389: RPM2PKG_PREFIX                       RPM2PKG_STAGE
        !          9390: RPM2PKG_STRIP                        RPM2PKG_SUBPREFIX
        !          9391: RPMFILES                             RPMIGNOREPATH
        !          9392: RPM_DB_PREFIX                        RSSH_CVS_PATH
        !          9393: RSSH_RDIST_PATH                      RSSH_RSYNC_PATH
        !          9394: RSSH_SCP_PATH                        RSSH_SFTP_SERVER_PATH
        !          9395: RUBY                                 RUBYGEM
        !          9396: RUBYGEM_NAME                         RUBYGEM_OPTIONS
        !          9397: RUBY_ABI_VERSION                     RUBY_ARCH
        !          9398: RUBY_ARCHINC                         RUBY_ARCHLIB
        !          9399: RUBY_BASE                            RUBY_BASERIDIR
        !          9400: RUBY_BUILD_DOCUMENT                  RUBY_DLEXT
        !          9401: RUBY_DOC                             RUBY_DYNAMIC_DIRS
        !          9402: RUBY_EG                              RUBY_ENCODING_ARG
        !          9403: RUBY_EXTCONF                         RUBY_EXTCONF_CHECK
        !          9404: RUBY_EXTCONF_DEBUG                   RUBY_EXTCONF_MAKEFILE
        !          9405: RUBY_GEM_BASE                        RUBY_INC
        !          9406: RUBY_LIB                             RUBY_LIB_BASE
        !          9407: RUBY_NAME                            RUBY_NOVERSION
        !          9408: RUBY_PKGPREFIX                       RUBY_RAILS
        !          9409: RUBY_RAILS51_VERSION                 RUBY_RAILS52_VERSION
        !          9410: RUBY_RAILS60_VERSION                 RUBY_RAILS_ACCEPTED
        !          9411: RUBY_RAILS_DEFAULT                   RUBY_RAILS_REQD
        !          9412: RUBY_RAILS_STRICT_DEP                RUBY_RIDIR
        !          9413: RUBY_SETUP                           RUBY_SHLIB
        !          9414: RUBY_SHLIBALIAS                      RUBY_SHLIBVER
        !          9415: RUBY_SIMPLE_INSTALL                  RUBY_SITEARCHLIB
        !          9416: RUBY_SITELIB                         RUBY_SITELIB_BASE
        !          9417: RUBY_SITERIDIR                       RUBY_SLEXT
        !          9418: RUBY_SRCDIR                          RUBY_STATICLIB
        !          9419: RUBY_SUFFIX                          RUBY_SYSRIDIR
        !          9420: RUBY_USE_PTHREAD                     RUBY_VENDORARCHLIB
        !          9421: RUBY_VENDORLIB                       RUBY_VENDORLIB_BASE
        !          9422: RUBY_VER                             RUBY_VERSION
        !          9423: RUBY_VERSIONS_ACCEPTED               RUBY_VERSIONS_INCOMPATIBLE
        !          9424: RUBY_VERSION_DEFAULT                 RUBY_VERSION_REQD
        !          9425: RUBY_VER_DIR                         RUN
        !          9426: RUN_LDCONFIG                         SAWFISH_THEMES
        !          9427: SCO                                  SCREWS_GROUP
        !          9428: SCREWS_USER                          SCRIPTS_ENV
        !          9429: SCROLLKEEPER_DATADIR                 SCROLLKEEPER_REBUILDDB
        !          9430: SCROLLKEEPER_UPDATEDB                SDIST_PAWD
        !          9431: SERIAL_DEVICES                       SETGIDGAME
        !          9432: SETGID_GAMES_PERMS                   SETUID_ROOT_PERMS
        !          9433: SH                                   SHLIB
        !          9434: SHORTNAME                            SIGN_PACKAGES
        !          9435: SILC_CLIENT_WITH_PERL                SITE_SPECIFIC_PKGS
        !          9436: SKIP_DEPENDS                         SMF_INSTANCES
        !          9437: SMF_MANIFEST                         SMF_METHODS
        !          9438: SMF_METHOD_SHELL                     SMF_METHOD_SRC
        !          9439: SMF_NAME                             SMF_PREFIX
        !          9440: SMF_SRCDIR                           SNIPROXY_GROUP
        !          9441: SNIPROXY_USER                        SOURCE_BUFFSIZE
        !          9442: SPECIAL_PERMS                        SPECIFIC_PKGS
        !          9443: SSH_SUID                             SSP_SUPPORTED
        !          9444: SSYNC_PAWD                           STEP_MSG
        !          9445: STRIP                                STRIP_DBG
        !          9446: STRIP_DEBUG                          STRIP_DEBUG_SUPPORTED
        !          9447: STRIP_FILES_SKIP                     SU
        !          9448: SUBDIR                               SUBST
        !          9449: SUBST_CLASSES                        SUBST_FILES
        !          9450: SUBST_FILTER_CMD                     SUBST_MESSAGE
        !          9451: SUBST_NOOP_OK                        SUBST_SED
        !          9452: SUBST_SHOW_DIFF                      SUBST_SKIP_TEXT_CHECK
        !          9453: SUBST_STAGE                          SUBST_VARS
        !          9454: SUNWSPROBASE                         SUSE_PREFER
        !          9455: SU_CMD                               SVN_EXTRACTDIR
        !          9456: SVN_REPO                             SVN_REPOSITORIES
        !          9457: SVN_REVISION                         TERMCAP_TYPE
        !          9458: TERMINFO_DEFAULT                     TERMINFO_TYPE
        !          9459: TEST                                 TEST_DEPENDS
        !          9460: TEST_DIRS                            TEST_ENV
        !          9461: TEST_ENV_SHELL                       TEST_MAKE_CMD
        !          9462: TEST_MAKE_FLAGS                      TEST_TARGET
        !          9463: TEXLIVE_IGNORE_PATTERNS              TEXLIVE_REV
        !          9464: TEXLIVE_UNVERSIONED                  TEXMFSITE
        !          9465: TEX_FORMATS                          TEX_HYPHEN_DAT
        !          9466: TEX_HYPHEN_DEF                       TEX_TEXMF_DIRS
        !          9467: THTTPD_LOG_FACILITY                  TO
        !          9468: TOOLS_ALIASES                        TOOLS_ALWAYS_WRAP
        !          9469: TOOLS_ARGS                           TOOLS_BROKEN
        !          9470: TOOLS_CMD                            TOOLS_CREATE
        !          9471: TOOLS_DIR                            TOOLS_FAIL
        !          9472: TOOLS_GNU_MISSING                    TOOLS_LDCONFIG
        !          9473: TOOLS_NOOP                           TOOLS_PATH
        !          9474: TOOLS_SCRIPT                         TOOL_DEPENDS
        !          9475: TTF_FONTDIR                          TTF_FONTS_DIR
        !          9476: TYPE                                 UAC_REQD_EXECS
        !          9477: UCSPI_SSL_GROUP                      UCSPI_SSL_USER
        !          9478: UNLIMIT_RESOURCES                    UNPRIVILEGED
        !          9479: UNPRIVILEGED_GROUP                   UNPRIVILEGED_GROUPS
        !          9480: UNPRIVILEGED_USER                    UNWRAP_FILES
        !          9481: UNWRAP_PATTERNS                      UPDATE_GEMSPEC
        !          9482: UPDATE_TARGET                        URI
        !          9483: USERGROUP_PHASE                      USERPPP_GROUP
        !          9484: USER_SPECIFIC_PKGS                   USE_ABI_DEPENDS
        !          9485: USE_APR                              USE_BSD_MAKEFILE
        !          9486: USE_BUILTIN                          USE_CROSS_COMPILE
        !          9487: USE_CURSES                           USE_CWRAPPERS
        !          9488: USE_DB185                            USE_FEATURES
        !          9489: USE_GAMESGROUP                       USE_GCC_RUNTIME
        !          9490: USE_IMAKE                            USE_JAVA
        !          9491: USE_JAVA2                            USE_LANGUAGES
        !          9492: USE_LIBTOOL                          USE_NATIVE_GCC
        !          9493: USE_NETBSD_REPO                      USE_PKGSRC_GCC
        !          9494: USE_PKGSRC_GCC_RUNTIME               USE_PKGTASKS
        !          9495: USE_PKG_ADMIN_DIGEST                 USE_RUBY_EXTCONF
        !          9496: USE_RUBY_INSTALL                     USE_RUBY_SETUP
        !          9497: USE_RUBY_SETUP_PKG                   USE_TOOLS
        !          9498: UUCP_GROUP                           UUCP_USER
        !          9499: VARBASE                              VARNAME
        !          9500: VIM_EXTRA_OPTS                       WARNING_MSG
        !          9501: WCALC_CGIDIR                         WCALC_CGIPATH
        !          9502: WCALC_HTMLDIR                        WCALC_HTMLPATH
        !          9503: WDM_MANAGERS                         WRAPPER_REORDER_CMDS
        !          9504: WRKDIR                               WRKDIR_BASENAME
        !          9505: WRKDIR_LOCKTYPE                      WRKLOG
        !          9506: WRKOBJDIR                            WRKSRC
        !          9507: X10_PORT                             X11
        !          9508: X11BASE                              X11_PKGSRCDIR
        !          9509: X11_TYPE                             X509_CERTIFICATE
        !          9510: X509_KEY                             XAW_TYPE
        !          9511: XLOCK_DEFAULT_MODE                   XMKMF_FLAGS
        !          9512: XXX                                  XXXX
        !          9513: YES                                  ZSH_STATIC
        !          9514: __stdc__                             _vargroups
        !          9515: accept                               acquire-localbase-lock
        !          9516: acquire-lock                         add
        !          9517: administrator                        alloca
        !          9518: alternatives                         aslr
        !          9519: asprintf                             atlas
        !          9520: autoconf                             automake
        !          9521: autoreconf                           awk
        !          9522: bash                                 big-endian
        !          9523: bin-install                          bind
        !          9524: binpkg-list                          blas
        !          9525: bootstrap-depends                    broken
        !          9526: broken_on_platform                   bsd
        !          9527: bsd.prog.mk                          build
        !          9528: build-env                            buildlink-directories
        !          9529: buildlink-oss-soundcard-h            c
        !          9530: c++                                  ccache
        !          9531: cce                                  cdefs
        !          9532: ceil                                 changes
        !          9533: changes-entry                        changes-entry-noupdate
        !          9534: check                                check-clean
        !          9535: check-files                          check-files-clean
        !          9536: check-vulnerable                     checksum
        !          9537: checksum-phase                       clean
        !          9538: clean-depends                        cleandir
        !          9539: commit                               commit-changes-entry
        !          9540: compact                              compiler
        !          9541: conf                                 config.guess
        !          9542: config.sub                           configuration
        !          9543: configure                            configure-env
        !          9544: configure-help                       configure_args
        !          9545: connect                              cos
        !          9546: cputime                              create-usergroup
        !          9547: csh                                  ctf
        !          9548: cvs                                  debug
        !          9549: declaration                          declare
        !          9550: defined                              depend
        !          9551: dependencies                         depends
        !          9552: depends-checksum                     depends-fetch
        !          9553: deps                                 describe
        !          9554: destdir                              disable
        !          9555: distclean                            distinfo
        !          9556: dl                                   dlopen
        !          9557: do-build                             do-buildlink
        !          9558: do-clean                             do-configure
        !          9559: do-configure-post-hook               do-extract
        !          9560: do-fetch                             do-install
        !          9561: emul                                 emul-distinfo
        !          9562: emul-fetch                           emulation
        !          9563: emulator                             enable
        !          9564: endian                               endif
        !          9565: enomem                               err
        !          9566: errx                                 etc
        !          9567: exp                                  extract-rpm
        !          9568: fabs                                 feature
        !          9569: features                             fetch
        !          9570: fetch-list                           follows
        !          9571: forbids                              form
        !          9572: format                               fortify
        !          9573: fortify_source                       fossil
        !          9574: friend                               fts
        !          9575: fts_close                            fts_open
        !          9576: fts_read                             fts_set
        !          9577: gcc                                  gethostbyaddr
        !          9578: gethostbyname                        gethostbyname2
        !          9579: getopt_long                          getprogname
        !          9580: getservbyname                        getservbyport
        !          9581: getservent                           gettext
        !          9582: git                                  github
        !          9583: gitlab                               glob
        !          9584: gnu                                  gnu_configure_strict
        !          9585: go                                   go-deps
        !          9586: golang                               guess-license
        !          9587: hashbang                             heimdal
        !          9588: help                                 hg
        !          9589: imake                                increment
        !          9590: inet_aton                            interp
        !          9591: interpreter                          intl
        !          9592: iso                                  kerberos
        !          9593: krb                                  krb5
        !          9594: ksh                                  lapack
        !          9595: latex                                libintl_bindtextdomain
        !          9596: libintl_gettext                      libintl_textdomain
        !          9597: libnbcompat                          libs
        !          9598: libtool                              licence
        !          9599: license                              lintl
        !          9600: little-endian                        lock
        !          9601: locking                              lvalue
        !          9602: make                                 makesum
        !          9603: memory                               mercurial
        !          9604: meta                                 meta-package
        !          9605: meta_package                         mit-krb5
        !          9606: mk.conf                              mkl
        !          9607: mount                                mprotect
        !          9608: mremap                               nb
        !          9609: nbcompat                             obstack
        !          9610: obstack_ptr_grow                     occurs
        !          9611: only                                 openblas
        !          9612: options                              options.mk
        !          9613: order                                override
        !          9614: override-intltool                    override-message-intltool
        !          9615: package                              parallel
        !          9616: path                                 pax
        !          9617: paxctl                               pbulk-index
        !          9618: pc                                   perl
        !          9619: perl5                                perms
        !          9620: php                                  pkg-build-options
        !          9621: pkg-config                           pkg_build_options
        !          9622: platform                             plist
        !          9623: post-extract                         post-fetch
        !          9624: post-wrapper                         pre-build-checks-hook
        !          9625: pre-configure                        pre-configure-checks-hook
        !          9626: pre-extract                          pre-fetch
        !          9627: print-go-deps                        print-plist
        !          9628: print-summary-data                   privileged-install-hook
        !          9629: pypi                                 python
        !          9630: readme-all                           recv
        !          9631: recvfrom                             regcomp
        !          9632: release-localbase-lock               release-lock
        !          9633: relro                                rename
        !          9634: reorder                              replace
        !          9635: replace_interpreter                  reproducible
        !          9636: resolv                               root
        !          9637: ruby                                 send
        !          9638: sendfile                             sendto
        !          9639: setenv                               setgid
        !          9640: setprogname                          setuid
        !          9641: sh                                   show
        !          9642: show-all                             show-build-defs
        !          9643: show-depends                         show-deps
        !          9644: show-distfiles                       show-downlevel
        !          9645: show-subdir-var                      show-tools
        !          9646: show-var                             show-vars
        !          9647: snprintf                             socket
        !          9648: ssp                                  st_mode
        !          9649: stage-install                        strcasestr
        !          9650: strict                               strip
        !          9651: strndup                              strnlen
        !          9652: strsep                               subst
        !          9653: substitutions                        subversion
        !          9654: sun                                  sunpro
        !          9655: sunwspro                             svn
        !          9656: symlink                              test
        !          9657: test-env                             tex
        !          9658: texlive                              tmp
        !          9659: tool                                 tools
        !          9660: tools-libtool-m4-override            type
        !          9661: ulimit                               undefined
        !          9662: undo-replace                         unlimit
        !          9663: unprivileged                         unprivileged-install-hook
        !          9664: unstripped                           update
        !          9665: upload                               upload-distfiles
        !          9666: use_tools                            user
        !          9667: utimes                               vasprintf
        !          9668: verbose                              vsnprintf
        !          9669: warn                                 warning
        !          9670: warnings                             warnx
        !          9671: wattr_off                            wattr_on
        !          9672: work                                 wrapper
        !          9673: wrkdir                                
1.154     rillig   9674: 
                   9675: Appendix E. Editing guidelines for the pkgsrc guide
1.1       dsieger  9676: 
                   9677: Table of Contents
                   9678: 
1.154     rillig   9679: E.1. Make targets
                   9680: E.2. Procedure
1.1       dsieger  9681: 
                   9682: This section contains information on editing the pkgsrc guide itself.
                   9683: 
1.154     rillig   9684: E.1. Make targets
1.1       dsieger  9685: 
                   9686: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
                   9687: files are created from it:
                   9688: 
                   9689:   * pkgsrc/doc/pkgsrc.txt
                   9690: 
                   9691:   * pkgsrc/doc/pkgsrc.html
                   9692: 
1.174     leot     9693:   * https://www.NetBSD.org/docs/pkgsrc/
1.1       dsieger  9694: 
1.174     leot     9695:   * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the
                   9696:     pkgsrc guide.
1.1       dsieger  9697: 
1.174     leot     9698:   * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
1.2       rillig   9699:     pkgsrc guide.
1.1       dsieger  9700: 
1.154     rillig   9701: E.2. Procedure
1.1       dsieger  9702: 
                   9703: The procedure to edit the pkgsrc guide is:
                   9704: 
                   9705:  1. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46      obache   9706:     other XML-based NetBSD documentation) installed. These are automatically
                   9707:     installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1       dsieger  9708: 
                   9709:  2. Run cd doc/guide to get to the right directory. All further steps will take
                   9710:     place here.
                   9711: 
                   9712:  3. Edit the XML file(s) in files/.
                   9713: 
                   9714:  4. Run bmake to check the pkgsrc guide for valid XML and to build the final
                   9715:     output files. If you get any errors at this stage, you can just edit the
                   9716:     files, as there are only symbolic links in the working directory, pointing
                   9717:     to the files in files/.
                   9718: 
                   9719:  5. (cd files && cvs commit)
                   9720: 
                   9721:  6. Run bmake clean && bmake to regenerate the output files with the proper RCS
                   9722:     Ids.
                   9723: 
                   9724:  7. Run bmake regen to install and commit the files in both pkgsrc/doc and
                   9725:     htdocs.
                   9726: 
                   9727:     Note
                   9728: 
                   9729:     If you have added, removed or renamed some chapters, you need to
                   9730:     synchronize them using cvs add or cvs delete in the htdocs directory.
                   9731: 

CVSweb <webmaster@jp.NetBSD.org>