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

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.146     jnemeth    15: Copyright   1994-2019 The NetBSD Foundation, Inc
1.1       dsieger    16: 
1.155     sevan      17: $NetBSD: pkgsrc.xml,v 1.35 2019/04/28 15:22:24 rillig 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
                    110:         8.4. Creating a multiple CD-ROM packages collection
1.6       rillig    111: 
1.154     rillig    112:             8.4.1. Example of cdpack
1.6       rillig    113: 
1.154     rillig    114:     9. Directory layout of the installed files
1.6       rillig    115: 
1.154     rillig    116:         9.1. File system layout in ${LOCALBASE}
                    117:         9.2. File system layout in ${VARBASE}
1.6       rillig    118: 
1.154     rillig    119:     10. Frequently Asked Questions
1.6       rillig    120: 
1.154     rillig    121:         10.1. Are there any mailing lists for pkg-related discussion?
                    122:         10.2. Utilities for package management (pkgtools)
                    123:         10.3. How to use pkgsrc as non-root
                    124:         10.4. How to resume transfers when fetching distfiles?
                    125:         10.5. How can I install/use modular X.org from pkgsrc?
                    126:         10.6. How to fetch files from behind a firewall
                    127:         10.7. How to fetch files from HTTPS sites
                    128:         10.8. How do I tell make fetch to do passive FTP?
                    129:         10.9. How to fetch all distfiles at once
                    130:         10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc"
1.24      wiz       131:             mean?
1.154     rillig    132:         10.11. What does "Could not find bsd.own.mk" mean?
                    133:         10.12. Using 'sudo' with pkgsrc
                    134:         10.13. How do I change the location of configuration files?
                    135:         10.14. Automated security checks
                    136:         10.15. Why do some packages ignore my CFLAGS?
                    137:         10.16. A package does not build. What shall I do?
                    138:         10.17. What does "Makefile appears to contain unresolved cvs/rcs/???
1.24      wiz       139:             merge conflicts" mean?
1.1       dsieger   140: 
                    141: II. The pkgsrc developer's guide
                    142: 
1.154     rillig    143:     11. Getting help
                    144:     12. Creating a new pkgsrc package from scratch
1.1       dsieger   145: 
1.154     rillig    146:         12.1. Common types of packages
1.1       dsieger   147: 
1.154     rillig    148:             12.1.1. Perl modules
                    149:             12.1.2. Python modules and programs
1.1       dsieger   150: 
1.154     rillig    151:         12.2. Examples
1.1       dsieger   152: 
1.154     rillig    153:             12.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger   154: 
1.154     rillig    155:     13. Package components - files, directories and contents
1.1       dsieger   156: 
1.154     rillig    157:         13.1. Makefile
                    158:         13.2. distinfo
                    159:         13.3. patches/*
1.1       dsieger   160: 
1.154     rillig    161:             13.3.1. Structure of a single patch file
                    162:             13.3.2. Creating patch files
                    163:             13.3.3. Sources where the patch files come from
                    164:             13.3.4. Patching guidelines
                    165:             13.3.5. Feedback to the author
1.1       dsieger   166: 
1.154     rillig    167:         13.4. Other mandatory files
                    168:         13.5. Optional files
1.1       dsieger   169: 
1.154     rillig    170:             13.5.1. Files affecting the binary package
                    171:             13.5.2. Files affecting the build process
                    172:             13.5.3. Files affecting nothing at all
1.1       dsieger   173: 
1.154     rillig    174:         13.6. work*
                    175:         13.7. files/*
1.1       dsieger   176: 
1.154     rillig    177:     14. Programming in Makefiles
1.1       dsieger   178: 
1.154     rillig    179:         14.1. Caveats
                    180:         14.2. Makefile variables
1.1       dsieger   181: 
1.154     rillig    182:             14.2.1. Naming conventions
1.1       dsieger   183: 
1.154     rillig    184:         14.3. Code snippets
1.1       dsieger   185: 
1.154     rillig    186:             14.3.1. Adding things to a list
                    187:             14.3.2. Echoing a string exactly as-is
                    188:             14.3.3. Passing CFLAGS to GNU configure scripts
                    189:             14.3.4. Handling possibly empty variables
1.1       dsieger   190: 
1.154     rillig    191:     15. PLIST issues
1.1       dsieger   192: 
1.154     rillig    193:         15.1. RCS ID
                    194:         15.2. Semi-automatic PLIST generation
                    195:         15.3. Tweaking output of make print-PLIST
                    196:         15.4. Variable substitution in PLIST
                    197:         15.5. Man page compression
                    198:         15.6. Changing PLIST source with PLIST_SRC
                    199:         15.7. Platform-specific and differing PLISTs
                    200:         15.8. Build-specific PLISTs
                    201:         15.9. Sharing directories between packages
1.1       dsieger   202: 
1.154     rillig    203:     16. Buildlink methodology
1.1       dsieger   204: 
1.154     rillig    205:         16.1. Converting packages to use buildlink3
                    206:         16.2. Writing buildlink3.mk files
1.1       dsieger   207: 
1.154     rillig    208:             16.2.1. Anatomy of a buildlink3.mk file
                    209:             16.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
1.27      wiz       210:                 BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
1.1       dsieger   211: 
1.154     rillig    212:         16.3. Writing builtin.mk files
1.1       dsieger   213: 
1.154     rillig    214:             16.3.1. Anatomy of a builtin.mk file
                    215:             16.3.2. Global preferences for native or pkgsrc software
1.1       dsieger   216: 
1.154     rillig    217:     17. The pkginstall framework
1.1       dsieger   218: 
1.154     rillig    219:         17.1. Files and directories outside the installation prefix
1.1       dsieger   220: 
1.154     rillig    221:             17.1.1. Directory manipulation
                    222:             17.1.2. File manipulation
1.1       dsieger   223: 
1.154     rillig    224:         17.2. Configuration files
1.1       dsieger   225: 
1.154     rillig    226:             17.2.1. How PKG_SYSCONFDIR is set
                    227:             17.2.2. Telling the software where configuration files are
                    228:             17.2.3. Patching installations
                    229:             17.2.4. Disabling handling of configuration files
1.1       dsieger   230: 
1.154     rillig    231:         17.3. System startup scripts
1.1       dsieger   232: 
1.154     rillig    233:             17.3.1. Disabling handling of system startup scripts
1.1       dsieger   234: 
1.154     rillig    235:         17.4. System users and groups
                    236:         17.5. System shells
1.1       dsieger   237: 
1.154     rillig    238:             17.5.1. Disabling shell registration
1.1       dsieger   239: 
1.154     rillig    240:         17.6. Fonts
1.1       dsieger   241: 
1.154     rillig    242:             17.6.1. Disabling automatic update of the fonts databases
1.1       dsieger   243: 
1.154     rillig    244:     18. Options handling
1.1       dsieger   245: 
1.154     rillig    246:         18.1. Global default options
                    247:         18.2. Converting packages to use bsd.options.mk
                    248:         18.3. Option Names
                    249:         18.4. Determining the options of dependencies
1.1       dsieger   250: 
1.154     rillig    251:     19. The build process
1.1       dsieger   252: 
1.154     rillig    253:         19.1. Introduction
                    254:         19.2. Program location
                    255:         19.3. Directories used during the build process
                    256:         19.4. Running a phase
                    257:         19.5. The fetch phase
1.1       dsieger   258: 
1.154     rillig    259:             19.5.1. What to fetch and where to get it from
                    260:             19.5.2. How are the files fetched?
1.1       dsieger   261: 
1.154     rillig    262:         19.6. The checksum phase
                    263:         19.7. The extract phase
                    264:         19.8. The patch phase
                    265:         19.9. The tools phase
                    266:         19.10. The wrapper phase
                    267:         19.11. The configure phase
                    268:         19.12. The build phase
                    269:         19.13. The test phase
                    270:         19.14. The install phase
                    271:         19.15. The package phase
                    272:         19.16. Cleaning up
                    273:         19.17. Other helpful targets
1.1       dsieger   274: 
1.154     rillig    275:     20. Tools needed for building or running
1.1       dsieger   276: 
1.154     rillig    277:         20.1. Tools for pkgsrc builds
                    278:         20.2. Tools needed by packages
                    279:         20.3. Tools provided by platforms
1.1       dsieger   280: 
1.154     rillig    281:     21. Making your package work
1.1       dsieger   282: 
1.154     rillig    283:         21.1. General operation
1.1       dsieger   284: 
1.154     rillig    285:             21.1.1. How to pull in user-settable variables from mk.conf
                    286:             21.1.2. User interaction
                    287:             21.1.3. Handling licenses
                    288:             21.1.4. Restricted packages
                    289:             21.1.5. Handling dependencies
                    290:             21.1.6. Handling conflicts with other packages
                    291:             21.1.7. Packages that cannot or should not be built
                    292:             21.1.8. Packages which should not be deleted, once installed
                    293:             21.1.9. Handling packages with security problems
                    294:             21.1.10. How to handle incrementing versions when fixing an
1.1       dsieger   295:                 existing package
1.154     rillig    296:             21.1.11. Substituting variable text in the package files (the SUBST
1.1       dsieger   297:                 framework)
                    298: 
1.154     rillig    299:         21.2. The fetch phase
1.1       dsieger   300: 
1.154     rillig    301:             21.2.1. Packages whose distfiles aren't available for plain
1.1       dsieger   302:                 downloading
1.154     rillig    303:             21.2.2. How to handle modified distfiles with the 'old' name
                    304:             21.2.3. Packages hosted on github.com
1.1       dsieger   305: 
1.154     rillig    306:         21.3. The configure phase
1.1       dsieger   307: 
1.154     rillig    308:             21.3.1. Shared libraries - libtool
                    309:             21.3.2. Using libtool on GNU packages that already support libtool
                    310:             21.3.3. GNU Autoconf/Automake
                    311: 
                    312:         21.4. Programming languages
                    313: 
                    314:             21.4.1. C, C++, and Fortran
                    315:             21.4.2. Java
                    316:             21.4.3. Packages containing perl scripts
                    317:             21.4.4. Packages containing shell scripts
                    318:             21.4.5. Other programming languages
                    319: 
                    320:         21.5. The build phase
                    321: 
                    322:             21.5.1. Compiling C and C++ code conditionally
                    323:             21.5.2. How to handle compiler bugs
                    324:             21.5.3. Undefined reference to "..."
                    325:             21.5.4. Running out of memory
                    326: 
                    327:         21.6. The install phase
                    328: 
                    329:             21.6.1. Creating needed directories
                    330:             21.6.2. Where to install documentation
                    331:             21.6.3. Installing highscore files
                    332:             21.6.4. Adding DESTDIR support to packages
                    333:             21.6.5. Packages with hardcoded paths to other interpreters
                    334:             21.6.6. Packages installing perl modules
                    335:             21.6.7. Packages installing info files
                    336:             21.6.8. Packages installing man pages
                    337:             21.6.9. Packages installing GConf data files
                    338:             21.6.10. Packages installing scrollkeeper/rarian data files
                    339:             21.6.11. Packages installing X11 fonts
                    340:             21.6.12. Packages installing GTK2 modules
                    341:             21.6.13. Packages installing SGML or XML data
                    342:             21.6.14. Packages installing extensions to the MIME database
                    343:             21.6.15. Packages using intltool
                    344:             21.6.16. Packages installing startup scripts
                    345:             21.6.17. Packages installing TeX modules
                    346:             21.6.18. Packages supporting running binaries in emulation
                    347:             21.6.19. Packages installing hicolor theme icons
                    348:             21.6.20. Packages installing desktop files
                    349: 
                    350:         21.7. Marking packages as having problems
                    351: 
                    352:     22. Debugging
                    353:     23. Submitting and Committing
                    354: 
                    355:         23.1. Submitting binary packages
                    356:         23.2. Submitting source packages (for non-NetBSD-developers)
                    357:         23.3. General notes when adding, updating, or removing packages
                    358:         23.4. Commit Messages
                    359:         23.5. Committing: Adding a package to CVS
                    360:         23.6. Updating a package to a newer version
                    361:         23.7. Renaming a package in pkgsrc
                    362:         23.8. Moving a package in pkgsrc
                    363: 
                    364:     24. Frequently Asked Questions
                    365:     25. GNOME packaging and porting
                    366: 
                    367:         25.1. Meta packages
                    368:         25.2. Packaging a GNOME application
                    369:         25.3. Updating GNOME to a newer version
                    370:         25.4. Patching guidelines
1.1       dsieger   371: 
                    372: III. The pkgsrc infrastructure internals
                    373: 
1.154     rillig    374:     26. Design of the pkgsrc infrastructure
1.1       dsieger   375: 
1.154     rillig    376:         26.1. The meaning of variable definitions
                    377:         26.2. Avoiding problems before they arise
                    378:         26.3. Variable evaluation
1.1       dsieger   379: 
1.154     rillig    380:             26.3.1. At load time
                    381:             26.3.2. At runtime
1.1       dsieger   382: 
1.154     rillig    383:         26.4. How can variables be specified?
                    384:         26.5. Designing interfaces for Makefile fragments
1.1       dsieger   385: 
1.154     rillig    386:             26.5.1. Procedures with parameters
                    387:             26.5.2. Actions taken on behalf of parameters
1.1       dsieger   388: 
1.154     rillig    389:         26.6. The order in which files are loaded
1.1       dsieger   390: 
1.154     rillig    391:             26.6.1. The order in bsd.prefs.mk
                    392:             26.6.2. The order in bsd.pkg.mk
1.1       dsieger   393: 
1.154     rillig    394:     27. Regression tests
1.1       dsieger   395: 
1.154     rillig    396:         27.1. Running the regression tests
                    397:         27.2. Adding a new regression test
1.1       dsieger   398: 
1.154     rillig    399:             27.2.1. Overridable functions
                    400:             27.2.2. Helper functions
1.1       dsieger   401: 
1.154     rillig    402:     28. Porting pkgsrc
1.1       dsieger   403: 
1.154     rillig    404:         28.1. Porting pkgsrc to a new operating system
1.1       dsieger   405: 
                    406: A. A simple example package: bison
                    407: 
                    408:     A.1. files
                    409: 
                    410:         A.1.1. Makefile
                    411:         A.1.2. DESCR
                    412:         A.1.3. PLIST
                    413:         A.1.4. Checking a package with pkglint
                    414: 
                    415:     A.2. Steps for building, installing, packaging
                    416: 
                    417: B. Build logs
                    418: 
                    419:     B.1. Building figlet
                    420:     B.2. Packaging figlet
                    421: 
                    422: C. Directory layout of the pkgsrc FTP server
                    423: 
1.23      jakllsch  424:     C.1. distfiles: The distributed source files
                    425:     C.2. misc: Miscellaneous things
                    426:     C.3. packages: Binary packages
                    427:     C.4. reports: Bulk build reports
1.148     leot      428:     C.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger   429: 
1.154     rillig    430: D. Help topics
                    431: E. Editing guidelines for the pkgsrc guide
1.1       dsieger   432: 
1.154     rillig    433:     E.1. Make targets
                    434:     E.2. Procedure
1.1       dsieger   435: 
                    436: List of Tables
                    437: 
                    438: 1.1. Platforms supported by pkgsrc
1.154     rillig    439: 13.1. Patching examples
                    440: 25.1. PLIST handling for GNOME packages
1.1       dsieger   441: 
                    442: Chapter 1. What is pkgsrc?
                    443: 
                    444: Table of Contents
                    445: 
                    446: 1.1. Introduction
                    447: 
                    448:     1.1.1. Why pkgsrc?
                    449:     1.1.2. Supported platforms
                    450: 
                    451: 1.2. Overview
                    452: 1.3. Terminology
                    453: 
                    454:     1.3.1. Roles involved in pkgsrc
                    455: 
                    456: 1.4. Typography
                    457: 
                    458: 1.1. Introduction
                    459: 
                    460: There is a lot of software freely available for Unix-based systems, which is
                    461: usually available in form of the source code. Before such software can be used,
                    462: it needs to be configured to the local system, compiled and installed, and this
                    463: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
                    464: some basic commands to handle binary packages, so that not every user has to
                    465: build the packages for himself, which is a time-costly task.
                    466: 
                    467: pkgsrc currently contains several thousand packages, including:
                    468: 
1.104     sevan     469:   * www/apache24 - The Apache web server
1.1       dsieger   470: 
                    471:   * www/firefox - The Firefox web browser
                    472: 
                    473:   * meta-pkgs/gnome - The GNOME Desktop Environment
                    474: 
1.102     ryoon     475:   * meta-pkgs/kde4 - The K Desktop Environment
1.1       dsieger   476: 
1.108     rillig    477: ? just to name a few.
1.1       dsieger   478: 
                    479: pkgsrc has built-in support for handling varying dependencies, such as pthreads
                    480: and X11, and extended features such as IPv6 support on a range of platforms.
                    481: 
                    482: 1.1.1. Why pkgsrc?
                    483: 
                    484: pkgsrc provides the following key features:
                    485: 
                    486:   * Easy building of software from source as well as the creation and
                    487:     installation of binary packages. The source and latest patches are
                    488:     retrieved from a master or mirror download site, checksum verified, then
                    489:     built on your system. Support for binary-only distributions is available
                    490:     for both native platforms and NetBSD emulated platforms.
                    491: 
                    492:   * All packages are installed in a consistent directory tree, including
                    493:     binaries, libraries, man pages and other documentation.
                    494: 
1.104     sevan     495:   * Tracking of package dependencies automatically, including when performing
                    496:     updates, to ensure required packages are installed. The configuration files
                    497:     of various packages are handled automatically during updates, so local
                    498:     changes are preserved.
1.1       dsieger   499: 
                    500:   * Like NetBSD, pkgsrc is designed with portability in mind and consists of
                    501:     highly portable code. This allows the greatest speed of development when
1.26      spz       502:     porting to a new platform. This portability also ensures that pkgsrc is 
1.1       dsieger   503:     consistent across all platforms.
                    504: 
                    505:   * The installation prefix, acceptable software licenses, international
                    506:     encryption requirements and build-time options for a large number of
                    507:     packages are all set in a simple, central configuration file.
                    508: 
                    509:   * The entire source (not including the distribution files) is freely
                    510:     available under a BSD license, so you may extend and adapt pkgsrc to your
                    511:     needs. Support for local packages and patches is available right out of the
                    512:     box, so you can configure it specifically for your environment.
                    513: 
                    514: The following principles are basic to pkgsrc:
                    515: 
                    516:   * "It should only work if it's right." ? That means, if a package contains
                    517:     bugs, it's better to find them and to complain about them rather than to
                    518:     just install the package and hope that it works. There are numerous checks
                    519:     in pkgsrc that try to find such bugs: Static analysis tools (pkgtools/
                    520:     pkglint), build-time checks (portability of shell scripts), and
                    521:     post-installation checks (installed files, references to shared libraries,
                    522:     script interpreters).
                    523: 
                    524:   * "If it works, it should work everywhere" ? Like NetBSD has been ported to
                    525:     many hardware architectures, pkgsrc has been ported to many operating
                    526:     systems. Care is taken that packages behave the same on all platforms.
                    527: 
                    528: 1.1.2. Supported platforms
                    529: 
                    530: pkgsrc consists of both a source distribution and a binary distribution for
                    531: these operating systems. After retrieving the required source or binaries, you
                    532: can be up and running with pkgsrc in just minutes!
                    533: 
                    534: pkgsrc was derived from FreeBSD's ports system, and initially developed for
                    535: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
                    536: platforms:
                    537: 
                    538: Table 1.1. Platforms supported by pkgsrc
                    539: 
1.92      sevan     540: +-----------------------------------------------------------------------------+
                    541: |               Platform               | Date Support  |        Notes         |
                    542: |                                      |     Added     |                      |
                    543: |--------------------------------------+---------------+----------------------|
                    544: |NetBSD                                |   Aug 1997    |                      |
                    545: |--------------------------------------+---------------+----------------------|
                    546: |Solaris                               |   Mar 1999    |README.Solaris        |
                    547: |--------------------------------------+---------------+----------------------|
                    548: |Linux                                 |   Jun 1999    |README.Linux          |
                    549: |--------------------------------------+---------------+----------------------|
1.118     sevan     550: |Darwin / Mac OS X / OS X / macOS      |   Oct 2001    |README.MacOSX         |
1.92      sevan     551: |--------------------------------------+---------------+----------------------|
                    552: |FreeBSD                               |   Nov 2002    |README.FreeBSD        |
                    553: |--------------------------------------+---------------+----------------------|
                    554: |OpenBSD                               |   Nov 2002    |README.OpenBSD        |
                    555: |--------------------------------------+---------------+----------------------|
                    556: |IRIX                                  |   Dec 2002    |README.IRIX           |
                    557: |                                      |               |README.IRIX5.3        |
                    558: |--------------------------------------+---------------+----------------------|
                    559: |BSD/OS                                |   Dec 2003    |                      |
                    560: |--------------------------------------+---------------+----------------------|
                    561: |AIX                                   |   Dec 2003    |README.AIX            |
                    562: |--------------------------------------+---------------+----------------------|
                    563: |Interix (Microsoft Windows Services   |   Mar 2004    |README.Interix        |
                    564: |for Unix)                             |               |                      |
                    565: |--------------------------------------+---------------+----------------------|
                    566: |DragonFlyBSD                          |   Oct 2004    |                      |
                    567: |--------------------------------------+---------------+----------------------|
                    568: |OSF/1                                 |   Nov 2004    |README.OSF1           |
                    569: |--------------------------------------+---------------+----------------------|
                    570: |HP-UX                                 |   Apr 2007    |README.HPUX           |
                    571: |--------------------------------------+---------------+----------------------|
                    572: |Haiku                                 |   Sep 2010    |README.Haiku          |
                    573: |--------------------------------------+---------------+----------------------|
                    574: |MirBSD                                |   Jan 2011    |                      |
                    575: |--------------------------------------+---------------+----------------------|
                    576: |Minix3                                |   Nov 2011    |README.Minix3         |
                    577: |--------------------------------------+---------------+----------------------|
                    578: |Cygwin                                |   Mar 2013    |README.Cygwin         |
                    579: |--------------------------------------+---------------+----------------------|
                    580: |GNU/kFreeBSD                          |   Jul 2013    |README.GNUkFreeBSD    |
1.104     sevan     581: |--------------------------------------+---------------+----------------------|
                    582: |Bitrig                                |   Jun 2014    |README.Bitrig         |
1.92      sevan     583: +-----------------------------------------------------------------------------+
1.1       dsieger   584: 
                    585: 
                    586: 1.2. Overview
                    587: 
                    588: This document is divided into three parts. The first, The pkgsrc user's guide,
                    589: describes how one can use one of the packages in the Package Collection, either
                    590: by installing a precompiled binary package, or by building one's own copy using
                    591: the NetBSD package system. The second part, The pkgsrc developer's guide,
                    592: explains how to prepare a package so it can be easily built by other NetBSD
                    593: users without knowing about the package's building details. The third part, The
                    594: pkgsrc infrastructure internals is intended for those who want to understand
                    595: how pkgsrc is implemented.
                    596: 
                    597: This document is available in various formats: HTML, PDF, PS, TXT.
                    598: 
                    599: 1.3. Terminology
                    600: 
                    601: There has been a lot of talk about "ports", "packages", etc. so far. Here is a
                    602: description of all the terminology used within this document.
                    603: 
                    604: Package
                    605: 
                    606:     A set of files and building instructions that describe what's necessary to
                    607:     build a certain piece of software using pkgsrc. Packages are traditionally
1.123     wiz       608:     stored under /usr/pkgsrc, but may be stored in any location, referred to as
                    609:     PKGSRCDIR.
1.1       dsieger   610: 
                    611: The NetBSD package system
                    612: 
                    613:     This is the former name of "pkgsrc". It is part of the NetBSD operating
                    614:     system and can be bootstrapped to run on non-NetBSD operating systems as
                    615:     well. It handles building (compiling), installing, and removing of
                    616:     packages.
                    617: 
                    618: Distfile
                    619: 
                    620:     This term describes the file or files that are provided by the author of
                    621:     the piece of software to distribute his work. All the changes necessary to
                    622:     build on NetBSD are reflected in the corresponding package. Usually the
                    623:     distfile is in the form of a compressed tar-archive, but other types are
                    624:     possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
                    625: 
                    626: Port
                    627: 
                    628:     This is the term used by FreeBSD and OpenBSD people for what we call a
                    629:     package. In NetBSD terminology, "port" refers to a different architecture.
                    630: 
                    631: Precompiled/binary package
                    632: 
                    633:     A set of binaries built with pkgsrc from a distfile and stuffed together in
                    634:     a single .tgz file so it can be installed on machines of the same machine
                    635:     architecture without the need to recompile. Packages are usually generated
                    636:     in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
                    637: 
                    638:     Sometimes, this is referred to by the term "package" too, especially in the
                    639:     context of precompiled packages.
                    640: 
                    641: Program
                    642: 
                    643:     The piece of software to be installed which will be constructed from all
                    644:     the files in the distfile by the actions defined in the corresponding
                    645:     package.
                    646: 
                    647: 1.3.1. Roles involved in pkgsrc
                    648: 
                    649: pkgsrc users
                    650: 
                    651:     The pkgsrc users are people who use the packages provided by pkgsrc.
                    652:     Typically they are system administrators. The people using the software
                    653:     that is inside the packages (maybe called "end users") are not covered by
                    654:     the pkgsrc guide.
                    655: 
                    656:     There are two kinds of pkgsrc users: Some only want to install pre-built
                    657:     binary packages. Others build the pkgsrc packages from source, either for
                    658:     installing them directly or for building binary packages themselves. For
                    659:     pkgsrc users Part I, "The pkgsrc user's guide" should provide all necessary
                    660:     documentation.
                    661: 
                    662: package maintainers
                    663: 
                    664:     A package maintainer creates packages as described in Part II, "The pkgsrc
                    665:     developer's guide".
                    666: 
                    667: infrastructure developers
                    668: 
                    669:     These people are involved in all those files that live in the mk/ directory
                    670:     and below. Only these people should need to read through Part III, "The
                    671:     pkgsrc infrastructure internals", though others might be curious, too.
                    672: 
                    673: 1.4. Typography
                    674: 
                    675: When giving examples for commands, shell prompts are used to show if the
                    676: command should/can be issued as root, or if "normal" user privileges are
1.115     sevan     677: sufficient. We use a # for root's shell prompt, a % for users' shell prompt,
                    678: assuming they use the C-shell or tcsh and a $ for bourne shell and derivatives.
1.1       dsieger   679: 
                    680: Part I. The pkgsrc user's guide
                    681: 
                    682: Table of Contents
                    683: 
1.154     rillig    684: 2. Getting help
                    685: 3. Where to get pkgsrc and how to keep it up-to-date
1.1       dsieger   686: 
1.154     rillig    687:     3.1. Getting pkgsrc for the first time
1.1       dsieger   688: 
1.154     rillig    689:         3.1.1. As tar archive
                    690:         3.1.2. Via anonymous CVS
1.1       dsieger   691: 
1.154     rillig    692:     3.2. Keeping pkgsrc up-to-date
1.1       dsieger   693: 
1.154     rillig    694:         3.2.1. Via tar files
                    695:         3.2.2. Via CVS
1.1       dsieger   696: 
1.154     rillig    697: 4. Using pkgsrc on systems other than NetBSD
1.1       dsieger   698: 
1.154     rillig    699:     4.1. Binary distribution
                    700:     4.2. Bootstrapping pkgsrc
1.1       dsieger   701: 
1.154     rillig    702: 5. Using pkgsrc
1.1       dsieger   703: 
1.154     rillig    704:     5.1. Using binary packages
1.1       dsieger   705: 
1.154     rillig    706:         5.1.1. Finding binary packages
                    707:         5.1.2. Installing binary packages
                    708:         5.1.3. Deinstalling packages
                    709:         5.1.4. Getting information about installed packages
                    710:         5.1.5. Checking for security vulnerabilities in installed packages
                    711:         5.1.6. Finding if newer versions of your installed packages are in
1.1       dsieger   712:             pkgsrc
1.154     rillig    713:         5.1.7. Other administrative functions
1.1       dsieger   714: 
1.154     rillig    715:     5.2. Building packages from source
1.1       dsieger   716: 
1.154     rillig    717:         5.2.1. Requirements
                    718:         5.2.2. Fetching distfiles
                    719:         5.2.3. How to build and install
1.1       dsieger   720: 
1.154     rillig    721: 6. Configuring pkgsrc
1.1       dsieger   722: 
1.154     rillig    723:     6.1. General configuration
                    724:     6.2. Variables affecting the build process
                    725:     6.3. Variables affecting the installation process
                    726:     6.4. Selecting and configuring the compiler
1.1       dsieger   727: 
1.154     rillig    728:         6.4.1. Selecting the compiler
                    729:         6.4.2. Additional flags to the compiler (CFLAGS)
                    730:         6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger   731: 
1.154     rillig    732:     6.5. Developer/advanced settings
                    733:     6.6. Selecting Build Options
1.1       dsieger   734: 
1.154     rillig    735: 7. Creating binary packages
1.1       dsieger   736: 
1.154     rillig    737:     7.1. Building a single binary package
                    738:     7.2. Settings for creation of binary packages
1.1       dsieger   739: 
1.154     rillig    740: 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig    741: 
1.154     rillig    742:     8.1. Preparations
                    743:     8.2. Running a pbulk-style bulk build
1.6       rillig    744: 
1.154     rillig    745:         8.2.1. Configuration
1.6       rillig    746: 
1.154     rillig    747:     8.3. Requirements of a full bulk build
                    748:     8.4. Creating a multiple CD-ROM packages collection
1.6       rillig    749: 
1.154     rillig    750:         8.4.1. Example of cdpack
1.6       rillig    751: 
1.154     rillig    752: 9. Directory layout of the installed files
1.6       rillig    753: 
1.154     rillig    754:     9.1. File system layout in ${LOCALBASE}
                    755:     9.2. File system layout in ${VARBASE}
1.6       rillig    756: 
1.154     rillig    757: 10. Frequently Asked Questions
1.6       rillig    758: 
1.154     rillig    759:     10.1. Are there any mailing lists for pkg-related discussion?
                    760:     10.2. Utilities for package management (pkgtools)
                    761:     10.3. How to use pkgsrc as non-root
                    762:     10.4. How to resume transfers when fetching distfiles?
                    763:     10.5. How can I install/use modular X.org from pkgsrc?
                    764:     10.6. How to fetch files from behind a firewall
                    765:     10.7. How to fetch files from HTTPS sites
                    766:     10.8. How do I tell make fetch to do passive FTP?
                    767:     10.9. How to fetch all distfiles at once
                    768:     10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
                    769:     10.11. What does "Could not find bsd.own.mk" mean?
                    770:     10.12. Using 'sudo' with pkgsrc
                    771:     10.13. How do I change the location of configuration files?
                    772:     10.14. Automated security checks
                    773:     10.15. Why do some packages ignore my CFLAGS?
                    774:     10.16. A package does not build. What shall I do?
                    775:     10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24      wiz       776:         conflicts" mean?
1.1       dsieger   777: 
1.154     rillig    778: Chapter 2. Getting help
                    779: 
                    780: To get help when using pkgsrc, the definitive source is this document, the
                    781: pkgsrc guide. If you don't find anything here, there are alternatives:
                    782: 
                    783:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
                    784:     Run bmake help topic=? to get help for any topic, such as a variable name
                    785:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                    786:     like strcasecmp or any other topic.
                    787: 
                    788:     The available help topics are listed in Appendix D, Help topics.
                    789: 
                    790:   * The pkgsrc-users mailing list, to which you can subscribe and then ask your
                    791:     questions.
                    792: 
                    793:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                    794:     a specialized chat program such as XChat. Pick any user name and join the
                    795:     channel #pkgsrc.
                    796: 
                    797: Chapter 3. Where to get pkgsrc and how to keep it up-to-date
1.1       dsieger   798: 
                    799: Table of Contents
                    800: 
1.154     rillig    801: 3.1. Getting pkgsrc for the first time
1.1       dsieger   802: 
1.154     rillig    803:     3.1.1. As tar archive
                    804:     3.1.2. Via anonymous CVS
1.1       dsieger   805: 
1.154     rillig    806: 3.2. Keeping pkgsrc up-to-date
1.1       dsieger   807: 
1.154     rillig    808:     3.2.1. Via tar files
                    809:     3.2.2. Via CVS
1.1       dsieger   810: 
                    811: Before you download and extract the files, you need to decide where you want to
                    812: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
                    813: usr/pkgsrc. You are though free to install the sources and binary packages
                    814: wherever you want in your filesystem, provided that the pathname does not
                    815: contain white-space or other characters that are interpreted specially by the
                    816: shell and some other programs. A safe bet is to use only letters, digits,
                    817: underscores and dashes.
                    818: 
1.154     rillig    819: 3.1. Getting pkgsrc for the first time
1.1       dsieger   820: 
1.25      wiz       821: Before you download any pkgsrc files, you should decide whether you want the 
1.1       dsieger   822: current branch or the stable branch. The latter is forked on a quarterly basis
                    823: from the current branch and only gets modified for security updates. The names
                    824: of the stable branches are built from the year and the quarter, for example
1.157     leot      825: 2019Q2.
1.1       dsieger   826: 
                    827: The second step is to decide how you want to download pkgsrc. You can get it as
1.24      wiz       828: a tar file or via CVS. Both ways are described here.
1.1       dsieger   829: 
1.52      asau      830: Note that tar archive contains CVS working copy. Thus you can switch to using
                    831: CVS at any later time.
1.1       dsieger   832: 
1.154     rillig    833: 3.1.1. As tar archive
1.52      asau      834: 
1.151     sevan     835: The primary download location for all pkgsrc files is https://cdn.NetBSD.org/
                    836: pub/pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same
                    837: location). There are a number of subdirectories for different purposes, which
                    838: are described in detail in Appendix C, Directory layout of the pkgsrc FTP
                    839: server.
1.1       dsieger   840: 
1.52      asau      841: The tar archive for the current branch is in the directory current and is
1.118     sevan     842: called pkgsrc.tar.gz. It is autogenerated weekly.
1.52      asau      843: 
                    844: To save download time we provide bzip2- and xz-compressed archives which are
                    845: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
                    846: 
                    847: You can fetch the same files using FTP.
1.1       dsieger   848: 
1.157     leot      849: The tar file for the stable branch 2019Q2 is in the directory pkgsrc-2019Q2 and
1.59      jnemeth   850: is also called pkgsrc.tar.gz.
1.1       dsieger   851: 
1.136     leot      852: To download the latest pkgsrc stable tarball, run:
1.12      weinem    853: 
1.157     leot      854: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2019Q2/pkgsrc.tar.gz
1.12      weinem    855: 
1.78      snj       856: If you prefer, you can also fetch it using "wget", "curl", or your web browser.
1.52      asau      857: 
1.12      weinem    858: Then, extract it with:
                    859: 
1.78      snj       860: $ tar -xzf pkgsrc.tar.gz -C /usr
1.12      weinem    861: 
                    862: This will create the directory pkgsrc/ in /usr/ and all the package source will
                    863: be stored under /usr/pkgsrc/.
                    864: 
                    865: To download pkgsrc-current, run:
                    866: 
                    867: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1       dsieger   868: 
1.154     rillig    869: 3.1.2. Via anonymous CVS
1.1       dsieger   870: 
1.24      wiz       871: To fetch a specific pkgsrc stable branch, run:
1.1       dsieger   872: 
1.157     leot      873: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2019Q2 -P pkgsrc
1.13      weinem    874: 
1.24      wiz       875: This will create the directory pkgsrc/ in your /usr/ directory and all the
                    876: package source will be stored under /usr/pkgsrc/.
                    877: 
                    878: To fetch the pkgsrc current branch, run:
1.1       dsieger   879: 
1.40      wiz       880: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   881: 
1.30      dholland  882: Refer to the list of available mirrors to choose a faster CVS mirror, if
                    883: needed.
1.1       dsieger   884: 
1.24      wiz       885: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1       dsieger   886: 
1.40      wiz       887: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   888: 
1.24      wiz       889: Refer to documentation on your command shell how to set CVS_RSH=ssh
                    890: permanently. For Bourne shells, you can set it in your .profile or better
                    891: globally in /etc/profile:
                    892: 
                    893: # set CVS remote shell command
                    894: CVS_RSH=ssh
                    895: export CVS_RSH
1.12      weinem    896: 
1.13      weinem    897: By default, CVS doesn't do things like most people would expect it to do. But
                    898: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12      weinem    899: directory and saving the following lines to it. This file will save you lots of
                    900: headache and some bug reports, so we strongly recommend it. You can find an
                    901: explanation of this file in the CVS documentation.
1.2       rillig    902: 
                    903: # recommended CVS configuration file from the pkgsrc guide
1.155     sevan     904: cvs -q
1.2       rillig    905: checkout -P
1.4       rillig    906: update -dP
                    907: diff -upN
1.2       rillig    908: rdiff -u
1.24      wiz       909: release -d
1.1       dsieger   910: 
1.154     rillig    911: 3.2. Keeping pkgsrc up-to-date
1.1       dsieger   912: 
                    913: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
                    914: have first installed it via a tar file). It saves bandwidth and hard disk
                    915: activity, compared to downloading the tar file again.
                    916: 
1.154     rillig    917: 3.2.1. Via tar files
1.1       dsieger   918: 
                    919: Warning
                    920: 
                    921: When updating from a tar file, you first need to completely remove the old
                    922: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
                    923: the mean time will not be removed on your local disk, resulting in
                    924: inconsistencies. When removing the old files, any changes that you have done to
                    925: the pkgsrc files will be lost after updating. Therefore updating via CVS is
                    926: strongly recommended.
                    927: 
                    928: Note that by default the distfiles and the binary packages are saved in the
                    929: pkgsrc tree, so don't forget to rescue them before updating. You can also
1.78      snj       930: configure pkgsrc to store distfiles and packages in directories outside the
1.154     rillig    931: pkgsrc tree by setting the DISTDIR and PACKAGES variables. See Chapter 6, 
1.78      snj       932: Configuring pkgsrc for the details.
1.1       dsieger   933: 
                    934: To update pkgsrc from a tar file, download the tar file as explained above.
                    935: Then, make sure that you have not made any changes to the files in the pkgsrc
                    936: directory. Remove the pkgsrc directory and extract the new tar file. Done.
                    937: 
1.154     rillig    938: 3.2.2. Via CVS
1.1       dsieger   939: 
1.26      spz       940: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12      weinem    941: 
1.26      spz       942: $ cd /usr/pkgsrc && cvs update -dP
                    943: 
                    944: If you get error messages from rsh, you need to set CVS_RSH variable as
                    945: described above. E.g.:
                    946: 
                    947: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1       dsieger   948: 
1.154     rillig    949: 3.2.2.1. Switching between different pkgsrc branches
1.1       dsieger   950: 
                    951: When updating pkgsrc, the CVS program keeps track of the branch you selected.
                    952: But if you, for whatever reason, want to switch from the stable branch to the
                    953: current one, you can do it by adding the option "-A" after the "update"
1.25      wiz       954: keyword. To switch from the current branch back to the stable branch, add the "
1.157     leot      955: -rpkgsrc-2019Q2" option.
1.1       dsieger   956: 
1.154     rillig    957: 3.2.2.2. What happens to my changes when updating?
1.1       dsieger   958: 
                    959: When you update pkgsrc, the CVS program will only touch those files that are
                    960: registered in the CVS repository. That means that any packages that you created
                    961: on your own will stay unmodified. If you change files that are managed by CVS,
                    962: later updates will try to merge your changes with those that have been done by
                    963: others. See the CVS manual, chapter "update" for details.
                    964: 
1.154     rillig    965: Chapter 4. Using pkgsrc on systems other than NetBSD
1.1       dsieger   966: 
                    967: Table of Contents
                    968: 
1.154     rillig    969: 4.1. Binary distribution
                    970: 4.2. Bootstrapping pkgsrc
1.1       dsieger   971: 
1.154     rillig    972: 4.1. Binary distribution
1.1       dsieger   973: 
1.154     rillig    974: See Section 5.1, "Using binary packages".
1.1       dsieger   975: 
1.154     rillig    976: 4.2. Bootstrapping pkgsrc
1.1       dsieger   977: 
1.44      asau      978: pkgsrc can be bootstrapped for use in two different modes: privileged and
                    979: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45      asau      980: programs are installed under one particular user and cannot utilise privileged
1.44      asau      981: operations (packages don't create special users and all special file
                    982: permissions like setuid are ignored).
                    983: 
1.1       dsieger   984: Installing the bootstrap kit from source should be as simple as:
                    985: 
1.60      asau      986: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   987: # cd pkgsrc/bootstrap
                    988: # ./bootstrap
                    989: 
                    990: 
1.44      asau      991: To bootstrap in unprivileged mode pass "--unprivileged" flag to bootstrap
                    992: 
                    993: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
1.118     sevan     994: will be installed in, and /usr/pkg/pkgdb for the package database directory
                    995: where pkgsrc will do its internal bookkeeping, /var is used as varbase, where
1.44      asau      996: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
1.118     sevan     997: for prefix, ~/pkg/pkgdb for the package database, and ~/pkg/var for varbase.
1.44      asau      998: 
                    999: You can change default layout using command-line arguments. Run "./bootstrap
                   1000: --help" to get details.
1.1       dsieger  1001: 
                   1002: Note
                   1003: 
                   1004: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
                   1005: For examples in this guide, use bmake instead of "make".
                   1006: 
1.44      asau     1007: Note
                   1008: 
                   1009: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
                   1010: directories. Use bmake corresponding to the installation you're working with to
                   1011: build and install packages.
                   1012: 
1.154     rillig   1013: Chapter 5. Using pkgsrc
1.1       dsieger  1014: 
                   1015: Table of Contents
                   1016: 
1.154     rillig   1017: 5.1. Using binary packages
1.1       dsieger  1018: 
1.154     rillig   1019:     5.1.1. Finding binary packages
                   1020:     5.1.2. Installing binary packages
                   1021:     5.1.3. Deinstalling packages
                   1022:     5.1.4. Getting information about installed packages
                   1023:     5.1.5. Checking for security vulnerabilities in installed packages
                   1024:     5.1.6. Finding if newer versions of your installed packages are in pkgsrc
                   1025:     5.1.7. Other administrative functions
                   1026: 
                   1027: 5.2. Building packages from source
                   1028: 
                   1029:     5.2.1. Requirements
                   1030:     5.2.2. Fetching distfiles
                   1031:     5.2.3. How to build and install
1.1       dsieger  1032: 
                   1033: Basically, there are two ways of using pkgsrc. The first is to only install the
                   1034: package tools and to use binary packages that someone else has prepared. This
                   1035: is the "pkg" in pkgsrc. The second way is to install the "src" of pkgsrc, too.
                   1036: Then you are able to build your own packages, and you can still use binary
                   1037: packages from someone else.
                   1038: 
1.154     rillig   1039: 5.1. Using binary packages
1.1       dsieger  1040: 
1.151     sevan    1041: On the cdn.NetBSD.org site and mirrors, there are collections of binary
1.9       rillig   1042: packages, ready to be installed. These binary packages have been built using
                   1043: the default settings for the directories, that is:
                   1044: 
                   1045:   * /usr/pkg for LOCALBASE, where most of the files are installed,
                   1046: 
                   1047:   * /usr/pkg/etc for configuration files,
                   1048: 
                   1049:   * /var for VARBASE, where those files are installed that may change after
                   1050:     installation.
                   1051: 
                   1052: If you cannot use these directories for whatever reasons (maybe because you're
                   1053: not root), you cannot use these binary packages, but have to build the packages
1.154     rillig   1054: yourself, which is explained in Section 4.2, "Bootstrapping pkgsrc".
1.1       dsieger  1055: 
1.154     rillig   1056: 5.1.1. Finding binary packages
1.1       dsieger  1057: 
1.5       weinem   1058: To install binary packages, you first need to know from where to get them. The
                   1059: first place where you should look is on the main pkgsrc FTP server in the
                   1060: directory /pub/pkgsrc/packages.
                   1061: 
                   1062: This directory contains binary packages for multiple platforms. First, select
                   1063: your operating system. (Ignore the directories with version numbers attached to
                   1064: it, they just exist for legacy reasons.) Then, select your hardware
                   1065: architecture, and in the third step, the OS version and the "version" of
1.9       rillig   1066: pkgsrc.
                   1067: 
                   1068: In this directory, you often find a file called bootstrap.tar.gz which contains
                   1069: the package management tools. If the file is missing, it is likely that your
                   1070: operating system already provides those tools. Download the file and extract it
                   1071: in the / directory. It will create the directories /usr/pkg (containing the
1.118     sevan    1072: tools for managing binary packages and the database of installed packages).
1.1       dsieger  1073: 
1.154     rillig   1074: 5.1.2. Installing binary packages
1.1       dsieger  1075: 
1.85      wiz      1076: In the directory from the last section, there is a subdirectory called All/,
1.9       rillig   1077: which contains all the binary packages that are available for the platform,
                   1078: excluding those that may not be distributed via FTP or CDROM (depending on
1.24      wiz      1079: which medium you are using).
1.9       rillig   1080: 
                   1081: To install packages directly from an FTP or HTTP server, run the following
                   1082: commands in a Bourne-compatible shell (be sure to su to root first):
                   1083: 
                   1084: # PATH="/usr/pkg/sbin:$PATH"
1.151     sevan    1085: # PKG_PATH="http://cdn.NetBSD.org/pub/pkgsrc/packages/OPSYS/ARCH/VERSIONS/All/"
1.9       rillig   1086: # export PATH PKG_PATH
                   1087: 
                   1088: Instead of URLs, you can also use local paths, for example if you are
                   1089: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
                   1090: to install packages from multiple sources, you can separate them by a semicolon
                   1091: in PKG_PATH.
                   1092: 
                   1093: After these preparations, installing a package is very easy:
                   1094: 
1.118     sevan    1095: # pkg_add libreoffice
                   1096: # pkg_add ap24-php71-*
1.1       dsieger  1097: 
                   1098: Note that any prerequisite packages needed to run the package in question will
                   1099: be installed, too, assuming they are present where you install from.
                   1100: 
1.25      wiz      1101: Adding packages might install vulnerable packages. Thus you should run 
1.24      wiz      1102: pkg_admin audit regularly, especially after installing new packages, and verify
                   1103: that the vulnerabilities are acceptable for your configuration.
1.1       dsieger  1104: 
                   1105: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
                   1106: in your PATH so you can actually start the just installed program.
                   1107: 
1.154     rillig   1108: 5.1.3. Deinstalling packages
1.1       dsieger  1109: 
                   1110: To deinstall a package, it does not matter whether it was installed from source
                   1111: code or from a binary package. The pkg_delete command does not know it anyway.
                   1112: To delete a package, you can just run pkg_delete package-name. The package name
                   1113: can be given with or without version number. Wildcards can also be used to
                   1114: deinstall a set of packages, for example *emacs*. Be sure to include them in
                   1115: quotes, so that the shell does not expand them before pkg_delete sees them.
                   1116: 
                   1117: The -r option is very powerful: it removes all the packages that require the
                   1118: package in question and then removes the package itself. For example:
                   1119: 
                   1120: # pkg_delete -r jpeg
                   1121: 
                   1122: 
                   1123: will remove jpeg and all the packages that used it; this allows upgrading the
                   1124: jpeg package.
                   1125: 
1.154     rillig   1126: 5.1.4. Getting information about installed packages
1.1       dsieger  1127: 
                   1128: The pkg_info shows information about installed packages or binary package
                   1129: files.
                   1130: 
1.154     rillig   1131: 5.1.5. Checking for security vulnerabilities in installed packages
1.1       dsieger  1132: 
                   1133: The NetBSD Security-Officer and Packages Groups maintain a list of known
                   1134: security vulnerabilities to packages which are (or have been) included in
1.151     sevan    1135: pkgsrc. The list is available from the NetBSD FTP site at http://ftp.NetBSD.org
                   1136: /pub/pkgsrc/distfiles/vulnerabilities.
1.1       dsieger  1137: 
1.23      jakllsch 1138: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
                   1139: automatically, and a security audit of all packages installed on a system can
                   1140: take place.
                   1141: 
                   1142: There are two components to auditing. The first step, pkg_admin
                   1143: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
                   1144: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
                   1145: your installed packages are vulnerable. If a package is vulnerable, you will
                   1146: see output similar to the following:
1.1       dsieger  1147: 
                   1148: Package samba-2.0.9 has a local-root-shell vulnerability, see
                   1149:     http://www.samba.org/samba/whatsnew/macroexploit.html
                   1150: 
1.23      jakllsch 1151: You may wish to have the vulnerabilities file downloaded daily so that it
                   1152: remains current. This may be done by adding an appropriate entry to the root
                   1153: users crontab(5) entry. For example the entry
                   1154: 
1.121     sevan    1155: # Download vulnerabilities file
1.118     sevan    1156: 0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1.121     sevan    1157: # Audit the installed packages and email results to root
                   1158: 9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
                   1159:             root >/dev/null 2>&1
1.118     sevan    1160: 
                   1161: 
                   1162: will update the vulnerability list every day at 3AM, followed by an audit at
                   1163: 3:09AM. The result of the audit are then emailed to root. On NetBSD this may be
                   1164: accomplished instead by adding the following line to /etc/daily.conf:
                   1165: 
                   1166: fetch_pkg_vulnerabilities=YES
                   1167: 
1.23      jakllsch 1168: 
1.118     sevan    1169: to fetch the vulnerability list from the daily security script. The system is
                   1170: set to audit the packages by default but can be set explicitly, if desired (not
1.123     wiz      1171: required), by adding the following line to /etc/security.conf:
1.23      jakllsch 1172: 
1.118     sevan    1173: check_pkg_vulnerabilities=YES
1.23      jakllsch 1174: 
                   1175: 
1.118     sevan    1176: see daily.conf(5) and security.conf(5) for more details.
1.1       dsieger  1177: 
1.154     rillig   1178: 5.1.6. Finding if newer versions of your installed packages are in pkgsrc
1.1       dsieger  1179: 
1.12      weinem   1180: Install pkgtools/lintpkgsrc and run lintpkgsrc with the "-i" argument to check
                   1181: if your packages are up-to-date, e.g.
1.1       dsieger  1182: 
                   1183: % lintpkgsrc -i
                   1184: ...
                   1185: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
                   1186: 
                   1187: 
                   1188: You can then use make update to update the package on your system and rebuild
                   1189: any dependencies.
                   1190: 
1.154     rillig   1191: 5.1.7. Other administrative functions
1.1       dsieger  1192: 
                   1193: The pkg_admin executes various administrative functions on the package system.
                   1194: 
1.154     rillig   1195: 5.2. Building packages from source
1.1       dsieger  1196: 
                   1197: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25      wiz      1198: organized into categories. You can browse the online index of packages, or run 
1.1       dsieger  1199: make readme from the pkgsrc directory to build local README.html files for all
                   1200: packages, viewable with any web browser such as www/lynx or www/firefox.
                   1201: 
                   1202: The default prefix for installed packages is /usr/pkg. If you wish to change
                   1203: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
                   1204: use multiple different LOCALBASE definitions on the same system (inside a
                   1205: chroot is an exception).
                   1206: 
                   1207: The rest of this chapter assumes that the package is already in pkgsrc. If it
                   1208: is not, see Part II, "The pkgsrc developer's guide" for instructions how to
                   1209: create your own packages.
                   1210: 
1.154     rillig   1211: 5.2.1. Requirements
1.1       dsieger  1212: 
                   1213: To build packages from source, you need a working C compiler. On NetBSD, you
                   1214: need to install the "comp" and the "text" distribution sets. If you want to
                   1215: build X11-related packages, the "xbase" and "xcomp" distribution sets are
                   1216: required, too.
                   1217: 
1.154     rillig   1218: 5.2.2. Fetching distfiles
1.1       dsieger  1219: 
                   1220: The first step for building a package is downloading the distfiles (i.e. the
                   1221: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
                   1222: them automatically.
                   1223: 
                   1224: If you have all files that you need in the distfiles directory, you don't need
                   1225: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
                   1226: and add:
                   1227: 
                   1228: DISTDIR=/cdrom/pkgsrc/distfiles
                   1229: 
                   1230: to your mk.conf.
                   1231: 
                   1232: By default a list of distribution sites will be randomly intermixed to prevent
                   1233: huge load on servers which holding popular packages (for example,
                   1234: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
                   1235: distfile all the mirrors will be tried in new (random) order. You can turn this
                   1236: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
                   1237: disabled).
                   1238: 
                   1239: You can overwrite some of the major distribution sites to fit to sites that are
                   1240: close to your own. By setting one or two variables you can modify the order in
                   1241: which the master sites are accessed. MASTER_SORT contains a whitespace
                   1242: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
                   1243: contains a whitespace delimited list of regular expressions. It has higher
                   1244: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
                   1245: some examples. This may save some of your bandwidth and time.
                   1246: 
                   1247: You can change these settings either in your shell's environment, or, if you
1.4       rillig   1248: want to keep the settings, by editing the mk.conf file, and adding the
1.1       dsieger  1249: definitions there.
                   1250: 
1.132     wiz      1251: If a package depends on many other packages (such as meta-pkgs/kde4), the build
1.1       dsieger  1252: process may alternate between periods of downloading source, and compiling. To
                   1253: ensure you have all the source downloaded initially you can run the command:
                   1254: 
                   1255: % make fetch-list | sh
                   1256: 
                   1257: which will output and run a set of shell commands to fetch the necessary files
                   1258: into the distfiles directory. You can also choose to download the files
                   1259: manually.
                   1260: 
1.154     rillig   1261: 5.2.3. How to build and install
1.1       dsieger  1262: 
                   1263: Once the software has downloaded, any patches will be applied, then it will be
                   1264: compiled for you. This may take some time depending on your computer, and how
                   1265: many other packages the software depends on and their compile time.
                   1266: 
                   1267: Note
                   1268: 
                   1269: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
                   1270: command instead of "make" in the examples in this guide.
                   1271: 
                   1272: For example, type
                   1273: 
                   1274: % cd misc/figlet
                   1275: % make
                   1276: 
                   1277: 
                   1278: at the shell prompt to build the various components of the package.
                   1279: 
                   1280: The next stage is to actually install the newly compiled program onto your
                   1281: system. Do this by entering:
                   1282: 
                   1283: % make install
                   1284: 
                   1285: 
                   1286: while you are still in the directory for whatever package you are installing.
                   1287: 
                   1288: Installing the package on your system may require you to be root. However,
                   1289: pkgsrc has a just-in-time-su feature, which allows you to only become root for
                   1290: the actual installation step.
                   1291: 
                   1292: That's it, the software should now be installed and setup for use. You can now
                   1293: enter:
                   1294: 
                   1295: % make clean
                   1296: 
                   1297: 
                   1298: to remove the compiled files in the work directory, as you shouldn't need them
                   1299: any more. If other packages were also added to your system (dependencies) to
                   1300: allow your program to compile, you can tidy these up also with the command:
                   1301: 
                   1302: % make clean-depends
                   1303: 
                   1304: 
                   1305: Taking the figlet utility as an example, we can install it on our system by
                   1306: building as shown in Appendix B, Build logs.
                   1307: 
                   1308: The program is installed under the default root of the packages tree - /usr/
                   1309: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
                   1310: environment, and it will use that value as the root of your packages tree. So,
                   1311: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
                   1312: that you should use a directory which is dedicated to packages and not shared
                   1313: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
                   1314: not try to add any of your own files or directories (such as src/, obj/, or
                   1315: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
                   1316: between programs and other files installed by the package system and whatever
                   1317: else may have been installed there.
                   1318: 
1.4       rillig   1319: Some packages look in mk.conf to alter some configuration options at build
1.1       dsieger  1320: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
                   1321: be set there by default. Environment variables such as LOCALBASE can be set in
1.4       rillig   1322: mk.conf to save having to remember to set them each time you want to use
1.1       dsieger  1323: pkgsrc.
                   1324: 
                   1325: Occasionally, people want to "look under the covers" to see what is going on
                   1326: when a package is building or being installed. This may be for debugging
                   1327: purposes, or out of simple curiosity. A number of utility values have been
                   1328: added to help with this.
                   1329: 
                   1330:  1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
                   1331:     amount of information will be displayed. For example,
                   1332: 
                   1333:     make patch PKG_DEBUG_LEVEL=2
                   1334: 
1.25      wiz      1335:     will show all the commands that are invoked, up to and including the "patch
                   1336:     " stage.
1.1       dsieger  1337: 
                   1338:  2. If you want to know the value of a certain make(1) definition, then the
                   1339:     VARNAME definition should be used, in conjunction with the show-var target.
                   1340:     e.g. to show the expansion of the make(1) variable LOCALBASE:
                   1341: 
                   1342:     % make show-var VARNAME=LOCALBASE
                   1343:     /usr/pkg
                   1344:     %
                   1345: 
                   1346: 
                   1347: If you want to install a binary package that you've either created yourself
                   1348: (see next section), that you put into pkgsrc/packages manually or that is
                   1349: located on a remote FTP server, you can use the "bin-install" target. This
                   1350: target will install a binary package - if available - via pkg_add(1), else do a
                   1351: make package. The list of remote FTP sites searched is kept in the variable
                   1352: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
                   1353: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
                   1354: for more details.
                   1355: 
                   1356: A final word of warning: If you set up a system that has a non-standard setting
                   1357: for LOCALBASE, be sure to set that before any packages are installed, as you
                   1358: cannot use several directories for the same purpose. Doing so will result in
                   1359: pkgsrc not being able to properly detect your installed packages, and fail
                   1360: miserably. Note also that precompiled binary packages are usually built with
                   1361: the default LOCALBASE of /usr/pkg, and that you should not install any if you
                   1362: use a non-standard LOCALBASE.
                   1363: 
1.154     rillig   1364: Chapter 6. Configuring pkgsrc
1.1       dsieger  1365: 
                   1366: Table of Contents
                   1367: 
1.154     rillig   1368: 6.1. General configuration
                   1369: 6.2. Variables affecting the build process
                   1370: 6.3. Variables affecting the installation process
                   1371: 6.4. Selecting and configuring the compiler
                   1372: 
                   1373:     6.4.1. Selecting the compiler
                   1374:     6.4.2. Additional flags to the compiler (CFLAGS)
                   1375:     6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger  1376: 
1.154     rillig   1377: 6.5. Developer/advanced settings
                   1378: 6.6. Selecting Build Options
1.1       dsieger  1379: 
                   1380: The whole pkgsrc system is configured in a single file, usually called mk.conf.
                   1381: In which directory pkgsrc looks for that file depends on the installation. On
                   1382: NetBSD, when you use make(1) from the base system, it is in the directory /etc
                   1383: /. In all other cases the default location is ${PREFIX}/etc/, depending on
                   1384: where you told the bootstrap program to install the binary packages.
                   1385: 
                   1386: The format of the configuration file is that of the usual BSD-style Makefiles.
                   1387: The whole pkgsrc configuration is done by setting variables in this file. Note
                   1388: that you can define all kinds of variables, and no special error checking (for
1.112     rillig   1389: example for spelling mistakes) takes place.
1.1       dsieger  1390: 
1.154     rillig   1391: 6.1. General configuration
1.1       dsieger  1392: 
1.112     rillig   1393: The following variables apply to all pkgsrc packages. A complete list of the
                   1394: variables that can be configured by the user is available in mk/defaults/
                   1395: mk.conf, together with some comments that describe each variable's intent.
1.1       dsieger  1396: 
                   1397:   * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
                   1398:     not mix binary packages with different LOCALBASEs!
                   1399: 
                   1400:   * CROSSBASE: Where "cross" category packages will be installed. The default
                   1401:     is ${LOCALBASE}/cross.
                   1402: 
1.84      wiz      1403:   * X11BASE: Where X11 is installed on the system. The default is /usr/X11R7.
1.1       dsieger  1404: 
                   1405:   * DISTDIR: Where to store the downloaded copies of the original source
                   1406:     distributions used for building pkgsrc packages. The default is $
                   1407:     {PKGSRCDIR}/distfiles.
                   1408: 
                   1409:   * PKG_DBDIR: Where the database about installed packages is stored. The
1.118     sevan    1410:     default is /usr/pkg/pkgdb.
1.1       dsieger  1411: 
                   1412:   * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
                   1413:     value.
                   1414: 
                   1415:   * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
                   1416:     files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.118     sevan    1417:     respectively. The defaults is ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1.1       dsieger  1418:     {DIST_SUBDIR}/.
                   1419: 
                   1420:   * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
                   1421:     with OS release ("2.0", etc.) and architecture ("mipsel", etc.).
                   1422: 
1.23      jakllsch 1423:   * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
                   1424:     case-sensitive. Whenever you try to build a package whose license is not in
                   1425:     this list, you will get an error message. If the license condition is
                   1426:     simple enough, the error message will include specific instructions on how
                   1427:     to change this variable.
1.1       dsieger  1428: 
1.154     rillig   1429: 6.2. Variables affecting the build process
1.1       dsieger  1430: 
                   1431:   * PACKAGES: The top level directory for the binary packages. The default is $
                   1432:     {PKGSRCDIR}/packages.
                   1433: 
                   1434:   * WRKOBJDIR: The top level directory where, if defined, the separate working
                   1435:     directories will get created, and symbolically linked to from ${WRKDIR}
                   1436:     (see below). This is useful for building packages on several architectures,
                   1437:     then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
                   1438:     architecture. (It should be noted that PKGSRCDIR should not be set by the
                   1439:     user ? it is an internal definition which refers to the root of the pkgsrc
                   1440:     tree. It is possible to have many pkgsrc tree instances.)
                   1441: 
                   1442:   * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.154     rillig   1443:     Section 13.3, "patches/*" for more information.
1.1       dsieger  1444: 
                   1445:   * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
                   1446:     Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
                   1447:     up settings used by builds in /usr/src.
                   1448: 
1.154     rillig   1449: 6.3. Variables affecting the installation process
1.1       dsieger  1450: 
1.143     maya     1451:   * PKGSRC_KEEP_BIN_PKGSRC: By default, binary packages of built packages are
1.150     leot     1452:     preserved in ${PACKAGES}/All. Setting this variable to "no" prevents this.
1.1       dsieger  1453: 
1.107     jnemeth  1454: Packages have to support installation into a subdirectory of WRKDIR. This
                   1455: allows a package to be built, before the actual filesystem is touched. DESTDIR
                   1456: support exists in two variations:
1.4       rillig   1457: 
                   1458:   * Basic DESTDIR support means that the package installation and packaging is
                   1459:     still run as root.
                   1460: 
                   1461:   * Full DESTDIR support can run the complete build, installation and packaging
                   1462:     as normal user. Root privileges are only needed to add packages.
                   1463: 
                   1464: With basic DESTDIR support, make clean needs to be run as root.
                   1465: 
1.17      imil     1466: Considering the foo/bar package, DESTDIR full support can be tested using the
                   1467: following commands
                   1468: 
                   1469: $ id
                   1470: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
                   1471: $ mkdir $HOME/packages
                   1472: $ cd $PKGSRCDIR/foo/bar
                   1473: 
                   1474: Verify DESTDIR full support, no root privileges should be needed
                   1475: 
1.66      asau     1476: $ make stage-install
1.17      imil     1477: 
                   1478: Create a package without root privileges
                   1479: 
1.66      asau     1480: $ make PACKAGES=$HOME/packages package
1.17      imil     1481: 
                   1482: For the following command, you must be able to gain root privileges using su(1)
                   1483: 
1.66      asau     1484: $ make PACKAGES=$HOME/packages install
1.17      imil     1485: 
                   1486: Then, as a simple user
                   1487: 
                   1488: $ make clean
                   1489: 
1.154     rillig   1490: 6.4. Selecting and configuring the compiler
1.4       rillig   1491: 
1.154     rillig   1492: 6.4.1. Selecting the compiler
1.1       dsieger  1493: 
                   1494: By default, pkgsrc will use GCC to build packages. This may be overridden by
                   1495: setting the following variables in /etc/mk.conf:
                   1496: 
                   1497: PKGSRC_COMPILER:
                   1498: 
                   1499:     This is a list of values specifying the chain of compilers to invoke when
                   1500:     building packages. Valid values are:
                   1501: 
1.66      asau     1502:       + ccc: Compaq C Compilers (Tru64)
                   1503: 
                   1504:       + ccache: compiler cache (chainable)
                   1505: 
                   1506:       + clang: Clang C and Objective-C compiler
                   1507: 
1.42      asau     1508:       + distcc: distributed C/C++ (chainable)
1.1       dsieger  1509: 
1.66      asau     1510:       + f2c: Fortran 77 to C compiler (chainable)
                   1511: 
                   1512:       + icc: Intel C++ Compiler (Linux)
                   1513: 
                   1514:       + ido: SGI IRIS Development Option cc (IRIX 5)
1.1       dsieger  1515: 
1.42      asau     1516:       + gcc: GNU C/C++ Compiler
1.1       dsieger  1517: 
1.66      asau     1518:       + hp: HP-UX C/aC++ compilers
                   1519: 
1.42      asau     1520:       + mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1       dsieger  1521: 
1.66      asau     1522:       + mipspro-ucode: Silicon Graphics, Inc. MIPSpro (o32)
1.1       dsieger  1523: 
1.42      asau     1524:       + sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1       dsieger  1525: 
1.118     sevan    1526:       + xlc: IBM's XL C/C++ compiler suite
1.66      asau     1527: 
1.1       dsieger  1528:     The default is "gcc". You can use ccache and/or distcc with an appropriate
                   1529:     PKGSRC_COMPILER setting, e.g. "ccache gcc". This variable should always be
                   1530:     terminated with a value for a real compiler. Note that only one real
                   1531:     compiler should be listed (e.g. "sunpro gcc" is not allowed).
                   1532: 
                   1533: GCC_REQD:
                   1534: 
                   1535:     This specifies the minimum version of GCC to use when building packages. If
                   1536:     the system GCC doesn't satisfy this requirement, then pkgsrc will build and
                   1537:     install one of the GCC packages to use instead.
                   1538: 
1.153     leot     1539: PYTHON_VERSION_DEFAULT:
1.114     maya     1540: 
                   1541:     Specifies which version of python to use when several options are
                   1542:     available.
                   1543: 
                   1544: PKGSRC_FORTRAN:
                   1545: 
                   1546:     Specifies the fortran compiler to use. The default is g95, and gfortran is
                   1547:     an alternative.
                   1548: 
                   1549: GFORTRAN_VERSION:
                   1550: 
                   1551:     If PKGSRC_FORTRAN= gfortran is used, this option specifies which version to
                   1552:     use.
                   1553: 
1.154     rillig   1554: 6.4.2. Additional flags to the compiler (CFLAGS)
1.1       dsieger  1555: 
                   1556: If you wish to set the CFLAGS variable, please make sure to use the += operator
                   1557: instead of the = operator:
                   1558: 
                   1559: CFLAGS+=        -your -flags
                   1560: 
                   1561: Using CFLAGS= (i.e. without the "+") may lead to problems with packages that
1.16      jnemeth  1562: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24      wiz      1563: package if you're interested in optimization specifically for the current CPU.
1.1       dsieger  1564: 
1.154     rillig   1565: 6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger  1566: 
                   1567: If you want to pass flags to the linker, both in the configure step and the
                   1568: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
                   1569: difference between the two is that LIBS will be appended to the command line,
                   1570: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
                   1571: machines depending on the setting of USE_IMAKE or the inclusion of mk/
                   1572: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
                   1573: settings, use the += operator:
                   1574: 
                   1575: LDFLAGS+=        -your -linkerflags
                   1576: 
1.154     rillig   1577: 6.5. Developer/advanced settings
1.1       dsieger  1578: 
                   1579:   * PKG_DEVELOPER: Run some sanity checks that package developers want:
                   1580: 
1.42      asau     1581:       + make sure patches apply with zero fuzz
1.1       dsieger  1582: 
1.42      asau     1583:       + run check-shlibs to see that all binaries will find their shared libs.
1.1       dsieger  1584: 
                   1585:   * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
                   1586:     making and installing the package. The default value for this is 0, which
                   1587:     will not display the commands as they are executed (normal, default, quiet
                   1588:     operation); the value 1 will display all shell commands before their
                   1589:     invocation, and the value 2 will display both the shell commands before
1.112     rillig   1590:     their invocation, as well as their actual execution progress with set -x.
1.1       dsieger  1591: 
1.154     rillig   1592: 6.6. Selecting Build Options
1.1       dsieger  1593: 
                   1594: Some packages have build time options, usually to select between different
                   1595: dependencies, enable optional support for big dependencies or enable
                   1596: experimental features.
                   1597: 
                   1598: To see which options, if any, a package supports, and which options are
                   1599: mutually exclusive, run make show-options, for example:
                   1600: 
                   1601:     The following options are supported by this package:
                   1602:         ssl      Enable SSL support.
                   1603:     Exactly one of the following gecko options is required:
                   1604:         firefox  Use firefox as gecko rendering engine.
                   1605:         mozilla  Use mozilla as gecko rendering engine.
                   1606:     At most one of the following database options may be selected:
                   1607:         mysql    Enable support for MySQL database.
                   1608:         pgsql    Enable support for PostgreSQL database.
                   1609: 
                   1610:     These options are enabled by default: firefox
                   1611:     These options are currently enabled: mozilla ssl
                   1612: 
1.4       rillig   1613: The following variables can be defined in mk.conf to select which options to
                   1614: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1       dsieger  1615: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
                   1616: which can be used to select or disable options specifically for package pkgbase
                   1617: . Options listed in these variables are selected, options preceded by "-" are
                   1618: disabled. A few examples:
                   1619: 
1.4       rillig   1620: $ grep "PKG.*OPTION" mk.conf
1.1       dsieger  1621: PKG_DEFAULT_OPTIONS=    -arts -dvdread -esound
                   1622: PKG_OPTIONS.kdebase=    debug -sasl
                   1623: PKG_OPTIONS.apache=     suexec
                   1624: 
1.11      rillig   1625: It is important to note that options that were specifically suggested by the
1.19      snj      1626: package maintainer must be explicitly removed if you do not wish to include the
                   1627: option. If you are unsure you can view the current state with make show-options
                   1628: .
1.11      rillig   1629: 
1.1       dsieger  1630: The following settings are consulted in the order given, and the last setting
                   1631: that selects or disables an option is used:
                   1632: 
                   1633:  1. the default options as suggested by the package maintainer
                   1634: 
                   1635:  2. the options implied by the settings of legacy variables (see below)
                   1636: 
                   1637:  3. PKG_DEFAULT_OPTIONS
                   1638: 
                   1639:  4. PKG_OPTIONS.pkgbase
                   1640: 
                   1641: For groups of mutually exclusive options, the last option selected is used, all
                   1642: others are automatically disabled. If an option of the group is explicitly
                   1643: disabled, the previously selected option, if any, is used. It is an error if no
                   1644: option from a required group of options is selected, and building the package
                   1645: will fail.
                   1646: 
                   1647: Before the options framework was introduced, build options were selected by
1.4       rillig   1648: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
                   1649: transition to the options framework for the user, these legacy variables are
                   1650: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
                   1651: automatically. A warning is issued to prompt the user to update mk.conf to use
                   1652: the options framework directly. Support for the legacy variables will be
1.1       dsieger  1653: removed eventually.
                   1654: 
1.154     rillig   1655: Chapter 7. Creating binary packages
1.1       dsieger  1656: 
                   1657: Table of Contents
                   1658: 
1.154     rillig   1659: 7.1. Building a single binary package
                   1660: 7.2. Settings for creation of binary packages
1.1       dsieger  1661: 
1.154     rillig   1662: 7.1. Building a single binary package
1.1       dsieger  1663: 
                   1664: Once you have built and installed a package, you can create a binary package
                   1665: which can be installed on another system with pkg_add(1). This saves having to
                   1666: build the same package on a group of hosts and wasting CPU time. It also
                   1667: provides a simple means for others to install your package, should you
                   1668: distribute it.
                   1669: 
                   1670: To create a binary package, change into the appropriate directory in pkgsrc,
                   1671: and run make package:
                   1672: 
1.112     rillig   1673: $ cd misc/figlet
                   1674: $ make package
1.1       dsieger  1675: 
                   1676: This will build and install your package (if not already done), and then build
                   1677: a binary package from what was installed. You can then use the pkg_* tools to
                   1678: manipulate it. Binary packages are created by default in /usr/pkgsrc/packages,
                   1679: in the form of a gzipped tar file. See Section B.2, "Packaging figlet" for a
                   1680: continuation of the above misc/figlet example.
                   1681: 
1.154     rillig   1682: See Chapter 23, Submitting and Committing for information on how to submit such
1.1       dsieger  1683: a binary package.
                   1684: 
1.154     rillig   1685: 7.2. Settings for creation of binary packages
1.1       dsieger  1686: 
1.154     rillig   1687: See Section 19.17, "Other helpful targets".
1.6       rillig   1688: 
1.154     rillig   1689: Chapter 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig   1690: 
                   1691: Table of Contents
                   1692: 
1.154     rillig   1693: 8.1. Preparations
                   1694: 8.2. Running a pbulk-style bulk build
1.6       rillig   1695: 
1.154     rillig   1696:     8.2.1. Configuration
1.6       rillig   1697: 
1.154     rillig   1698: 8.3. Requirements of a full bulk build
                   1699: 8.4. Creating a multiple CD-ROM packages collection
1.6       rillig   1700: 
1.154     rillig   1701:     8.4.1. Example of cdpack
1.6       rillig   1702: 
1.71      wiz      1703: For a number of reasons you may want to build binary packages for a large
                   1704: selected set of packages in pkgsrc or even for all pkgsrc packages. For
                   1705: instance, when you have multiple machines that should run the same software, it
                   1706: is wasted time if they all build their packages themselves from source. Or you
                   1707: may want to build a list of packages you want and check them before deploying
                   1708: onto production system. There is a way of getting a set of binary packages: The
1.112     rillig   1709: bulk build system, or pbulk ("p" stands for "parallel"). This chapter describes
                   1710: how to set it up.
1.71      wiz      1711: 
1.154     rillig   1712: 8.1. Preparations
1.71      wiz      1713: 
                   1714: First of all, you have to decide whether you build all packages or a limited
                   1715: set of them. Full bulk builds usually consume a lot more resources, both space
                   1716: and time, than builds for some practical sets of packages. There exists a
                   1717: number of particularly heavy packages that are not actually interesting to a
                   1718: wide audience. For a limited bulk builds you need to make a list of packages
1.112     rillig   1719: you want to build. Note that all their dependencies will be built, so you don't
                   1720: need to track them manually.
1.71      wiz      1721: 
                   1722: During bulk builds various packages are installed and deinstalled in /usr/pkg
                   1723: (or whatever LOCALBASE is), so make sure that you don't need any package during
1.112     rillig   1724: the builds. Essentially, you should provide a fresh system, either a chroot
1.71      wiz      1725: environment or something even more restrictive, depending on what the operating
                   1726: system provides, or dedicate the whole physical machine. As a useful side
                   1727: effect this makes sure that bulk builds cannot break anything in your system.
                   1728: There have been numerous cases where certain packages tried to install files
                   1729: outside the LOCALBASE or wanted to edit some files in /etc.
1.6       rillig   1730: 
1.154     rillig   1731: 8.2. Running a pbulk-style bulk build
1.6       rillig   1732: 
1.15      rillig   1733: Running a pbulk-style bulk build works roughly as follows:
                   1734: 
                   1735:   * First, build the pbulk infrastructure in a fresh pkgsrc location.
                   1736: 
                   1737:   * Then, build each of the packages from a clean installation directory using
                   1738:     the infrastructure.
                   1739: 
1.154     rillig   1740: 8.2.1. Configuration
1.6       rillig   1741: 
1.112     rillig   1742: To simplify configuration, we provide the helper script mk/pbulk/pbulk.sh.
1.6       rillig   1743: 
1.68      asau     1744: In order to use it, prepare a clear system (real one, chroot environment, jail,
                   1745: zone, virtual machine). Configure network access to fetch distribution files.
1.112     rillig   1746: Create a user with name "pbulk".
1.68      asau     1747: 
                   1748: Fetch and extract pkgsrc. Use a command like one of these:
                   1749: 
1.151     sevan    1750: # (cd /usr && ftp -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
                   1751: # (cd /usr && fetch -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1.72      wiz      1752: # (cd /usr && cvs -Q -z3 -d anoncvs@anoncvs.NetBSD.org:/cvsroot get -P pkgsrc)
1.68      asau     1753: 
                   1754: Or any other way that fits (e.g., curl, wget).
                   1755: 
                   1756: Deploy and configure pbulk tools, e.g.:
                   1757: 
1.118     sevan    1758: # sh pbulk.sh -n # use native make, no bootstrap kit needed (for use on NetBSD)
1.68      asau     1759: # sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment
                   1760: # sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build
                   1761: 
                   1762: Note
                   1763: 
                   1764: mk.conf.frag is a fragment of mk.conf that contains settings you want to apply
                   1765: to packages you build. For instance,
                   1766: 
1.112     rillig   1767: PKG_DEVELOPER=          yes     # perform more checks
                   1768: X11_TYPE=               modular # use pkgsrc X11
                   1769: SKIP_LICENSE_CHECK=     yes     # accept all licences (useful
                   1770:                                 # when building all packages)
1.68      asau     1771: 
                   1772: If configured for limited list, replace the list in /usr/pbulk/etc/pbulk.list
1.112     rillig   1773: with your list of packages, one per line without empty lines or comments. E.g.:
1.68      asau     1774: 
                   1775: www/firefox
                   1776: mail/thunderbird
                   1777: misc/libreoffice4
                   1778: 
1.69      asau     1779: At this point you can also review configuration in /usr/pbulk/etc and make
                   1780: final amendments, if wanted.
                   1781: 
1.68      asau     1782: Start it:
                   1783: 
                   1784: # /usr/pbulk/bin/bulkbuild
                   1785: 
                   1786: After it finishes, you'll have /mnt filled with distribution files, binary
                   1787: packages, and reports, plain text summary in /mnt/bulklog/meta/report.txt
                   1788: 
                   1789: Note
                   1790: 
                   1791: The pbulk.sh script does not cover all possible use cases. While being ready to
                   1792: run, it serves as a good starting point to understand and build more complex
                   1793: setups. The script is kept small enough for better understanding.
                   1794: 
                   1795: Note
                   1796: 
                   1797: The pbulk.sh script supports running unprivileged bulk build and helps
                   1798: configuring distributed bulk builds.
1.15      rillig   1799: 
1.154     rillig   1800: 8.3. Requirements of a full bulk build
1.71      wiz      1801: 
                   1802: A complete bulk build requires lots of disk space. Some of the disk space can
                   1803: be read-only, some other must be writable. Some can be on remote filesystems
                   1804: (such as NFS) and some should be local. Some can be temporary filesystems,
                   1805: others must survive a sudden reboot.
                   1806: 
                   1807:   * 40 GB for the distfiles (read-write, remote, temporary)
                   1808: 
                   1809:   * 30 GB for the binary packages (read-write, remote, permanent)
                   1810: 
                   1811:   * 1 GB for the pkgsrc tree (read-only, remote, permanent)
                   1812: 
                   1813:   * 5 GB for LOCALBASE (read-write, local, temporary)
                   1814: 
                   1815:   * 10 GB for the log files (read-write, remote, permanent)
                   1816: 
                   1817:   * 5 GB for temporary files (read-write, local, temporary)
                   1818: 
1.154     rillig   1819: 8.4. Creating a multiple CD-ROM packages collection
1.1       dsieger  1820: 
                   1821: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
                   1822: of the resulting binary packages to assist in installing packages on other
                   1823: machines. The pkgtools/cdpack package provides a simple tool for creating the
                   1824: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
                   1825: keeps all the dependencies for a given package on the same CD as that package.
                   1826: 
1.154     rillig   1827: 8.4.1. Example of cdpack
1.1       dsieger  1828: 
                   1829: Complete documentation for cdpack is found in the cdpack(1) man page. The
                   1830: following short example assumes that the binary packages are left in /usr/
                   1831: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
                   1832: ISO 9660 images.
                   1833: 
                   1834: # mkdir /u2/images
                   1835: # pkg_add /usr/pkgsrc/packages/All/cdpack
                   1836: # cdpack /usr/pkgsrc/packages/All /u2/images
                   1837: 
                   1838: 
                   1839: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
                   1840: CD in the collection, then you need to create a directory which contains these
                   1841: files. e.g.
                   1842: 
                   1843: # mkdir /tmp/common
                   1844: # echo "This is a README" > /tmp/common/README
                   1845: # echo "Another file" > /tmp/common/COPYING
                   1846: # mkdir /tmp/common/bin
                   1847: # echo "#!/bin/sh" > /tmp/common/bin/myscript
                   1848: # echo "echo Hello world" >> /tmp/common/bin/myscript
                   1849: # chmod 755 /tmp/common/bin/myscript
                   1850: 
                   1851: 
                   1852: Now create the images:
                   1853: 
                   1854: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
                   1855: 
                   1856: Each image will contain README, COPYING, and bin/myscript in their root
                   1857: directories.
                   1858: 
1.154     rillig   1859: Chapter 9. Directory layout of the installed files
1.1       dsieger  1860: 
                   1861: Table of Contents
                   1862: 
1.154     rillig   1863: 9.1. File system layout in ${LOCALBASE}
                   1864: 9.2. File system layout in ${VARBASE}
1.1       dsieger  1865: 
                   1866: The files that are installed by pkgsrc are organized in a way that is similar
                   1867: to what you find in the /usr directory of the base system. But some details are
                   1868: different. This is because pkgsrc initially came from FreeBSD and had adopted
                   1869: its file system hierarchy. Later it was largely influenced by NetBSD. But no
                   1870: matter which operating system you are using pkgsrc with, you can expect the
                   1871: same layout for pkgsrc.
                   1872: 
                   1873: There are mainly four root directories for pkgsrc, which are all configurable
                   1874: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
                   1875: default locations are:
                   1876: 
                   1877: LOCALBASE=              /usr/pkg
                   1878: PKG_SYSCONFBASE=        /usr/pkg/etc
                   1879: VARBASE=                /var
1.119     sevan    1880: PKG_DBDIR=              /usr/pkg/pkgdb
1.1       dsieger  1881: 
                   1882: In unprivileged mode (when pkgsrc has been installed as any other user), the
                   1883: default locations are:
                   1884: 
                   1885: LOCALBASE=              ${HOME}/pkg
                   1886: PKG_SYSCONFBASE=        ${HOME}/pkg/etc
                   1887: VARBASE=                ${HOME}/pkg/var
1.119     sevan    1888: PKG_DBDIR=              ${HOME}/pkg/pkgdb
1.1       dsieger  1889: 
                   1890: What these four directories are for, and what they look like is explained
                   1891: below.
                   1892: 
1.25      wiz      1893:   * LOCALBASE corresponds to the /usr directory in the base system. It is the "
                   1894:     main" directory where the files are installed and contains the well-known
1.1       dsieger  1895:     subdirectories like bin, include, lib, share and sbin.
                   1896: 
                   1897:   * VARBASE corresponds to /var in the base system. Some programs (especially
                   1898:     games, network daemons) need write access to it during normal operation.
                   1899: 
                   1900:   * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
                   1901:     configuration files of the packages, as well as pkgsrc's mk.conf itself.
                   1902: 
1.154     rillig   1903: 9.1. File system layout in ${LOCALBASE}
1.1       dsieger  1904: 
                   1905: The following directories exist in a typical pkgsrc installation in $
                   1906: {LOCALBASE}.
                   1907: 
                   1908: bin
                   1909: 
                   1910:     Contains executable programs that are intended to be directly used by the
                   1911:     end user.
                   1912: 
                   1913: emul
                   1914: 
                   1915:     Contains files for the emulation layers of various other operating systems,
                   1916:     especially for NetBSD.
                   1917: 
                   1918: etc (the usual location of ${PKG_SYSCONFDIR})
                   1919: 
                   1920:     Contains the configuration files.
                   1921: 
                   1922: include
                   1923: 
                   1924:     Contains headers for the C and C++ programming languages.
                   1925: 
                   1926: info
                   1927: 
                   1928:     Contains GNU info files of various packages.
                   1929: 
                   1930: lib
                   1931: 
                   1932:     Contains shared and static libraries.
                   1933: 
                   1934: libdata
                   1935: 
                   1936:     Contains data files that don't change after installation. Other data files
                   1937:     belong into ${VARBASE}.
                   1938: 
                   1939: libexec
                   1940: 
                   1941:     Contains programs that are not intended to be used by end users, such as
                   1942:     helper programs or network daemons.
                   1943: 
                   1944: libexec/cgi-bin
                   1945: 
                   1946:     Contains programs that are intended to be executed as CGI scripts by a web
                   1947:     server.
                   1948: 
                   1949: man (the usual value of ${PKGMANDIR})
                   1950: 
                   1951:     Contains brief documentation in form of manual pages.
                   1952: 
                   1953: sbin
                   1954: 
                   1955:     Contains programs that are intended to be used only by the super-user.
                   1956: 
                   1957: share
                   1958: 
                   1959:     Contains platform-independent data files that don't change after
                   1960:     installation.
                   1961: 
                   1962: share/doc
                   1963: 
                   1964:     Contains documentation files provided by the packages.
                   1965: 
                   1966: share/examples
                   1967: 
                   1968:     Contains example files provided by the packages. Among others, the original
                   1969:     configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
                   1970:     installation.
                   1971: 
                   1972: share/examples/rc.d
                   1973: 
                   1974:     Contains the original files for rc.d scripts.
                   1975: 
                   1976: var (the usual location of ${VARBASE})
                   1977: 
                   1978:     Contains files that may be modified after installation.
                   1979: 
1.154     rillig   1980: 9.2. File system layout in ${VARBASE}
1.1       dsieger  1981: 
                   1982: db/pkg (the usual location of ${PKG_DBDIR})
                   1983: 
                   1984:     Contains information about the currently installed packages.
                   1985: 
                   1986: games
                   1987: 
                   1988:     Contains highscore files.
                   1989: 
                   1990: log
                   1991: 
                   1992:     Contains log files.
                   1993: 
                   1994: run
                   1995: 
                   1996:     Contains informational files about daemons that are currently running.
                   1997: 
1.154     rillig   1998: Chapter 10. Frequently Asked Questions
1.1       dsieger  1999: 
                   2000: Table of Contents
                   2001: 
1.154     rillig   2002: 10.1. Are there any mailing lists for pkg-related discussion?
                   2003: 10.2. Utilities for package management (pkgtools)
                   2004: 10.3. How to use pkgsrc as non-root
                   2005: 10.4. How to resume transfers when fetching distfiles?
                   2006: 10.5. How can I install/use modular X.org from pkgsrc?
                   2007: 10.6. How to fetch files from behind a firewall
                   2008: 10.7. How to fetch files from HTTPS sites
                   2009: 10.8. How do I tell make fetch to do passive FTP?
                   2010: 10.9. How to fetch all distfiles at once
                   2011: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
                   2012: 10.11. What does "Could not find bsd.own.mk" mean?
                   2013: 10.12. Using 'sudo' with pkgsrc
                   2014: 10.13. How do I change the location of configuration files?
                   2015: 10.14. Automated security checks
                   2016: 10.15. Why do some packages ignore my CFLAGS?
                   2017: 10.16. A package does not build. What shall I do?
                   2018: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24      wiz      2019:     conflicts" mean?
1.1       dsieger  2020: 
                   2021: This section contains hints, tips & tricks on special things in pkgsrc that we
                   2022: didn't find a better place for in the previous chapters, and it contains items
                   2023: for both pkgsrc users and developers.
                   2024: 
1.154     rillig   2025: 10.1. Are there any mailing lists for pkg-related discussion?
1.1       dsieger  2026: 
                   2027: The following mailing lists may be of interest to pkgsrc users:
                   2028: 
                   2029:   * pkgsrc-users: This is a general purpose list for most issues regarding
                   2030:     pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
                   2031:     configuration, unexpected build failures, using particular packages,
                   2032:     upgrading pkgsrc installations, questions regarding the pkgsrc release
                   2033:     branches, etc. General announcements or proposals for changes that impact
                   2034:     the pkgsrc user community, e.g. major infrastructure changes, new features,
                   2035:     package removals, etc., may also be posted.
                   2036: 
                   2037:   * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
                   2038:     discussed.
                   2039: 
                   2040:   * pkgsrc-changes: This list is for those who are interested in getting a
                   2041:     commit message for every change committed to pkgsrc. It is also available
                   2042:     in digest form, meaning one daily message containing all commit messages
                   2043:     for changes to the package source tree in that 24 hour period.
                   2044: 
                   2045: To subscribe, do:
                   2046: 
                   2047: % echo subscribe listname | mail majordomo@NetBSD.org
                   2048: 
                   2049: Archives for all these mailing lists are available from http://
                   2050: mail-index.NetBSD.org/.
                   2051: 
1.154     rillig   2052: 10.2. Utilities for package management (pkgtools)
1.1       dsieger  2053: 
                   2054: The directory pkgsrc/pkgtools contains a number of useful utilities for both
                   2055: users and developers of pkgsrc. This section attempts only to make the reader
1.121     sevan    2056: aware of some of the utilities and when they might be useful, and not to
                   2057: duplicate the documentation that comes with each package.
1.1       dsieger  2058: 
                   2059: Utilities used by pkgsrc (automatically installed when needed):
                   2060: 
                   2061:   * pkgtools/x11-links: Symlinks for use by buildlink.
                   2062: 
                   2063: OS tool augmentation (automatically installed when needed):
                   2064: 
1.121     sevan    2065:   * pkgtools/digest: Calculates various kinds of checksums (including SHA3).
1.1       dsieger  2066: 
                   2067:   * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
                   2068: 
                   2069:   * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
                   2070: 
                   2071:   * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
                   2072:     for use on operating systems where pkg_install is not present.
                   2073: 
                   2074: Utilities used by pkgsrc (not automatically installed):
                   2075: 
                   2076:   * pkgtools/pkg_tarup: Create a binary package from an already-installed
                   2077:     package. Used by make replace to save the old package.
                   2078: 
                   2079:   * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
                   2080:     distfiles from multiple locations. It currently supports the following
                   2081:     methods: multiple CD-ROMs and network FTP/HTTP connections.
                   2082: 
                   2083:   * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24      wiz      2084:     current CPU and compiler.
1.1       dsieger  2085: 
                   2086: Utilities for keeping track of installed packages, being up to date, etc:
                   2087: 
1.65      wiz      2088:   * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
                   2089:     and upgrade binary packages easily.
                   2090: 
1.1       dsieger  2091:   * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
                   2092:     the latest pkgsrc entries.
                   2093: 
                   2094:   * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
                   2095:     strategy for updating.
                   2096: 
                   2097:   * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
                   2098:     graphviz).
                   2099: 
1.12      weinem   2100:   * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
                   2101: 
                   2102:   * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
                   2103:     complete pkgsrc system.
1.1       dsieger  2104: 
                   2105:   * pkgtools/pkgsurvey: Report what packages you have installed.
                   2106: 
                   2107: Utilities for people maintaining or creating individual packages:
                   2108: 
                   2109:   * pkgtools/pkgdiff: Automate making and maintaining patches for a package
                   2110:     (includes pkgdiff, pkgvi, mkpatches, etc.).
                   2111: 
1.65      wiz      2112:   * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1       dsieger  2113: 
                   2114: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
                   2115: 
                   2116:   * pkgtools/pkg_comp: Build packages in a chrooted area.
                   2117: 
                   2118:   * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
                   2119: 
1.154     rillig   2120: 10.3. How to use pkgsrc as non-root
1.1       dsieger  2121: 
1.108     rillig   2122: To install packages from source as a non-root user, download pkgsrc as
1.154     rillig   2123: described in Chapter 3, Where to get pkgsrc and how to keep it up-to-date, cd
1.108     rillig   2124: into that directory and run the command ./bootstrap/bootstrap --unprivileged.
                   2125: 
                   2126: This will install the binary part of pkgsrc to ~/pkg and put the pkgsrc
                   2127: configuration mk.conf into ~/pkg/etc.
                   2128: 
                   2129: For more details, see mk/unprivileged.mk.
1.1       dsieger  2130: 
1.154     rillig   2131: 10.4. How to resume transfers when fetching distfiles?
1.1       dsieger  2132: 
                   2133: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4       rillig   2134: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
                   2135: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1       dsieger  2136: 
1.61      wiz      2137: You can also use a different program than the platform default program by
                   2138: changing the FETCH_USING variable. You can specify the program by using of ftp,
                   2139: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
                   2140: manual. A value of custom disables the system defaults and dependency tracking
                   2141: for the fetch program. In that case you have to provide FETCH_CMD,
                   2142: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1       dsieger  2143: 
1.16      jnemeth  2144: For example, if you want to use wget to download, you'll have to use something
                   2145: like:
1.1       dsieger  2146: 
1.16      jnemeth  2147: FETCH_USING=    wget
1.1       dsieger  2148: 
1.154     rillig   2149: 10.5. How can I install/use modular X.org from pkgsrc?
1.1       dsieger  2150: 
1.4       rillig   2151: If you want to use modular X.org from pkgsrc instead of your system's own X11
                   2152: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1       dsieger  2153: mk.conf:
                   2154: 
1.4       rillig   2155: X11_TYPE=modular
1.1       dsieger  2156: 
1.154     rillig   2157: 10.6. How to fetch files from behind a firewall
1.1       dsieger  2158: 
                   2159: If you are sitting behind a firewall which does not allow direct connections to
                   2160: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
                   2161: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
                   2162: machine "orpheus.amdahl.com" is one of the firewalls, and it uses port 80 as
                   2163: the proxy port number. So the proxy environment variables are:
                   2164: 
                   2165: ftp_proxy=ftp://orpheus.amdahl.com:80/
                   2166: http_proxy=http://orpheus.amdahl.com:80/
                   2167: 
1.154     rillig   2168: 10.7. How to fetch files from HTTPS sites
1.65      wiz      2169: 
                   2170: Some fetch tools are not prepared to support HTTPS by default (for example, the
                   2171: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
                   2172: openssl dependency that low in the dependency graph).
                   2173: 
                   2174: Usually you won't notice, because distribution files are mirrored weekly to "
                   2175: ftp.NetBSD.org", but that might not be often enough if you are following
                   2176: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to "curl" or
                   2177: "wget", which are both compiled with HTTPS support by default. Of course, these
                   2178: tools need to be installed before you can use them this way.
                   2179: 
1.154     rillig   2180: 10.8. How do I tell make fetch to do passive FTP?
1.1       dsieger  2181: 
                   2182: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
                   2183: FETCH_CMD is assigned the first available command from the following list:
                   2184: 
                   2185:   * ${LOCALBASE}/bin/ftp
                   2186: 
                   2187:   * /usr/bin/ftp
                   2188: 
                   2189: On a default NetBSD installation, this will be /usr/bin/ftp, which
                   2190: automatically tries passive connections first, and falls back to active
                   2191: connections if the server refuses to do passive. For the other tools, add the
1.4       rillig   2192: following to your mk.conf file: PASSIVE_FETCH=1.
1.1       dsieger  2193: 
                   2194: Having that option present will prevent /usr/bin/ftp from falling back to
                   2195: active transfers.
                   2196: 
1.154     rillig   2197: 10.9. How to fetch all distfiles at once
1.1       dsieger  2198: 
                   2199: You would like to download all the distfiles in a single batch from work or
                   2200: university, where you can't run a make fetch. There is an archive of distfiles
                   2201: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
                   2202: 
                   2203: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
                   2204: subdirectories, carry the resulting list to your machine at work/school and use
                   2205: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
                   2206: don't forget to set FETCH_CMD to something that fetches a URL:
                   2207: 
                   2208: At home:
                   2209: 
                   2210: % cd /usr/pkgsrc
                   2211: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
                   2212: % scp /tmp/fetch.sh work:/tmp
                   2213: 
                   2214: At work:
                   2215: 
                   2216: % sh /tmp/fetch.sh
                   2217: 
                   2218: then tar up /tmp/distfiles and take it home.
                   2219: 
                   2220: If you have a machine running NetBSD, and you want to get all distfiles (even
                   2221: ones that aren't for your machine architecture), you can do so by using the
                   2222: above-mentioned make fetch-list approach, or fetch the distfiles directly by
                   2223: running:
                   2224: 
                   2225: % make mirror-distfiles
                   2226: 
                   2227: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
                   2228: everything by running:
                   2229: 
                   2230: % make fetch NO_SKIP=yes
                   2231: 
1.154     rillig   2232: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
1.1       dsieger  2233: 
                   2234: When compiling the pkgtools/pkg_install package, you get the error from make
                   2235: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
                   2236: that you don't have installed the "text" set (nroff, ...) from the NetBSD base
                   2237: distribution on your machine. It is recommended to do that to format man pages.
                   2238: 
                   2239: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4       rillig   2240: NOMAN=YES either in the environment or in mk.conf.
1.1       dsieger  2241: 
1.154     rillig   2242: 10.11. What does "Could not find bsd.own.mk" mean?
1.1       dsieger  2243: 
                   2244: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
                   2245: machine. Please get and install it, by extracting it in /:
                   2246: 
                   2247: # cd /
                   2248: # tar --unlink -zxvpf .../comp.tgz
                   2249: 
                   2250: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
                   2251: release (determine via uname -r).
                   2252: 
1.154     rillig   2253: 10.12. Using 'sudo' with pkgsrc
1.1       dsieger  2254: 
                   2255: When installing packages as non-root user and using the just-in-time su(1)
                   2256: feature of pkgsrc, it can become annoying to type in the root password for each
                   2257: required package installed. To avoid this, the sudo package can be used, which
                   2258: does password caching over a limited time. To use it, install sudo (either as
1.4       rillig   2259: binary package or from security/sudo) and then put the following into your
                   2260: mk.conf, somewhere after the definition of the LOCALBASE variable:
1.1       dsieger  2261: 
                   2262: .if exists(${LOCALBASE}/bin/sudo)
                   2263: SU_CMD=        ${LOCALBASE}/bin/sudo /bin/sh -c
                   2264: .endif
                   2265: 
1.154     rillig   2266: 10.13. How do I change the location of configuration files?
1.1       dsieger  2267: 
                   2268: As the system administrator, you can choose where configuration files are
                   2269: installed. The default settings make all these files go into ${PREFIX}/etc or
                   2270: some of its subdirectories; this may be suboptimal depending on your
                   2271: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
                   2272: configuration of the provided packages).
                   2273: 
                   2274: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4       rillig   2275: (in mk.conf) to point to your preferred configuration directory; some common
                   2276: examples include /etc or /etc/pkg.
1.1       dsieger  2277: 
                   2278: Furthermore, you can change this value on a per-package basis by setting the
                   2279: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
                   2280: matches the name of the package you would like to modify, that is, the contents
                   2281: of PKGBASE.
                   2282: 
                   2283: Note that after changing these settings, you must rebuild and reinstall any
                   2284: affected packages.
                   2285: 
1.154     rillig   2286: 10.14. Automated security checks
1.1       dsieger  2287: 
                   2288: Please be aware that there can often be bugs in third-party software, and some
                   2289: of these bugs can leave a machine vulnerable to exploitation by attackers. In
                   2290: an effort to lessen the exposure, the NetBSD packages team maintains a database
                   2291: of known-exploits to packages which have at one time been included in pkgsrc.
                   2292: The database can be downloaded automatically, and a security audit of all
1.14      jmcneill 2293: packages installed on a system can take place. To do this, refer to the
                   2294: following two tools (installed as part of the pkgtools/pkg_install package):
1.1       dsieger  2295: 
1.21      snj      2296:  1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
                   2297:     security vulnerabilities information. This list is kept up to date by the
1.26      spz      2298:     pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1       dsieger  2299: 
1.26      spz      2300:     ftp://ftp.NetBSD.org/pkgsrc/distfiles/pkg-vulnerabilities
1.1       dsieger  2301: 
1.21      snj      2302:  2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24      wiz      2303:     known vulnerability. If a vulnerable package is installed, it will be shown
                   2304:     by output to stdout, including a description of the type of vulnerability,
                   2305:     and a URL containing more information.
1.1       dsieger  2306: 
1.154     rillig   2307: Use of these tools is strongly recommended! See Section 5.1.5, "Checking for
1.121     sevan    2308: security vulnerabilities in installed packages" for instructions on how to
                   2309: automate checking and reporting.
                   2310: 
                   2311: If this database is installed, pkgsrc builds will use it to perform a security
                   2312: check before building any package.
1.1       dsieger  2313: 
1.154     rillig   2314: 10.15. Why do some packages ignore my CFLAGS?
1.1       dsieger  2315: 
                   2316: When you add your own preferences to the CFLAGS variable in your mk.conf, these
                   2317: flags are passed in environment variables to the ./configure scripts and to
                   2318: make(1). Some package authors ignore the CFLAGS from the environment variable
                   2319: by overriding them in the Makefiles of their package.
                   2320: 
                   2321: Currently there is no solution to this problem. If you really need the package
                   2322: to use your CFLAGS you should run make patch in the package directory and then
                   2323: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
                   2324: Usually you can remove these lines. But be aware that some "smart" programmers
                   2325: write so bad code that it only works for the specific combination of CFLAGS
                   2326: they have chosen.
                   2327: 
1.154     rillig   2328: 10.16. A package does not build. What shall I do?
1.1       dsieger  2329: 
                   2330:  1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
                   2331:     is that people only update pkgsrc in parts, because of performance reasons.
                   2332:     Since pkgsrc is one large system, not a collection of many small systems,
                   2333:     there are sometimes changes that only work when the whole pkgsrc tree is
                   2334:     updated.
                   2335: 
1.25      wiz      2336:  2. Make sure that you don't have any CVS conflicts. Search for "<<<<<<" or "
                   2337:     >>>>>>" in all your pkgsrc files.
1.1       dsieger  2338: 
1.25      wiz      2339:  3. Make sure that you don't have old copies of the packages extracted. Run 
1.1       dsieger  2340:     make clean clean-depends to verify this.
                   2341: 
1.108     rillig   2342:  4. If you are a package developer who wants to invest some work, have a look
1.154     rillig   2343:     at Chapter 21, Making your package work.
1.108     rillig   2344: 
                   2345:  5. If the problem still exists, write a mail to the pkgsrc-users mailing list.
1.1       dsieger  2346: 
1.154     rillig   2347: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.1       dsieger  2348: conflicts" mean?
                   2349: 
                   2350: You have modified a file from pkgsrc, and someone else has modified that same
                   2351: file afterwards in the CVS repository. Both changes are in the same region of
                   2352: the file, so when you updated pkgsrc, the cvs command marked the conflicting
                   2353: changes in the file. Because of these markers, the file is no longer a valid
                   2354: Makefile.
                   2355: 
                   2356: Have a look at that file, and if you don't need your local changes anymore, you
                   2357: can remove that file and run cvs -q update -dP in that directory to download
                   2358: the current version.
                   2359: 
                   2360: Part II. The pkgsrc developer's guide
                   2361: 
                   2362: This part of the book deals with creating and modifying packages. It starts
                   2363: with a "HOWTO"-like guide on creating a new package. The remaining chapters are
                   2364: more like a reference manual for pkgsrc.
                   2365: 
                   2366: Table of Contents
                   2367: 
1.154     rillig   2368: 11. Getting help
                   2369: 12. Creating a new pkgsrc package from scratch
1.1       dsieger  2370: 
1.154     rillig   2371:     12.1. Common types of packages
1.1       dsieger  2372: 
1.154     rillig   2373:         12.1.1. Perl modules
                   2374:         12.1.2. Python modules and programs
1.1       dsieger  2375: 
1.154     rillig   2376:     12.2. Examples
1.1       dsieger  2377: 
1.154     rillig   2378:         12.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  2379: 
1.154     rillig   2380: 13. Package components - files, directories and contents
1.1       dsieger  2381: 
1.154     rillig   2382:     13.1. Makefile
                   2383:     13.2. distinfo
                   2384:     13.3. patches/*
1.1       dsieger  2385: 
1.154     rillig   2386:         13.3.1. Structure of a single patch file
                   2387:         13.3.2. Creating patch files
                   2388:         13.3.3. Sources where the patch files come from
                   2389:         13.3.4. Patching guidelines
                   2390:         13.3.5. Feedback to the author
1.1       dsieger  2391: 
1.154     rillig   2392:     13.4. Other mandatory files
                   2393:     13.5. Optional files
1.1       dsieger  2394: 
1.154     rillig   2395:         13.5.1. Files affecting the binary package
                   2396:         13.5.2. Files affecting the build process
                   2397:         13.5.3. Files affecting nothing at all
1.1       dsieger  2398: 
1.154     rillig   2399:     13.6. work*
                   2400:     13.7. files/*
1.1       dsieger  2401: 
1.154     rillig   2402: 14. Programming in Makefiles
1.1       dsieger  2403: 
1.154     rillig   2404:     14.1. Caveats
                   2405:     14.2. Makefile variables
1.1       dsieger  2406: 
1.154     rillig   2407:         14.2.1. Naming conventions
1.1       dsieger  2408: 
1.154     rillig   2409:     14.3. Code snippets
1.1       dsieger  2410: 
1.154     rillig   2411:         14.3.1. Adding things to a list
                   2412:         14.3.2. Echoing a string exactly as-is
                   2413:         14.3.3. Passing CFLAGS to GNU configure scripts
                   2414:         14.3.4. Handling possibly empty variables
1.1       dsieger  2415: 
1.154     rillig   2416: 15. PLIST issues
1.1       dsieger  2417: 
1.154     rillig   2418:     15.1. RCS ID
                   2419:     15.2. Semi-automatic PLIST generation
                   2420:     15.3. Tweaking output of make print-PLIST
                   2421:     15.4. Variable substitution in PLIST
                   2422:     15.5. Man page compression
                   2423:     15.6. Changing PLIST source with PLIST_SRC
                   2424:     15.7. Platform-specific and differing PLISTs
                   2425:     15.8. Build-specific PLISTs
                   2426:     15.9. Sharing directories between packages
1.1       dsieger  2427: 
1.154     rillig   2428: 16. Buildlink methodology
1.1       dsieger  2429: 
1.154     rillig   2430:     16.1. Converting packages to use buildlink3
                   2431:     16.2. Writing buildlink3.mk files
1.1       dsieger  2432: 
1.154     rillig   2433:         16.2.1. Anatomy of a buildlink3.mk file
                   2434:         16.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
1.27      wiz      2435:             pkg in buildlink3.mk files
1.1       dsieger  2436: 
1.154     rillig   2437:     16.3. Writing builtin.mk files
1.1       dsieger  2438: 
1.154     rillig   2439:         16.3.1. Anatomy of a builtin.mk file
                   2440:         16.3.2. Global preferences for native or pkgsrc software
1.1       dsieger  2441: 
1.154     rillig   2442: 17. The pkginstall framework
1.1       dsieger  2443: 
1.154     rillig   2444:     17.1. Files and directories outside the installation prefix
1.1       dsieger  2445: 
1.154     rillig   2446:         17.1.1. Directory manipulation
                   2447:         17.1.2. File manipulation
1.1       dsieger  2448: 
1.154     rillig   2449:     17.2. Configuration files
1.1       dsieger  2450: 
1.154     rillig   2451:         17.2.1. How PKG_SYSCONFDIR is set
                   2452:         17.2.2. Telling the software where configuration files are
                   2453:         17.2.3. Patching installations
                   2454:         17.2.4. Disabling handling of configuration files
1.1       dsieger  2455: 
1.154     rillig   2456:     17.3. System startup scripts
1.1       dsieger  2457: 
1.154     rillig   2458:         17.3.1. Disabling handling of system startup scripts
1.1       dsieger  2459: 
1.154     rillig   2460:     17.4. System users and groups
                   2461:     17.5. System shells
1.1       dsieger  2462: 
1.154     rillig   2463:         17.5.1. Disabling shell registration
1.1       dsieger  2464: 
1.154     rillig   2465:     17.6. Fonts
1.1       dsieger  2466: 
1.154     rillig   2467:         17.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  2468: 
1.154     rillig   2469: 18. Options handling
1.1       dsieger  2470: 
1.154     rillig   2471:     18.1. Global default options
                   2472:     18.2. Converting packages to use bsd.options.mk
                   2473:     18.3. Option Names
                   2474:     18.4. Determining the options of dependencies
1.1       dsieger  2475: 
1.154     rillig   2476: 19. The build process
1.1       dsieger  2477: 
1.154     rillig   2478:     19.1. Introduction
                   2479:     19.2. Program location
                   2480:     19.3. Directories used during the build process
                   2481:     19.4. Running a phase
                   2482:     19.5. The fetch phase
1.1       dsieger  2483: 
1.154     rillig   2484:         19.5.1. What to fetch and where to get it from
                   2485:         19.5.2. How are the files fetched?
1.1       dsieger  2486: 
1.154     rillig   2487:     19.6. The checksum phase
                   2488:     19.7. The extract phase
                   2489:     19.8. The patch phase
                   2490:     19.9. The tools phase
                   2491:     19.10. The wrapper phase
                   2492:     19.11. The configure phase
                   2493:     19.12. The build phase
                   2494:     19.13. The test phase
                   2495:     19.14. The install phase
                   2496:     19.15. The package phase
                   2497:     19.16. Cleaning up
                   2498:     19.17. Other helpful targets
1.1       dsieger  2499: 
1.154     rillig   2500: 20. Tools needed for building or running
1.1       dsieger  2501: 
1.154     rillig   2502:     20.1. Tools for pkgsrc builds
                   2503:     20.2. Tools needed by packages
                   2504:     20.3. Tools provided by platforms
1.1       dsieger  2505: 
1.154     rillig   2506: 21. Making your package work
1.1       dsieger  2507: 
1.154     rillig   2508:     21.1. General operation
1.1       dsieger  2509: 
1.154     rillig   2510:         21.1.1. How to pull in user-settable variables from mk.conf
                   2511:         21.1.2. User interaction
                   2512:         21.1.3. Handling licenses
                   2513:         21.1.4. Restricted packages
                   2514:         21.1.5. Handling dependencies
                   2515:         21.1.6. Handling conflicts with other packages
                   2516:         21.1.7. Packages that cannot or should not be built
                   2517:         21.1.8. Packages which should not be deleted, once installed
                   2518:         21.1.9. Handling packages with security problems
                   2519:         21.1.10. How to handle incrementing versions when fixing an existing
1.1       dsieger  2520:             package
1.154     rillig   2521:         21.1.11. Substituting variable text in the package files (the SUBST
1.1       dsieger  2522:             framework)
                   2523: 
1.154     rillig   2524:     21.2. The fetch phase
1.1       dsieger  2525: 
1.154     rillig   2526:         21.2.1. Packages whose distfiles aren't available for plain downloading
                   2527:         21.2.2. How to handle modified distfiles with the 'old' name
                   2528:         21.2.3. Packages hosted on github.com
                   2529: 
                   2530:     21.3. The configure phase
                   2531: 
                   2532:         21.3.1. Shared libraries - libtool
                   2533:         21.3.2. Using libtool on GNU packages that already support libtool
                   2534:         21.3.3. GNU Autoconf/Automake
                   2535: 
                   2536:     21.4. Programming languages
                   2537: 
                   2538:         21.4.1. C, C++, and Fortran
                   2539:         21.4.2. Java
                   2540:         21.4.3. Packages containing perl scripts
                   2541:         21.4.4. Packages containing shell scripts
                   2542:         21.4.5. Other programming languages
                   2543: 
                   2544:     21.5. The build phase
                   2545: 
                   2546:         21.5.1. Compiling C and C++ code conditionally
                   2547:         21.5.2. How to handle compiler bugs
                   2548:         21.5.3. Undefined reference to "..."
                   2549:         21.5.4. Running out of memory
                   2550: 
                   2551:     21.6. The install phase
                   2552: 
                   2553:         21.6.1. Creating needed directories
                   2554:         21.6.2. Where to install documentation
                   2555:         21.6.3. Installing highscore files
                   2556:         21.6.4. Adding DESTDIR support to packages
                   2557:         21.6.5. Packages with hardcoded paths to other interpreters
                   2558:         21.6.6. Packages installing perl modules
                   2559:         21.6.7. Packages installing info files
                   2560:         21.6.8. Packages installing man pages
                   2561:         21.6.9. Packages installing GConf data files
                   2562:         21.6.10. Packages installing scrollkeeper/rarian data files
                   2563:         21.6.11. Packages installing X11 fonts
                   2564:         21.6.12. Packages installing GTK2 modules
                   2565:         21.6.13. Packages installing SGML or XML data
                   2566:         21.6.14. Packages installing extensions to the MIME database
                   2567:         21.6.15. Packages using intltool
                   2568:         21.6.16. Packages installing startup scripts
                   2569:         21.6.17. Packages installing TeX modules
                   2570:         21.6.18. Packages supporting running binaries in emulation
                   2571:         21.6.19. Packages installing hicolor theme icons
                   2572:         21.6.20. Packages installing desktop files
                   2573: 
                   2574:     21.7. Marking packages as having problems
                   2575: 
                   2576: 22. Debugging
                   2577: 23. Submitting and Committing
                   2578: 
                   2579:     23.1. Submitting binary packages
                   2580:     23.2. Submitting source packages (for non-NetBSD-developers)
                   2581:     23.3. General notes when adding, updating, or removing packages
                   2582:     23.4. Commit Messages
                   2583:     23.5. Committing: Adding a package to CVS
                   2584:     23.6. Updating a package to a newer version
                   2585:     23.7. Renaming a package in pkgsrc
                   2586:     23.8. Moving a package in pkgsrc
                   2587: 
                   2588: 24. Frequently Asked Questions
                   2589: 25. GNOME packaging and porting
                   2590: 
                   2591:     25.1. Meta packages
                   2592:     25.2. Packaging a GNOME application
                   2593:     25.3. Updating GNOME to a newer version
                   2594:     25.4. Patching guidelines
                   2595: 
                   2596: Chapter 11. Getting help
                   2597: 
                   2598: To get help when developing pkgsrc, the definitive source is this document, the
                   2599: pkgsrc guide. If you don't find anything here, there are alternatives:
                   2600: 
                   2601:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
                   2602:     Run bmake help topic=? to get help for any topic, such as a variable name
                   2603:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                   2604:     like strcasecmp or any other topic.
                   2605: 
                   2606:     The available help topics are listed in Appendix D, Help topics.
                   2607: 
                   2608:   * The tech-pkg mailing list, to which you can subscribe and then ask your
                   2609:     questions.
                   2610: 
                   2611:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                   2612:     a specialized chat program such as XChat. Pick any user name and join the
                   2613:     channel #pkgsrc.
1.1       dsieger  2614: 
1.154     rillig   2615: Chapter 12. Creating a new pkgsrc package from scratch
1.1       dsieger  2616: 
                   2617: Table of Contents
                   2618: 
1.154     rillig   2619: 12.1. Common types of packages
1.1       dsieger  2620: 
1.154     rillig   2621:     12.1.1. Perl modules
                   2622:     12.1.2. Python modules and programs
1.1       dsieger  2623: 
1.154     rillig   2624: 12.2. Examples
1.1       dsieger  2625: 
1.154     rillig   2626:     12.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  2627: 
                   2628: When you find a package that is not yet in pkgsrc, you most likely have a URL
                   2629: from where you can download the source code. Starting with this URL, creating a
                   2630: package involves only a few steps.
                   2631: 
                   2632:  1. First, install the packages pkgtools/url2pkg and pkgtools/pkglint.
                   2633: 
                   2634:  2. Then, choose one of the top-level directories as the category in which you
                   2635:     want to place your package. You can also create a directory of your own
                   2636:     (maybe called local). In that category directory, create another directory
                   2637:     for your package and change into it.
                   2638: 
                   2639:  3. Run the program url2pkg, which will ask you for a URL. Enter the URL of the
                   2640:     distribution file (in most cases a .tar.gz file) and watch how the basic
                   2641:     ingredients of your package are created automatically. The distribution
                   2642:     file is extracted automatically to fill in some details in the Makefile
                   2643:     that would otherwise have to be done manually.
                   2644: 
                   2645:  4. Examine the extracted files to determine the dependencies of your package.
                   2646:     Ideally, this is mentioned in some README file, but things may differ. For
                   2647:     each of these dependencies, look where it exists in pkgsrc, and if there is
                   2648:     a file called buildlink3.mk in that directory, add a line to your package
                   2649:     Makefile which includes that file just before the last line. If the
1.26      spz      2650:     buildlink3.mk file does not exist, it must be created first. The
                   2651:     buildlink3.mk file makes sure that the package's include files and
                   2652:     libraries are provided.
                   2653: 
                   2654:     If you just need binaries from a package, add a DEPENDS line to the
                   2655:     Makefile, which specifies the version of the dependency and where it can be
                   2656:     found in pkgsrc. This line should be placed in the third paragraph. If the
1.1       dsieger  2657:     dependency is only needed for building the package, but not when using it,
1.156     leot     2658:     use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The difference
                   2659:     between TOOL_DEPENDS and BUILD_DEPENDS occurs when cross-compiling:
                   2660:     TOOL_DEPENDS are native packages, i.e. packages for the architecture where
                   2661:     the package is built; BUILD_DEPENDS are target packages, i.e. packages for
                   2662:     the architecture for which the package is built. Your package may then look
                   2663:     like this:
1.1       dsieger  2664: 
                   2665:     [...]
                   2666: 
1.156     leot     2667:     TOOL_DEPENDS+=  libxslt-[0-9]*:../../textproc/libxslt
1.1       dsieger  2668:     DEPENDS+=       screen-[0-9]*:../../misc/screen
                   2669:     DEPENDS+=       screen>=4.0:../../misc/screen
                   2670: 
                   2671:     [...]
                   2672: 
                   2673:     .include "../../category/package/buildlink3.mk"
                   2674:     .include "../../devel/glib2/buildlink3.mk"
                   2675:     .include "../../mk/bsd.pkg.mk"
                   2676: 
                   2677:  5. Run pkglint to see what things still need to be done to make your package a
                   2678:     "good" one. If you don't know what pkglint's warnings want to tell you, try
                   2679:     pkglint --explain or pkglint -e, which outputs additional explanations.
                   2680: 
                   2681:  6. In many cases the package is not yet ready to build. You can find
1.154     rillig   2682:     instructions for the most common cases in the next section, Section 12.1,
1.1       dsieger  2683:     "Common types of packages". After you have followed the instructions over
                   2684:     there, you can hopefully continue here.
                   2685: 
                   2686:  7. Run bmake clean to clean the working directory from the extracted files.
                   2687:     Besides these files, a lot of cache files and other system information has
                   2688:     been saved in the working directory, which may become wrong after you
                   2689:     edited the Makefile.
                   2690: 
                   2691:  8. Now, run bmake to build the package. For the various things that can go
1.154     rillig   2692:     wrong in this phase, consult Chapter 21, Making your package work.
1.1       dsieger  2693: 
1.25      wiz      2694:  9. When the package builds fine, the next step is to install the package. Run 
1.1       dsieger  2695:     bmake install and hope that everything works.
                   2696: 
                   2697: 10. Up to now, the file PLIST, which contains a list of the files that are
                   2698:     installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
                   2699:     generate a probably correct list. Check the file using your preferred text
                   2700:     editor to see if the list of files looks plausible.
                   2701: 
                   2702: 11. Run pkglint again to see if the generated PLIST contains garbage or not.
                   2703: 
                   2704: 12. When you ran bmake install, the package has been registered in the database
                   2705:     of installed files, but with an empty list of files. To fix this, run bmake
                   2706:     deinstall and bmake install again. Now the package is registered with the
                   2707:     list of files from PLIST.
                   2708: 
                   2709: 13. Run bmake package to create a binary package from the set of installed
                   2710:     files.
                   2711: 
1.154     rillig   2712: 12.1. Common types of packages
1.1       dsieger  2713: 
1.154     rillig   2714: 12.1.1. Perl modules
1.1       dsieger  2715: 
                   2716: Simple Perl modules are handled automatically by url2pkg, including
                   2717: dependencies.
                   2718: 
1.154     rillig   2719: 12.1.2. Python modules and programs
1.17      imil     2720: 
                   2721: Python modules and programs packages are easily created using a set of
                   2722: predefined variables.
                   2723: 
1.63      wiz      2724: If some Python versions are not supported by the software, set the
                   2725: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
                   2726: supported, e.g.
1.17      imil     2727: 
1.93      sevan    2728: PYTHON_VERSIONS_INCOMPATIBLE=       27
1.17      imil     2729: 
1.103     wiz      2730: If the packaged software is a Python module, include one of ../../lang/python/
                   2731: egg.mk, ../../lang/python/distutils.mk, or ../../lang/python/extension.mk.
                   2732: 
                   2733: Most Python packages use either "distutils" or easy-setup/setuptools ("eggs").
                   2734: if the packaged software is using setuptools, you only need to include "../../
                   2735: lang/python/egg.mk". Otherwise, if the software uses "distutils", include "..
                   2736: /../lang/python/distutils.mk". so pkgsrc will use this framework. "distutils"
                   2737: uses a script called setup.py, if the "distutils" driver is not called
                   2738: setup.py, set the PYSETUP variable to the name of the script.
                   2739: 
                   2740: Either way, the package directory should be called "py-software" and PKGNAME
                   2741: should be set to "${PYPKGPREFIX}-${DISTNAME}", e.g.
1.17      imil     2742: 
                   2743: DISTNAME=   foopymodule-1.2.10
                   2744: PKGNAME=    ${PYPKGPREFIX}-${DISTNAME}
                   2745: 
1.63      wiz      2746: If it is an application, include "../../lang/python/application.mk". In order
                   2747: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
                   2748: variable and set it to the list of files (paths relative to WRKSRC) that must
                   2749: be corrected. For example:
1.17      imil     2750: 
1.63      wiz      2751: REPLACE_PYTHON=   *.py
1.17      imil     2752: 
1.63      wiz      2753: Some Python modules have separate distributions for Python-2.x and Python-3.x
                   2754: support. In pkgsrc this is handled by the versioned_dependencies.mk file. Set
                   2755: PYTHON_VERSIONED_DEPENDENCIES to the list of packages that should be depended
                   2756: upon and include "../../lang/python/versioned_dependencies.mk", then the pkgsrc
                   2757: infrastructure will depend on the appropriate package version. For example:
1.17      imil     2758: 
1.135     wiz      2759: PYTHON_VERSIONED_DEPENDENCIES=dialog
1.63      wiz      2760: 
                   2761: Look inside versioned_dependencies.mk for a list of supported packages.
1.17      imil     2762: 
1.154     rillig   2763: 12.2. Examples
1.1       dsieger  2764: 
1.154     rillig   2765: 12.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  2766: 
1.154     rillig   2767: 12.2.1.1. The initial package
1.1       dsieger  2768: 
                   2769: Looking at the file pkgsrc/doc/TODO, I saw that the "nvu" package has not yet
                   2770: been imported into pkgsrc. As the description says it has to do with the web,
                   2771: the obvious choice for the category is "www".
                   2772: 
                   2773: $ mkdir www/nvu
                   2774: $ cd www/nvu
                   2775: 
                   2776: The web site says that the sources are available as a tar file, so I fed that
                   2777: URL to the url2pkg program:
                   2778: 
                   2779: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
                   2780: 
                   2781: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
                   2782: package name should not have the word "sources" in it. I also filled in the
                   2783: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
                   2784: that:
                   2785: 
1.121     sevan    2786: # $NetBSD $
1.1       dsieger  2787: #
                   2788: 
                   2789: DISTNAME=       nvu-1.0-sources
                   2790: PKGNAME=        nvu-1.0
                   2791: CATEGORIES=     www
                   2792: MASTER_SITES=   http://cvs.nvu.com/download/
                   2793: EXTRACT_SUFX=   .tar.bz2
                   2794: 
                   2795: MAINTAINER=     rillig@NetBSD.org
                   2796: HOMEPAGE=       http://cvs.nvu.com/
                   2797: COMMENT=        Web Authoring System
                   2798: 
                   2799: # url2pkg-marker (please do not remove this line.)
                   2800: .include "../../mk/bsd.pkg.mk"
                   2801: 
1.124     wiz      2802: On the first line of output above, an artificial space has been added between
1.121     sevan    2803: NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
                   2804: the guide.
                   2805: 
1.1       dsieger  2806: Then, I quit the editor and watched pkgsrc downloading a large source archive:
                   2807: 
                   2808: url2pkg> Running "make makesum" ...
                   2809: => Required installed package digest>=20010302: digest-20060826 found
                   2810: => Fetching nvu-1.0-sources.tar.bz2
                   2811: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
                   2812: 100% |*************************************| 28992 KB  150.77 KB/s00:00 ETA
                   2813: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
                   2814: url2pkg> Running "make extract" ...
                   2815: => Required installed package digest>=20010302: digest-20060826 found
                   2816: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   2817: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   2818: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
                   2819: ===> Installing dependencies for nvu-1.0
                   2820: ===> Overriding tools for nvu-1.0
                   2821: ===> Extracting for nvu-1.0
                   2822: url2pkg> Adjusting the Makefile.
                   2823: 
                   2824: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
                   2825: 
                   2826: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
                   2827: 
1.154     rillig   2828: 12.2.1.2. Fixing all kinds of problems to make the package work
1.1       dsieger  2829: 
                   2830: Now that the package has been extracted, let's see what's inside it. The
                   2831: package has a README.txt, but that only says something about mozilla, so it's
                   2832: probably useless for seeing what dependencies this package has. But since there
                   2833: is a GNU configure script in the package, let's hope that it will complain
                   2834: about everything it needs.
                   2835: 
                   2836: $ bmake
                   2837: => Required installed package digest>=20010302: digest-20060826 found
                   2838: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   2839: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   2840: ===> Patching for nvu-1.0
                   2841: ===> Creating toolchain wrappers for nvu-1.0
                   2842: ===> Configuring for nvu-1.0
                   2843: [...]
                   2844: configure: error: Perl 5.004 or higher is required.
                   2845: [...]
                   2846: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
                   2847: [...]
                   2848: 
                   2849: That worked quite well. So I opened the package Makefile in my editor, and
                   2850: since it already has a USE_TOOLS line, I just appended "perl" to it. Since the
                   2851: dependencies of the package have changed now, and since a perl wrapper is
                   2852: automatically installed in the "tools" phase, I need to build the package from
                   2853: scratch.
                   2854: 
                   2855: $ bmake clean
                   2856: ===> Cleaning for nvu-1.0
                   2857: $ bmake
                   2858: [...]
                   2859: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
                   2860: GNU Make.  You will not be able to build Mozilla without GNU Make.
                   2861: [...]
                   2862: 
                   2863: So I added "gmake" to the USE_TOOLS line and tried again (from scratch).
                   2864: 
                   2865: [...]
                   2866: checking for GTK - version >= 1.2.0... no
                   2867: *** Could not run GTK test program, checking why...
                   2868: [...]
                   2869: 
                   2870: Now to the other dependencies. The first question is: Where is the GTK package
                   2871: hidden in pkgsrc?
                   2872: 
                   2873: $ echo ../../*/gtk*
                   2874: [many packages ...]
                   2875: $ echo ../../*/gtk
                   2876: ../../x11/gtk
                   2877: $ echo ../../*/gtk2
                   2878: ../../x11/gtk2
                   2879: $ echo ../../*/gtk2/bui*
                   2880: ../../x11/gtk2/buildlink3.mk
                   2881: 
                   2882: The first try was definitely too broad. The second one had exactly one result,
                   2883: which is very good. But there is one pitfall with GNOME packages. Before GNOME
                   2884: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
                   2885: able to continue to use these packages, the GNOME 2 packages were imported as
                   2886: separate packages, and their names usually have a "2" appended. So I checked
                   2887: whether this was the case here, and indeed it was.
                   2888: 
                   2889: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
                   2890: easy. I just inserted an .include line before the last line of the package
                   2891: Makefile, so that it now looks like this:
                   2892: 
                   2893: [...]
                   2894: .include "../../x11/gtk2/buildlink3.mk"
                   2895: .include "../../mk/bsd.pkg.mk
                   2896: 
                   2897: After another bmake clean && bmake, the answer was:
                   2898: 
                   2899: [...]
                   2900: checking for gtk-config... /home/roland/pkg/bin/gtk-config
                   2901: checking for GTK - version >= 1.2.0... no
                   2902: *** Could not run GTK test program, checking why...
                   2903: *** The test program failed to compile or link. See the file config.log for the
                   2904: *** exact error that occured. This usually means GTK was incorrectly installed
                   2905: *** or that you have moved GTK since it was installed. In the latter case, you
                   2906: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
                   2907: configure: error: Test for GTK failed.
                   2908: [...]
                   2909: 
                   2910: In this particular case, the assumption that "every package prefers GNOME 2"
                   2911: had been wrong. The first of the lines above told me that this package really
                   2912: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
                   2913: it would have looked for pkg-config instead of gtk-config. So I changed the x11
                   2914: /gtk2 to x11/gtk in the package Makefile, and tried again.
                   2915: 
                   2916: [...]
1.59      jnemeth  2917: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\"  [...]
1.1       dsieger  2918: In file included from xpidl.c:42:
                   2919: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
                   2920: In file included from xpidl.c:42:
                   2921: xpidl.h:132: error: parse error before "IDL_ns"
                   2922: [...]
                   2923: 
                   2924: The package still does not find all of its dependencies. Now the question is:
                   2925: Which package provides the libIDL/IDL.h header file?
                   2926: 
                   2927: $ echo ../../*/*idl*
                   2928: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
                   2929: $ echo ../../*/*IDL*
                   2930: ../../net/libIDL
                   2931: 
                   2932: Let's take the one from the second try. So I included the ../../net/libIDL/
                   2933: buildlink3.mk file and tried again. But the error didn't change. After digging
                   2934: through some of the code, I concluded that the build process of the package was
                   2935: broken and couldn't have ever worked, but since the Mozilla source tree is
                   2936: quite large, I didn't want to fix it. So I added the following to the package
                   2937: Makefile and tried again:
                   2938: 
                   2939: CPPFLAGS+=              -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
1.139     leot     2940: BUILDLINK_TRANSFORM+=   l:IDL:IDL-2
1.1       dsieger  2941: 
                   2942: The latter line is needed because the package expects the library libIDL.so,
                   2943: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
                   2944: that on the fly.
                   2945: 
                   2946: The next problem was related to a recent change of the FreeType interface. I
                   2947: looked up in www/seamonkey which patch files were relevant for this issue and
                   2948: copied them to the patches directory. Then I retried, fixed the patches so that
                   2949: they applied cleanly and retried again. This time, everything worked.
                   2950: 
1.154     rillig   2951: 12.2.1.3. Installing the package
1.1       dsieger  2952: 
                   2953: $ bmake CHECK_FILES=no install
                   2954: [...]
                   2955: $ bmake print-PLIST >PLIST
                   2956: $ bmake deinstall
                   2957: $ bmake install
                   2958: 
1.154     rillig   2959: Chapter 13. Package components - files, directories and contents
1.1       dsieger  2960: 
                   2961: Table of Contents
                   2962: 
1.154     rillig   2963: 13.1. Makefile
                   2964: 13.2. distinfo
                   2965: 13.3. patches/*
                   2966: 
                   2967:     13.3.1. Structure of a single patch file
                   2968:     13.3.2. Creating patch files
                   2969:     13.3.3. Sources where the patch files come from
                   2970:     13.3.4. Patching guidelines
                   2971:     13.3.5. Feedback to the author
                   2972: 
                   2973: 13.4. Other mandatory files
                   2974: 13.5. Optional files
                   2975: 
                   2976:     13.5.1. Files affecting the binary package
                   2977:     13.5.2. Files affecting the build process
                   2978:     13.5.3. Files affecting nothing at all
1.1       dsieger  2979: 
1.154     rillig   2980: 13.6. work*
                   2981: 13.7. files/*
1.1       dsieger  2982: 
                   2983: Whenever you're preparing a package, there are a number of files involved which
                   2984: are described in the following sections.
                   2985: 
1.154     rillig   2986: 13.1. Makefile
1.1       dsieger  2987: 
                   2988: Building, installation and creation of a binary package are all controlled by
                   2989: the package's Makefile. The Makefile describes various things about a package,
                   2990: for example from where to get it, how to configure, build, and install it.
                   2991: 
                   2992: A package Makefile contains several sections that describe the package.
                   2993: 
                   2994: In the first section there are the following variables, which should appear
                   2995: exactly in the order given here. The order and grouping of the variables is
                   2996: mostly historical and has no further meaning.
                   2997: 
                   2998:   * DISTNAME is the basename of the distribution file to be downloaded from the
                   2999:     package's website.
                   3000: 
1.66      asau     3001:   * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
                   3002:     it if DISTNAME (which is the default) is not a good name for the package in
                   3003:     pkgsrc or DISTNAME is not provided (no distribution file is required).
                   3004:     Usually it is the pkgsrc directory name together with the version number.
                   3005:     It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
                   3006:     is, it starts with a letter or digit, and contains only letters, digits,
                   3007:     dashes, underscores, dots and plus signs.
1.1       dsieger  3008: 
                   3009:   * CATEGORIES is a list of categories which the package fits in. You can
                   3010:     choose any of the top-level directories of pkgsrc for it.
                   3011: 
                   3012:     Currently the following values are available for CATEGORIES. If more than
                   3013:     one is used, they need to be separated by spaces:
                   3014: 
                   3015:     archivers     cross         geography     meta-pkgs     security
                   3016:     audio         databases     graphics      misc          shells
                   3017:     benchmarks    devel         ham           multimedia    sysutils
                   3018:     biology       editors       inputmethod   net           textproc
                   3019:     cad           emulators     lang          news          time
                   3020:     chat          finance       mail          parallel      wm
                   3021:     comms         fonts         math          pkgtools      www
                   3022:     converters    games         mbone         print         x11
                   3023: 
                   3024:   * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
1.154     rillig   3025:     are discussed in detail in Section 19.5, "The fetch phase".
1.1       dsieger  3026: 
                   3027: The second section contains information about separately downloaded patches, if
                   3028: any.
                   3029: 
                   3030:   * PATCHFILES: Name(s) of additional files that contain distribution patches.
                   3031:     There is no default. pkgsrc will look for them at PATCH_SITES. They will
                   3032:     automatically be uncompressed before patching if the names end with .gz or
                   3033:     .Z.
                   3034: 
                   3035:   * PATCH_SITES: Primary location(s) for distribution patch files (see
1.80      wiz      3036:     PATCHFILES above) if not found locally.
                   3037: 
                   3038:   * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
                   3039:     count to help find the correct files to patch. It defaults to -p0.
1.1       dsieger  3040: 
                   3041: The third section contains the following variables.
                   3042: 
                   3043:   * MAINTAINER is the email address of the person who feels responsible for
                   3044:     this package, and who is most likely to look at problems or questions
                   3045:     regarding this package which have been reported with send-pr(1). Other
1.14      jmcneill 3046:     developers may contact the MAINTAINER before making changes to the package,
                   3047:     but are not required to do so. When packaging a new program, set MAINTAINER
                   3048:     to yourself. If you really can't maintain the package for future updates,
                   3049:     set it to <pkgsrc-users@NetBSD.org>.
                   3050: 
                   3051:   * OWNER should be used instead of MAINTAINER when you do not want other
                   3052:     developers to update or change the package without contacting you first. A
                   3053:     package Makefile should contain one of MAINTAINER or OWNER, but not both.
1.1       dsieger  3054: 
                   3055:   * HOMEPAGE is a URL where users can find more information about the package.
                   3056: 
                   3057:   * COMMENT is a one-line description of the package (should not include the
                   3058:     package name).
                   3059: 
1.122     leot     3060:   * LICENSE indicates the license(s) applicable for the package. See
1.154     rillig   3061:     Section 21.1.3, "Handling licenses" for further details.
1.122     leot     3062: 
1.1       dsieger  3063: Other variables that affect the build:
                   3064: 
                   3065:   * WRKSRC: The directory where the interesting distribution files of the
                   3066:     package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
                   3067:     most packages.
                   3068: 
                   3069:     If a package doesn't create a subdirectory for itself (most GNU software
                   3070:     does, for instance), but extracts itself in the current directory, you
                   3071:     should set WRKSRC=${WRKDIR}.
                   3072: 
                   3073:     If a package doesn't create a subdirectory with the name of DISTNAME but
                   3074:     some different name, set WRKSRC to point to the proper name in ${WRKDIR},
                   3075:     for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
                   3076:     other examples.
                   3077: 
                   3078:     The name of the working directory created by pkgsrc is taken from the
                   3079:     WRKDIR_BASENAME variable. By default, its value is work. If you want to use
                   3080:     the same pkgsrc tree for building different kinds of binary packages, you
                   3081:     can change the variable according to your needs. Two other variables handle
                   3082:     common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
1.4       rillig   3083:     defined in mk.conf, the first component of the host's name is attached to
                   3084:     the directory name. If OBJMACHINE is defined, the platform name is
1.1       dsieger  3085:     attached, which might look like work.i386 or work.sparc.
                   3086: 
                   3087: Please pay attention to the following gotchas:
                   3088: 
                   3089:   * Add MANCOMPRESSED if man pages are installed in compressed form by the
                   3090:     package. For packages using BSD-style makefiles which honor MANZ, there is
                   3091:     MANCOMPRESSED_IF_MANZ.
                   3092: 
                   3093:   * Replace /usr/local with "${PREFIX}" in all files (see patches, below).
                   3094: 
1.154     rillig   3095:   * If the package installs any info files, see Section 21.6.7, "Packages
1.1       dsieger  3096:     installing info files".
                   3097: 
1.154     rillig   3098: 13.2. distinfo
1.1       dsieger  3099: 
                   3100: The distinfo file contains the message digest, or checksum, of each distfile
                   3101: needed for the package. This ensures that the distfiles retrieved from the
                   3102: Internet have not been corrupted during transfer or altered by a malign force
1.108     rillig   3103: to introduce a security hole. To provide maximum security, all distfiles are
                   3104: protected using three different message digest algorithms (SHA1, RMD160,
                   3105: SHA512), as well as the file size.
1.1       dsieger  3106: 
                   3107: The distinfo file also contains the checksums for all the patches found in the
1.154     rillig   3108: patches directory (see Section 13.3, "patches/*"). These checksums ensure that
1.145     leot     3109: patches are only applied intentionally and that they don't accidentally change,
                   3110: e.g. when merging different changes together. They also make sure that new
                   3111: patches are actually added to CVS and old ones are removed. Too see whether the
                   3112: patches and the distinfo file match, run pkglint after changing the patches.
1.1       dsieger  3113: 
1.108     rillig   3114: To regenerate the distinfo file, use the make distinfo command.
1.1       dsieger  3115: 
                   3116: Some packages have different sets of distfiles depending on the platform, for
1.24      wiz      3117: example lang/openjdk7. These are kept in the same distinfo file and care should
                   3118: be taken when upgrading such a package to ensure distfile information is not
                   3119: lost.
1.1       dsieger  3120: 
1.154     rillig   3121: 13.3. patches/*
1.1       dsieger  3122: 
1.108     rillig   3123: Some packages don't work out-of-the box on the various platforms that are
                   3124: supported by pkgsrc. These packages need to be patched to make them work. The
                   3125: patch files can be found in the patches/ directory.
1.1       dsieger  3126: 
                   3127: In the patch phase, these patches are applied to the files in WRKSRC directory
1.25      wiz      3128: after extracting them, in alphabetic order.
1.1       dsieger  3129: 
1.154     rillig   3130: 13.3.1. Structure of a single patch file
1.1       dsieger  3131: 
                   3132: The patch-* files should be in diff -bu format, and apply without a fuzz to
                   3133: avoid problems. (To force patches to apply with fuzz you can set
                   3134: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
                   3135: a single file, and no file should be patched by more than one patch file. This
                   3136: helps to keep future modifications simple.
                   3137: 
                   3138: Each patch file is structured as follows: In the first line, there is the RCS
                   3139: Id of the patch itself. The second line should be empty for aesthetic reasons.
                   3140: After that, there should be a comment for each change that the patch does.
                   3141: There are a number of standard cases:
                   3142: 
                   3143:   * Patches for commonly known vulnerabilities should mention the vulnerability
                   3144:     ID (CAN, CVE).
                   3145: 
                   3146:   * Patches that change source code should mention the platform and other
                   3147:     environment (for example, the compiler) that the patch is needed for.
                   3148: 
1.108     rillig   3149: The patch should be commented so that any developer who knows the code of the
                   3150: application can make some use of the patch. Special care should be taken for
                   3151: the upstream developers, since we generally want that they accept our patches,
                   3152: so we have less work in the future.
1.1       dsieger  3153: 
1.154     rillig   3154: 13.3.2. Creating patch files
1.1       dsieger  3155: 
                   3156: One important thing to mention is to pay attention that no RCS IDs get stored
                   3157: in the patch files, as these will cause problems when later checked into the
                   3158: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
                   3159: avoid these problems.
                   3160: 
                   3161: For even more automation, we recommend using mkpatches from the same package to
                   3162: make a whole set of patches. You just have to backup files before you edit them
1.25      wiz      3163: to filename.orig, e.g. with cp -p filename filename.orig or, easier, by using 
1.1       dsieger  3164: pkgvi again from the same package. If you upgrade a package this way, you can
1.25      wiz      3165: easily compare the new set of patches with the previously existing one with 
                   3166: patchdiff. The files in patches are replaced by new files, so carefully check
                   3167: if you want to take all the changes.
1.1       dsieger  3168: 
                   3169: When you have finished a package, remember to generate the checksums for the
1.154     rillig   3170: patch files by using the make makepatchsum command, see Section 13.2,
1.1       dsieger  3171: "distinfo".
                   3172: 
                   3173: When adding a patch that corrects a problem in the distfile (rather than e.g.
                   3174: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
                   3175: report to the maintainer. This benefits non-pkgsrc users of the package, and
                   3176: usually makes it possible to remove the patch in future version.
                   3177: 
1.25      wiz      3178: The file names of the patch files are usually of the form patch-
                   3179: path_to_file__with__underscores.c. Many packages still use the previous
                   3180: convention patch-[a-z][a-z], but new patches should be of the form containing
                   3181: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
                   3182: automatically.
1.2       rillig   3183: 
1.154     rillig   3184: 13.3.3. Sources where the patch files come from
1.1       dsieger  3185: 
                   3186: If you want to share patches between multiple packages in pkgsrc, e.g. because
                   3187: they use the same distfiles, set PATCHDIR to the path where the patch files can
                   3188: be found, e.g.:
                   3189: 
1.159   ! rillig   3190: PATCHDIR=       ../../editors/xemacs/patches
1.1       dsieger  3191: 
                   3192: Patch files that are distributed by the author or other maintainers can be
                   3193: listed in PATCHFILES.
                   3194: 
                   3195: If it is desired to store any patches that should not be committed into pkgsrc,
                   3196: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
                   3197: directory tree there is expected to have the same "category/package" structure
                   3198: as pkgsrc, and patches are expected to be stored inside these dirs (also known
                   3199: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
                   3200: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
                   3201: files in the named directory are expected to be patch files, and they are
                   3202: applied after pkgsrc patches are applied.
                   3203: 
1.154     rillig   3204: 13.3.4. Patching guidelines
1.1       dsieger  3205: 
                   3206: When fixing a portability issue in the code do not use preprocessor magic to
                   3207: check for the current operating system nor platform. Doing so hurts portability
                   3208: to other platforms because the OS-specific details are not abstracted
                   3209: appropriately.
                   3210: 
                   3211: The general rule to follow is: instead of checking for the operating system the
                   3212: application is being built on, check for the specific features you need. For
                   3213: example, instead of assuming that kqueue is available under NetBSD and using
                   3214: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
                   3215: kqueue itself ? yes, this generally involves patching the configure script.
                   3216: There is absolutely nothing that prevents some OSes from adopting interfaces
                   3217: from other OSes (e.g. Linux implementing kqueue), something that the above
                   3218: checks cannot take into account.
                   3219: 
                   3220: Of course, checking for features generally involves more work on the
                   3221: developer's side, but the resulting changes are cleaner and there are chances
                   3222: they will work on many other platforms. Not to mention that there are higher
                   3223: chances of being later integrated into the mainstream sources. Remember: It
                   3224: doesn't work unless it is right!
                   3225: 
                   3226: Some typical examples:
                   3227: 
1.154     rillig   3228: Table 13.1. Patching examples
1.1       dsieger  3229: 
                   3230: +-------------------------------------------------------------------------------------------+
                   3231: |  Where  |        Incorrect         |                       Correct                        |
                   3232: |---------+--------------------------+------------------------------------------------------|
                   3233: |         |case ${target_os} in      |                                                      |
                   3234: |configure|netbsd*) have_kvm=yes ;;  |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
                   3235: |script   |*)       have_kvm=no  ;;  |                                                      |
                   3236: |         |esac                      |                                                      |
                   3237: |---------+--------------------------+------------------------------------------------------|
1.2       rillig   3238: |C source |#if defined(__NetBSD__)   |#if defined(HAVE_SYS_EVENT_H)                         |
                   3239: |file     |#  include <sys/event.h>  |#  include <sys/event.h>                              |
                   3240: |         |#endif                    |#endif                                                |
1.1       dsieger  3241: |---------+--------------------------+------------------------------------------------------|
                   3242: |         |int                       |int                                                   |
                   3243: |         |monitor_file(...)         |monitor_file(...)                                     |
                   3244: |         |{                         |{                                                     |
                   3245: |         |#if defined(__NetBSD__)   |#if defined(HAVE_KQUEUE)                              |
                   3246: |C source |        int fd = kqueue();|        int fd = kqueue();                            |
                   3247: |file     |        ...               |        ...                                           |
                   3248: |         |#else                     |#else                                                 |
                   3249: |         |        ...               |        ...                                           |
                   3250: |         |#endif                    |#endif                                                |
                   3251: |         |}                         |}                                                     |
                   3252: +-------------------------------------------------------------------------------------------+
                   3253: 
                   3254: 
1.154     rillig   3255: 13.3.5. Feedback to the author
1.1       dsieger  3256: 
                   3257: Always, always, always feed back any portability fixes or improvements you do
                   3258: to a package to the mainstream developers. This is the only way to get their
                   3259: attention on portability issues and to ensure that future versions can be built
                   3260: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
                   3261: get the fixes straight from the packaged code.
                   3262: 
                   3263: This generally involves cleaning up the patches (because sometimes the patches
1.41      wiz      3264: that are added to pkgsrc are quick hacks), filing bug reports in the
1.1       dsieger  3265: appropriate trackers for the projects and working with the mainstream authors
                   3266: to accept your changes. It is extremely important that you do it so that the
                   3267: packages in pkgsrc are kept simple and thus further changes can be done without
                   3268: much hassle.
                   3269: 
1.25      wiz      3270: When you have done this, please add a URL to the upstream bug report to the
                   3271: patch comment.
                   3272: 
1.1       dsieger  3273: Support the idea of free software!
                   3274: 
1.154     rillig   3275: 13.4. Other mandatory files
1.1       dsieger  3276: 
                   3277: DESCR
                   3278: 
                   3279:     A multi-line description of the piece of software. This should include any
                   3280:     credits where they are due. Please bear in mind that others do not share
                   3281:     your sense of humour (or spelling idiosyncrasies), and that others will
                   3282:     read everything that you write here.
                   3283: 
                   3284: PLIST
                   3285: 
                   3286:     This file governs the files that are installed on your system: all the
                   3287:     binaries, manual pages, etc. There are other directives which may be
                   3288:     entered in this file, to control the creation and deletion of directories,
1.154     rillig   3289:     and the location of inserted files. See Chapter 15, PLIST issues for more
1.1       dsieger  3290:     information.
                   3291: 
1.154     rillig   3292: 13.5. Optional files
1.1       dsieger  3293: 
1.154     rillig   3294: 13.5.1. Files affecting the binary package
1.1       dsieger  3295: 
                   3296: INSTALL
                   3297: 
                   3298:     This shell script is invoked twice by pkg_add(1). First time after package
                   3299:     extraction and before files are moved in place, the second time after the
                   3300:     files to install are moved in place. This can be used to do any custom
                   3301:     procedures not possible with @exec commands in PLIST. See pkg_add(1) and
1.154     rillig   3302:     pkg_create(1) for more information. See also Section 17.1, "Files and
1.29      wiz      3303:     directories outside the installation prefix". Please note that you can
                   3304:     modify variables in it easily by using FILES_SUBST in the package's
                   3305:     Makefile:
                   3306: 
                   3307:     FILES_SUBST+=  SOMEVAR="somevalue"
                   3308: 
                   3309:     replaces "@SOMEVAR@" with "somevalue" in the INSTALL. By default,
                   3310:     substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
                   3311:     few others, type make help topic=FILES_SUBST for a complete list.
1.1       dsieger  3312: 
                   3313: DEINSTALL
                   3314: 
                   3315:     This script is executed before and after any files are removed. It is this
                   3316:     script's responsibility to clean up any additional messy details around the
                   3317:     package's installation, since all pkg_delete knows is how to delete the
                   3318:     files created in the original distribution. See pkg_delete(1) and
1.29      wiz      3319:     pkg_create(1) for more information. The same methods to replace variables
                   3320:     can be used as for the INSTALL file.
1.1       dsieger  3321: 
                   3322: MESSAGE
                   3323: 
                   3324:     This file is displayed after installation of the package. Useful for things
                   3325:     like legal notices on almost-free software and hints for updating config
                   3326:     files after installing modules for apache, PHP etc. Please note that you
                   3327:     can modify variables in it easily by using MESSAGE_SUBST in the package's
                   3328:     Makefile:
                   3329: 
                   3330:     MESSAGE_SUBST+=  SOMEVAR="somevalue"
                   3331: 
                   3332:     replaces "${SOMEVAR}" with "somevalue" in MESSAGE. By default, substitution
1.99      sevan    3333:     is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11BASE,
1.16      jnemeth  3334:     PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1       dsieger  3335: 
                   3336:     You can display a different or additional files by setting the MESSAGE_SRC
                   3337:     variable. Its default is MESSAGE, if the file exists.
                   3338: 
                   3339: ALTERNATIVES
                   3340: 
1.66      asau     3341:     This file is used by the alternatives framework. It creates, configures,
                   3342:     and destroys generic wrappers used to run programs with similar interfaces.
                   3343:     See pkg_alternatives(8) from pkgtools/pkg_alternatives for more
                   3344:     information.
                   3345: 
                   3346:     Each line of the file contains two filenames, first the wrapper and then
                   3347:     the alternative provided by the package. Both paths are relative to PREFIX.
1.1       dsieger  3348: 
1.154     rillig   3349: 13.5.2. Files affecting the build process
1.1       dsieger  3350: 
                   3351: Makefile.common
                   3352: 
                   3353:     This file contains arbitrary things that could also go into a Makefile, but
                   3354:     its purpose is to be used by more than one package. This file should only
                   3355:     be used when the packages that will use the file are known in advance. For
                   3356:     other purposes it is often better to write a *.mk file and give it a good
                   3357:     name that describes what it does.
                   3358: 
                   3359: buildlink3.mk
                   3360: 
                   3361:     This file contains the dependency information for the buildlink3 framework
1.154     rillig   3362:     (see Chapter 16, Buildlink methodology).
1.1       dsieger  3363: 
                   3364: hacks.mk
                   3365: 
                   3366:     This file contains workarounds for compiler bugs and similar things. It is
                   3367:     included automatically by the pkgsrc infrastructure, so you don't need an
                   3368:     extra .include line for it.
                   3369: 
                   3370: options.mk
                   3371: 
                   3372:     This file contains the code for the package-specific options (see
1.154     rillig   3373:     Chapter 18, Options handling) that can be selected by the user. If a
1.1       dsieger  3374:     package has only one or two options, it is equally acceptable to put the
                   3375:     code directly into the Makefile.
                   3376: 
1.154     rillig   3377: 13.5.3. Files affecting nothing at all
1.1       dsieger  3378: 
                   3379: README*
                   3380: 
                   3381:     These files do not take place in the creation of a package and thus are
                   3382:     purely informative to the package developer.
                   3383: 
                   3384: TODO
                   3385: 
                   3386:     This file contains things that need to be done to make the package even
                   3387:     better.
                   3388: 
1.154     rillig   3389: 13.6. work*
1.1       dsieger  3390: 
                   3391: When you type make, the distribution files are unpacked into the directory
                   3392: denoted by WRKDIR. It can be removed by running make clean. Besides the
                   3393: sources, this directory is also used to keep various timestamp files. The
                   3394: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
                   3395: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
                   3396: 
1.154     rillig   3397: 13.7. files/*
1.1       dsieger  3398: 
                   3399: If you have any files that you wish to be placed in the package prior to
                   3400: configuration or building, you could place these files here and use a ${CP}
                   3401: command in the "pre-configure" target to achieve this. Alternatively, you could
                   3402: simply diff the file against /dev/null and use the patch mechanism to manage
                   3403: the creation of this file.
                   3404: 
                   3405: If you want to share files in this way with other packages, set the FILESDIR
                   3406: variable to point to the other package's files directory, e.g.:
                   3407: 
1.159   ! rillig   3408: FILESDIR=       ../../editors/xemacs/files
1.1       dsieger  3409: 
1.154     rillig   3410: Chapter 14. Programming in Makefiles
1.1       dsieger  3411: 
                   3412: Table of Contents
                   3413: 
1.154     rillig   3414: 14.1. Caveats
                   3415: 14.2. Makefile variables
1.1       dsieger  3416: 
1.154     rillig   3417:     14.2.1. Naming conventions
1.1       dsieger  3418: 
1.154     rillig   3419: 14.3. Code snippets
1.1       dsieger  3420: 
1.154     rillig   3421:     14.3.1. Adding things to a list
                   3422:     14.3.2. Echoing a string exactly as-is
                   3423:     14.3.3. Passing CFLAGS to GNU configure scripts
                   3424:     14.3.4. Handling possibly empty variables
1.1       dsieger  3425: 
                   3426: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
                   3427: part of the pkgsrc system. Using the make(1) system as a programming language
                   3428: for a big system like pkgsrc requires some discipline to keep the code correct
                   3429: and understandable.
                   3430: 
1.154     rillig   3431: The basic ingredients for Makefile programming are variables and shell
                   3432: commands. Among these shell commands may even be more complex ones like awk(1)
                   3433: programs. To make sure that every shell command runs as intended it is
                   3434: necessary to quote all variables correctly when they are used.
1.1       dsieger  3435: 
1.154     rillig   3436: This chapter describes some patterns that appear quite often in Makefiles,
1.1       dsieger  3437: including the pitfalls that come along with them.
                   3438: 
1.154     rillig   3439: 14.1. Caveats
1.1       dsieger  3440: 
                   3441:   * When you are creating a file as a target of a rule, always write the data
                   3442:     to a temporary file first and finally rename that file. Otherwise there
                   3443:     might occur an error in the middle of generating the file, and when the
                   3444:     user runs make(1) for the second time, the file exists and will not be
                   3445:     regenerated properly. Example:
                   3446: 
                   3447:     wrong:
                   3448:             @echo "line 1" > ${.TARGET}
                   3449:             @echo "line 2" >> ${.TARGET}
                   3450:             @false
                   3451: 
                   3452:     correct:
                   3453:             @echo "line 1" > ${.TARGET}.tmp
                   3454:             @echo "line 2" >> ${.TARGET}.tmp
                   3455:             @false
                   3456:             @mv ${.TARGET}.tmp ${.TARGET}
                   3457: 
                   3458:     When you run make wrong twice, the file wrong will exist, although there
                   3459:     was an error message in the first run. On the other hand, running make
                   3460:     correct gives an error message twice, as expected.
                   3461: 
                   3462:     You might remember that make(1) sometimes removes ${.TARGET} in case of
                   3463:     error, but this only happens when it is interrupted, for example by
1.154     rillig   3464:     pressing Ctrl+C. This does not happen when one of the commands fails (like
1.1       dsieger  3465:     false(1) above).
                   3466: 
1.154     rillig   3467: 14.2. Makefile variables
1.1       dsieger  3468: 
                   3469: Makefile variables contain strings that can be processed using the five
1.154     rillig   3470: operators =, +=, ?=, := and !=, which are described in the make(1) man page.
1.1       dsieger  3471: 
1.154     rillig   3472: When a variable's value is parsed from a Makefile, the hash character # and the
                   3473: backslash character \ are handled specially. If a backslash is the last
                   3474: character in a line, that backslash is removed from the line and the line
                   3475: continues with the next line of the file.
                   3476: 
                   3477: The # character starts a comment that reaches until the end of the line. To get
                   3478: an actual # character, such as in a URL, write \# instead.
1.1       dsieger  3479: 
1.108     rillig   3480: The evaluation of variables either happens immediately or lazy. It happens
1.154     rillig   3481: immediately when the variable occurs on the right-hand side of the := or the !=
                   3482: operator, in a .if condition or a .for loop. In the other cases, it is
                   3483: evaluated lazily.
1.1       dsieger  3484: 
                   3485: Some of the modifiers split the string into words and then operate on the
                   3486: words, others operate on the string as a whole. When a string is split into
1.154     rillig   3487: words, double quotes and single quotes are interpreted as delimiters, just like
                   3488: in sh(1).
1.1       dsieger  3489: 
1.154     rillig   3490: 14.2.1. Naming conventions
1.1       dsieger  3491: 
                   3492:   * All variable names starting with an underscore are reserved for use by the
1.154     rillig   3493:     pkgsrc infrastructure. They shall not be used by packages.
1.1       dsieger  3494: 
                   3495:   * In .for loops you should use lowercase variable names for the iteration
                   3496:     variables.
                   3497: 
1.154     rillig   3498:   * All list variables should have a plural name, such as PKG_OPTIONS or
1.1       dsieger  3499:     DISTFILES.
                   3500: 
1.154     rillig   3501: 14.3. Code snippets
1.1       dsieger  3502: 
1.154     rillig   3503: 14.3.1. Adding things to a list
1.108     rillig   3504: 
                   3505: When adding a string that possibly contains whitespace or quotes to a list
                   3506: (example 1), it must be quoted using the :Q modifier.
1.1       dsieger  3507: 
1.108     rillig   3508: When adding another list to a list (example 2), it must not be quoted, since
                   3509: its elements are already quoted.
1.1       dsieger  3510: 
1.108     rillig   3511: STRING=         foo * bar `date`
                   3512: LIST=           # empty
                   3513: ANOTHER_LIST=   a=b c=d
1.1       dsieger  3514: 
1.108     rillig   3515: LIST+=          ${STRING:Q}       # 1
                   3516: LIST+=          ${ANOTHER_LIST}   # 2
1.1       dsieger  3517: 
1.154     rillig   3518: 14.3.2. Echoing a string exactly as-is
1.1       dsieger  3519: 
1.108     rillig   3520: Echoing a string containing special characters needs special work.
1.1       dsieger  3521: 
                   3522: STRING=         foo bar <    > * `date` $$HOME ' "
1.108     rillig   3523: EXAMPLE_ENV=    string=${STRING:Q} x=multiple\ quoted\ words
1.1       dsieger  3524: 
                   3525: all:
                   3526:         echo ${STRING}                  # 1
1.108     rillig   3527:         echo ${STRING:Q}                # 2
                   3528:         printf '%s\n' ${STRING:Q}''     # 3
                   3529:         env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"'   # 4
1.1       dsieger  3530: 
                   3531: Example 1 leads to a syntax error in the shell, as the characters are just
                   3532: copied.
                   3533: 
1.108     rillig   3534: Example 2 quotes the string so that the shell interprets it correctly. But the
                   3535: echo command may additionally interpret strings with a leading dash or those
                   3536: containing backslashes.
                   3537: 
                   3538: Example 3 can handle arbitrary strings, since printf(1) only interprets the
1.139     leot     3539: format string, but not the next argument. The trailing single quotes handle the
                   3540: case when the string is empty. In that case, the :Q modifier would result in an
                   3541: empty string too, which would then be skipped by the shell. For printf(1) this
                   3542: doesn't make a difference, but other programs may care.
1.108     rillig   3543: 
                   3544: In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
                   3545: has already been done when adding elements to the list.
                   3546: 
1.154     rillig   3547: 14.3.3. Passing CFLAGS to GNU configure scripts
1.108     rillig   3548: 
                   3549: When passing CFLAGS or similar variables to a GNU-style configure script
                   3550: (especially those that call other configure scripts), it must not have leading
                   3551: or trailing whitespace, since otherwise the configure script gets confused. To
                   3552: trim leading and trailing whitespace, use the :M modifier, as in the following
                   3553: example:
                   3554: 
                   3555: CPPFLAGS=               # empty
                   3556: CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX}\"
                   3557: CPPFLAGS+=              ${MY_CPPFLAGS}
                   3558: 
                   3559: CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
                   3560: 
                   3561: all:
                   3562:         echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
                   3563:         echo x${CONFIGURE_ARGS:Q}x      # properly trimmed
                   3564: 
                   3565: In this example, CPPFLAGS has both leading and trailing whitespace because the
                   3566: += operator always adds a space.
                   3567: 
1.154     rillig   3568: 14.3.4. Handling possibly empty variables
1.108     rillig   3569: 
                   3570: When a possibly empty variable is used in a shell program, it may lead to a
                   3571: syntax error.
                   3572: 
                   3573: EGFILES=        # empty
                   3574: 
                   3575: install-examples:   # produces a syntax error in the shell
                   3576:         for egfile in ${EGFILES}; do            \
                   3577:                 echo "Installing $$egfile";     \
                   3578:         done
                   3579: 
                   3580: The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
                   3581: with an empty string by make(1). To fix this syntax error, use one of the
                   3582: snippets below.
                   3583: 
                   3584: EMPTY=          # empty
                   3585: 
                   3586: install-examples:
                   3587:         for egfile in ${EGFILES} ""; do         \
                   3588:                 [ -n "$$egfile" ] || continue;  \
                   3589:                 echo "Installing $$egfile";     \
                   3590:         done
                   3591: 
                   3592: In this case, an empty string is appended to the iteration list (to prevent the
                   3593: syntax error) and filtered out later.
1.1       dsieger  3594: 
1.108     rillig   3595: EGFILES=        # empty
1.1       dsieger  3596: 
1.108     rillig   3597: install-examples:
                   3598: .for egfile in ${EGFILES}
                   3599:         echo "Installing ${egfile}"
                   3600: .endfor
                   3601: 
1.154     rillig   3602: If one of the filenames contains special characters, it should be enclosed in
                   3603: single or double quotes.
1.108     rillig   3604: 
                   3605: To have a shell command test whether a make variable is empty, use the
                   3606: following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
1.1       dsieger  3607: 
1.154     rillig   3608: Chapter 15. PLIST issues
1.1       dsieger  3609: 
                   3610: Table of Contents
                   3611: 
1.154     rillig   3612: 15.1. RCS ID
                   3613: 15.2. Semi-automatic PLIST generation
                   3614: 15.3. Tweaking output of make print-PLIST
                   3615: 15.4. Variable substitution in PLIST
                   3616: 15.5. Man page compression
                   3617: 15.6. Changing PLIST source with PLIST_SRC
                   3618: 15.7. Platform-specific and differing PLISTs
                   3619: 15.8. Build-specific PLISTs
                   3620: 15.9. Sharing directories between packages
1.1       dsieger  3621: 
                   3622: The PLIST file contains a package's "packing list", i.e. a list of files that
                   3623: belong to the package (relative to the ${PREFIX} directory it's been installed
                   3624: in) plus some additional statements - see the pkg_create(1) man page for a full
                   3625: list. This chapter addresses some issues that need attention when dealing with
                   3626: the PLIST file (or files, see below!).
                   3627: 
1.154     rillig   3628: 15.1. RCS ID
1.1       dsieger  3629: 
                   3630: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
                   3631: 
1.121     sevan    3632: @comment $NetBSD $
                   3633: 
1.123     wiz      3634: An artificial space has been added between NetBSD and $, this is a workaround
1.121     sevan    3635: here to prevent CVS expanding to the filename of the guide. When adding the RCS
1.125     leot     3636: ID the space should be omitted.
1.1       dsieger  3637: 
1.154     rillig   3638: 15.2. Semi-automatic PLIST generation
1.1       dsieger  3639: 
                   3640: You can use the make print-PLIST command to output a PLIST that matches any new
1.154     rillig   3641: files since the package was extracted. See Section 19.17, "Other helpful
1.1       dsieger  3642: targets" for more information on this target.
                   3643: 
1.154     rillig   3644: 15.3. Tweaking output of make print-PLIST
1.1       dsieger  3645: 
                   3646: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
                   3647: used to filter the output of print-PLIST. You can append any chunk of AWK
                   3648: scripting you like to it, but be careful with quoting.
                   3649: 
                   3650: For example, to get all files inside the libdata/foo directory removed from the
                   3651: resulting PLIST:
                   3652: 
                   3653: PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
                   3654: 
1.154     rillig   3655: 15.4. Variable substitution in PLIST
1.1       dsieger  3656: 
                   3657: A number of variables are substituted automatically in PLISTs when a package is
                   3658: installed on a system. This includes the following variables:
                   3659: 
                   3660: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
                   3661: 
                   3662:     Some packages like emacs and perl embed information about which
                   3663:     architecture they were built on into the pathnames where they install their
                   3664:     files. To handle this case, PLIST will be preprocessed before actually
                   3665:     used, and the symbol "${MACHINE_ARCH}" will be replaced by what uname -p
                   3666:     gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
                   3667:     PLIST somewhere - use this on packages that have GNU autoconf-created
                   3668:     configure scripts.
                   3669: 
                   3670:     Legacy note
                   3671: 
                   3672:     There used to be a symbol "$ARCH" that was replaced by the output of uname
                   3673:     -m, but that's no longer supported and has been removed.
                   3674: 
                   3675: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
                   3676: 
                   3677:     Some packages want to embed the OS name and version into some paths. To do
                   3678:     this, use these variables in the PLIST:
                   3679: 
1.42      asau     3680:       + ${OPSYS} - output of "uname -s"
1.1       dsieger  3681: 
1.42      asau     3682:       + ${LOWER_OPSYS} - lowercase common name (eg. "solaris")
1.1       dsieger  3683: 
1.42      asau     3684:       + ${OS_VERSION} - "uname -r"
1.1       dsieger  3685: 
1.88      tnn      3686: For a list of values which are replaced by default, the output of make help
                   3687: topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
                   3688: PLIST_SUBST should help.
1.1       dsieger  3689: 
                   3690: If you want to change other variables not listed above, you can add variables
                   3691: and their expansions to this variable in the following way, similar to
1.154     rillig   3692: MESSAGE_SUBST (see Section 13.5, "Optional files"):
1.1       dsieger  3693: 
                   3694: PLIST_SUBST+=   SOMEVAR="somevalue"
                   3695: 
                   3696: This replaces all occurrences of "${SOMEVAR}" in the PLIST with "somevalue".
                   3697: 
1.19      snj      3698: The PLIST_VARS variable can be used to simplify the common case of
                   3699: conditionally including some PLIST entries. It can be done by adding
                   3700: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
                   3701: entry should be included. This will substitute "${PLIST.foo}" in the PLIST with
                   3702: either """" or ""@comment "". For example, in Makefile:
1.18      mishka   3703: 
                   3704: PLIST_VARS+=    foo
                   3705: .if condition
                   3706: PLIST.foo=      yes
                   3707: .else
                   3708: 
                   3709: And then in PLIST:
                   3710: 
1.121     sevan    3711: @comment $NetBSD $
1.18      mishka   3712: bin/bar
                   3713: man/man1/bar.1
                   3714: ${PLIST.foo}bin/foo
                   3715: ${PLIST.foo}man/man1/foo.1
                   3716: ${PLIST.foo}share/bar/foo.data
                   3717: 
1.123     wiz      3718: An artificial space has been added between NetBSD and $, this is a workaround
1.121     sevan    3719: here to prevent CVS expanding to the filename of the guide. When adding the RCS
                   3720: ID the space should be ommited.
                   3721: 
1.154     rillig   3722: 15.5. Man page compression
1.1       dsieger  3723: 
                   3724: Man pages should be installed in compressed form if MANZ is set (in
                   3725: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
                   3726: suffix ".gz" is appended/removed automatically for man pages according to MANZ
                   3727: and MANCOMPRESSED being set or not, see above for details. This modification of
                   3728: the PLIST file is done on a copy of it, not PLIST itself.
                   3729: 
1.154     rillig   3730: 15.6. Changing PLIST source with PLIST_SRC
1.1       dsieger  3731: 
                   3732: To use one or more files as source for the PLIST used in generating the binary
                   3733: package, set the variable PLIST_SRC to the names of that file(s). The files are
                   3734: later concatenated using cat(1), and the order of things is important. The
                   3735: default for PLIST_SRC is ${PKGDIR}/PLIST.
                   3736: 
1.154     rillig   3737: 15.7. Platform-specific and differing PLISTs
1.1       dsieger  3738: 
                   3739: Some packages decide to install a different set of files based on the operating
                   3740: system being used. These differences can be automatically handled by using the
                   3741: following files:
                   3742: 
                   3743:   * PLIST.common
                   3744: 
                   3745:   * PLIST.${OPSYS}
                   3746: 
                   3747:   * PLIST.${MACHINE_ARCH}
                   3748: 
                   3749:   * PLIST.${OPSYS}-${MACHINE_ARCH}
                   3750: 
                   3751:   * PLIST.common_end
                   3752: 
1.154     rillig   3753: 15.8. Build-specific PLISTs
1.86      wiz      3754: 
                   3755: Some packages decide to generate hard-to-guess file names during installation
                   3756: that are hard to wire down.
                   3757: 
                   3758: In such cases, you can set the GENERATE_PLIST variable to shell code terminated
                   3759: (with a semicolon) that will output PLIST entries which will be appended to the
                   3760: PLIST
                   3761: 
                   3762: You can find one example in editors/xemacs:
                   3763: 
1.111     sevan    3764: GENERATE_PLIST+=        ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
1.86      wiz      3765: 
                   3766: which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
                   3767: 
1.154     rillig   3768: 15.9. Sharing directories between packages
1.1       dsieger  3769: 
                   3770: A "shared directory" is a directory where multiple (and unrelated) packages
1.23      jakllsch 3771: install files. These directories were problematic because you had to add
1.1       dsieger  3772: special tricks in the PLIST to conditionally remove them, or have some
                   3773: centralized package handle them.
                   3774: 
1.23      jakllsch 3775: In pkgsrc, it is now easy: Each package should create directories and install
                   3776: files as needed; pkg_delete will remove any directories left empty after
                   3777: uninstalling a package.
1.1       dsieger  3778: 
1.23      jakllsch 3779: If a package needs an empty directory to work, create the directory during
                   3780: installation as usual, and also add an entry to the PLIST:
1.1       dsieger  3781: 
1.23      jakllsch 3782: @pkgdir path/to/empty/directory
1.1       dsieger  3783: 
1.86      wiz      3784: or take a look at MAKE_DIRS and OWN_DIRS.
                   3785: 
1.154     rillig   3786: Chapter 16. Buildlink methodology
1.1       dsieger  3787: 
                   3788: Table of Contents
                   3789: 
1.154     rillig   3790: 16.1. Converting packages to use buildlink3
                   3791: 16.2. Writing buildlink3.mk files
1.1       dsieger  3792: 
1.154     rillig   3793:     16.2.1. Anatomy of a buildlink3.mk file
                   3794:     16.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.27      wiz      3795:         buildlink3.mk files
1.1       dsieger  3796: 
1.154     rillig   3797: 16.3. Writing builtin.mk files
1.1       dsieger  3798: 
1.154     rillig   3799:     16.3.1. Anatomy of a builtin.mk file
                   3800:     16.3.2. Global preferences for native or pkgsrc software
1.1       dsieger  3801: 
                   3802: Buildlink is a framework in pkgsrc that controls what headers and libraries are
                   3803: seen by a package's configure and build processes. This is implemented in a two
                   3804: step process:
                   3805: 
                   3806:  1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
                   3807:     default is a subdirectory of WRKDIR.
                   3808: 
                   3809:  2. Create wrapper scripts that are used in place of the normal compiler tools
                   3810:     that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
                   3811:     references to BUILDLINK_DIR. The wrapper scripts also make native compiler
                   3812:     on some operating systems look like GCC, so that packages that expect GCC
                   3813:     won't require modifications to build with those native compilers.
                   3814: 
                   3815: This normalizes the environment in which a package is built so that the package
                   3816: may be built consistently despite what other software may be installed. Please
                   3817: note that the normal system header and library paths, e.g. /usr/include, /usr/
                   3818: lib, etc., are always searched -- buildlink3 is designed to insulate the
                   3819: package build from non-system-supplied software.
                   3820: 
1.154     rillig   3821: 16.1. Converting packages to use buildlink3
1.1       dsieger  3822: 
1.25      wiz      3823: The process of converting packages to use the buildlink3 framework ("bl3ifying"
                   3824: ) is fairly straightforward. The things to keep in mind are:
1.1       dsieger  3825: 
                   3826:  1. Ensure that the build always calls the wrapper scripts instead of the
                   3827:     actual toolchain. Some packages are tricky, and the only way to know for
                   3828:     sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
                   3829:     invoked.
                   3830: 
                   3831:  2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
                   3832:     standalone shells, etc., because the code to symlink files into $
                   3833:     {BUILDLINK_DIR} looks for files relative to "pkg_info -qp pkgname".
                   3834: 
                   3835:  3. Remember that only the buildlink3.mk files that you list in a package's
                   3836:     Makefile are added as dependencies for that package.
                   3837: 
                   3838: If a dependency on a particular package is required for its libraries and
                   3839: headers, then we replace:
                   3840: 
                   3841: DEPENDS+=       foo>=1.1.0:../../category/foo
                   3842: 
                   3843: with
                   3844: 
                   3845: .include "../../category/foo/buildlink3.mk"
                   3846: 
                   3847: The buildlink3.mk files usually define the required dependencies. If you need a
                   3848: newer version of the dependency when using buildlink3.mk files, then you can
                   3849: define it in your Makefile; for example:
                   3850: 
                   3851: BUILDLINK_API_DEPENDS.foo+=   foo>=1.1.0
                   3852: .include "../../category/foo/buildlink3.mk"
                   3853: 
                   3854: There are several buildlink3.mk files in pkgsrc/mk that handle special package
                   3855: issues:
                   3856: 
                   3857:   * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
                   3858:     implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
                   3859: 
                   3860:   * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
                   3861:     this will take care to install the devel/ncurses package.
                   3862: 
                   3863:   * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
                   3864:     a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
                   3865:     implementation.
                   3866: 
                   3867:   * motif.buildlink3.mk checks for a system-provided Motif installation or adds
1.126     leot     3868:     a dependency on x11/lesstif or x11/motif. The user can set MOTIF_TYPE to "
                   3869:     dt", "lesstif" or "motif" to choose which Motif version will be used.
1.1       dsieger  3870: 
1.57      wiz      3871:   * readline.buildlink3.mk checks for a system-provided GNU readline or
                   3872:     editline (libedit) installation, or adds a dependency on devel/readline,
                   3873:     devel/editline. The user can set READLINE_DEFAULT to choose readline
1.56      ryoon    3874:     implementation. If your package really needs GNU readline library, its
                   3875:     Makefile should include devel/readline/buildlink3.mk instead of
                   3876:     readline.buildlink3.mk.
                   3877: 
1.1       dsieger  3878:   * oss.buildlink3.mk defines several variables that may be used by packages
                   3879:     that use the Open Sound System (OSS) API.
                   3880: 
1.36      wiz      3881:   * pgsql.buildlink3.mk will accept any of the Postgres versions in the
                   3882:     variable PGSQL_VERSIONS_ACCEPTED and default to the version
                   3883:     PGSQL_VERSION_DEFAULT. See the file for more information.
1.1       dsieger  3884: 
                   3885:   * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
                   3886:     pthreads or adds a dependency on devel/pth as needed.
                   3887: 
                   3888:   * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
                   3889:     widgets library.
                   3890: 
                   3891: The comments in those buildlink3.mk files provide a more complete description
                   3892: of how to use them properly.
                   3893: 
1.154     rillig   3894: 16.2. Writing buildlink3.mk files
1.1       dsieger  3895: 
                   3896: A package's buildlink3.mk file is included by Makefiles to indicate the need to
                   3897: compile and link against header files and libraries provided by the package. A
                   3898: buildlink3.mk file should always provide enough information to add the correct
                   3899: type of dependency relationship and include any other buildlink3.mk files that
                   3900: it needs to find headers and libraries that it needs in turn.
                   3901: 
                   3902: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
                   3903: pkgtools/createbuildlink package is highly recommended. For most packages, the
                   3904: following command will generate a good starting point for buildlink3.mk files:
                   3905: 
                   3906: % cd pkgsrc/category/pkgdir
                   3907: % createbuildlink >buildlink3.mk
                   3908: 
                   3909: 
1.154     rillig   3910: 16.2.1. Anatomy of a buildlink3.mk file
1.1       dsieger  3911: 
                   3912: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
                   3913: tiff:
                   3914: 
1.19      snj      3915: # $NetBSD: buildlink3.mk,v 1.16 2009/03/20 19:24:45 joerg Exp $
1.1       dsieger  3916: 
1.19      snj      3917: BUILDLINK_TREE+=        tiff
1.1       dsieger  3918: 
1.19      snj      3919: .if !defined(TIFF_BUILDLINK3_MK)
                   3920: TIFF_BUILDLINK3_MK:=
1.1       dsieger  3921: 
1.19      snj      3922: BUILDLINK_API_DEPENDS.tiff+=    tiff>=3.6.1
                   3923: BUILDLINK_ABI_DEPENDS.tiff+=    tiff>=3.7.2nb1
1.1       dsieger  3924: BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
                   3925: 
                   3926: .include "../../devel/zlib/buildlink3.mk"
                   3927: .include "../../graphics/jpeg/buildlink3.mk"
1.19      snj      3928: .endif # TIFF_BUILDLINK3_MK
1.1       dsieger  3929: 
1.19      snj      3930: BUILDLINK_TREE+=        -tiff
1.1       dsieger  3931: 
1.19      snj      3932: The header and footer manipulate BUILDLINK_TREE, which is common across all
                   3933: buildlink3.mk files and is used to track the dependency tree.
1.1       dsieger  3934: 
1.19      snj      3935: The main section is protected from multiple inclusion and controls how the
1.1       dsieger  3936: dependency on pkg is added. Several important variables are set in the section:
                   3937: 
                   3938:   * BUILDLINK_API_DEPENDS.pkg is the actual dependency recorded in the
                   3939:     installed package; this should always be set using += to ensure that we're
                   3940:     appending to any pre-existing list of values. This variable should be set
1.27      wiz      3941:     to the first version of the package that had an backwards-incompatible API
                   3942:     change.
1.1       dsieger  3943: 
                   3944:   * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
                   3945: 
                   3946:   * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
                   3947:     BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
                   3948:     is selected by setting BUILDLINK_DEPMETHOD.pkg to "build". By default, the
                   3949:     full dependency is used.
                   3950: 
                   3951:   * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
                   3952:     of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
                   3953:     library search paths. These default to "include" and "lib" respectively.
                   3954: 
                   3955:   * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
                   3956:     to add to CPPFLAGS, which are passed on to the configure and build phases.
                   3957:     The "-I" option should be avoided and instead be handled using
                   3958:     BUILDLINK_INCDIRS.pkg as above.
                   3959: 
                   3960: The following variables are all optionally defined within this second section
                   3961: (protected against multiple inclusion) and control which package files are
                   3962: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
                   3963: symlinking:
                   3964: 
                   3965:   * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
                   3966:     {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
                   3967:     *.h.
                   3968: 
                   3969:   * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
                   3970:     to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
                   3971:     resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
                   3972:     takes the +CONTENTS of a pkg and filters it through $
                   3973:     {BUILDLINK_CONTENTS_FILTER.pkg}.
                   3974: 
                   3975:   * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
                   3976:     filters +CONTENTS input into a list of files relative to $
1.84      wiz      3977:     {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
                   3978:     outputs the contents of the include and lib directories in the package
                   3979:     +CONTENTS.
1.1       dsieger  3980: 
                   3981:   * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
                   3982:     used to transform the name of the source filename into a destination
                   3983:     filename, e.g. -e "s|/curses.h|/ncurses.h|g".
                   3984: 
1.19      snj      3985: This section can additionally include any buildlink3.mk needed for pkg's
                   3986: library dependencies. Including these buildlink3.mk files means that the
                   3987: headers and libraries for these dependencies are also symlinked into $
                   3988: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
                   3989: are only added for directly include buildlink3.mk files.
1.1       dsieger  3990: 
1.48      wiz      3991: When providing a buildlink3.mk and including other buildlink3.mk files in it,
1.51      wiz      3992: please only add necessary ones, i.e., those whose libraries or header files are
1.48      wiz      3993: automatically exposed when the package is use.
                   3994: 
                   3995: In particular, if only an executable (bin/foo) is linked against a library,
                   3996: that library does not need to be propagated in the buildlink3.mk file.
                   3997: 
                   3998: The following steps should help you decide if a buildlink3.mk file needs to be
                   3999: included:
                   4000: 
                   4001:   * Look at the installed header files: What headers do they include? The
                   4002:     packages providing these files must be buildlinked.
                   4003: 
1.50      wiz      4004:   * Run ldd on all installed libraries and look against what other libraries
                   4005:     they link. Some of the packages providing these probably need to be
                   4006:     buildlinked; however, it's not automatic, since e.g. GTK on some systems
                   4007:     pulls in the X libraries, so they will show up in the ldd output, while on
1.51      wiz      4008:     others (like OS X) it won't. ldd output can thus only be used as a hint.
1.50      wiz      4009: 
1.154     rillig   4010: 16.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
1.27      wiz      4011: buildlink3.mk files
1.1       dsieger  4012: 
1.27      wiz      4013: These two variables differ in that one describes source compatibility (API) and
                   4014: the other binary compatibility (ABI). The difference is that a change in the
                   4015: API breaks compilation of programs while changes in the ABI stop compiled
                   4016: programs from running.
                   4017: 
1.28      wiz      4018: Changes to the BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk file
                   4019: happen very rarely. One possible reason is that all packages depending on this
                   4020: already need a newer version. In case it is bumped see the description below.
1.27      wiz      4021: 
                   4022: The most common example of an ABI change is that the major version of a shared
                   4023: library is increased. In this case, BUILDLINK_ABI_DEPENDS.pkg should be
                   4024: adjusted to require at least the new package version. Then the packages that
                   4025: depend on this package need their PKGREVISIONs increased and, if they have
                   4026: buildlink3.mk files, their BUILDLINK_ABI_DEPENDS.pkg adjusted, too. This is
                   4027: needed so pkgsrc will require the correct package dependency and not settle for
                   4028: an older one when building the source.
1.1       dsieger  4029: 
1.154     rillig   4030: See Section 21.1.5, "Handling dependencies" for more information about
1.1       dsieger  4031: dependencies on other packages, including the BUILDLINK_ABI_DEPENDS and
                   4032: ABI_DEPENDS definitions.
                   4033: 
                   4034: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
                   4035: BUILDLINK_ABI_DEPENDS.pkg as we don't want to cause unneeded package deletions
                   4036: and rebuilds. In many cases, new versions of packages work just fine with older
                   4037: dependencies.
                   4038: 
                   4039: Also it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
                   4040: BUILDLINK_API_DEPENDS.pkg.
                   4041: 
1.154     rillig   4042: 16.3. Writing builtin.mk files
1.1       dsieger  4043: 
                   4044: Some packages in pkgsrc install headers and libraries that coincide with
                   4045: headers and libraries present in the base system. Aside from a buildlink3.mk
                   4046: file, these packages should also include a builtin.mk file that includes the
                   4047: necessary checks to decide whether using the built-in software or the pkgsrc
                   4048: software is appropriate.
                   4049: 
                   4050: The only requirements of a builtin.mk file for pkg are:
                   4051: 
                   4052:  1. It should set USE_BUILTIN.pkg to either "yes" or "no" after it is included.
                   4053: 
                   4054:  2. It should not override any USE_BUILTIN.pkg which is already set before the
                   4055:     builtin.mk file is included.
                   4056: 
                   4057:  3. It should be written to allow multiple inclusion. This is very important
                   4058:     and takes careful attention to Makefile coding.
                   4059: 
1.154     rillig   4060: 16.3.1. Anatomy of a builtin.mk file
1.1       dsieger  4061: 
                   4062: The following is the recommended template for builtin.mk files:
                   4063: 
                   4064: .if !defined(IS_BUILTIN.foo)
                   4065: #
                   4066: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
                   4067: # genuinely exists in the system or not.
                   4068: #
                   4069: IS_BUILTIN.foo?=        no
                   4070: 
                   4071: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
                   4072: # version can be determined.
                   4073: #
                   4074: .  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
                   4075: BUILTIN_PKG.foo?=       foo-1.0
                   4076: .  endif
                   4077: .endif  # IS_BUILTIN.foo
                   4078: 
                   4079: .if !defined(USE_BUILTIN.foo)
                   4080: USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
                   4081: .  if defined(BUILTIN_PKG.foo)
                   4082: .    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
                   4083: .      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
                   4084: USE_BUILTIN.foo!=                                                       \
                   4085:         ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}            \
                   4086:         && ${ECHO} "yes" || ${ECHO} "no"
                   4087: .      endif
                   4088: .    endfor
                   4089: .  endif
                   4090: .endif  # USE_BUILTIN.foo
                   4091: 
                   4092: CHECK_BUILTIN.foo?=     no
                   4093: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
                   4094: #
                   4095: # Here we place code that depends on whether USE_BUILTIN.foo is set to
                   4096: # "yes" or "no".
                   4097: #
                   4098: .endif  # CHECK_BUILTIN.foo
                   4099: 
                   4100: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
                   4101: base system. This should not be a base system software with similar
                   4102: functionality to pkg; it should only be "yes" if the actual package is included
                   4103: as part of the base system. This variable is only used internally within the
                   4104: builtin.mk file.
                   4105: 
                   4106: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
                   4107: system if it exists (if IS_BUILTIN.pkg is "yes"). This variable is only used
                   4108: internally within the builtin.mk file.
                   4109: 
                   4110: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
                   4111: The code in this section must make the determination whether the built-in
                   4112: software is adequate to satisfy the dependencies listed in
                   4113: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
1.25      wiz      4114: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg 
1.1       dsieger  4115: must be set to the correct value by the end of the builtin.mk file. Note that
                   4116: USE_BUILTIN.pkg may be "yes" even if IS_BUILTIN.pkg is "no" because we may make
                   4117: the determination that the built-in version of the software is similar enough
                   4118: to be used as a replacement.
                   4119: 
                   4120: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
                   4121: the value of USE_BUILTIN.pkg set in the previous section. This typically
                   4122: includes, e.g., adding additional dependency restrictions and listing
                   4123: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
                   4124: 
1.154     rillig   4125: 16.3.2. Global preferences for native or pkgsrc software
1.1       dsieger  4126: 
                   4127: When building packages, it's possible to choose whether to set a global
                   4128: preference for using either the built-in (native) version or the pkgsrc version
                   4129: of software to satisfy a dependency. This is controlled by setting
1.25      wiz      4130: PREFER_PKGSRC and PREFER_NATIVE. These variables take values of either "yes", "
                   4131: no", or a list of packages. PREFER_PKGSRC tells pkgsrc to use the pkgsrc
1.1       dsieger  4132: versions of software, while PREFER_NATIVE tells pkgsrc to use the built-in
                   4133: versions. Preferences are determined by the most specific instance of the
                   4134: package in either PREFER_PKGSRC or PREFER_NATIVE. If a package is specified in
                   4135: neither or in both variables, then PREFER_PKGSRC has precedence over
                   4136: PREFER_NATIVE. For example, to require using pkgsrc versions of software for
                   4137: all but the most basic bits on a NetBSD system, you can set:
                   4138: 
                   4139: PREFER_PKGSRC=  yes
                   4140: PREFER_NATIVE=  getopt skey tcp_wrappers
                   4141: 
                   4142: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
                   4143: it is simply ignored in that list.
                   4144: 
1.117     sevan    4145: Setting PREFER_NATIVE should be performed straight after bootstrap and
                   4146: PREFER_PKGSRC during bootstrap. Switching between settings globally at a later
                   4147: date can introduce complications with dependency resolution. This is caused by
                   4148: packages built with the opposite preference being installed alongside each
                   4149: other.
                   4150: 
                   4151: # ./bootstrap --prefer-pkgsrc yes
                   4152: 
1.154     rillig   4153: Chapter 17. The pkginstall framework
1.1       dsieger  4154: 
                   4155: Table of Contents
                   4156: 
1.154     rillig   4157: 17.1. Files and directories outside the installation prefix
1.1       dsieger  4158: 
1.154     rillig   4159:     17.1.1. Directory manipulation
                   4160:     17.1.2. File manipulation
1.1       dsieger  4161: 
1.154     rillig   4162: 17.2. Configuration files
1.1       dsieger  4163: 
1.154     rillig   4164:     17.2.1. How PKG_SYSCONFDIR is set
                   4165:     17.2.2. Telling the software where configuration files are
                   4166:     17.2.3. Patching installations
                   4167:     17.2.4. Disabling handling of configuration files
1.1       dsieger  4168: 
1.154     rillig   4169: 17.3. System startup scripts
1.1       dsieger  4170: 
1.154     rillig   4171:     17.3.1. Disabling handling of system startup scripts
1.1       dsieger  4172: 
1.154     rillig   4173: 17.4. System users and groups
                   4174: 17.5. System shells
1.1       dsieger  4175: 
1.154     rillig   4176:     17.5.1. Disabling shell registration
1.1       dsieger  4177: 
1.154     rillig   4178: 17.6. Fonts
1.1       dsieger  4179: 
1.154     rillig   4180:     17.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  4181: 
                   4182: This chapter describes the framework known as pkginstall, whose key features
                   4183: are:
                   4184: 
                   4185:   * Generic installation and manipulation of directories and files outside the
                   4186:     pkgsrc-handled tree, LOCALBASE.
                   4187: 
                   4188:   * Automatic handling of configuration files during installation, provided
                   4189:     that packages are correctly designed.
                   4190: 
                   4191:   * Generation and installation of system startup scripts.
                   4192: 
                   4193:   * Registration of system users and groups.
                   4194: 
                   4195:   * Registration of system shells.
                   4196: 
                   4197:   * Automatic updating of fonts databases.
                   4198: 
                   4199: The following sections inspect each of the above points in detail.
                   4200: 
                   4201: You may be thinking that many of the things described here could be easily done
                   4202: with simple code in the package's post-installation target (post-install). This
                   4203: is incorrect, as the code in them is only executed when building from source.
                   4204: Machines using binary packages could not benefit from it at all (as the code
                   4205: itself could be unavailable). Therefore, the only way to achieve any of the
                   4206: items described above is by means of the installation scripts, which are
                   4207: automatically generated by pkginstall.
                   4208: 
1.154     rillig   4209: 17.1. Files and directories outside the installation prefix
1.1       dsieger  4210: 
                   4211: As you already know, the PLIST file holds a list of files and directories that
                   4212: belong to a package. The names used in it are relative to the installation
                   4213: prefix (${PREFIX}), which means that it cannot register files outside this
                   4214: directory (absolute path names are not allowed). Despite this restriction, some
                   4215: packages need to install files outside this location; e.g., under ${VARBASE} or
                   4216: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
                   4217: installation time by using installation scripts.
                   4218: 
                   4219: The generic installation scripts are shell scripts that can contain arbitrary
                   4220: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
                   4221: which defaults to INSTALL. A similar variable exists for package removal
                   4222: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
                   4223: commands, so they have the potential to create and manage files anywhere in the
                   4224: file system.
                   4225: 
                   4226: Using these general installation files is not recommended, but may be needed in
                   4227: some special cases. One reason for avoiding them is that the user has to trust
                   4228: the packager that there is no unwanted or simply erroneous code included in the
                   4229: installation script. Also, previously there were many similar scripts for the
                   4230: same functionality, and fixing a common error involved finding and changing all
                   4231: of them.
                   4232: 
                   4233: The pkginstall framework offers another, standardized way. It provides generic
                   4234: scripts to abstract the manipulation of such files and directories based on
                   4235: variables set in the package's Makefile. The rest of this section describes
                   4236: these variables.
                   4237: 
1.154     rillig   4238: 17.1.1. Directory manipulation
1.1       dsieger  4239: 
                   4240: The following variables can be set to request the creation of directories
                   4241: anywhere in the file system:
                   4242: 
                   4243:   * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
                   4244:     and should attempt to be destroyed by the installation scripts. The
                   4245:     difference between the two is that the latter prompts the administrator to
                   4246:     remove any directories that may be left after deinstallation (because they
1.108     rillig   4247:     were not empty), while the former does not. Example:
                   4248: 
                   4249:     MAKE_DIRS+=             ${VARBASE}/foo/private
1.1       dsieger  4250: 
                   4251:   * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
                   4252:     which directories should be created and should attempt to be destroyed by
                   4253:     the installation scripts. Each tuple holds the following values, separated
                   4254:     by spaces: the directory name, its owner, its group and its numerical mode.
                   4255:     For example:
                   4256: 
1.108     rillig   4257:     MAKE_DIRS_PERMS+=       ${VARBASE}/foo/private \
                   4258:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  4259: 
                   4260:     The difference between the two is exactly the same as their non-PERMS
                   4261:     counterparts.
                   4262: 
1.154     rillig   4263: 17.1.2. File manipulation
1.1       dsieger  4264: 
                   4265: Creating non-empty files outside the installation prefix is tricky because the
                   4266: PLIST forces all files to be inside it. To overcome this problem, the only
                   4267: solution is to extract the file in the known place (i.e., inside the
                   4268: installation prefix) and copy it to the appropriate location during
                   4269: installation (done by the installation scripts generated by pkginstall). We
                   4270: will call the former the master file in the following paragraphs, which
                   4271: describe the variables that can be used to automatically and consistently
                   4272: handle files outside the installation prefix:
                   4273: 
1.31      wiz      4274:   * CONF_FILES and REQD_FILES are pairs of master and target files. During
1.1       dsieger  4275:     installation time, the master file is copied to the target one if and only
                   4276:     if the latter does not exist. Upon deinstallation, the target file is
                   4277:     removed provided that it was not modified by the installation.
                   4278: 
                   4279:     The difference between the two is that the latter prompts the administrator
                   4280:     to remove any files that may be left after deinstallation (because they
                   4281:     were not empty), while the former does not.
                   4282: 
1.31      wiz      4283:   * CONF_FILES_PERMS and REQD_FILES_PERMS contain tuples describing master
1.1       dsieger  4284:     files as well as their target locations. For each of them, it also
                   4285:     specifies their owner, their group and their numeric permissions, in this
                   4286:     order. For example:
                   4287: 
1.108     rillig   4288:     REQD_FILES_PERMS+=      ${PREFIX}/share/somefile ${VARBASE}/somefile \
                   4289:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  4290: 
                   4291:     The difference between the two is exactly the same as their non-PERMS
                   4292:     counterparts.
                   4293: 
1.154     rillig   4294: 17.2. Configuration files
1.1       dsieger  4295: 
                   4296: Configuration files are special in the sense that they are installed in their
                   4297: own specific directory, PKG_SYSCONFDIR, and need special treatment during
                   4298: installation (most of which is automated by pkginstall). The main concept you
                   4299: must bear in mind is that files marked as configuration files are automatically
                   4300: copied to the right place (somewhere inside PKG_SYSCONFDIR) during installation
                   4301: if and only if they didn't exist before. Similarly, they will not be removed if
                   4302: they have local modifications. This ensures that administrators never lose any
                   4303: custom changes they may have made.
                   4304: 
1.154     rillig   4305: 17.2.1. How PKG_SYSCONFDIR is set
1.1       dsieger  4306: 
                   4307: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
                   4308: shall be installed. Its contents are set based upon the following variables:
                   4309: 
                   4310:   * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
                   4311:     etc although it may be overridden by the user to point to his preferred
                   4312:     location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
                   4313: 
                   4314:   * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
                   4315:     configuration files for the package being built shall be installed. The
                   4316:     definition of this variable only makes sense in the package's Makefile
                   4317:     (i.e., it is not user-customizable).
                   4318: 
1.68      asau     4319:     As an example, consider the Apache package, www/apache24, which places its
1.1       dsieger  4320:     configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
                   4321:     should be set in the package Makefile.
                   4322: 
                   4323:   * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
                   4324:     package's configuration directory (if different from PKG_SYSCONFBASE). It
                   4325:     defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
                   4326: 
                   4327:   * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
                   4328:     configuration files for the package identified by PKG_SYSCONFVAR's shall be
                   4329:     placed.
                   4330: 
                   4331: Based on the above variables, pkginstall determines the value of
                   4332: PKG_SYSCONFDIR, which is the only variable that can be used within a package to
                   4333: refer to its configuration directory. The algorithm used to set its value is
                   4334: basically the following:
                   4335: 
                   4336:  1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
                   4337: 
                   4338:  2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
                   4339:     package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
                   4340:     {PKG_SYSCONFSUBDIR}.
                   4341: 
                   4342:  3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
                   4343: 
                   4344: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
1.154     rillig   4345: OWN_DIRS. See Section 17.1.1, "Directory manipulation" what this means. This
1.16      jnemeth  4346: does not apply to subdirectories of ${PKG_SYSCONFDIR}, they still have to be
                   4347: created with OWN_DIRS or MAKE_DIRS.
1.1       dsieger  4348: 
1.154     rillig   4349: 17.2.2. Telling the software where configuration files are
1.1       dsieger  4350: 
                   4351: Given that pkgsrc (and users!) expect configuration files to be in a known
                   4352: place, you need to teach each package where it shall install its files. In some
                   4353: cases you will have to patch the package Makefiles to achieve it. If you are
                   4354: lucky, though, it may be as easy as passing an extra flag to the configuration
                   4355: script; this is the case of GNU Autoconf- generated files:
                   4356: 
                   4357: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
                   4358: 
                   4359: Note that this specifies where the package has to look for its configuration
                   4360: files, not where they will be originally installed (although the difference is
                   4361: never explicit, unfortunately).
                   4362: 
1.154     rillig   4363: 17.2.3. Patching installations
1.1       dsieger  4364: 
                   4365: As said before, pkginstall automatically handles configuration files. This
                   4366: means that the packages themselves must not touch the contents of $
                   4367: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
                   4368: will, out of the box, mess with the contents of that directory. So what is the
                   4369: correct procedure to fix this issue?
                   4370: 
                   4371: You must teach the package (usually by manually patching it) to install any
                   4372: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
                   4373: This way, the PLIST registers them and the administrator always has the
                   4374: original copies available.
                   4375: 
                   4376: Once the required configuration files are in place (i.e., under the examples
                   4377: hierarchy), the pkginstall framework can use them as master copies during the
                   4378: package installation to update what is in ${PKG_SYSCONFDIR}. To achieve this,
                   4379: the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
1.154     rillig   4380: Section 17.1.2, "File manipulation" for information about their syntax and
1.1       dsieger  4381: their purpose. Here is an example, taken from the mail/mutt package:
                   4382: 
                   4383: EGDIR=        ${PREFIX}/share/doc/mutt/samples
                   4384: CONF_FILES=   ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
                   4385: 
                   4386: Note that the EGDIR variable is specific to that package and has no meaning
                   4387: outside it.
                   4388: 
1.154     rillig   4389: 17.2.4. Disabling handling of configuration files
1.1       dsieger  4390: 
                   4391: The automatic copying of config files can be toggled by setting the environment
                   4392: variable PKG_CONFIG prior to package installation.
                   4393: 
1.154     rillig   4394: 17.3. System startup scripts
1.1       dsieger  4395: 
                   4396: System startup scripts are special files because they must be installed in a
                   4397: place known by the underlying OS, usually outside the installation prefix.
1.154     rillig   4398: Therefore, the same rules described in Section 17.1, "Files and directories
1.1       dsieger  4399: outside the installation prefix" apply, and the same solutions can be used.
                   4400: However, pkginstall provides a special mechanism to handle these files.
                   4401: 
                   4402: In order to provide system startup scripts, the package has to:
                   4403: 
                   4404:  1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
                   4405:     Considering the print/cups package as an example, it has a cupsd.sh in its
                   4406:     files directory.
                   4407: 
                   4408:  2. Tell pkginstall to handle it, appending the name of the script, without its
                   4409:     extension, to the RCD_SCRIPTS variable. Continuing the previous example:
                   4410: 
                   4411:     RCD_SCRIPTS+=   cupsd
                   4412: 
                   4413: Once this is done, pkginstall will do the following steps for each script in an
                   4414: automated fashion:
                   4415: 
                   4416:  1. Process the file found in the files directory applying all the
                   4417:     substitutions described in the FILES_SUBST variable.
                   4418: 
                   4419:  2. Copy the script from the files directory to the examples hierarchy, $
                   4420:     {PREFIX}/share/examples/rc.d/. Note that this master file must be
                   4421:     explicitly registered in the PLIST.
                   4422: 
                   4423:  3. Add code to the installation scripts to copy the startup script from the
                   4424:     examples hierarchy into the system-wide startup scripts directory.
                   4425: 
1.154     rillig   4426: 17.3.1. Disabling handling of system startup scripts
1.1       dsieger  4427: 
                   4428: The automatic copying of config files can be toggled by setting the environment
                   4429: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
                   4430: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
                   4431: rc.d/, no matter what the value of this variable is.
                   4432: 
1.154     rillig   4433: 17.4. System users and groups
1.1       dsieger  4434: 
                   4435: If a package needs to create special users and/or groups during installation,
                   4436: it can do so by using the pkginstall framework.
                   4437: 
                   4438: Users can be created by adding entries to the PKG_USERS variable. Each entry
                   4439: has the following syntax:
                   4440: 
                   4441: user:group
                   4442: 
                   4443: Further specification of user details may be done by setting per-user
                   4444: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
                   4445: user's description or comment. PKG_HOME.user is the user's home directory, and
                   4446: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
                   4447: and defaults to /sbin/nologin if not specified.
                   4448: 
                   4449: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
                   4450: whose syntax is:
                   4451: 
                   4452: group
                   4453: 
                   4454: The numeric GID of the group may be set by defining PKG_GID.group.
                   4455: 
                   4456: If a package needs to create the users and groups at an earlier stage, then it
1.116     wiz      4457: can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
                   4458: the phase before which the users and groups are created. In this case, the
                   4459: numeric UIDs and GIDs of the created users and groups are automatically
                   4460: hardcoded into the final installation scripts.
1.1       dsieger  4461: 
1.154     rillig   4462: 17.5. System shells
1.1       dsieger  4463: 
                   4464: Packages that install system shells should register them in the shell database,
                   4465: /etc/shells, to make things easier to the administrator. This must be done from
                   4466: the installation scripts to keep binary packages working on any system.
                   4467: pkginstall provides an easy way to accomplish this task.
                   4468: 
                   4469: When a package provides a shell interpreter, it has to set the PKG_SHELL
                   4470: variable to its absolute file name. This will add some hooks to the
                   4471: installation scripts to handle it. Consider the following example, taken from
                   4472: shells/zsh:
                   4473: 
                   4474: PKG_SHELL=      ${PREFIX}/bin/zsh
                   4475: 
1.154     rillig   4476: 17.5.1. Disabling shell registration
1.1       dsieger  4477: 
                   4478: The automatic registration of shell interpreters can be disabled by the
                   4479: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
                   4480: 
1.154     rillig   4481: 17.6. Fonts
1.1       dsieger  4482: 
                   4483: Packages that install X11 fonts should update the database files that index the
                   4484: fonts within each fonts directory. This can easily be accomplished within the
                   4485: pkginstall framework.
                   4486: 
                   4487: When a package installs X11 fonts, it must list the directories in which fonts
                   4488: are installed in the FONTS_DIRS.type variables, where type can be one of "ttf",
                   4489: "type1" or "x11". This will add hooks to the installation scripts to run the
                   4490: appropriate commands to update the fonts database files within each of those
                   4491: directories. For convenience, if the directory path is relative, it is taken to
                   4492: be relative to the package's installation prefix. Consider the following
                   4493: example, taken from fonts/dbz-ttf:
                   4494: 
1.67      wiz      4495: FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
1.1       dsieger  4496: 
1.154     rillig   4497: 17.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  4498: 
                   4499: The automatic update of fonts databases can be disabled by the administrator by
                   4500: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
                   4501: 
1.154     rillig   4502: Chapter 18. Options handling
1.1       dsieger  4503: 
                   4504: Table of Contents
                   4505: 
1.154     rillig   4506: 18.1. Global default options
                   4507: 18.2. Converting packages to use bsd.options.mk
                   4508: 18.3. Option Names
                   4509: 18.4. Determining the options of dependencies
1.1       dsieger  4510: 
                   4511: Many packages have the ability to be built to support different sets of
                   4512: features. bsd.options.mk is a framework in pkgsrc that provides generic
                   4513: handling of those options that determine different ways in which the packages
                   4514: can be built. It's possible for the user to specify exactly which sets of
                   4515: options will be built into a package or to allow a set of global default
                   4516: options apply.
                   4517: 
1.7       rillig   4518: There are two broad classes of behaviors that one might want to control via
                   4519: options. One is whether some particular feature is enabled in a program that
                   4520: will be built anyway, often by including or not including a dependency on some
                   4521: other package. The other is whether or not an additional program will be built
                   4522: as part of the package. Generally, it is better to make a split package for
                   4523: such additional programs instead of using options, because it enables binary
                   4524: packages to be built which can then be added separately. For example, the foo
                   4525: package might have minimal dependencies (those packages without which foo
                   4526: doesn't make sense), and then the foo-gfoo package might include the GTK
                   4527: frontend program gfoo. This is better than including a gtk option to foo that
                   4528: adds gfoo, because either that option is default, in which case binary users
                   4529: can't get foo without gfoo, or not default, in which case they can't get gfoo.
                   4530: With split packages, they can install foo without having GTK, and later decide
                   4531: to install gfoo (pulling in GTK at that time). This is an advantage to source
                   4532: users too, avoiding the need for rebuilds.
                   4533: 
                   4534: Plugins with widely varying dependencies should usually be split instead of
                   4535: options.
                   4536: 
                   4537: It is often more work to maintain split packages, especially if the upstream
                   4538: package does not support this. The decision of split vs. option should be made
                   4539: based on the likelihood that users will want or object to the various pieces,
                   4540: the size of the dependencies that are included, and the amount of work.
                   4541: 
                   4542: A further consideration is licensing. Non-free parts, or parts that depend on
                   4543: non-free dependencies (especially plugins) should almost always be split if
                   4544: feasible.
                   4545: 
1.154     rillig   4546: 18.1. Global default options
1.1       dsieger  4547: 
                   4548: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
                   4549: the options that should be built into every package if that option is
1.4       rillig   4550: supported. This variable should be set in mk.conf.
1.1       dsieger  4551: 
1.154     rillig   4552: 18.2. Converting packages to use bsd.options.mk
1.1       dsieger  4553: 
                   4554: The following example shows how bsd.options.mk should be used by the
                   4555: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
                   4556: e.g. options.mk, that is included by the main package Makefile.
                   4557: 
                   4558: PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
                   4559: PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
                   4560: PKG_OPTIONS_OPTIONAL_GROUPS=    database
                   4561: PKG_OPTIONS_GROUP.database=     mysql pgsql
                   4562: PKG_SUGGESTED_OPTIONS=          wibble-foo
                   4563: PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
                   4564: PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
                   4565: 
                   4566: .include "../../mk/bsd.prefs.mk"
                   4567: 
                   4568: # this package was previously named wibble2
                   4569: .if defined(PKG_OPTIONS.wibble2)
                   4570: PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
                   4571: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
                   4572:         "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
                   4573: .endif
                   4574: 
                   4575: .include "../../mk/bsd.options.mk"
                   4576: 
                   4577: # Package-specific option-handling
                   4578: 
                   4579: ###
                   4580: ### FOO support
                   4581: ###
                   4582: .if !empty(PKG_OPTIONS:Mwibble-foo)
                   4583: CONFIGURE_ARGS+=    --enable-foo
                   4584: .endif
                   4585: 
                   4586: ###
                   4587: ### LDAP support
                   4588: ###
                   4589: .if !empty(PKG_OPTIONS:Mldap)
                   4590: .  include "../../databases/openldap-client/buildlink3.mk"
                   4591: CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
                   4592: .endif
                   4593: 
                   4594: ###
                   4595: ### database support
                   4596: ###
                   4597: .if !empty(PKG_OPTIONS:Mmysql)
                   4598: .  include "../../mk/mysql.buildlink3.mk"
                   4599: .endif
                   4600: .if !empty(PKG_OPTIONS:Mpgsql)
                   4601: .  include "../../mk/pgsql.buildlink3.mk"
                   4602: .endif
                   4603: 
                   4604: The first section contains the information about which build options are
                   4605: supported by the package, and any default options settings if needed.
                   4606: 
                   4607:  1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
                   4608:     to override the default options. It should be set to PKG_OPTIONS.pkgbase.
                   4609:     Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
                   4610:     the point where the options are processed.
                   4611: 
                   4612:  2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
                   4613: 
                   4614:  3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
                   4615:     exclusive options. The options in each group are listed in
                   4616:     PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
                   4617:     the group takes precedence over all other options in the group. Options
                   4618:     from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
                   4619: 
                   4620:  4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
                   4621:     building the packages will fail if no option from the group is selected.
                   4622: 
                   4623:  5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
                   4624:     one option from each set must be selected. The options in each set are
                   4625:     listed in PKG_OPTIONS_SET.setname. Options from the sets will be
                   4626:     automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
                   4627:     fail if no option from the set is selected.
                   4628: 
                   4629:  6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
                   4630:     default.
                   4631: 
                   4632:  7. PKG_OPTIONS_LEGACY_VARS is a list of "USE_VARIABLE:option" pairs that map
1.4       rillig   4633:     legacy mk.conf variables to their option counterparts. Pairs should be
1.1       dsieger  4634:     added with "+=" to keep the listing of global legacy variables. A warning
                   4635:     will be issued if the user uses a legacy variable.
                   4636: 
                   4637:  8. PKG_OPTIONS_LEGACY_OPTS is a list of "old-option:new-option" pairs that map
                   4638:     options that have been renamed to their new counterparts. Pairs should be
                   4639:     added with "+=" to keep the listing of global legacy options. A warning
                   4640:     will be issued if the user uses a legacy option.
                   4641: 
                   4642:  9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
                   4643:     used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
                   4644:     PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
                   4645: 
                   4646: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
                   4647:     variables or options used, and what to use instead.
                   4648: 
                   4649: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
                   4650: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
                   4651: options, use PKG_SUGGESTED_OPTIONS.
                   4652: 
                   4653: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
                   4654: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
                   4655: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
                   4656: options if none of them is supported on the current platform), PKG_OPTIONS is
                   4657: set to the empty list and the package is otherwise treated as not using the
                   4658: options framework.
                   4659: 
                   4660: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
                   4661: list of selected build options, properly filtered to remove unsupported and
                   4662: duplicate options.
                   4663: 
                   4664: The remaining sections contain the logic that is specific to each option. The
                   4665: correct way to check for an option is to check whether it is listed in
                   4666: PKG_OPTIONS:
                   4667: 
                   4668: .if !empty(PKG_OPTIONS:Moption)
                   4669: 
1.154     rillig   4670: 18.3. Option Names
1.1       dsieger  4671: 
                   4672: Options that enable similar features in different packages (like optional
                   4673: support for a library) should use a common name in all packages that support it
                   4674: (like the name of the library). If another package already has an option with
                   4675: the same meaning, use the same name.
                   4676: 
                   4677: Options that enable features specific to one package, where it's unlikely that
                   4678: another (unrelated) package has the same (or a similar) optional feature,
                   4679: should use a name prefixed with pkgname-.
                   4680: 
                   4681: If a group of related packages share an optional feature specific to that
                   4682: group, prefix it with the name of the "main" package (e. g.
                   4683: djbware-errno-hack).
                   4684: 
                   4685: For new options, add a line to mk/defaults/options.description. Lines have two
                   4686: fields, separated by tab. The first field is the option name, the second its
                   4687: description. The description should be a whole sentence (starting with an
                   4688: uppercase letter and ending with a period) that describes what enabling the
                   4689: option does. E. g. "Enable ispell support." The file is sorted by option names.
                   4690: 
1.154     rillig   4691: 18.4. Determining the options of dependencies
1.7       rillig   4692: 
                   4693: When writing buildlink3.mk files, it is often necessary to list different
                   4694: dependencies based on the options with which the package was built. For
                   4695: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
                   4696: A typical example looks like this:
                   4697: 
                   4698: pkgbase := libpurple
                   4699: .include "../../mk/pkg-build-options.mk"
                   4700: 
                   4701: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
                   4702: ...
                   4703: .endif
                   4704: 
                   4705: Including pkg-build-options.mk here will set the variable
                   4706: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
                   4707: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
                   4708: pkg-build-options.mk for more details.
                   4709: 
1.154     rillig   4710: Chapter 19. The build process
1.1       dsieger  4711: 
                   4712: Table of Contents
                   4713: 
1.154     rillig   4714: 19.1. Introduction
                   4715: 19.2. Program location
                   4716: 19.3. Directories used during the build process
                   4717: 19.4. Running a phase
                   4718: 19.5. The fetch phase
                   4719: 
                   4720:     19.5.1. What to fetch and where to get it from
                   4721:     19.5.2. How are the files fetched?
                   4722: 
                   4723: 19.6. The checksum phase
                   4724: 19.7. The extract phase
                   4725: 19.8. The patch phase
                   4726: 19.9. The tools phase
                   4727: 19.10. The wrapper phase
                   4728: 19.11. The configure phase
                   4729: 19.12. The build phase
                   4730: 19.13. The test phase
                   4731: 19.14. The install phase
                   4732: 19.15. The package phase
                   4733: 19.16. Cleaning up
                   4734: 19.17. Other helpful targets
1.1       dsieger  4735: 
1.154     rillig   4736: 19.1. Introduction
1.1       dsieger  4737: 
                   4738: This chapter gives a detailed description on how a package is built. Building a
                   4739: package is separated into different phases (for example fetch, build, install),
1.19      snj      4740: all of which are described in the following sections. Each phase is split into
                   4741: so-called stages, which take the name of the containing phase, prefixed by one
                   4742: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
                   4743: actual work is done in the do-* stages.
1.1       dsieger  4744: 
                   4745: Never override the regular targets (like fetch), if you have to, override the
                   4746: do-* ones instead.
                   4747: 
                   4748: The basic steps for building a program are always the same. First the program's
                   4749: source (distfile) must be brought to the local system and then extracted. After
                   4750: any pkgsrc-specific patches to compile properly are applied, the software can
                   4751: be configured, then built (usually by compiling), and finally the generated
                   4752: binaries, etc. can be put into place on the system.
                   4753: 
                   4754: To get more details about what is happening at each step, you can set the
                   4755: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
                   4756: more details about the patch step.
                   4757: 
1.154     rillig   4758: 19.2. Program location
1.1       dsieger  4759: 
                   4760: Before outlining the process performed by the NetBSD package system in the next
                   4761: section, here's a brief discussion on where programs are installed, and which
                   4762: variables influence this.
                   4763: 
                   4764: The automatic variable PREFIX indicates where all files of the final program
                   4765: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
                   4766: pkgs in the cross category. The value of PREFIX needs to be put into the
                   4767: various places in the program's source where paths to these files are encoded.
1.154     rillig   4768: See Section 13.3, "patches/*" and Section 21.3.1, "Shared libraries - libtool"
1.1       dsieger  4769: for more details.
                   4770: 
                   4771: When choosing which of these variables to use, follow the following rules:
                   4772: 
                   4773:   * PREFIX always points to the location where the current pkg will be
1.25      wiz      4774:     installed. When referring to a pkg's own installation path, use "${PREFIX}"
                   4775:     .
1.1       dsieger  4776: 
                   4777:   * LOCALBASE is where all non-X11 pkgs are installed. If you need to construct
                   4778:     a -I or -L argument to the compiler to find includes and libraries
                   4779:     installed by another non-X11 pkg, use "${LOCALBASE}". The name LOCALBASE
                   4780:     stems from FreeBSD, which installed all packages in /usr/local. As pkgsrc
                   4781:     leaves /usr/local for the system administrator, this variable is a
                   4782:     misnomer.
                   4783: 
                   4784:   * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
                   4785:     installed. When looking for standard X11 includes (not those installed by a
                   4786:     package), use "${X11BASE}".
                   4787: 
1.99      sevan    4788:   * X11-based packages using imake must set USE_IMAKE to be installed correctly
                   4789:     under LOCALBASE.
1.1       dsieger  4790: 
                   4791:   * Within ${PREFIX}, packages should install files according to hier(7), with
                   4792:     the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
                   4793:     man.
                   4794: 
1.154     rillig   4795: 19.3. Directories used during the build process
1.1       dsieger  4796: 
1.14      jmcneill 4797: When building a package, various directories are used to store source files,
1.1       dsieger  4798: temporary files, pkgsrc-internal files, and so on. These directories are
                   4799: explained here.
                   4800: 
                   4801: Some of the directory variables contain relative pathnames. There are two
                   4802: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
                   4803: used for directories that are pkgsrc-specific. WRKSRC is used for directories
                   4804: inside the package itself.
                   4805: 
                   4806: PKGSRCDIR
                   4807: 
                   4808:     This is an absolute pathname that points to the pkgsrc root directory.
                   4809:     Generally, you don't need it.
                   4810: 
                   4811: PKGDIR
                   4812: 
                   4813:     This is an absolute pathname that points to the current package.
                   4814: 
                   4815: PKGPATH
                   4816: 
                   4817:     This is a pathname relative to PKGSRCDIR that points to the current
                   4818:     package.
                   4819: 
                   4820: WRKDIR
                   4821: 
                   4822:     This is an absolute pathname pointing to the directory where all work takes
                   4823:     place. The distfiles are extracted to this directory. It also contains
                   4824:     temporary directories and log files used by the various pkgsrc frameworks,
                   4825:     like buildlink or the wrappers.
                   4826: 
                   4827: WRKSRC
                   4828: 
                   4829:     This is an absolute pathname pointing to the directory where the distfiles
                   4830:     are extracted. It is usually a direct subdirectory of WRKDIR, and often
                   4831:     it's the only directory entry that isn't hidden. This variable may be
                   4832:     changed by a package Makefile.
                   4833: 
1.14      jmcneill 4834: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
1.15      rillig   4835: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
1.14      jmcneill 4836: created in the pkgsrc entry's directory. If users would like to have their
                   4837: pkgsrc trees behave in a read-only manner, then the value of
                   4838: CREATE_WRKDIR_SYMLINK should be set to no.
                   4839: 
1.154     rillig   4840: 19.4. Running a phase
1.1       dsieger  4841: 
                   4842: You can run a particular phase by typing make phase, where phase is the name of
                   4843: the phase. This will automatically run all phases that are required for this
                   4844: phase. The default phase is build, that is, when you run make without
                   4845: parameters in a package directory, the package will be built, but not
                   4846: installed.
                   4847: 
1.154     rillig   4848: 19.5. The fetch phase
1.1       dsieger  4849: 
                   4850: The first step in building a package is to fetch the distribution files
1.25      wiz      4851: (distfiles) from the sites that are providing them. This is the task of the 
1.1       dsieger  4852: fetch phase.
                   4853: 
1.154     rillig   4854: 19.5.1. What to fetch and where to get it from
1.1       dsieger  4855: 
                   4856: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
                   4857: name is derived from the DISTNAME variable, is fetched. The more complicated
                   4858: cases are described below.
                   4859: 
                   4860: The variable DISTFILES specifies the list of distfiles that have to be fetched.
1.66      asau     4861: Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
                   4862: {EXTRACT_SUFX}, so that most packages don't need to define it at all.
                   4863: EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
                   4864: your package requires additional distfiles to the default one, you cannot just
                   4865: append the additional filenames using the += operator, but you have write for
                   4866: example:
1.1       dsieger  4867: 
1.66      asau     4868: DISTFILES=      ${DEFAULT_DISTFILES} additional-files.tar.gz
1.1       dsieger  4869: 
                   4870: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
                   4871: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
                   4872: can set SITES.distfile to the list of URLs where the file distfile (including
                   4873: the suffix) can be found.
                   4874: 
                   4875: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
                   4876: DISTFILES+=     foo-file.tar.gz
                   4877: SITES.foo-file.tar.gz= \
                   4878: http://www.somewhere.com/somehow/ \
                   4879: http://www.somewhereelse.com/mirror/somehow/
                   4880: 
                   4881: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
                   4882: gets the name of each distfile appended to it, without an intermediate slash.
                   4883: Therefore, all site values have to end with a slash or other separator
                   4884: character. This allows for example to set MASTER_SITES to a URL of a CGI script
                   4885: that gets the name of the distfile as a parameter. In this case, the definition
                   4886: would look like:
                   4887: 
                   4888: MASTER_SITES=   http://www.example.com/download.cgi?file=
                   4889: 
1.23      jakllsch 4890: The exception to this rule are URLs starting with a dash. In that case the URL
                   4891: is taken as is, fetched and the result stored under the name of the distfile.
1.66      asau     4892: You can use this style for the case when the download URL style does not match
                   4893: the above common case. For example, if permanent download URL is a redirector
                   4894: to the real download URL, or the download file name is offered by an HTTP
                   4895: Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
                   4896: created instead of the default v1.0.0.tar.gz.
                   4897: 
                   4898: DISTNAME=       foo-1.0.0
                   4899: MASTER_SITES=   -http://www.example.com/archive/v1.0.0.tar.gz
1.23      jakllsch 4900: 
1.1       dsieger  4901: There are some predefined values for MASTER_SITES, which can be used in
                   4902: packages. The names of the variables should speak for themselves.
                   4903: 
1.156     leot     4904: MASTER_SITE_APACHE          MASTER_SITE_BACKUP
                   4905: MASTER_SITE_CRATESIO        MASTER_SITE_CYGWIN
                   4906: MASTER_SITE_DEBIAN          MASTER_SITE_FREEBSD
                   4907: MASTER_SITE_FREEBSD_LOCAL   MASTER_SITE_GENTOO
                   4908: MASTER_SITE_GITHUB          MASTER_SITE_GNOME
                   4909: MASTER_SITE_GNU             MASTER_SITE_GNUSTEP
                   4910: MASTER_SITE_HASKELL_HACKAGE MASTER_SITE_IFARCHIVE
                   4911: MASTER_SITE_KDE             MASTER_SITE_MOZILLA
                   4912: MASTER_SITE_MOZILLA_ALL     MASTER_SITE_MYSQL
                   4913: MASTER_SITE_NETLIB          MASTER_SITE_OPENBSD
                   4914: MASTER_SITE_OPENOFFICE      MASTER_SITE_OSDN
                   4915: MASTER_SITE_PERL_CPAN       MASTER_SITE_PGSQL
                   4916: MASTER_SITE_PYPI            MASTER_SITE_RUBYGEMS
                   4917: MASTER_SITE_R_CRAN          MASTER_SITE_SOURCEFORGE
                   4918: MASTER_SITE_SUNSITE         MASTER_SITE_SUSE
                   4919: MASTER_SITE_TEX_CTAN        MASTER_SITE_XCONTRIB
                   4920: MASTER_SITE_XEMACS          MASTER_SITE_XORG
1.1       dsieger  4921: 
                   4922: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
                   4923: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
1.27      wiz      4924: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
1.26      spz      4925: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
                   4926: distfiles/LOCAL_PORTS/.
1.1       dsieger  4927: 
                   4928: If you choose one of these predefined sites, you may want to specify a
                   4929: subdirectory of that site. Since these macros may expand to more than one
                   4930: actual site, you must use the following construct to specify a subdirectory:
                   4931: 
                   4932: MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
                   4933: MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
                   4934: 
                   4935: Note the trailing slash after the subdirectory name.
                   4936: 
1.154     rillig   4937: 19.5.2. How are the files fetched?
1.1       dsieger  4938: 
                   4939: The fetch phase makes sure that all the distfiles exist in a local directory
                   4940: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
                   4941: are fetched using commands of the form
                   4942: 
                   4943: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
                   4944: 
                   4945: where ${site} varies through several possibilities in turn: first,
                   4946: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
                   4947: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
                   4948: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
                   4949: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
                   4950: MASTER_SORT_AWK or MASTER_SORT_REGEX.
                   4951: 
1.16      jnemeth  4952: The specific command and arguments used depend on the FETCH_USING parameter.
                   4953: The example above is for FETCH_USING=custom.
                   4954: 
1.1       dsieger  4955: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
                   4956: target to mirror the distfiles, if they are freely distributable. Packages
                   4957: setting NO_SRC_ON_FTP (usually to "${RESTRICTED}") will not have their
                   4958: distfiles mirrored.
                   4959: 
1.154     rillig   4960: 19.6. The checksum phase
1.1       dsieger  4961: 
                   4962: After the distfile(s) are fetched, their checksum is generated and compared
                   4963: with the checksums stored in the distinfo file. If the checksums don't match,
                   4964: the build is aborted. This is to ensure the same distfile is used for building,
                   4965: and that the distfile wasn't changed, e.g. by some malign force, deliberately
                   4966: changed distfiles on the master distribution site or network lossage.
                   4967: 
1.154     rillig   4968: 19.7. The extract phase
1.1       dsieger  4969: 
                   4970: When the distfiles are present on the local system, they need to be extracted,
                   4971: as they usually come in the form of some compressed archive format.
                   4972: 
                   4973: By default, all DISTFILES are extracted. If you only need some of them, you can
                   4974: set the EXTRACT_ONLY variable to the list of those files.
                   4975: 
                   4976: Extracting the files is usually done by a little program, mk/extract/extract,
                   4977: which already knows how to extract various archive formats, so most likely you
                   4978: will not need to change anything here. But if you need, the following variables
                   4979: may help you:
                   4980: 
                   4981: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
                   4982: 
                   4983:     Use these variables to override the default options for an extract command,
                   4984:     which are defined in mk/extract/extract.
                   4985: 
                   4986: EXTRACT_USING
                   4987: 
1.14      jmcneill 4988:     This variable can be set to bsdtar, gtar, nbtar (which is the default
                   4989:     value), pax, or an absolute pathname pointing to the command with which tar
                   4990:     archives should be extracted. It is preferred to choose bsdtar over gtar if
                   4991:     NetBSD's pax-as-tar is not good enough.
1.1       dsieger  4992: 
                   4993: If the extract program doesn't serve your needs, you can also override the
                   4994: EXTRACT_CMD variable, which holds the command used for extracting the files.
                   4995: This command is executed in the ${WRKSRC} directory. During execution of this
                   4996: command, the shell variable extract_file holds the absolute pathname of the
                   4997: file that is going to be extracted.
                   4998: 
                   4999: And if that still does not suffice, you can override the do-extract target in
                   5000: the package Makefile.
                   5001: 
1.154     rillig   5002: 19.8. The patch phase
1.1       dsieger  5003: 
                   5004: After extraction, all the patches named by the PATCHFILES, those present in the
                   5005: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
                   5006: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
                   5007: are uncompressed before they are applied, files ending in .orig or .rej are
                   5008: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
1.154     rillig   5009: Section 13.3, "patches/*" for more details.
1.1       dsieger  5010: 
                   5011: By default patch(1) is given special args to make it fail if the patches apply
                   5012: with some lines of fuzz. Please fix (regen) the patches so that they apply
                   5013: cleanly. The rationale behind this is that patches that don't apply cleanly may
                   5014: end up being applied in the wrong place, and cause severe harm there.
                   5015: 
1.154     rillig   5016: 19.9. The tools phase
1.1       dsieger  5017: 
1.154     rillig   5018: This is covered in Chapter 20, Tools needed for building or running.
1.1       dsieger  5019: 
1.154     rillig   5020: 19.10. The wrapper phase
1.1       dsieger  5021: 
                   5022: This phase creates wrapper programs for the compilers and linkers. The
                   5023: following variables can be used to tweak the wrappers.
                   5024: 
                   5025: ECHO_WRAPPER_MSG
                   5026: 
                   5027:     The command used to print progress messages. Does nothing by default. Set
                   5028:     to ${ECHO} to see the progress messages.
                   5029: 
                   5030: WRAPPER_DEBUG
                   5031: 
                   5032:     This variable can be set to yes (default) or no, depending on whether you
                   5033:     want additional information in the wrapper log file.
                   5034: 
                   5035: WRAPPER_UPDATE_CACHE
                   5036: 
                   5037:     This variable can be set to yes or no, depending on whether the wrapper
                   5038:     should use its cache, which will improve the speed. The default value is
                   5039:     yes, but is forced to no if the platform does not support it.
                   5040: 
                   5041: WRAPPER_REORDER_CMDS
                   5042: 
                   5043:     A list of reordering commands. A reordering command has the form reorder:l:
                   5044:     lib1:lib2. It ensures that that -llib1 occurs before -llib2.
                   5045: 
                   5046: WRAPPER_TRANSFORM_CMDS
                   5047: 
                   5048:     A list of transformation commands. [TODO: investigate further]
                   5049: 
1.154     rillig   5050: 19.11. The configure phase
1.1       dsieger  5051: 
                   5052: Most pieces of software need information on the header files, system calls, and
                   5053: library routines which are available on the platform they run on. The process
                   5054: of determining this information is known as configuration, and is usually
                   5055: automated. In most cases, a script is supplied with the distfiles, and its
                   5056: invocation results in generation of header files, Makefiles, etc.
                   5057: 
                   5058: If the package contains a configure script, this can be invoked by setting
                   5059: HAS_CONFIGURE to "yes". If the configure script is a GNU autoconf script, you
                   5060: should set GNU_CONFIGURE to "yes" instead. What happens in the configure phase
                   5061: is roughly:
                   5062: 
                   5063: .for d in ${CONFIGURE_DIRS}
                   5064:         cd ${WRKSRC} \
                   5065:         && cd ${d} \
                   5066:         && env ${CONFIGURE_ENV} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
                   5067: .endfor
                   5068: 
                   5069: CONFIGURE_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In
                   5070: each of these directories, the configure script is run with the environment
                   5071: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
                   5072: CONFIGURE_SCRIPT (default: "./configure") and CONFIGURE_ARGS may all be changed
                   5073: by the package.
                   5074: 
1.38      wiz      5075: If the program uses the Perl way of configuration (mainly Perl modules, but not
                   5076: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
                   5077: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
                   5078: (e.g., MAKE_PARAMS+=foo=bar
                   5079: 
1.1       dsieger  5080: If the program uses an Imakefile for configuration, the appropriate steps can
1.99      sevan    5081: be invoked by setting USE_IMAKE to "yes". If you only need xmkmf, add it to
                   5082: USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
                   5083: SCRIPTS_ENV variable.
1.1       dsieger  5084: 
1.11      rillig   5085: If the program uses cmake for configuration, the appropriate steps can be
                   5086: invoked by setting USE_CMAKE to "yes". You can add variables to cmake's
                   5087: environment by adding them to the CONFIGURE_ENV variable and arguments to cmake
                   5088: by adding them to the CMAKE_ARGS variable. The top directory argument is given
                   5089: by the CMAKE_ARG_PATH variable, that defaults to "." (relative to
                   5090: CONFIGURE_DIRS)
                   5091: 
1.1       dsieger  5092: If there is no configure step at all, set NO_CONFIGURE to "yes".
                   5093: 
1.154     rillig   5094: 19.12. The build phase
1.1       dsieger  5095: 
                   5096: For building a package, a rough equivalent of the following code is executed.
                   5097: 
                   5098: .for d in ${BUILD_DIRS}
                   5099:         cd ${WRKSRC} \
                   5100:         && cd ${d} \
                   5101:         && env ${MAKE_ENV} \
                   5102:             ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
                   5103:                 -f ${MAKE_FILE} \
                   5104:                 ${BUILD_TARGET}
                   5105: .endfor
                   5106: 
                   5107: BUILD_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In each of
                   5108: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
                   5109: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
                   5110: and BUILD_TARGET may all be changed by the package.
                   5111: 
1.25      wiz      5112: The default value of MAKE_PROGRAM is "gmake" if USE_TOOLS contains "gmake", "
                   5113: make" otherwise. The default value of MAKE_FILE is "Makefile", and BUILD_TARGET
                   5114: defaults to "all".
1.1       dsieger  5115: 
                   5116: If there is no build step at all, set NO_BUILD to "yes".
                   5117: 
1.154     rillig   5118: 19.13. The test phase
1.1       dsieger  5119: 
                   5120: [TODO]
                   5121: 
1.154     rillig   5122: 19.14. The install phase
1.1       dsieger  5123: 
                   5124: Once the build stage has completed, the final step is to install the software
                   5125: in public directories, so users can access the programs and files.
                   5126: 
                   5127: In the install phase, a rough equivalent of the following code is executed.
                   5128: Additionally, before and after this code, much magic is performed to do
                   5129: consistency checks, registering the package, and so on.
                   5130: 
                   5131: .for d in ${INSTALL_DIRS}
                   5132:         cd ${WRKSRC} \
                   5133:         && cd ${d} \
                   5134:         && env ${MAKE_ENV} \
                   5135:             ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
                   5136:                 -f ${MAKE_FILE} \
                   5137:                 ${INSTALL_TARGET}
                   5138: .endfor
                   5139: 
                   5140: The variable's meanings are analogous to the ones in the build phase.
                   5141: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is "install" by default,
                   5142: plus "install.man" if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
                   5143: defined.
                   5144: 
                   5145: In the install phase, the following variables are useful. They are all
                   5146: variations of the install(1) command that have the owner, group and permissions
                   5147: preset. INSTALL is the plain install command. The specialized variants,
                   5148: together with their intended use, are:
                   5149: 
                   5150: INSTALL_PROGRAM_DIR
                   5151: 
                   5152:     directories that contain binaries
                   5153: 
                   5154: INSTALL_SCRIPT_DIR
                   5155: 
                   5156:     directories that contain scripts
                   5157: 
                   5158: INSTALL_LIB_DIR
                   5159: 
                   5160:     directories that contain shared and static libraries
                   5161: 
                   5162: INSTALL_DATA_DIR
                   5163: 
                   5164:     directories that contain data files
                   5165: 
                   5166: INSTALL_MAN_DIR
                   5167: 
                   5168:     directories that contain man pages
                   5169: 
1.100     leot     5170: INSTALL_GAME_DIR
                   5171: 
                   5172:     directories that contain data files for games
                   5173: 
1.1       dsieger  5174: INSTALL_PROGRAM
                   5175: 
                   5176:     binaries that can be stripped from debugging symbols
                   5177: 
                   5178: INSTALL_SCRIPT
                   5179: 
                   5180:     binaries that cannot be stripped
                   5181: 
                   5182: INSTALL_GAME
                   5183: 
                   5184:     game binaries
                   5185: 
                   5186: INSTALL_LIB
                   5187: 
                   5188:     shared and static libraries
                   5189: 
                   5190: INSTALL_DATA
                   5191: 
                   5192:     data files
                   5193: 
                   5194: INSTALL_GAME_DATA
                   5195: 
                   5196:     data files for games
                   5197: 
                   5198: INSTALL_MAN
                   5199: 
                   5200:     man pages
                   5201: 
                   5202: Some other variables are:
                   5203: 
1.106     tnn      5204: INSTALL_UNSTRIPPED
                   5205: 
                   5206:     If set to yes, do not run strip(1) when installing binaries. Any debugging
                   5207:     sections and symbols present in binaries will be preserved.
                   5208: 
1.1       dsieger  5209: INSTALLATION_DIRS
                   5210: 
                   5211:     A list of directories relative to PREFIX that are created by pkgsrc at the
                   5212:     beginning of the install phase. The package is supposed to create all
                   5213:     needed directories itself before installing files to it and list all other
                   5214:     directories here.
                   5215: 
1.25      wiz      5216: In the rare cases that a package shouldn't install anything, set NO_INSTALL to 
1.1       dsieger  5217: "yes". This is mostly relevant for packages in the regress category.
                   5218: 
1.154     rillig   5219: 19.15. The package phase
1.1       dsieger  5220: 
                   5221: Once the install stage has completed, a binary package of the installed files
                   5222: can be built. These binary packages can be used for quick installation without
                   5223: previous compilation, e.g. by the make bin-install or by using pkg_add.
                   5224: 
                   5225: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
                   5226: created in ${PACKAGES}/category, one for each category in the CATEGORIES
                   5227: variable. PACKAGES defaults to pkgsrc/packages.
                   5228: 
1.154     rillig   5229: 19.16. Cleaning up
1.1       dsieger  5230: 
                   5231: Once you're finished with a package, you can clean the work directory by
                   5232: running make clean. If you want to clean the work directories of all
                   5233: dependencies too, use make clean-depends.
                   5234: 
1.154     rillig   5235: 19.17. Other helpful targets
1.1       dsieger  5236: 
                   5237: pre/post-*
                   5238: 
                   5239:     For any of the main targets described in the previous section, two
                   5240:     auxiliary targets exist with "pre-" and "post-" used as a prefix for the
                   5241:     main target's name. These targets are invoked before and after the main
                   5242:     target is called, allowing extra configuration or installation steps be
                   5243:     performed from a package's Makefile, for example, which a program's
                   5244:     configure script or install target omitted.
                   5245: 
                   5246: do-*
                   5247: 
                   5248:     Should one of the main targets do the wrong thing, and should there be no
                   5249:     variable to fix this, you can redefine it with the do-* target. (Note that
                   5250:     redefining the target itself instead of the do-* target is a bad idea, as
                   5251:     the pre-* and post-* targets won't be called anymore, etc.) You will not
                   5252:     usually need to do this.
                   5253: 
                   5254: reinstall
                   5255: 
                   5256:     If you did a make install and you noticed some file was not installed
                   5257:     properly, you can repeat the installation with this target, which will
                   5258:     ignore the "already installed" flag.
                   5259: 
                   5260:     This is the default value of DEPENDS_TARGET except in the case of make
                   5261:     update and make package, where the defaults are "package" and "update",
                   5262:     respectively.
                   5263: 
                   5264: deinstall
                   5265: 
                   5266:     This target does a pkg_delete(1) in the current directory, effectively
                   5267:     de-installing the package. The following variables can be used to tune the
                   5268:     behaviour:
                   5269: 
                   5270:     PKG_VERBOSE
                   5271: 
                   5272:         Add a "-v" to the pkg_delete(1) command.
                   5273: 
                   5274:     DEINSTALLDEPENDS
                   5275: 
                   5276:         Remove all packages that require (depend on) the given package. This
                   5277:         can be used to remove any packages that may have been pulled in by a
                   5278:         given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
1.25      wiz      5279:         pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding "-R
                   5280:         " to the pkg_delete(1) command line.
1.1       dsieger  5281: 
                   5282: bin-install
                   5283: 
                   5284:     Install a binary package from local disk and via FTP from a list of sites
                   5285:     (see the BINPKG_SITES variable), and do a make package if no binary package
                   5286:     is available anywhere. The arguments given to pkg_add can be set via
                   5287:     BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
                   5288: 
1.95      wiz      5289: install-clean
                   5290: 
                   5291:     This target removes the state files for the "install" and later phases so
                   5292:     that the "install" target may be re-invoked. This can be used after editing
                   5293:     the PLIST to install the package without rebuilding it.
                   5294: 
                   5295: build-clean
                   5296: 
                   5297:     This target removes the state files for the "build" and later phases so
                   5298:     that the "build" target may be re-invoked.
                   5299: 
1.1       dsieger  5300: update
                   5301: 
                   5302:     This target causes the current package to be updated to the latest version.
                   5303:     The package and all depending packages first get de-installed, then current
                   5304:     versions of the corresponding packages get compiled and installed. This is
                   5305:     similar to manually noting which packages are currently installed, then
                   5306:     performing a series of make deinstall and make install (or whatever
                   5307:     UPDATE_TARGET is set to) for these packages.
                   5308: 
                   5309:     You can use the "update" target to resume package updating in case a
                   5310:     previous make update was interrupted for some reason. However, in this
                   5311:     case, make sure you don't call make clean or otherwise remove the list of
                   5312:     dependent packages in WRKDIR. Otherwise, you lose the ability to
                   5313:     automatically update the current package along with the dependent packages
                   5314:     you have installed.
                   5315: 
                   5316:     Resuming an interrupted make update will only work as long as the package
                   5317:     tree remains unchanged. If the source code for one of the packages to be
                   5318:     updated has been changed, resuming make update will most certainly fail!
                   5319: 
1.4       rillig   5320:     The following variables can be used either on the command line or in
1.1       dsieger  5321:     mk.conf to alter the behaviour of make update:
                   5322: 
                   5323:     UPDATE_TARGET
                   5324: 
                   5325:         Install target to recursively use for the updated package and the
                   5326:         dependent packages. Defaults to DEPENDS_TARGET if set, "install"
1.25      wiz      5327:         otherwise for make update. Other good targets are "package" or "
                   5328:         bin-install". Do not set this to "update" or you will get stuck in an
1.1       dsieger  5329:         endless loop!
                   5330: 
                   5331:     NOCLEAN
                   5332: 
                   5333:         Don't clean up after updating. Useful if you want to leave the work
                   5334:         sources of the updated packages around for inspection or other
1.25      wiz      5335:         purposes. Be sure you eventually clean up the source tree (see the "
                   5336:         clean-update" target below) or you may run into troubles with old
1.1       dsieger  5337:         source code still lying around on your next make or make update.
                   5338: 
                   5339:     REINSTALL
                   5340: 
                   5341:         Deinstall each package before installing (making DEPENDS_TARGET). This
                   5342:         may be necessary if the "clean-update" target (see below) was called
                   5343:         after interrupting a running make update.
                   5344: 
                   5345:     DEPENDS_TARGET
                   5346: 
                   5347:         Allows you to disable recursion and hardcode the target for packages.
                   5348:         The default is "update" for the update target, facilitating a recursive
                   5349:         update of prerequisite packages. Only set DEPENDS_TARGET if you want to
                   5350:         disable recursive updates. Use UPDATE_TARGET instead to just set a
                   5351:         specific target for each package to be installed during make update
                   5352:         (see above).
                   5353: 
                   5354: clean-update
                   5355: 
                   5356:     Clean the source tree for all packages that would get updated if make
                   5357:     update was called from the current directory. This target should not be
                   5358:     used if the current package (or any of its depending packages) have already
                   5359:     been de-installed (e.g., after calling make update) or you may lose some
1.25      wiz      5360:     packages you intended to update. As a rule of thumb: only use this target 
1.1       dsieger  5361:     before the first time you run make update and only if you have a dirty
                   5362:     package tree (e.g., if you used NOCLEAN).
                   5363: 
                   5364:     If you are unsure about whether your tree is clean, you can either perform
                   5365:     a make clean at the top of the tree, or use the following sequence of
                   5366:     commands from the directory of the package you want to update (before
                   5367:     running make update for the first time, otherwise you lose all the packages
                   5368:     you wanted to update!):
                   5369: 
                   5370:     # make clean-update
                   5371:     # make clean CLEANDEPENDS=YES
                   5372:     # make update
                   5373: 
                   5374: 
1.4       rillig   5375:     The following variables can be used either on the command line or in
1.1       dsieger  5376:     mk.conf to alter the behaviour of make clean-update:
                   5377: 
                   5378:     CLEAR_DIRLIST
                   5379: 
                   5380:         After make clean, do not reconstruct the list of directories to update
                   5381:         for this package. Only use this if make update successfully installed
                   5382:         all packages you wanted to update. Normally, this is done automatically
                   5383:         on make update, but may have been suppressed by the NOCLEAN variable
                   5384:         (see above).
                   5385: 
                   5386: replace
                   5387: 
                   5388:     Update the installation of the current package. This differs from update in
                   5389:     that it does not replace dependent packages. You will need to install
                   5390:     pkgtools/pkg_tarup for this target to work.
                   5391: 
                   5392:     Be careful when using this target! There are no guarantees that dependent
                   5393:     packages will still work, in particular they will most certainly break if
                   5394:     you make replace a library package whose shared library major version
                   5395:     changed between your installed version and the new one. For this reason,
                   5396:     this target is not officially supported and only recommended for advanced
                   5397:     users.
                   5398: 
                   5399: info
                   5400: 
                   5401:     This target invokes pkg_info(1) for the current package. You can use this
                   5402:     to check which version of a package is installed.
                   5403: 
                   5404: index
                   5405: 
                   5406:     This is a top-level command, i.e. it should be used in the pkgsrc
                   5407:     directory. It creates a database of all packages in the local pkgsrc tree,
                   5408:     including dependencies, comment, maintainer, and some other useful
                   5409:     information. Individual entries are created by running make describe in the
                   5410:     packages' directories. This index file is saved as pkgsrc/INDEX. It can be
                   5411:     displayed in verbose format by running make print-index. You can search in
                   5412:     it with make search key=something. You can extract a list of all packages
                   5413:     that depend on a particular one by running make show-deps PKG=somepackage.
                   5414: 
                   5415:     Running this command takes a very long time, some hours even on fast
                   5416:     machines!
                   5417: 
                   5418: readme
                   5419: 
                   5420:     This target generates a README.html file, which can be viewed using a
                   5421:     browser such as www/firefox or www/links. The generated files contain
                   5422:     references to any packages which are in the PACKAGES directory on the local
                   5423:     host. The generated files can be made to refer to URLs based on
                   5424:     FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
                   5425:     README.html files which pointed to binary packages on the local machine, in
                   5426:     the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
                   5427:     FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
                   5428:     subdirectories will be searched for all the binary packages.
                   5429: 
                   5430:     The target can be run at the toplevel or in category directories, in which
                   5431:     case it descends recursively.
                   5432: 
                   5433: readme-all
                   5434: 
                   5435:     This is a top-level command, run it in pkgsrc. Use this target to create a
                   5436:     file README-all.html which contains a list of all packages currently
                   5437:     available in the NetBSD Packages Collection, together with the category
                   5438:     they belong to and a short description. This file is compiled from the
                   5439:     pkgsrc/*/README.html files, so be sure to run this after a make readme.
                   5440: 
                   5441: cdrom-readme
                   5442: 
                   5443:     This is very much the same as the "readme" target (see above), but is to be
                   5444:     used when generating a pkgsrc tree to be written to a CD-ROM. This target
                   5445:     also produces README.html files, and can be made to refer to URLs based on
                   5446:     CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
                   5447: 
                   5448: show-distfiles
                   5449: 
                   5450:     This target shows which distfiles and patchfiles are needed to build the
                   5451:     package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
                   5452:     patches/*).
                   5453: 
                   5454: show-downlevel
                   5455: 
                   5456:     This target shows nothing if the package is not installed. If a version of
                   5457:     this package is installed, but is not the version provided in this version
                   5458:     of pkgsrc, then a warning message is displayed. This target can be used to
                   5459:     show which of your installed packages are downlevel, and so the old
                   5460:     versions can be deleted, and the current ones added.
                   5461: 
                   5462: show-pkgsrc-dir
                   5463: 
                   5464:     This target shows the directory in the pkgsrc hierarchy from which the
                   5465:     package can be built and installed. This may not be the same directory as
                   5466:     the one from which the package was installed. This target is intended to be
                   5467:     used by people who may wish to upgrade many packages on a single host, and
1.25      wiz      5468:     can be invoked from the top-level pkgsrc Makefile by using the "
                   5469:     show-host-specific-pkgs" target.
1.1       dsieger  5470: 
                   5471: show-installed-depends
                   5472: 
                   5473:     This target shows which installed packages match the current package's
                   5474:     DEPENDS. Useful if out of date dependencies are causing build problems.
                   5475: 
1.95      wiz      5476: print-build-depends-list
                   5477: 
                   5478:     This target shows the list of packages that the current package depends on
                   5479:     for building.
                   5480: 
                   5481: print-run-depends-list
                   5482: 
                   5483:     This target shows the list of packages that the current package depends on
                   5484:     for running.
                   5485: 
1.1       dsieger  5486: check-shlibs
                   5487: 
                   5488:     After a package is installed, check all its binaries and (on ELF platforms)
                   5489:     shared libraries to see if they find the shared libs they need. Run by
1.4       rillig   5490:     default if PKG_DEVELOPER is set in mk.conf.
1.1       dsieger  5491: 
                   5492: print-PLIST
                   5493: 
                   5494:     After a "make install" from a new or upgraded pkg, this prints out an
                   5495:     attempt to generate a new PLIST from a find -newer work/.extract_done. An
                   5496:     attempt is made to care for shared libs etc., but it is strongly
                   5497:     recommended to review the result before putting it into PLIST. On upgrades,
                   5498:     it's useful to diff the output of this command against an already existing
                   5499:     PLIST file.
                   5500: 
                   5501:     If the package installs files via tar(1) or other methods that don't update
                   5502:     file access times, be sure to add these files manually to your PLIST, as
                   5503:     the "find -newer" command used by this target won't catch them!
                   5504: 
1.154     rillig   5505:     See Section 15.3, "Tweaking output of make print-PLIST" for more
1.1       dsieger  5506:     information on this target.
                   5507: 
                   5508: bulk-package
                   5509: 
                   5510:     Used to do bulk builds. If an appropriate binary package already exists, no
                   5511:     action is taken. If not, this target will compile, install and package it
1.154     rillig   5512:     (and its depends, if PKG_DEPENDS is set properly. See Chapter 8, Creating
1.66      asau     5513:     binary packages for everything in pkgsrc (bulk builds)). After creating the
                   5514:     binary package, the sources, the just-installed package and its required
                   5515:     packages are removed, preserving free disk space.
1.1       dsieger  5516: 
                   5517:     Beware that this target may deinstall all packages installed on a system!
                   5518: 
                   5519: bulk-install
                   5520: 
                   5521:     Used during bulk-installs to install required packages. If an up-to-date
1.25      wiz      5522:     binary package is available, it will be installed via pkg_add(1). If not, 
1.1       dsieger  5523:     make bulk-package will be executed, but the installed binary won't be
                   5524:     removed.
                   5525: 
                   5526:     A binary package is considered "up-to-date" to be installed via pkg_add(1)
                   5527:     if:
                   5528: 
1.42      asau     5529:       + None of the package's files (Makefile, ...) were modified since it was
1.1       dsieger  5530:         built.
                   5531: 
1.42      asau     5532:       + None of the package's required (binary) packages were modified since it
1.1       dsieger  5533:         was built.
                   5534: 
                   5535:     Beware that this target may deinstall all packages installed on a system!
                   5536: 
1.154     rillig   5537: Chapter 20. Tools needed for building or running
1.1       dsieger  5538: 
                   5539: Table of Contents
                   5540: 
1.154     rillig   5541: 20.1. Tools for pkgsrc builds
                   5542: 20.2. Tools needed by packages
                   5543: 20.3. Tools provided by platforms
1.1       dsieger  5544: 
                   5545: The USE_TOOLS definition is used both internally by pkgsrc and also for
                   5546: individual packages to define what commands are needed for building a package
1.156     leot     5547: (like TOOL_DEPENDS) or for later run-time of an installed packaged (such as
1.1       dsieger  5548: DEPENDS). If the native system provides an adequate tool, then in many cases, a
                   5549: pkgsrc package will not be used.
                   5550: 
                   5551: When building a package, the replacement tools are made available in a
                   5552: directory (as symlinks or wrapper scripts) that is early in the executable
                   5553: search path. Just like the buildlink system, this helps with consistent builds.
                   5554: 
                   5555: A tool may be needed to help build a specific package. For example, perl, GNU
                   5556: make (gmake) or yacc may be needed.
                   5557: 
                   5558: Also a tool may be needed, for example, because the native system's supplied
                   5559: tool may be inefficient for building a package with pkgsrc. For example, a
                   5560: package may need GNU awk, bison (instead of yacc) or a better sed.
                   5561: 
                   5562: The tools used by a package can be listed by running make show-tools.
                   5563: 
1.154     rillig   5564: 20.1. Tools for pkgsrc builds
1.1       dsieger  5565: 
                   5566: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
                   5567: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
                   5568: seen by running: make show-var VARNAME=USE_TOOLS.
                   5569: 
                   5570: If a package needs a specific program to build then the USE_TOOLS variable can
                   5571: be used to define the tools needed.
                   5572: 
1.154     rillig   5573: 20.2. Tools needed by packages
1.1       dsieger  5574: 
1.29      wiz      5575: In the following examples, the :run means that it is needed at run-time (and
                   5576: becomes a DEPENDS). The default is a build dependency which can be set with
                   5577: :build. (So in this example, it is the same as gmake:build and
                   5578: pkg-config:build.)
1.1       dsieger  5579: 
                   5580: USE_TOOLS+=     gmake perl:run pkg-config
                   5581: 
                   5582: When using the tools framework, a TOOLS_PATH.foo variable is defined which
                   5583: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
                   5584: could be "/bin/bash" on Linux systems.
                   5585: 
                   5586: If you always need a pkgsrc version of the tool at run-time, then just use
                   5587: DEPENDS instead.
                   5588: 
1.154     rillig   5589: 20.3. Tools provided by platforms
1.1       dsieger  5590: 
                   5591: When improving or porting pkgsrc to a new platform, have a look at (or create)
                   5592: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
                   5593: tools.${OPSYS}.mk which defines the name of the common tools. For example:
                   5594: 
                   5595: .if exists(/usr/bin/bzcat)
                   5596: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
                   5597: .elif exists(/usr/bin/bzip2)
                   5598: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
                   5599: .endif
                   5600: 
                   5601: TOOLS_PLATFORM.true?=           true                    # shell builtin
                   5602: 
1.154     rillig   5603: Chapter 21. Making your package work
1.1       dsieger  5604: 
                   5605: Table of Contents
                   5606: 
1.154     rillig   5607: 21.1. General operation
1.1       dsieger  5608: 
1.154     rillig   5609:     21.1.1. How to pull in user-settable variables from mk.conf
                   5610:     21.1.2. User interaction
                   5611:     21.1.3. Handling licenses
                   5612:     21.1.4. Restricted packages
                   5613:     21.1.5. Handling dependencies
                   5614:     21.1.6. Handling conflicts with other packages
                   5615:     21.1.7. Packages that cannot or should not be built
                   5616:     21.1.8. Packages which should not be deleted, once installed
                   5617:     21.1.9. Handling packages with security problems
                   5618:     21.1.10. How to handle incrementing versions when fixing an existing
1.1       dsieger  5619:         package
1.154     rillig   5620:     21.1.11. Substituting variable text in the package files (the SUBST
1.1       dsieger  5621:         framework)
                   5622: 
1.154     rillig   5623: 21.2. The fetch phase
1.1       dsieger  5624: 
1.154     rillig   5625:     21.2.1. Packages whose distfiles aren't available for plain downloading
                   5626:     21.2.2. How to handle modified distfiles with the 'old' name
                   5627:     21.2.3. Packages hosted on github.com
                   5628: 
                   5629: 21.3. The configure phase
                   5630: 
                   5631:     21.3.1. Shared libraries - libtool
                   5632:     21.3.2. Using libtool on GNU packages that already support libtool
                   5633:     21.3.3. GNU Autoconf/Automake
                   5634: 
                   5635: 21.4. Programming languages
                   5636: 
                   5637:     21.4.1. C, C++, and Fortran
                   5638:     21.4.2. Java
                   5639:     21.4.3. Packages containing perl scripts
                   5640:     21.4.4. Packages containing shell scripts
                   5641:     21.4.5. Other programming languages
                   5642: 
                   5643: 21.5. The build phase
                   5644: 
                   5645:     21.5.1. Compiling C and C++ code conditionally
                   5646:     21.5.2. How to handle compiler bugs
                   5647:     21.5.3. Undefined reference to "..."
                   5648:     21.5.4. Running out of memory
                   5649: 
                   5650: 21.6. The install phase
                   5651: 
                   5652:     21.6.1. Creating needed directories
                   5653:     21.6.2. Where to install documentation
                   5654:     21.6.3. Installing highscore files
                   5655:     21.6.4. Adding DESTDIR support to packages
                   5656:     21.6.5. Packages with hardcoded paths to other interpreters
                   5657:     21.6.6. Packages installing perl modules
                   5658:     21.6.7. Packages installing info files
                   5659:     21.6.8. Packages installing man pages
                   5660:     21.6.9. Packages installing GConf data files
                   5661:     21.6.10. Packages installing scrollkeeper/rarian data files
                   5662:     21.6.11. Packages installing X11 fonts
                   5663:     21.6.12. Packages installing GTK2 modules
                   5664:     21.6.13. Packages installing SGML or XML data
                   5665:     21.6.14. Packages installing extensions to the MIME database
                   5666:     21.6.15. Packages using intltool
                   5667:     21.6.16. Packages installing startup scripts
                   5668:     21.6.17. Packages installing TeX modules
                   5669:     21.6.18. Packages supporting running binaries in emulation
                   5670:     21.6.19. Packages installing hicolor theme icons
                   5671:     21.6.20. Packages installing desktop files
1.1       dsieger  5672: 
1.154     rillig   5673: 21.7. Marking packages as having problems
1.1       dsieger  5674: 
1.154     rillig   5675: 21.1. General operation
1.1       dsieger  5676: 
                   5677: One appealing feature of pkgsrc is that it runs on many different platforms. As
                   5678: a result, it is important to ensure, where possible, that packages in pkgsrc
                   5679: are portable. This chapter mentions some particular details you should pay
                   5680: attention to while working on pkgsrc.
                   5681: 
1.154     rillig   5682: 21.1.1. How to pull in user-settable variables from mk.conf
1.1       dsieger  5683: 
                   5684: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4       rillig   5685: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
                   5686: those variables in the preprocessor directives of make(1) (for example .if or
                   5687: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
                   5688: loads the user preferences.
1.1       dsieger  5689: 
                   5690: But note that some variables may not be completely defined after ../../mk/
                   5691: bsd.prefs.mk has been included, as they may contain references to variables
1.108     rillig   5692: that are not yet defined. In shell commands (the lines in Makefile that are
                   5693: indented with a tab) this is no problem, since variables are only expanded when
                   5694: they are used. But in the preprocessor directives mentioned above and in
                   5695: dependency lines (of the form target: dependencies) the variables are expanded
                   5696: at load time.
1.1       dsieger  5697: 
                   5698: Note
                   5699: 
1.108     rillig   5700: To check whether a variable can be used at load time, run pkglint -Wall on your
                   5701: package.
1.1       dsieger  5702: 
1.154     rillig   5703: 21.1.2. User interaction
1.1       dsieger  5704: 
                   5705: Occasionally, packages require interaction from the user, and this can be in a
                   5706: number of ways:
                   5707: 
                   5708:   * When fetching the distfiles, some packages require user interaction such as
                   5709:     entering username/password or accepting a license on a web page.
                   5710: 
                   5711:   * When extracting the distfiles, some packages may ask for passwords.
                   5712: 
                   5713:   * help to configure the package before it is built
                   5714: 
                   5715:   * help during the build process
                   5716: 
                   5717:   * help during the installation of a package
                   5718: 
1.108     rillig   5719: A package can set the INTERACTIVE_STAGE variable to define which stages need
                   5720: interaction. This should be done in the package's Makefile, e.g.:
1.1       dsieger  5721: 
                   5722: INTERACTIVE_STAGE=      configure install
                   5723: 
                   5724: The user can then decide to skip this package by setting the BATCH variable.
1.108     rillig   5725: Packages that require interaction are also excluded from bulk builds.
1.1       dsieger  5726: 
1.154     rillig   5727: 21.1.3. Handling licenses
1.1       dsieger  5728: 
                   5729: Authors of software can choose the licence under which software can be copied.
1.111     sevan    5730: The Free Software Foundation has declared some licenses "Free", and the Open
                   5731: Source Initiative has a definition of "Open Source".
                   5732: 
                   5733: By default, pkgsrc allows packages with Free or Open Source licenses to be
                   5734: built. To allow packages with other licenses to be built as well, the pkgsrc
                   5735: user needs to add these licenses to the ACCEPTABLE_LICENSES variable in mk.conf
                   5736: . Note that this variable only affects which packages may be built, while the
                   5737: license terms often also restrict the actual use of the package and its
                   5738: redistribution.
1.1       dsieger  5739: 
                   5740: One might want to only install packages with a BSD license, or the GPL, and not
1.20      jnemeth  5741: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
1.111     sevan    5742: variable. The pkgsrc user can override the default by setting the
                   5743: ACCEPTABLE_LICENSES variable with "=" instead of "+=". The licenses accepted by
                   5744: default are defined in the DEFAULT_ACCEPTABLE_LICENSES variable in the file
                   5745: pkgsrc/mk/license.mk.
1.1       dsieger  5746: 
                   5747: The license tag mechanism is intended to address copyright-related issues
                   5748: surrounding building, installing and using a package, and not to address
1.20      jnemeth  5749: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
                   5750: redistribution restrictions should set these tags.
1.1       dsieger  5751: 
                   5752: Denoting that a package may be copied according to a particular license is done
                   5753: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
                   5754: string identifying the license, e.g. in graphics/xv:
                   5755: 
                   5756: LICENSE=        xv-license
                   5757: 
                   5758: When trying to build, the user will get a notice that the package is covered by
                   5759: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
                   5760: 
                   5761: % make
                   5762: ===> xv-3.10anb9 has an unacceptable license: xv-license.
                   5763: ===>     To view the license, enter "/usr/bin/make show-license".
                   5764: ===>     To indicate acceptance, add this line to your /etc/mk.conf:
                   5765: ===>     ACCEPTABLE_LICENSES+=xv-license
                   5766: *** Error code 1
                   5767: 
                   5768: The license can be viewed with make show-license, and if the user so chooses,
1.4       rillig   5769: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1       dsieger  5770: should not in the future fail because of that license:
                   5771: 
                   5772: ACCEPTABLE_LICENSES+=xv-license
                   5773: 
1.111     sevan    5774: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
                   5775: is deprecated because it does not crisply refer to a particular license text.
                   5776: Another problem with such usage is that it does not enable a user to tell
                   5777: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
                   5778: for all packages with that tag.
                   5779: 
1.154     rillig   5780: 21.1.3.1. Adding a package with a new license
1.1       dsieger  5781: 
1.49      rodent   5782: When adding a package with a new license, the following steps are required:
                   5783: 
1.111     sevan    5784:  1. Check whether the license qualifies as Free or Open Source by referencing
                   5785:     Various Licenses and Comments about Them and Licenses by Name | Open Source
                   5786:     Initiative. If this is the case, the filename in pkgsrc/licenses/ does not
                   5787:     need the -license suffix, and the license name should be added to:
1.49      rodent   5788: 
                   5789:       + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
                   5790: 
                   5791:       + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
                   5792:         license.c
                   5793: 
                   5794:  2. The license text should be added to pkgsrc/licenses for displaying. A list
                   5795:     of known licenses can be seen in this directory.
1.1       dsieger  5796: 
1.154     rillig   5797: 21.1.3.2. Change to the license
1.1       dsieger  5798: 
1.111     sevan    5799: When the license changes (in a way other than formatting), make sure that the
                   5800: new license has a different name (e.g., append the version number if it exists,
                   5801: or the date). Just because a user told pkgsrc to build programs under a
                   5802: previous version of a license does not mean that pkgsrc should build programs
                   5803: under the new licenses. The higher-level point is that pkgsrc does not evaluate
                   5804: licenses for reasonableness; the only test is a mechanistic test of whether a
                   5805: particular text has been approved by either of two bodies (FSF or OSI).
1.1       dsieger  5806: 
1.154     rillig   5807: 21.1.4. Restricted packages
1.1       dsieger  5808: 
1.111     sevan    5809: Some licenses restrict how software may be re-distributed. By declaring the
                   5810: restrictions, package tools can automatically refrain from e.g. placing binary
                   5811: packages on FTP sites.
                   5812: 
                   5813: There are four possible restrictions, which are the cross product of sources
                   5814: (distfiles) and binaries not being placed on FTP sites and CD-ROMs. Because
                   5815: this is rarely the exact language in any license, and because non-Free licenses
                   5816: tend to be different from each other, pkgsrc adopts a definition of FTP and
                   5817: CD-ROM. "FTP" means making the source or binary file available over the
                   5818: Internet at no charge. "CD-ROM" means making the source or binary available on
                   5819: some kind of media, together with other source and binary packages, which is
                   5820: sold for a distribution charge.
1.1       dsieger  5821: 
                   5822: In order to encode these restrictions, the package system defines five make
                   5823: variables that can be set to note these restrictions:
                   5824: 
                   5825:   * RESTRICTED
                   5826: 
                   5827:     This variable should be set whenever a restriction exists (regardless of
                   5828:     its kind). Set this variable to a string containing the reason for the
                   5829:     restriction. It should be understood that those wanting to understand the
                   5830:     restriction will have to read the license, and perhaps seek advice of
                   5831:     counsel.
                   5832: 
                   5833:   * NO_BIN_ON_CDROM
                   5834: 
                   5835:     Binaries may not be placed on CD-ROM containing other binary packages, for
                   5836:     which a distribution charge may be made. In this case, set this variable to
                   5837:     ${RESTRICTED}.
                   5838: 
                   5839:   * NO_BIN_ON_FTP
                   5840: 
                   5841:     Binaries may not made available on the Internet without charge. In this
                   5842:     case, set this variable to ${RESTRICTED}. If this variable is set, binary
                   5843:     packages will not be included on ftp.NetBSD.org.
                   5844: 
                   5845:   * NO_SRC_ON_CDROM
                   5846: 
                   5847:     Distfiles may not be placed on CD-ROM, together with other distfiles, for
                   5848:     which a fee may be charged. In this case, set this variable to $
                   5849:     {RESTRICTED}.
                   5850: 
                   5851:   * NO_SRC_ON_FTP
                   5852: 
                   5853:     Distfiles may not made available via FTP at no charge. In this case, set
                   5854:     this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
                   5855:     will not be mirrored on ftp.NetBSD.org.
                   5856: 
1.111     sevan    5857: Please note that packages will be removed from pkgsrc when the distfiles are
1.33      wiz      5858: not distributable and cannot be obtained for a period of one full quarter
1.111     sevan    5859: branch. Packages with manual/interactive fetch must have a maintainer and it is
                   5860: his/her responsibility to ensure this.
1.33      wiz      5861: 
1.154     rillig   5862: 21.1.5. Handling dependencies
1.1       dsieger  5863: 
                   5864: Your package may depend on some other package being present - and there are
                   5865: various ways of expressing this dependency. pkgsrc supports the BUILD_DEPENDS
1.156     leot     5866: and DEPENDS and TOOL_DEPENDS definitions, the USE_TOOLS definition, as well as
                   5867: dependencies via buildlink3.mk, which is the preferred way to handle
                   5868: dependencies, and which uses the variables named above. See Chapter 16, 
                   5869: Buildlink methodology for more information.
1.1       dsieger  5870: 
                   5871: The basic difference between the two variables is as follows: The DEPENDS
                   5872: definition registers that pre-requisite in the binary package so it will be
                   5873: pulled in when the binary package is later installed, whilst the BUILD_DEPENDS
1.156     leot     5874: and TOOL_DEPENDS definitions does not, marking a dependency that is only needed
                   5875: for building the package.
1.1       dsieger  5876: 
                   5877: This means that if you only need a package present whilst you are building, it
1.156     leot     5878: should be noted as a TOOL_DEPENDS or BUILD_DEPENDS. When cross-compiling,
                   5879: TOOL_DEPENDS are native packages, i.e. packages for the architecture where the
                   5880: package is built; BUILD_DEPENDS are target packages, i.e. packages for the
                   5881: architecture for which the package is built.
1.1       dsieger  5882: 
1.156     leot     5883: The format for BUILD_DEPENDS, DEPENDS and TOOL_DEPENDS definition is:
1.1       dsieger  5884: 
                   5885: <pre-req-package-name>:../../<category>/<pre-req-package>
                   5886: 
                   5887: Please note that the "pre-req-package-name" may include any of the wildcard
                   5888: version numbers recognized by pkg_info(1).
                   5889: 
1.55      wiz      5890:  1. If your package needs another package's binaries or libraries to build and
1.1       dsieger  5891:     run, and if that package has a buildlink3.mk file available, use it:
                   5892: 
                   5893:     .include "../../graphics/jpeg/buildlink3.mk"
                   5894: 
1.55      wiz      5895:  2. If your package needs another package's binaries or libraries only for
                   5896:     building, and if that package has a buildlink3.mk file available, use it:
                   5897: 
                   5898:     .include "../../graphics/jpeg/buildlink3.mk"
                   5899: 
                   5900:     but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
                   5901:     This case is rather rare.
                   5902: 
                   5903:  3. If your package needs binaries from another package to build, use the
1.156     leot     5904:     TOOL_DEPENDS definition:
                   5905: 
                   5906:     TOOL_DEPENDS+= itstool-[0-9]*:../../textproc/itstool
1.1       dsieger  5907: 
1.156     leot     5908:  4. If your package needs static libraries to link against, header files to
                   5909:     include, etc. from another package to build, use the BUILD_DEPENDS
                   5910:     definition.
1.1       dsieger  5911: 
1.156     leot     5912:  5. If your package needs a library with which to link and there is no
1.26      spz      5913:     buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
                   5914:     because the include files and libraries will be hidden from the compiler.
1.1       dsieger  5915: 
1.156     leot     5916:  6. If your package needs some executable to be able to run correctly and if
1.26      spz      5917:     there's no buildlink3.mk file, this is specified using the DEPENDS
                   5918:     variable. The print/lyx package needs to be able to execute the latex
1.129     wiz      5919:     binary from the tex-latex-bin package when it runs, and that is specified:
1.1       dsieger  5920: 
1.129     wiz      5921:     DEPENDS+=        tex-latex-bin-[0-9]*:../../print/tex-latex-bin
1.1       dsieger  5922: 
1.156     leot     5923:  7. You can use wildcards in package dependencies. Note that such wildcard
1.26      spz      5924:     dependencies are retained when creating binary packages. The dependency is
                   5925:     checked when installing the binary package and any package which matches
                   5926:     the pattern will be used. Wildcard dependencies should be used with care.
1.1       dsieger  5927: 
                   5928:     The "-[0-9]*" should be used instead of "-*" to avoid potentially ambiguous
                   5929:     matches such as "tk-postgresql" matching a "tk-*" DEPENDS.
                   5930: 
                   5931:     Wildcards can also be used to specify that a package will only build
                   5932:     against a certain minimum version of a pre-requisite:
                   5933: 
1.26      spz      5934:     DEPENDS+=       ImageMagick>=6.0:../../graphics/ImageMagick
1.1       dsieger  5935: 
1.26      spz      5936:     This means that the package will build using version 6.0 of ImageMagick or
                   5937:     newer. Such a dependency may be warranted if, for example, the command line
                   5938:     options of an executable have changed.
                   5939: 
                   5940:     If you need to depend on minimum versions of libraries, see the buildlink
                   5941:     section of the pkgsrc guide.
1.1       dsieger  5942: 
                   5943:     For security fixes, please update the package vulnerabilities file. See
1.154     rillig   5944:     Section 21.1.9, "Handling packages with security problems" for more
1.1       dsieger  5945:     information.
                   5946: 
                   5947: If your package needs files from another package to build, add the relevant
                   5948: distribution files to DISTFILES, so they will be extracted automatically. See
                   5949: the print/ghostscript package for an example. (It relies on the jpeg sources
                   5950: being present in source form during the build.)
                   5951: 
1.154     rillig   5952: 21.1.6. Handling conflicts with other packages
1.1       dsieger  5953: 
                   5954: Your package may conflict with other packages a user might already have
                   5955: installed on his system, e.g. if your package installs the same set of files as
1.80      wiz      5956: another package in the pkgsrc tree or has the same PKGNAME.
1.1       dsieger  5957: 
1.142     leot     5958: For example, x11/libXaw3d and x11/Xaw-Xpm install the same shared library, thus
                   5959: you set in pkgsrc/x11/libXaw3d/Makefile:
1.1       dsieger  5960: 
1.142     leot     5961: CONFLICTS=      Xaw-Xpm-[0-9]*
1.1       dsieger  5962: 
                   5963: 
1.142     leot     5964: and in pkgsrc/x11/Xaw-Xpm/Makefile:
1.1       dsieger  5965: 
1.142     leot     5966: CONFLICTS=      libXaw3d-[0-9]*
1.1       dsieger  5967: 
1.142     leot     5968: 
                   5969: pkg_add(1) is able to detect attempts to install packages that conflict with
                   5970: existing packages and abort. However, in many situations this is too late in
                   5971: the process. Binary package managers will not know about the conflict until
                   5972: they attempt to install the package after already downloading it and all its
                   5973: dependencies. Users may also waste time building a package and its dependencies
                   5974: only to find out at the end that it conflicts with another package they have
                   5975: installed.
                   5976: 
                   5977: To avoid these issues CONFLICTS entries should be added in all cases where it
                   5978: is known that packages conflict with each other. These CONFLICTS entries are
                   5979: exported in pkg_summary(5) files and consumed by binary package managers to
                   5980: inform users that packages cannot be installed onto the target system.
1.1       dsieger  5981: 
1.154     rillig   5982: 21.1.7. Packages that cannot or should not be built
1.1       dsieger  5983: 
                   5984: There are several reasons why a package might be instructed to not build under
                   5985: certain circumstances. If the package builds and runs on most platforms, the
1.83      dholland 5986: exceptions should be noted with BROKEN_ON_PLATFORM. If the package builds and
                   5987: runs on a small handful of platforms, set BROKEN_EXCEPT_ON_PLATFORM instead.
                   5988: Both BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM are OS triples
                   5989: (OS-version-platform) that can use glob-style wildcards.
                   5990: 
1.114     maya     5991: If a package is not appropriate for some platforms (as opposed to merely
1.83      dholland 5992: broken), a different set of variables should be used as this affects failure
                   5993: reporting and statistics. If the package is appropriate for most platforms, the
                   5994: exceptions should be noted with NOT_FOR_PLATFORM. If the package is appropriate
                   5995: for only a small handful of platforms (often exactly one), set
                   5996: ONLY_FOR_PLATFORM instead. Both ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS
                   5997: triples (OS-version-platform) that can use glob-style wildcards.
1.1       dsieger  5998: 
                   5999: Some packages are tightly bound to a specific version of an operating system,
                   6000: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
                   6001: with other versions of the OS, and should be uploaded to a version specific
                   6002: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
                   6003: to "yes". This variable is not currently used by any of the package system
                   6004: internals, but may be used in the future.
                   6005: 
                   6006: If the package should be skipped (for example, because it provides
                   6007: functionality already provided by the system), set PKG_SKIP_REASON to a
                   6008: descriptive message. If the package should fail because some preconditions are
                   6009: not met, set PKG_FAIL_REASON to a descriptive message.
                   6010: 
1.154     rillig   6011: 21.1.8. Packages which should not be deleted, once installed
1.1       dsieger  6012: 
                   6013: To ensure that a package may not be deleted, once it has been installed, the
                   6014: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.25      wiz      6015: carried into any binary package that is made from this pkgsrc entry. A "
                   6016: preserved" package will not be deleted using pkg_delete(1) unless the "-f"
1.1       dsieger  6017: option is used.
                   6018: 
1.154     rillig   6019: 21.1.9. Handling packages with security problems
1.1       dsieger  6020: 
                   6021: When a vulnerability is found, this should be noted in localsrc/security/
1.32      wiz      6022: advisories/pkg-vulnerabilities, and after committing that file, ask
                   6023: pkgsrc-security@NetBSD.org to update the file on ftp.NetBSD.org.
1.1       dsieger  6024: 
                   6025: After fixing the vulnerability by a patch, its PKGREVISION should be increased
                   6026: (this is of course not necessary if the problem is fixed by using a newer
1.32      wiz      6027: release of the software), and the pattern in the pkg-vulnerabilities file must
                   6028: be updated.
1.1       dsieger  6029: 
                   6030: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
                   6031: submit a pullup request!
                   6032: 
                   6033: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
                   6034: a weekly cron job.
                   6035: 
1.154     rillig   6036: 21.1.10. How to handle incrementing versions when fixing an existing package
1.1       dsieger  6037: 
                   6038: When making fixes to an existing package it can be useful to change the version
                   6039: number in PKGNAME. To avoid conflicting with future versions by the original
                   6040: author, a "nb1", "nb2", ... suffix can be used on package versions by setting
                   6041: PKGREVISION=1 (2, ...). The "nb" is treated like a "." by the package tools.
                   6042: e.g.
                   6043: 
                   6044: DISTNAME=       foo-17.42
                   6045: PKGREVISION=    9
                   6046: 
                   6047: will result in a PKGNAME of "foo-17.42nb9". If you want to use the original
                   6048: value of PKGNAME without the "nbX" suffix, e.g. for setting DIST_SUBDIR, use
                   6049: PKGNAME_NOREV.
                   6050: 
                   6051: When a new release of the package is released, the PKGREVISION should be
                   6052: removed, e.g. on a new minor release of the above package, things should be
                   6053: like:
                   6054: 
                   6055: DISTNAME=       foo-17.43
                   6056: 
                   6057: PKGREVISION should be incremented for any non-trivial change in the resulting
                   6058: binary package. Without a PKGREVISION bump, someone with the previous version
                   6059: installed has no way of knowing that their package is out of date. Thus,
                   6060: changes without increasing PKGREVISION are essentially labeled "this is so
                   6061: trivial that no reasonable person would want to upgrade", and this is the rough
                   6062: test for when increasing PKGREVISION is appropriate. Examples of changes that
                   6063: do not merit increasing PKGREVISION are:
                   6064: 
1.14      jmcneill 6065:   * Changing HOMEPAGE, MAINTAINER, OWNER, or comments in Makefile.
1.1       dsieger  6066: 
                   6067:   * Changing build variables if the resulting binary package is the same.
                   6068: 
                   6069:   * Changing DESCR.
                   6070: 
                   6071:   * Adding PKG_OPTIONS if the default options don't change.
                   6072: 
                   6073: Examples of changes that do merit an increase to PKGREVISION include:
                   6074: 
                   6075:   * Security fixes
                   6076: 
                   6077:   * Changes or additions to a patch file
                   6078: 
                   6079:   * Changes to the PLIST
                   6080: 
1.12      weinem   6081:   * A dependency is changed or renamed.
                   6082: 
1.1       dsieger  6083: PKGREVISION must also be incremented when dependencies have ABI changes.
                   6084: 
1.154     rillig   6085: 21.1.11. Substituting variable text in the package files (the SUBST framework)
1.1       dsieger  6086: 
                   6087: When you want to replace the same text in multiple files or when the
                   6088: replacement text varies, patches alone cannot help. This is where the SUBST
                   6089: framework comes in. It provides an easy-to-use interface for replacing text in
                   6090: files. Example:
                   6091: 
                   6092: SUBST_CLASSES+=                 fix-paths
                   6093: SUBST_STAGE.fix-paths=          pre-configure
                   6094: SUBST_MESSAGE.fix-paths=        Fixing absolute paths.
                   6095: SUBST_FILES.fix-paths=          src/*.c
                   6096: SUBST_FILES.fix-paths+=         scripts/*.sh
                   6097: SUBST_SED.fix-paths=            -e 's,"/usr/local,"${PREFIX},g'
                   6098: SUBST_SED.fix-paths+=           -e 's,"/var/log,"${VARBASE}/log,g'
                   6099: 
                   6100: SUBST_CLASSES is a list of identifiers that are used to identify the different
                   6101: SUBST blocks that are defined. The SUBST framework is heavily used by pkgsrc,
                   6102: so it is important to always use the += operator with this variable. Otherwise
                   6103: some substitutions may be skipped.
                   6104: 
                   6105: The remaining variables of each SUBST block are parameterized with the
                   6106: identifier from the first line (fix-paths in this case.) They can be seen as
                   6107: parameters to a function call.
                   6108: 
                   6109: SUBST_STAGE.* specifies the stage at which the replacement will take place. All
                   6110: combinations of pre-, do- and post- together with a phase name are possible,
                   6111: though only few are actually used. Most commonly used are post-patch and
                   6112: pre-configure. Of these two, pre-configure should be preferred because then it
                   6113: is possible to run bmake patch and have the state after applying the patches
                   6114: but before making any other changes. This is especially useful when you are
                   6115: debugging a package in order to create new patches for it. Similarly,
                   6116: post-build is preferred over pre-install, because the install phase should
                   6117: generally be kept as simple as possible. When you use post-build, you have the
                   6118: same files in the working directory that will be installed later, so you can
                   6119: check if the substitution has succeeded.
                   6120: 
                   6121: SUBST_MESSAGE.* is an optional text that is printed just before the
                   6122: substitution is done.
                   6123: 
                   6124: SUBST_FILES.* is the list of shell globbing patterns that specifies the files
                   6125: in which the substitution will take place. The patterns are interpreted
                   6126: relatively to the WRKSRC directory.
                   6127: 
                   6128: SUBST_SED.* is a list of arguments to sed(1) that specify the actual
                   6129: substitution. Every sed command should be prefixed with -e, so that all SUBST
                   6130: blocks look uniform.
                   6131: 
                   6132: There are some more variables, but they are so seldomly used that they are only
                   6133: documented in the mk/subst.mk file.
                   6134: 
1.154     rillig   6135: 21.2. The fetch phase
1.1       dsieger  6136: 
1.154     rillig   6137: 21.2.1. Packages whose distfiles aren't available for plain downloading
1.1       dsieger  6138: 
                   6139: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
                   6140: a make fetch will call files/getsite.sh with the name of each file to download
                   6141: as an argument, expecting it to output the URL of the directory from which to
                   6142: download it. graphics/ns-cult3d is an example of this usage.
                   6143: 
                   6144: If the download can't be automated, because the user must submit personal
                   6145: information to apply for a password, or must pay for the source, or whatever,
                   6146: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
                   6147: before aborting the build. Example:
                   6148: 
                   6149: FETCH_MESSAGE=  "Please download the files"
                   6150: FETCH_MESSAGE+= "    "${DISTFILES:Q}
                   6151: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
                   6152: 
1.154     rillig   6153: 21.2.2. How to handle modified distfiles with the 'old' name
1.1       dsieger  6154: 
                   6155: Sometimes authors of a software package make some modifications after the
                   6156: software was released, and they put up a new distfile without changing the
                   6157: package's version number. If a package is already in pkgsrc at that time, the
                   6158: checksum will no longer match. The contents of the new distfile should be
                   6159: compared against the old one before changing anything, to make sure the
                   6160: distfile was really updated on purpose, and that no trojan horse or so crept
                   6161: in. Please mention that the distfiles were compared and what was found in your
1.54      rodent   6162: commit message.
                   6163: 
                   6164: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
1.109     wiz      6165: directory name, usually based on PKGNAME_NOREV (but take care with python or
                   6166: ruby packages, where PKGNAME includes a variable prefix). All DISTFILES and
                   6167: PATCHFILES for this package will be put in that subdirectory of the local
1.154     rillig   6168: distfiles directory. (See Section 21.1.10, "How to handle incrementing versions
1.109     wiz      6169: when fixing an existing package" for more details.) In case this happens more
                   6170: often, PKGNAME can be used (thus including the nbX suffix) or a date stamp can
                   6171: be appended, like ${PKGNAME_NOREV}-YYYYMMDD.
1.54      rodent   6172: 
                   6173: DIST_SUBDIR is also used when a distfile's name does not contain a version and
                   6174: the distfile is apt to change. In cases where the likelihood of this is very
                   6175: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
                   6176: removed unless the distfile name changes, even if a package is being moved or
                   6177: renamed.
                   6178: 
                   6179: Do not forget regenerating the distinfo file after that, since it contains the
                   6180: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
                   6181: installed package is different. Furthermore, a mail to the package's authors
                   6182: seems appropriate telling them that changing distfiles after releases without
                   6183: changing the file names is not good practice.
1.1       dsieger  6184: 
1.154     rillig   6185: 21.2.3. Packages hosted on github.com
1.88      tnn      6186: 
1.90      tnn      6187: Helper methods exist for packages hosted on github.com which will often have
                   6188: distfile names that clash with other packages, for example 1.0.tar.gz. Use one
                   6189: of the three recipes from below:
1.88      tnn      6190: 
1.154     rillig   6191: 21.2.3.1. Fetch based on a tagged release
1.88      tnn      6192: 
                   6193: If your distfile URL looks similar to http://github.com/username/exampleproject
                   6194: /archive/v1.0.zip, then you are packaging a tagged release.
                   6195: 
                   6196: DISTNAME=       exampleproject-1.0
1.90      tnn      6197: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6198: #GITHUB_PROJECT=        # can be omitted if same as DISTNAME
                   6199: GITHUB_TAG=     v${PKGVERSION_NOREV}
1.88      tnn      6200: EXTRACT_SUFX=   .zip
                   6201: 
1.154     rillig   6202: 21.2.3.2. Fetch based on a specific commit
1.88      tnn      6203: 
                   6204: If your distfile URL looks similar to http://github.com/example/example/archive
                   6205: /988881adc9fc3655077dc2d4d757d480b5ea0e11.tar.gz, then you are packaging a
                   6206: specific commit not tied to a release.
                   6207: 
                   6208: DISTNAME=       example-1.0
1.107     jnemeth  6209: MASTER_SITES=   ${MASTER_SITE_GITHUB:=example/}
1.90      tnn      6210: #GITHUB_PROJECT=        # can be omitted if same as DISTNAME
                   6211: GITHUB_TAG=     988881adc9fc3655077dc2d4d757d480b5ea0e11
1.88      tnn      6212: 
1.154     rillig   6213: 21.2.3.3. Fetch based on release
1.88      tnn      6214: 
                   6215: If your distfile URL looks similar to http://github.com/username/exampleproject
                   6216: /releases/download/rel-1.6/offensive-1.6.zip, then you are packaging a release.
                   6217: 
1.90      tnn      6218: DISTNAME=       offensive-1.6
1.88      tnn      6219: PKGNAME=        ${DISTNAME:S/offensive/proper/}
1.90      tnn      6220: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6221: GITHUB_PROJECT= exampleproject
                   6222: GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
                   6223: EXTRACT_SUFX=   .zip
1.88      tnn      6224: 
1.154     rillig   6225: 21.3. The configure phase
1.1       dsieger  6226: 
1.154     rillig   6227: 21.3.1. Shared libraries - libtool
1.1       dsieger  6228: 
                   6229: pkgsrc supports many different machines, with different object formats like
                   6230: a.out and ELF, and varying abilities to do shared library and dynamic loading
                   6231: at all. To accompany this, varying commands and options have to be passed to
                   6232: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
                   6233: especially if you don't have all the machines at your hand to test things. The
                   6234: devel/libtool pkg can help here, as it just "knows" how to build both static
                   6235: and dynamic libraries from a set of source files, thus being
                   6236: platform-independent.
                   6237: 
                   6238: Here's how to use libtool in a package in seven simple steps:
                   6239: 
                   6240:  1. Add USE_LIBTOOL=yes to the package Makefile.
                   6241: 
                   6242:  2. For library objects, use "${LIBTOOL} --mode=compile ${CC}" in place of "$
                   6243:     {CC}". You could even add it to the definition of CC, if only libraries are
                   6244:     being built in a given Makefile. This one command will build both PIC and
                   6245:     non-PIC library objects, so you need not have separate shared and
                   6246:     non-shared library rules.
                   6247: 
                   6248:  3. For the linking of the library, remove any "ar", "ranlib", and "ld
                   6249:     -Bshareable" commands, and instead use:
                   6250: 
                   6251:     ${LIBTOOL} --mode=link \
                   6252:         ${CC} -o ${.TARGET:.a=.la} \
                   6253:             ${OBJS:.o=.lo} \
                   6254:             -rpath ${PREFIX}/lib \
                   6255:             -version-info major:minor
                   6256: 
                   6257:     Note that the library is changed to have a .la extension, and the objects
                   6258:     are changed to have a .lo extension. Change OBJS as necessary. This
                   6259:     automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
                   6260:     necessary) in the build directory. Be sure to include "-version-info",
                   6261:     especially when major and minor are zero, as libtool will otherwise strip
                   6262:     off the shared library version.
                   6263: 
                   6264:     From the libtool manual:
                   6265: 
                   6266:     So, libtool library versions are described by three integers:
                   6267: 
                   6268:     CURRENT
                   6269:     The most recent interface number that this library implements.
                   6270: 
                   6271:     REVISION
                   6272:     The implementation number of the CURRENT interface.
                   6273: 
                   6274:     AGE
                   6275:     The difference between the newest and oldest interfaces that
                   6276:     this library implements.  In other words, the library implements
                   6277:     all the interface numbers in the range from number `CURRENT -
                   6278:     AGE' to `CURRENT'.
                   6279: 
                   6280:     If two libraries have identical CURRENT and AGE numbers, then the
                   6281:     dynamic linker chooses the library with the greater REVISION number.
                   6282: 
                   6283:     The "-release" option will produce different results for a.out and ELF
1.25      wiz      6284:     (excluding symlinks) in only one case. An ELF library of the form "
                   6285:     libfoo-release.so.x.y" will have a symlink of "libfoo.so.x.y" on an a.out
1.1       dsieger  6286:     platform. This is handled automatically.
                   6287: 
                   6288:     The "-rpath argument" is the install directory of the library being built.
                   6289: 
                   6290:     In the PLIST, include only the .la file, the other files will be added
                   6291:     automatically.
                   6292: 
                   6293:  4. When linking shared object (.so) files, i.e. files that are loaded via
                   6294:     dlopen(3), NOT shared libraries, use "-module -avoid-version" to prevent
                   6295:     them getting version tacked on.
                   6296: 
                   6297:     The PLIST file gets the foo.so entry.
                   6298: 
                   6299:  5. When linking programs that depend on these libraries before they are
                   6300:     installed, preface the cc(1) or ld(1) line with "${LIBTOOL} --mode=link",
                   6301:     and it will find the correct libraries (static or shared), but please be
                   6302:     aware that libtool will not allow you to specify a relative path in -L
                   6303:     (such as "-L../somelib"), because it expects you to change that argument to
                   6304:     be the .la file. e.g.
                   6305: 
                   6306:     ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
                   6307: 
                   6308:     should be changed to:
                   6309: 
                   6310:     ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
                   6311: 
                   6312:     and it will do the right thing with the libraries.
                   6313: 
                   6314:  6. When installing libraries, preface the install(1) or cp(1) command with "$
                   6315:     {LIBTOOL} --mode=install", and change the library name to .la. e.g.
                   6316: 
1.23      jakllsch 6317:     ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1       dsieger  6318: 
                   6319:     This will install the static .a, shared library, any needed symlinks, and
                   6320:     run ldconfig(8).
                   6321: 
                   6322:  7. In your PLIST, include only the .la file (this is a change from previous
                   6323:     behaviour).
                   6324: 
1.154     rillig   6325: 21.3.2. Using libtool on GNU packages that already support libtool
1.1       dsieger  6326: 
                   6327: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
                   6328: own libtool in most cases. For older libtool using packages, libtool is made by
                   6329: ltconfig script during the do-configure step; you can check the libtool script
                   6330: location by doing make configure; find work*/ -name libtool.
                   6331: 
                   6332: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
                   6333: override. By default, it is set to "libtool */libtool */*/libtool". If this
                   6334: does not match the location of the package's libtool script(s), set it as
                   6335: appropriate.
                   6336: 
                   6337: If you do not need *.a static libraries built and installed, then use
                   6338: SHLIBTOOL_OVERRIDE instead.
                   6339: 
                   6340: If your package makes use of the platform-independent library for loading
                   6341: dynamic shared objects, that comes with libtool (libltdl), you should include
                   6342: devel/libltdl/buildlink3.mk.
                   6343: 
                   6344: Some packages use libtool incorrectly so that the package may not work or build
                   6345: in some circumstances. Some of the more common errors are:
                   6346: 
                   6347:   * The inclusion of a shared object (-module) as a dependent library in an
                   6348:     executable or library. This in itself isn't a problem if one of two things
                   6349:     has been done:
                   6350: 
                   6351:      1. The shared object is named correctly, i.e. libfoo.la, not foo.la
                   6352: 
                   6353:      2. The -dlopen option is used when linking an executable.
                   6354: 
                   6355:   * The use of libltdl without the correct calls to initialisation routines.
                   6356:     The function lt_dlinit() should be called and the macro
                   6357:     LTDL_SET_PRELOADED_SYMBOLS included in executables.
                   6358: 
1.154     rillig   6359: 21.3.3. GNU Autoconf/Automake
1.1       dsieger  6360: 
                   6361: If a package needs GNU autoconf or automake to be executed to regenerate the
                   6362: configure script and Makefile.in makefile templates, then they should be
                   6363: executed in a pre-configure target.
                   6364: 
                   6365: For packages that need only autoconf:
                   6366: 
                   6367: AUTOCONF_REQD=  2.50            # if default version is not good enough
                   6368: USE_TOOLS+=     autoconf        # use "autoconf213" for autoconf-2.13
                   6369: ...
                   6370: 
                   6371: pre-configure:
                   6372:         cd ${WRKSRC} && autoconf
                   6373: 
                   6374: ...
                   6375: 
                   6376: and for packages that need automake and autoconf:
                   6377: 
                   6378: AUTOMAKE_REQD=  1.7.1           # if default version is not good enough
                   6379: USE_TOOLS+=     automake        # use "automake14" for automake-1.4
                   6380: ...
                   6381: 
                   6382: pre-configure:
                   6383:         set -e; cd ${WRKSRC}; \
                   6384:         aclocal; autoheader; automake -a --foreign -i; autoconf
                   6385: 
                   6386: ...
                   6387: 
                   6388: Packages which use GNU Automake will almost certainly require GNU Make.
                   6389: 
                   6390: There are times when the configure process makes additional changes to the
                   6391: generated files, which then causes the build process to try to re-execute the
                   6392: automake sequence. This is prevented by touching various files in the configure
                   6393: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
                   6394: NO in the package Makefile.
                   6395: 
1.154     rillig   6396: 21.4. Programming languages
1.1       dsieger  6397: 
1.154     rillig   6398: 21.4.1. C, C++, and Fortran
1.1       dsieger  6399: 
                   6400: Compilers for the C, C++, and Fortran languages comes with the NetBSD base
                   6401: system. By default, pkgsrc assumes that a package is written in C and will hide
1.154     rillig   6402: all other compilers (via the wrapper framework, see Chapter 16, Buildlink
1.1       dsieger  6403: methodology).
                   6404: 
                   6405: To declare which language's compiler a package needs, set the USE_LANGUAGES
                   6406: variable. Allowed values currently are "c", "c++", and "fortran" (and any
                   6407: combination). The default is "c". Packages using GNU configure scripts, even if
                   6408: written in C++, usually need a C compiler for the configure phase.
                   6409: 
1.154     rillig   6410: 21.4.2. Java
1.1       dsieger  6411: 
                   6412: If a program is written in Java, use the Java framework in pkgsrc. The package
                   6413: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
                   6414: variables:
                   6415: 
                   6416:   * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
                   6417:     set to "run", then there is only a runtime dependency on the JDK. The
                   6418:     default is "yes", which also adds a build dependency on the JDK.
                   6419: 
                   6420:   * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
                   6421:     supported values are "yes", "1.4", and "1.5". "yes" accepts any Java2
                   6422:     implementation, "1.4" insists on versions 1.4 or above, and "1.5" only
                   6423:     accepts versions 1.5 or above. This variable is not set by default.
                   6424: 
1.25      wiz      6425:   * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
                   6426:     implementation dependency. It may be used to set JAVA_HOME to a good value
                   6427:     if the program needs this variable to be defined.
                   6428: 
1.154     rillig   6429: 21.4.3. Packages containing perl scripts
1.1       dsieger  6430: 
                   6431: If your package contains interpreted perl scripts, add "perl" to the USE_TOOLS
                   6432: variable and set REPLACE_PERL to ensure that the proper interpreter path is
                   6433: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
1.74      wiz      6434: you want adjusted. Every occurrence of */bin/perl in a she-bang line will be
                   6435: replaced with the full path to the perl executable.
1.1       dsieger  6436: 
                   6437: If a particular version of perl is needed, set the PERL5_REQD variable to the
                   6438: version number. The default is "5.0".
                   6439: 
1.154     rillig   6440: See Section 21.6.6, "Packages installing perl modules" for information about
1.1       dsieger  6441: handling perl modules.
                   6442: 
1.154     rillig   6443: 21.4.4. Packages containing shell scripts
1.41      wiz      6444: 
                   6445: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
                   6446: shell hash bangs in files. Please use the appropriate one, prefering REPLACE_SH
1.74      wiz      6447: in case this shell is sufficient. Each should contain a list of scripts,
                   6448: relative to WRKSRC, that you want adjusted. Every occurrence of the matching
                   6449: shell in a she-bang line will be replaced with the full path to the shell
                   6450: executable. When using REPLACE_BASH, don't forget to add bash to USE_TOOLS.
1.41      wiz      6451: 
1.154     rillig   6452: 21.4.5. Other programming languages
1.1       dsieger  6453: 
                   6454: Currently, there is no special handling for other languages in pkgsrc. If a
                   6455: compiler package provides a buildlink3.mk file, include that, otherwise just
                   6456: add a (build) dependency on the appropriate compiler package.
                   6457: 
1.154     rillig   6458: 21.5. The build phase
1.1       dsieger  6459: 
                   6460: The most common failures when building a package are that some platforms do not
                   6461: provide certain header files, functions or libraries, or they provide the
                   6462: functions in a library that the original package author didn't know. To work
                   6463: around this, you can rewrite the source code in most cases so that it does not
                   6464: use the missing functions or provides a replacement function.
                   6465: 
1.154     rillig   6466: 21.5.1. Compiling C and C++ code conditionally
1.1       dsieger  6467: 
                   6468: If a package already comes with a GNU configure script, the preferred way to
                   6469: fix the build failure is to change the configure script, not the code. In the
                   6470: other cases, you can utilize the C preprocessor, which defines certain macros
                   6471: depending on the operating system and hardware architecture it compiles for.
                   6472: These macros can be queried using for example #if defined(__i386). Almost every
                   6473: operating system, hardware architecture and compiler has its own macro. For
                   6474: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
                   6475: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
                   6476: GCC.
                   6477: 
                   6478: The list of the following macros for hardware and operating system depends on
                   6479: the compiler that is used. For example, if you want to conditionally compile
                   6480: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
                   6481: Use __sun instead.
                   6482: 
1.154     rillig   6483: 21.5.1.1. C preprocessor macros to identify the operating system
1.1       dsieger  6484: 
                   6485: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
                   6486: should use the following code.
                   6487: 
                   6488: #include <sys/param.h>
                   6489: #if (defined(BSD) && BSD >= 199306)
                   6490: /* BSD-specific code goes here */
                   6491: #else
                   6492: /* non-BSD-specific code goes here */
                   6493: #endif
                   6494: 
                   6495: If this distinction is not fine enough, you can also test for the following
                   6496: macros.
                   6497: 
1.46      obache   6498: Cygwin      __CYGWIN__
                   6499: DragonFly   __DragonFly__
1.1       dsieger  6500: FreeBSD     __FreeBSD__
1.46      obache   6501: Haiku       __HAIKU__
1.1       dsieger  6502: Interix     __INTERIX
                   6503: IRIX        __sgi (TODO: get a definite source for this)
                   6504: Linux       linux, __linux, __linux__
1.83      dholland 6505: Mac OS X    __APPLE__
1.46      obache   6506: MirBSD      __MirBSD__ (__OpenBSD__ is also defined)
                   6507: Minix3      __minix
1.1       dsieger  6508: NetBSD      __NetBSD__
                   6509: OpenBSD     __OpenBSD__
                   6510: Solaris     sun, __sun
                   6511: 
1.154     rillig   6512: 21.5.1.2. C preprocessor macros to identify the hardware architecture
1.1       dsieger  6513: 
                   6514: i386        i386, __i386, __i386__
                   6515: MIPS        __mips
                   6516: SPARC       sparc, __sparc
                   6517: 
1.154     rillig   6518: 21.5.1.3. C preprocessor macros to identify the compiler
1.1       dsieger  6519: 
                   6520: GCC         __GNUC__ (major version), __GNUC_MINOR__
                   6521: MIPSpro     _COMPILER_VERSION (0x741 for MIPSpro 7.41)
                   6522: SunPro      __SUNPRO_C (0x570 for Sun C 5.7)
                   6523: SunPro C++  __SUNPRO_CC (0x580 for Sun C++ 5.8)
                   6524: 
1.154     rillig   6525: 21.5.2. How to handle compiler bugs
1.1       dsieger  6526: 
                   6527: Some source files trigger bugs in the compiler, based on combinations of
                   6528: compiler version and architecture and almost always relation to optimisation
                   6529: being enabled. Common symptoms are gcc internal errors or never finishing
                   6530: compiling a file.
                   6531: 
                   6532: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
1.87      tnn      6533: disabling optimisation for that combination of file, MACHINE_ARCH and compiler.
                   6534: 
                   6535: This used to be a big problem in the past, but is rarely needed now as compiler
                   6536: technology has matured. If you still need to add a compiler specific
                   6537: workaround, please do so in the file hacks.mk and describe the symptom and
                   6538: compiler version as detailed as possible.
1.1       dsieger  6539: 
1.154     rillig   6540: 21.5.3. Undefined reference to "..."
1.1       dsieger  6541: 
                   6542: This error message often means that a package did not link to a shared library
                   6543: it needs. The following functions are known to cause this error message over
                   6544: and over.
                   6545: 
                   6546: +-----------------------------------------------------+
                   6547: |        Function         |Library |Affected platforms|
                   6548: |-------------------------+--------+------------------|
                   6549: |accept, bind, connect    |-lsocket|Solaris           |
                   6550: |-------------------------+--------+------------------|
                   6551: |crypt                    |-lcrypt |DragonFly, NetBSD |
                   6552: |-------------------------+--------+------------------|
                   6553: |dlopen, dlsym            |-ldl    |Linux             |
                   6554: |-------------------------+--------+------------------|
                   6555: |gethost*                 |-lnsl   |Solaris           |
                   6556: |-------------------------+--------+------------------|
                   6557: |inet_aton                |-lresolv|Solaris           |
                   6558: |-------------------------+--------+------------------|
                   6559: |nanosleep, sem_*, timer_*|-lrt    |Solaris           |
                   6560: |-------------------------+--------+------------------|
                   6561: |openpty                  |-lutil  |Linux             |
                   6562: +-----------------------------------------------------+
                   6563: 
                   6564: To fix these linker errors, it is often sufficient to say LIBS.OperatingSystem+
                   6565: = -lfoo to the package Makefile and then say bmake clean; bmake.
                   6566: 
1.154     rillig   6567: 21.5.3.1. Special issue: The SunPro compiler
1.1       dsieger  6568: 
                   6569: When you are using the SunPro compiler, there is another possibility. That
                   6570: compiler cannot handle the following code:
                   6571: 
                   6572: extern int extern_func(int);
                   6573: 
                   6574: static inline int
                   6575: inline_func(int x)
                   6576: {
                   6577:         return extern_func(x);
                   6578: }
                   6579: 
                   6580: int main(void)
                   6581: {
                   6582:         return 0;
                   6583: }
                   6584: 
                   6585: It generates the code for inline_func even if that function is never used. This
                   6586: code then refers to extern_func, which can usually not be resolved. To solve
                   6587: this problem you can try to tell the package to disable inlining of functions.
                   6588: 
1.154     rillig   6589: 21.5.4. Running out of memory
1.1       dsieger  6590: 
                   6591: Sometimes packages fail to build because the compiler runs into an operating
                   6592: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
1.94      wiz      6593: told to unlimit the resources. Currently, the allowed values are any
                   6594: combination of "cputime", "datasize", "memorysize", and "stacksize". Setting
                   6595: this variable is similar to running the shell builtin ulimit command to raise
                   6596: the maximum data segment size or maximum stack size of a process, respectively,
                   6597: to their hard limits.
1.1       dsieger  6598: 
1.154     rillig   6599: 21.6. The install phase
1.1       dsieger  6600: 
1.154     rillig   6601: 21.6.1. Creating needed directories
1.1       dsieger  6602: 
                   6603: The BSD-compatible install supplied with some operating systems cannot create
                   6604: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
                   6605: like this:
                   6606: 
                   6607: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
                   6608: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
                   6609: 
                   6610: You can also just append "dir1 dir2" to the INSTALLATION_DIRS variable, which
                   6611: will automatically do the right thing.
                   6612: 
1.154     rillig   6613: 21.6.2. Where to install documentation
1.1       dsieger  6614: 
                   6615: In general, documentation should be installed into ${PREFIX}/share/doc/$
                   6616: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME} (the latter includes the version
                   6617: number of the package).
                   6618: 
                   6619: Many modern packages using GNU autoconf allow to set the directory where HTML
                   6620: documentation is installed with the "--with-html-dir" option. Sometimes using
                   6621: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
                   6622: share/doc/html or other places.
                   6623: 
                   6624: An exception to the above is that library API documentation generated with the
                   6625: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
                   6626: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
                   6627: can be recognized from files ending in .devhelp or .devhelp2. (It is also
                   6628: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
                   6629: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
                   6630: then, no additional subdirectory level is allowed in this case. This is usually
                   6631: achieved by using "--with-html-dir=${PREFIX}/share/doc". ${PREFIX}/share/
                   6632: gtk-doc is preferred though.)
                   6633: 
1.154     rillig   6634: 21.6.3. Installing highscore files
1.1       dsieger  6635: 
                   6636: Certain packages, most of them in the games category, install a score file that
                   6637: allows all users on the system to record their highscores. In order for this to
                   6638: work, the binaries need to be installed setgid and the score files owned by the
1.36      wiz      6639: appropriate group and/or owner (traditionally the "games" user/group). Set
                   6640: USE_GAMESGROUP to yes to support this. The following variables, documented in
                   6641: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
1.100     leot     6642: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER. Other useful variables are:
                   6643: GAMEDIR_PERMS, GAMEDATA_PERMS and SETGID_GAMES_PERMS.
                   6644: 
                   6645: An example that illustrates some of the variables described above is games/
                   6646: moon-buggy. OWN_DIRS_PERMS is used to properly set directory permissions of the
                   6647: directory where the scorefile is saved, REQD_FILES_PERMS is used to create a
                   6648: dummy scorefile (mbscore) with the proper permissions and SPECIAL_PERMS is used
                   6649: to install setgid the game binary:
                   6650: 
                   6651: USE_GAMESGROUP=         yes
                   6652: 
                   6653: BUILD_DEFS+=            VARBASE
                   6654: 
                   6655: OWN_DIRS_PERMS+=        ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
                   6656: REQD_FILES_PERMS+=      /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
                   6657: SPECIAL_PERMS+=         ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
                   6658: 
                   6659: Various INSTALL_* variables are also available: INSTALL_GAME to install setgid
                   6660: game binaries, INSTALL_GAME_DIR to install game directories that are needed to
                   6661: be accessed by setgid games and INSTALL_GAME_DATA to install scorefiles.
1.1       dsieger  6662: 
1.14      jmcneill 6663: A package should therefore never hard code file ownership or access permissions
1.100     leot     6664: but rely on *_PERMS as described above or alternatively on INSTALL_GAME,
                   6665: INSTALL_GAME_DATA and INSTALL_GAME_DIR to set these correctly.
1.1       dsieger  6666: 
1.154     rillig   6667: 21.6.4. Adding DESTDIR support to packages
1.4       rillig   6668: 
1.14      jmcneill 6669: DESTDIR support means that a package installs into a staging directory, not the
                   6670: final location of the files. Then a binary package is created which can be used
                   6671: for installation as usual. There are two ways: Either the package must install
1.25      wiz      6672: as root ("destdir") or the package can install as non-root user ("user-destdir"
                   6673: ).
1.14      jmcneill 6674: 
1.113     leot     6675:   * PKG_DESTDIR_SUPPORT has to be set to "destdir" or "user-destdir". By
                   6676:     default PKG_DESTDIR_SUPPORT is set to "user-destdir" to help catching more
                   6677:     potential packaging problems. If bsd.prefs.mk is included in the Makefile,
                   6678:     PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14      jmcneill 6679: 
1.4       rillig   6680:   * All installation operations have to be prefixed with ${DESTDIR}.
                   6681: 
                   6682:   * automake gets this DESTDIR mostly right automatically. Many manual rules
                   6683:     and pre/post-install often are incorrect; fix them.
                   6684: 
1.17      imil     6685:   * If files are installed with special owner/group use SPECIAL_PERMS.
1.4       rillig   6686: 
                   6687:   * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
                   6688: 
1.154     rillig   6689: 21.6.5. Packages with hardcoded paths to other interpreters
1.1       dsieger  6690: 
                   6691: Your package may also contain scripts with hardcoded paths to other
                   6692: interpreters besides (or as well as) perl. To correct the full pathname to the
                   6693: script interpreter, you need to set the following definitions in your Makefile
                   6694: (we shall use tclsh in this example):
                   6695: 
                   6696: REPLACE_INTERPRETER+=   tcl
                   6697: REPLACE.tcl.old=        .*/bin/tclsh
                   6698: REPLACE.tcl.new=        ${PREFIX}/bin/tclsh
                   6699: REPLACE_FILES.tcl=      # list of tcl scripts which need to be fixed,
                   6700: # relative to ${WRKSRC}, just as in REPLACE_PERL
                   6701: 
                   6702: Note
                   6703: 
                   6704: Before March 2006, these variables were called _REPLACE.* and _REPLACE_FILES.*.
                   6705: 
1.154     rillig   6706: 21.6.6. Packages installing perl modules
1.1       dsieger  6707: 
                   6708: Makefiles of packages providing perl5 modules should include the Makefile
                   6709: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
                   6710: standard perl configuration for such modules as well as various hooks to tune
                   6711: this configuration. See comments in this file for details.
                   6712: 
                   6713: Perl5 modules will install into different places depending on the version of
                   6714: perl used during the build process. To address this, pkgsrc will append lines
                   6715: to the PLIST corresponding to the files listed in the installed .packlist file
                   6716: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48      wiz      6717: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
                   6718: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1       dsieger  6719: 
1.48      wiz      6720: PERL5_PACKLIST= auto/Pg/.packlist
1.1       dsieger  6721: 
1.48      wiz      6722: The perl5 config variables installarchlib, installscript, installvendorbin,
                   6723: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
                   6724: and installvendorman3dir represent those locations in which components of perl5
                   6725: modules may be installed, provided as variable with uppercase and prefixed with
                   6726: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
                   6727: have a packlist. These variables are also substituted for in the PLIST as
                   6728: uppercase prefixed with PERL5_SUB_.
1.1       dsieger  6729: 
1.154     rillig   6730: 21.6.7. Packages installing info files
1.1       dsieger  6731: 
                   6732: Some packages install info files or use the "makeinfo" or "install-info"
                   6733: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
                   6734: and DEINSTALL scripts will be generated to handle registration of the info
                   6735: files in the Info directory file. The "install-info" command used for the info
                   6736: files registration is either provided by the system, or by a special purpose
                   6737: package automatically added as dependency if needed.
                   6738: 
                   6739: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
                   6740: located. PKGINFODIR defaults to "info" and can be overridden by the user.
                   6741: 
                   6742: The info files for the package should be listed in the package PLIST; however
                   6743: any split info files need not be listed.
                   6744: 
                   6745: A package which needs the "makeinfo" command at build time must add "makeinfo"
                   6746: to USE_TOOLS in its Makefile. If a minimum version of the "makeinfo" command is
                   6747: needed it should be noted with the TEXINFO_REQD variable in the package
                   6748: Makefile. By default, a minimum version of 3.12 is required. If the system does
                   6749: not provide a makeinfo command or if it does not match the required minimum, a
                   6750: build dependency on the devel/gtexinfo package will be added automatically.
                   6751: 
                   6752: The build and installation process of the software provided by the package
                   6753: should not use the install-info command as the registration of info files is
1.25      wiz      6754: the task of the package INSTALL script, and it must use the appropriate 
1.1       dsieger  6755: makeinfo command.
                   6756: 
                   6757: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
                   6758: the install-info and makeinfo commands in a directory listed early in PATH.
                   6759: 
                   6760: The script overriding install-info has no effect except the logging of a
                   6761: message. The script overriding makeinfo logs a message and according to the
                   6762: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
                   6763: error.
                   6764: 
1.154     rillig   6765: 21.6.8. Packages installing man pages
1.1       dsieger  6766: 
                   6767: All packages that install manual pages should install them into the same
                   6768: directory, so that there is one common place to look for them. In pkgsrc, this
                   6769: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.25      wiz      6770: packages. The default for PKGMANDIR is "man". Another often-used value is "
                   6771: share/man".
1.1       dsieger  6772: 
                   6773: Note
                   6774: 
                   6775: The support for a custom PKGMANDIR is far from complete.
                   6776: 
                   6777: The PLIST files can just use man/ as the top level directory for the man page
                   6778: file entries, and the pkgsrc framework will convert as needed. In all other
                   6779: places, the correct PKGMANDIR must be used.
                   6780: 
                   6781: Packages that are configured with GNU_CONFIGURE set as "yes", by default will
                   6782: use the ./configure --mandir switch to set where the man pages should be
                   6783: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
                   6784: {PKGMANDIR}.
                   6785: 
                   6786: Packages that use GNU_CONFIGURE but do not use --mandir, can set
                   6787: CONFIGURE_HAS_MANDIR to "no". Or if the ./configure script uses a non-standard
                   6788: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
                   6789: 
1.154     rillig   6790: See Section 15.5, "Man page compression" for information on installation of
1.1       dsieger  6791: compressed manual pages.
                   6792: 
1.154     rillig   6793: 21.6.9. Packages installing GConf data files
1.1       dsieger  6794: 
1.7       rillig   6795: If a package installs .schemas or .entries files, used by GConf, you need to
1.1       dsieger  6796: take some extra steps to make sure they get registered in the database:
                   6797: 
1.7       rillig   6798:  1. Include ../../devel/GConf/schemas.mk instead of its buildlink3.mk file.
                   6799:     This takes care of rebuilding the GConf database at installation and
                   6800:     deinstallation time, and tells the package where to install GConf data
1.1       dsieger  6801:     files using some standard configure arguments. It also disallows any access
                   6802:     to the database directly from the package.
                   6803: 
                   6804:  2. Ensure that the package installs its .schemas files under ${PREFIX}/share/
                   6805:     gconf/schemas. If they get installed under ${PREFIX}/etc, you will need to
                   6806:     manually patch the package.
                   6807: 
                   6808:  3. Check the PLIST and remove any entries under the etc/gconf directory, as
1.154     rillig   6809:     they will be handled automatically. See Section 10.13, "How do I change the
1.1       dsieger  6810:     location of configuration files?" for more information.
                   6811: 
1.7       rillig   6812:  4. Define the GCONF_SCHEMAS variable in your Makefile with a list of all
1.1       dsieger  6813:     .schemas files installed by the package, if any. Names must not contain any
                   6814:     directories in them.
                   6815: 
1.7       rillig   6816:  5. Define the GCONF_ENTRIES variable in your Makefile with a list of all
1.1       dsieger  6817:     .entries files installed by the package, if any. Names must not contain any
                   6818:     directories in them.
                   6819: 
1.154     rillig   6820: 21.6.10. Packages installing scrollkeeper/rarian data files
1.1       dsieger  6821: 
1.18      mishka   6822: If a package installs .omf files, used by scrollkeeper/rarian, you need to take
                   6823: some extra steps to make sure they get registered in the database:
1.1       dsieger  6824: 
1.18      mishka   6825:  1. Include ../../mk/omf-scrollkeeper.mk instead of rarian's buildlink3.mk
                   6826:     file. This takes care of rebuilding the scrollkeeper database at
                   6827:     installation and deinstallation time, and disallows any access to it
                   6828:     directly from the package.
1.1       dsieger  6829: 
                   6830:  2. Check the PLIST and remove any entries under the libdata/scrollkeeper
                   6831:     directory, as they will be handled automatically.
                   6832: 
                   6833:  3. Remove the share/omf directory from the PLIST. It will be handled by
1.18      mishka   6834:     rarian. (make print-PLIST does this automatically.)
1.1       dsieger  6835: 
1.154     rillig   6836: 21.6.11. Packages installing X11 fonts
1.1       dsieger  6837: 
                   6838: If a package installs font files, you will need to rebuild the fonts database
                   6839: in the directory where they get installed at installation and deinstallation
                   6840: time. This can be automatically done by using the pkginstall framework.
                   6841: 
                   6842: You can list the directories where fonts are installed in the FONTS_DIRS.type
                   6843: variables, where type can be one of "ttf", "type1" or "x11". Also make sure
                   6844: that the database file fonts.dir is not listed in the PLIST.
                   6845: 
                   6846: Note that you should not create new directories for fonts; instead use the
                   6847: standard ones to avoid that the user needs to manually configure his X server
                   6848: to find them.
                   6849: 
1.154     rillig   6850: 21.6.12. Packages installing GTK2 modules
1.1       dsieger  6851: 
                   6852: If a package installs GTK2 immodules or loaders, you need to take some extra
                   6853: steps to get them registered in the GTK2 database properly:
                   6854: 
                   6855:  1. Include ../../x11/gtk2/modules.mk instead of its buildlink3.mk file. This
                   6856:     takes care of rebuilding the database at installation and deinstallation
                   6857:     time.
                   6858: 
                   6859:  2. Set GTK2_IMMODULES=YES if your package installs GTK2 immodules.
                   6860: 
                   6861:  3. Set GTK2_LOADERS=YES if your package installs GTK2 loaders.
                   6862: 
                   6863:  4. Patch the package to not touch any of the GTK2 databases directly. These
                   6864:     are:
                   6865: 
1.42      asau     6866:       + libdata/gtk-2.0/gdk-pixbuf.loaders
1.1       dsieger  6867: 
1.42      asau     6868:       + libdata/gtk-2.0/gtk.immodules
1.1       dsieger  6869: 
                   6870:  5. Check the PLIST and remove any entries under the libdata/gtk-2.0 directory,
                   6871:     as they will be handled automatically.
                   6872: 
1.154     rillig   6873: 21.6.13. Packages installing SGML or XML data
1.1       dsieger  6874: 
                   6875: If a package installs SGML or XML data files that need to be registered in
                   6876: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
                   6877: extra steps:
                   6878: 
                   6879:  1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
                   6880:     care of registering those files in system-wide catalogs at installation and
                   6881:     deinstallation time.
                   6882: 
                   6883:  2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
                   6884:     package.
                   6885: 
                   6886:  3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
                   6887:     package.
                   6888: 
                   6889:  4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
                   6890:     These come in groups of three strings; see xmlcatmgr(1) for more
                   6891:     information (specifically, arguments recognized by the 'add' action). Note
                   6892:     that you will normally not use this variable.
                   6893: 
                   6894:  5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
                   6895:     come in groups of three strings; see xmlcatmgr(1) for more information
                   6896:     (specifically, arguments recognized by the 'add' action). Note that you
                   6897:     will normally not use this variable.
                   6898: 
1.154     rillig   6899: 21.6.14. Packages installing extensions to the MIME database
1.1       dsieger  6900: 
                   6901: If a package provides extensions to the MIME database by installing .xml files
                   6902: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
                   6903: ensure that the database is kept consistent with respect to these new files:
                   6904: 
                   6905:  1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
                   6906:     buildlink3.mk file from this same directory, which is reserved for
                   6907:     inclusion from other buildlink3.mk files). It takes care of rebuilding the
                   6908:     MIME database at installation and deinstallation time, and disallows any
                   6909:     access to it directly from the package.
                   6910: 
1.25      wiz      6911:  2. Check the PLIST and remove any entries under the share/mime directory, 
1.1       dsieger  6912:     except for files saved under share/mime/packages. The former are handled
                   6913:     automatically by the update-mime-database program, but the latter are
                   6914:     package-dependent and must be removed by the package that installed them in
                   6915:     the first place.
                   6916: 
                   6917:  3. Remove any share/mime/* directories from the PLIST. They will be handled by
                   6918:     the shared-mime-info package.
                   6919: 
1.154     rillig   6920: 21.6.15. Packages using intltool
1.1       dsieger  6921: 
                   6922: If a package uses intltool during its build, add intltool to the USE_TOOLS,
                   6923: which forces it to use the intltool package provided by pkgsrc, instead of the
                   6924: one bundled with the distribution file.
                   6925: 
                   6926: This tracks intltool's build-time dependencies and uses the latest available
                   6927: version; this way, the package benefits of any bug fixes that may have appeared
                   6928: since it was released.
                   6929: 
1.154     rillig   6930: 21.6.16. Packages installing startup scripts
1.1       dsieger  6931: 
                   6932: If a package contains a rc.d script, it won't be copied into the startup
                   6933: directory by default, but you can enable it, by adding the option
1.4       rillig   6934: PKG_RCD_SCRIPTS=YES in mk.conf. This option will copy the scripts into /etc/
                   6935: rc.d when a package is installed, and it will automatically remove the scripts
                   6936: when the package is deinstalled.
1.1       dsieger  6937: 
1.154     rillig   6938: 21.6.17. Packages installing TeX modules
1.1       dsieger  6939: 
                   6940: If a package installs TeX packages into the texmf tree, the ls-R database of
                   6941: the tree needs to be updated.
                   6942: 
                   6943: Note
                   6944: 
1.23      jakllsch 6945: Except the main TeX packages such as kpathsea, packages should install files
                   6946: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1       dsieger  6947: 
1.23      jakllsch 6948:  1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
                   6949:     ls-R database at installation and deinstallation time.
1.1       dsieger  6950: 
1.23      jakllsch 6951:  2. If your package installs files into a texmf tree other than the one at $
                   6952:     {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
                   6953:     trees that need database update.
1.1       dsieger  6954: 
                   6955:     If your package also installs font map files that need to be registered
1.30      dholland 6956:     using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
                   6957:     and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then 
                   6958:     updmap will be run automatically at installation/deinstallation to enable/
                   6959:     disable font map files for TeX output drivers.
1.1       dsieger  6960: 
                   6961:  3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30      dholland 6962:     be removed only by the kpathsea package.
1.1       dsieger  6963: 
1.154     rillig   6964: 21.6.18. Packages supporting running binaries in emulation
1.1       dsieger  6965: 
                   6966: There are some packages that provide libraries and executables for running
                   6967: binaries from a one operating system on a different one (if the latter supports
                   6968: it). One example is running Linux binaries on NetBSD.
                   6969: 
                   6970: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
                   6971: 
                   6972: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
                   6973: if all libraries for each installed executable can be found by the dynamic
                   6974: linker. Since the standard dynamic linker is run, this fails for emulation
                   6975: packages, because the libraries used by the emulation are not in the standard
                   6976: directories.
                   6977: 
1.154     rillig   6978: 21.6.19. Packages installing hicolor theme icons
1.1       dsieger  6979: 
                   6980: If a package installs images under the share/icons/hicolor and/or updates the
                   6981: share/icons/hicolor/icon-theme.cache database, you need to take some extra
                   6982: steps to make sure that the shared theme directory is handled appropriately and
                   6983: that the cache database is rebuilt:
                   6984: 
                   6985:  1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
                   6986: 
                   6987:  2. Check the PLIST and remove the entry that refers to the theme cache.
                   6988: 
                   6989:  3. Ensure that the PLIST does not remove the shared icon directories from the
                   6990:     share/icons/hicolor hierarchy because they will be handled automatically.
                   6991: 
                   6992: The best way to verify that the PLIST is correct with respect to the last two
                   6993: points is to regenerate it using make print-PLIST.
                   6994: 
1.154     rillig   6995: 21.6.20. Packages installing desktop files
1.1       dsieger  6996: 
                   6997: If a package installs .desktop files under share/applications and these include
1.54      rodent   6998: MIME information (MimeType key), you need to take extra steps to ensure that
                   6999: they are registered into the MIME database:
1.1       dsieger  7000: 
                   7001:  1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
                   7002: 
                   7003:  2. Check the PLIST and remove the entry that refers to the share/applications/
                   7004:     mimeinfo.cache file. It will be handled automatically.
                   7005: 
                   7006: The best way to verify that the PLIST is correct with respect to the last point
                   7007: is to regenerate it using make print-PLIST.
                   7008: 
1.154     rillig   7009: 21.7. Marking packages as having problems
1.1       dsieger  7010: 
1.23      jakllsch 7011: In some cases one does not have the time to solve a problem immediately. In
                   7012: this case, one can plainly mark a package as broken. For this, one just sets
                   7013: the variable BROKEN to the reason why the package is broken (similar to the
                   7014: RESTRICTED variable). A user trying to build the package will immediately be
                   7015: shown this message, and the build will not be even tried.
1.1       dsieger  7016: 
1.23      jakllsch 7017: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1       dsieger  7018: 
1.154     rillig   7019: Chapter 22. Debugging
1.1       dsieger  7020: 
                   7021: To check out all the gotchas when building a package, here are the steps that I
                   7022: do in order to get a package working. Please note this is basically the same as
                   7023: what was explained in the previous sections, only with some debugging aids.
                   7024: 
1.4       rillig   7025:   * Be sure to set PKG_DEVELOPER=yes in mk.conf.
1.1       dsieger  7026: 
                   7027:   * Install pkgtools/url2pkg, create a directory for a new package, change into
                   7028:     it, then run url2pkg:
                   7029: 
                   7030:     % mkdir /usr/pkgsrc/category/examplepkg
                   7031:     % cd /usr/pkgsrc/category/examplepkg
                   7032:     % url2pkg http://www.example.com/path/to/distfile.tar.gz
                   7033: 
                   7034:   * Edit the Makefile as requested.
                   7035: 
                   7036:   * Fill in the DESCR file
                   7037: 
                   7038:   * Run make configure
                   7039: 
                   7040:   * Add any dependencies glimpsed from documentation and the configure step to
                   7041:     the package's Makefile.
                   7042: 
                   7043:   * Make the package compile, doing multiple rounds of
                   7044: 
                   7045:     % make
                   7046:     % pkgvi ${WRKSRC}/some/file/that/does/not/compile
                   7047:     % mkpatches
                   7048:     % patchdiff
                   7049:     % mv ${WRKDIR}/.newpatches/* patches
                   7050:     % make mps
                   7051:     % make clean
                   7052: 
                   7053:     Doing this step as non-root user will ensure that no files are modified
                   7054:     that shouldn't be, especially during the build phase. mkpatches, patchdiff
                   7055:     and pkgvi are from the pkgtools/pkgdiff package.
                   7056: 
1.154     rillig   7057:   * Look at the Makefile, fix if necessary; see Section 13.1, "Makefile".
1.1       dsieger  7058: 
                   7059:   * Generate a PLIST:
                   7060: 
                   7061:     # make install
                   7062:     # make print-PLIST >PLIST
                   7063:     # make deinstall
                   7064:     # make install
                   7065:     # make deinstall
                   7066: 
                   7067:     You usually need to be root to do this. Look if there are any files left:
                   7068: 
                   7069:     # make print-PLIST
                   7070: 
                   7071:     If this reveals any files that are missing in PLIST, add them.
                   7072: 
                   7073:   * Now that the PLIST is OK, install the package again and make a binary
                   7074:     package:
                   7075: 
                   7076:     # make reinstall
                   7077:     # make package
                   7078: 
                   7079:   * Delete the installed package:
                   7080: 
                   7081:     # pkg_delete examplepkg
                   7082: 
                   7083:   * Repeat the above make print-PLIST command, which shouldn't find anything
                   7084:     now:
                   7085: 
                   7086:     # make print-PLIST
                   7087: 
                   7088:   * Reinstall the binary package:
                   7089: 
                   7090:     # pkg_add .../examplepkg.tgz
                   7091: 
                   7092:   * Play with it. Make sure everything works.
                   7093: 
                   7094:   * Run pkglint from pkgtools/pkglint, and fix the problems it reports:
                   7095: 
                   7096:     # pkglint
                   7097: 
1.154     rillig   7098:   * Submit (or commit, if you have cvs access); see Chapter 23, Submitting and
1.1       dsieger  7099:     Committing.
                   7100: 
1.154     rillig   7101: Chapter 23. Submitting and Committing
1.1       dsieger  7102: 
                   7103: Table of Contents
                   7104: 
1.154     rillig   7105: 23.1. Submitting binary packages
                   7106: 23.2. Submitting source packages (for non-NetBSD-developers)
                   7107: 23.3. General notes when adding, updating, or removing packages
                   7108: 23.4. Commit Messages
                   7109: 23.5. Committing: Adding a package to CVS
                   7110: 23.6. Updating a package to a newer version
                   7111: 23.7. Renaming a package in pkgsrc
                   7112: 23.8. Moving a package in pkgsrc
1.1       dsieger  7113: 
1.154     rillig   7114: 23.1. Submitting binary packages
1.1       dsieger  7115: 
                   7116: Our policy is that we accept binaries only from pkgsrc developers to guarantee
                   7117: that the packages don't contain any trojan horses etc. This is not to annoy
                   7118: anyone but rather to protect our users! You're still free to put up your
                   7119: home-made binary packages and tell the world where to get them. NetBSD
1.154     rillig   7120: developers doing bulk builds and wanting to upload them please see Chapter 8, 
1.66      asau     7121: Creating binary packages for everything in pkgsrc (bulk builds).
1.1       dsieger  7122: 
1.154     rillig   7123: 23.2. Submitting source packages (for non-NetBSD-developers)
1.1       dsieger  7124: 
                   7125: First, check that your package is complete, compiles and runs well; see
1.154     rillig   7126: Chapter 22, Debugging and the rest of this document. Next, generate an
1.1       dsieger  7127: uuencoded gzipped tar(1) archive that contains all files that make up the
                   7128: package. Finally, send this package to the pkgsrc bug tracking system, either
                   7129: with the send-pr(1) command, or if you don't have that, go to the web page
1.4       rillig   7130: http://www.NetBSD.org/support/send-pr.html, which contains some instructions
1.22      snj      7131: and a link to a form where you can submit packages. The sysutils/gtk-send-pr
                   7132: package is also available as a substitute for either of the above two tools.
1.1       dsieger  7133: 
                   7134: In the form of the problem report, the category should be "pkg", the synopsis
                   7135: should include the package name and version number, and the description field
                   7136: should contain a short description of your package (contents of the COMMENT
1.25      wiz      7137: variable or DESCR file are OK). The uuencoded package data should go into the "
                   7138: fix" field.
1.1       dsieger  7139: 
                   7140: If you want to submit several packages, please send a separate PR for each one,
                   7141: it's easier for us to track things that way.
                   7142: 
                   7143: Alternatively, you can also import new packages into pkgsrc-wip ("pkgsrc
1.105     wiz      7144: work-in-progress"); see the homepage at http://pkgsrc.org/wip/ for details.
1.1       dsieger  7145: 
1.154     rillig   7146: 23.3. General notes when adding, updating, or removing packages
1.1       dsieger  7147: 
                   7148: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
                   7149: CHANGES-YYYY. It's very important to keep this file up to date and conforming
                   7150: to the existing format, because it will be used by scripts to automatically
                   7151: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
                   7152: doc/TODO file and remove the entry for the package you updated or removed, in
                   7153: case it was mentioned there.
                   7154: 
                   7155: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
                   7156: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
                   7157: that result from a dependency being updated should not be mentioned. In all
                   7158: other cases it's the developer's decision.
                   7159: 
                   7160: There is a make target that helps in creating proper CHANGES-YYYY entries: make
                   7161: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
                   7162: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
                   7163: (to avoid having to resolve conflicts later-on) and then to cd to the package
                   7164: directory. For package updates, make changes-entry is enough. For new packages,
                   7165: or package moves or removals, set the CTYPE variable on the command line to
1.4       rillig   7166: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23      jakllsch 7167: your local login name is not the same as your NetBSD login name. The target
                   7168: also automatically removes possibly existing entries for the package in the
                   7169: TODO file. Don't forget to commit the changes, e.g. by using make
1.66      asau     7170: commit-changes-entry! If you are not using a checkout directly from
1.23      jakllsch 7171: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
                   7172: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1       dsieger  7173: 
1.154     rillig   7174: 23.4. Commit Messages
1.130     wiz      7175: 
                   7176: For several years, there have been mirrors of pkgsrc in fossil, git, and hg.
                   7177: Standard practise when using these tools is to make the first line of a commit
                   7178: message function as a summary that can be read without the rest, such as is
                   7179: commonly done with "git log --oneline". For this reason, we have the following
                   7180: guidelines for pkgsrc commit messages:
                   7181: 
1.131     wiz      7182:   * Start the commit message with a line that explains the big picture in 65
1.130     wiz      7183:     characters or less. When a commit is for one package, include the name of
                   7184:     the package. For updates, include the version to which it is updated.
                   7185: 
                   7186:   * Leave the next line empty.
                   7187: 
                   7188:   * Then come the details for the commit (changes in that package, reason for a
                   7189:     change) and any relevant PRs. Wrap this section.
                   7190: 
                   7191: Here is an example:
                   7192: 
                   7193:   libxslt: update to 1.0.30
                   7194: 
                   7195:   Changes since 1.0.29:
                   7196:   ...
                   7197: 
                   7198: 
                   7199: Here is another example:
                   7200: 
                   7201:   mk/bsd.pkg.mk: enable SSP by default on NetBSD
                   7202: 
                   7203:   (rationale)
                   7204: 
                   7205: 
                   7206: Commit messages are final: no "cvs admin" is allowed on the pkgsrc repository
                   7207: to change commit messages.
                   7208: 
1.154     rillig   7209: 23.5. Committing: Adding a package to CVS
1.1       dsieger  7210: 
                   7211: This section is only of interest for pkgsrc developers with write access to the
1.34      wiz      7212: pkgsrc repository.
                   7213: 
                   7214: When the package is finished, "cvs add" the files. Start by adding the
                   7215: directory and then files in the directory. Don't forget to add the new package
                   7216: to the category's Makefile. Make sure you don't forget any files; you can check
                   7217: by running "cvs status". An example:
                   7218: 
                   7219: $ cd .../pkgsrc/category
                   7220: $ cvs add pkgname
                   7221: $ cd pkgname
                   7222: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
                   7223: $ cvs add patches/p*
                   7224: $ cvs status | less
1.35      wiz      7225: $ cvs commit
1.34      wiz      7226: $ cd ..
                   7227: $ vi Makefile # add SUBDIRS+=pkgname line
1.35      wiz      7228: $ cvs commit Makefile
1.66      asau     7229: $ cd pkgname
1.73      jnemeth  7230: $ make CTYPE=Added commit-changes-entry
1.1       dsieger  7231: 
                   7232: The commit message of the initial import should include part of the DESCR file,
                   7233: so people reading the mailing lists know what the package is/does.
                   7234: 
1.34      wiz      7235: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
                   7236: 
                   7237: Previously, "cvs import" was suggested, but it was much easier to get wrong
                   7238: than "cvs add".
1.1       dsieger  7239: 
1.154     rillig   7240: 23.6. Updating a package to a newer version
1.1       dsieger  7241: 
                   7242: Please always put a concise, appropriate and relevant summary of the changes
                   7243: between old and new versions into the commit log when updating a package. There
                   7244: are various reasons for this:
                   7245: 
                   7246:   * A URL is volatile, and can change over time. It may go away completely or
                   7247:     its information may be overwritten by newer information.
                   7248: 
                   7249:   * Having the change information between old and new versions in our CVS
                   7250:     repository is very useful for people who use either cvs or anoncvs.
                   7251: 
                   7252:   * Having the change information between old and new versions in our CVS
                   7253:     repository is very useful for people who read the pkgsrc-changes mailing
                   7254:     list, so that they can make tactical decisions about when to upgrade the
                   7255:     package.
                   7256: 
                   7257: Please also recognize that, just because a new version of a package has been
                   7258: released, it should not automatically be upgraded in the CVS repository. We
                   7259: prefer to be conservative in the packages that are included in pkgsrc -
                   7260: development or beta packages are not really the best thing for most places in
                   7261: which pkgsrc is used. Please use your judgement about what should go into
                   7262: pkgsrc, and bear in mind that stability is to be preferred above new and
                   7263: possibly untested features.
                   7264: 
1.154     rillig   7265: 23.7. Renaming a package in pkgsrc
1.21      snj      7266: 
                   7267: Renaming packages is not recommended.
                   7268: 
                   7269: When renaming packages, be sure to fix any references to old name in other
                   7270: Makefiles, options, buildlink files, etc.
                   7271: 
                   7272: Also When renaming a package, please define SUPERSEDES to the package name and
                   7273: dewey version pattern(s) of the previous package name. This may be repeated for
                   7274: multiple renames. The new package would be an exact replacement.
                   7275: 
                   7276: Note that "successor" in the CHANGES-YYYY file doesn't necessarily mean that it
                   7277: supersedes, as that successor may not be an exact replacement but is a
                   7278: suggestion for the replaced functionality.
                   7279: 
1.154     rillig   7280: 23.8. Moving a package in pkgsrc
1.21      snj      7281: 
                   7282: It is preferred that packages are not renamed or moved, but if needed please
                   7283: follow these steps.
1.1       dsieger  7284: 
                   7285:  1. Make a copy of the directory somewhere else.
                   7286: 
                   7287:  2. Remove all CVS dirs.
                   7288: 
                   7289:     Alternatively to the first two steps you can also do:
                   7290: 
                   7291:     % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
                   7292: 
                   7293:     and use that for further work.
                   7294: 
1.25      wiz      7295:  3. Fix CATEGORIES and any DEPENDS paths that just did "../package" instead of 
1.1       dsieger  7296:     "../../category/package".
                   7297: 
1.21      snj      7298:  4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
                   7299:     previous category/package pathname. The PREV_PKGPATH can be used by tools
                   7300:     for doing an update using pkgsrc building; for example, it can search the
                   7301:     pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
                   7302:     the corresponding new PKGPATH for that moved package. Note that it may have
                   7303:     multiple matches, so the tool should also check on the PKGBASE too. The
                   7304:     PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
                   7305:     PKGBASE stays the same.
                   7306: 
                   7307:  5. cvs import the modified package in the new place.
1.1       dsieger  7308: 
1.21      snj      7309:  6. Check if any package depends on it:
1.1       dsieger  7310: 
                   7311:     % cd /usr/pkgsrc
                   7312:     % grep /package */*/Makefile* */*/buildlink*
                   7313: 
1.21      snj      7314:  7. Fix paths in packages from step 5 to point to new location.
1.1       dsieger  7315: 
1.21      snj      7316:  8. cvs rm (-f) the package at the old location.
1.1       dsieger  7317: 
1.21      snj      7318:  9. Remove from oldcategory/Makefile.
1.1       dsieger  7319: 
1.21      snj      7320: 10. Add to newcategory/Makefile.
1.1       dsieger  7321: 
1.21      snj      7322: 11. Commit the changed and removed files:
1.1       dsieger  7323: 
                   7324:     % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
                   7325: 
                   7326:     (and any packages from step 5, of course).
                   7327: 
1.154     rillig   7328: Chapter 24. Frequently Asked Questions
1.1       dsieger  7329: 
                   7330: This section contains the answers to questions that may arise when you are
                   7331: writing a package. If you don't find your question answered here, first have a
                   7332: look in the other chapters, and if you still don't have the answer, ask on the
                   7333: pkgsrc-users mailing list.
                   7334: 
1.154     rillig   7335: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
                   7336: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
                   7337: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
                   7338: 24.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1       dsieger  7339:     BUILDLINK_LIBS?
1.154     rillig   7340: 24.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
                   7341: 24.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1       dsieger  7342:     the := inside it.
1.154     rillig   7343: 24.7. Which mailing lists are there for package developers?
                   7344: 24.8. Where is the pkgsrc documentation?
                   7345: 24.9. I have a little time to kill. What shall I do?
1.1       dsieger  7346: 
1.154     rillig   7347: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1       dsieger  7348: 
                   7349:       MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
                   7350:       (1), while MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM
                   7351:       when building the package. [FIXME: What is .MAKEFLAGS for?]
                   7352: 
1.154     rillig   7353: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1       dsieger  7354: 
                   7355:       MAKE is the path to the make(1) program that is used in the pkgsrc
                   7356:       infrastructure. GMAKE is the path to GNU Make, but you need to say
                   7357:       USE_TOOLS+=gmake to use that. MAKE_PROGRAM is the path to the Make
                   7358:       program that is used for building the package.
                   7359: 
1.154     rillig   7360: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1       dsieger  7361: 
                   7362:       CC is the path to the real C compiler, which can be configured by the
                   7363:       pkgsrc user. PKG_CC is the path to the compiler wrapper. PKGSRC_COMPILER
                   7364:       is not a path to a compiler, but the type of compiler that should be
                   7365:       used. See mk/compiler.mk for more information about the latter variable.
                   7366: 
1.154     rillig   7367: 24.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1       dsieger  7368:       BUILDLINK_LIBS?
                   7369: 
                   7370:       [FIXME]
                   7371: 
1.154     rillig   7372: 24.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1       dsieger  7373: 
1.25      wiz      7374:       For optimization reasons, some variables are only available in the "
                   7375:       wrapper" phase and later. To "simulate" the wrapper phase, append 
1.1       dsieger  7376:       PKG_PHASE=wrapper to the above command.
                   7377: 
1.154     rillig   7378: 24.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1       dsieger  7379:       the := inside it.
                   7380: 
1.108     rillig   7381:       The := is not really an assignment operator, although it looks like it.
                   7382:       Instead, it is a degenerate form of ${LIST:old_string=new_string}, which
                   7383:       is documented in the make(1) man page and which is commonly used in the
                   7384:       form ${SRCS:.c=.o}. In the case of MASTER_SITE_*, old_string is the empty
                   7385:       string and new_string is package/. That's where the : and the = fall
                   7386:       together.
1.1       dsieger  7387: 
1.154     rillig   7388: 24.7. Which mailing lists are there for package developers?
1.1       dsieger  7389: 
                   7390:       tech-pkg
                   7391: 
                   7392:           This is a list for technical discussions related to pkgsrc
                   7393:           development, e.g. soliciting feedback for changes to pkgsrc
                   7394:           infrastructure, proposed new features, questions related to porting
                   7395:           pkgsrc to a new platform, advice for maintaining a package, patches
                   7396:           that affect many packages, help requests moved from pkgsrc-users when
                   7397:           an infrastructure bug is found, etc.
                   7398: 
                   7399:       pkgsrc-bugs
                   7400: 
                   7401:           All bug reports in category "pkg" sent with send-pr(1) appear here.
                   7402:           Please do not report your bugs here directly; use one of the other
                   7403:           mailing lists.
                   7404: 
1.154     rillig   7405: 24.8. Where is the pkgsrc documentation?
1.1       dsieger  7406: 
                   7407:       There are many places where you can find documentation about pkgsrc:
                   7408: 
                   7409:         * The pkgsrc guide (this document) is a collection of chapters that
                   7410:           explain large parts of pkgsrc, but some chapters tend to be outdated.
                   7411:           Which ones they are is hard to say.
                   7412: 
                   7413:         * On the mailing list archives (see http://mail-index.NetBSD.org/), you
                   7414:           can find discussions about certain features, announcements of new
                   7415:           parts of the pkgsrc infrastructure and sometimes even announcements
                   7416:           that a certain feature has been marked as obsolete. The benefit here
                   7417:           is that each message has a date appended to it.
                   7418: 
                   7419:         * Many of the files in the mk/ directory start with a comment that
                   7420:           describes the purpose of the file and how it can be used by the
                   7421:           pkgsrc user and package authors. An easy way to find this
                   7422:           documentation is to run bmake help.
                   7423: 
                   7424:         * The CVS log messages are a rich source of information, but they tend
                   7425:           to be highly abbreviated, especially for actions that occur often.
                   7426:           Some contain a detailed description of what has changed, but they are
                   7427:           geared towards the other pkgsrc developers, not towards an average
                   7428:           pkgsrc user. They also only document changes, so if you don't know
                   7429:           what has been before, these messages may not be worth too much to
                   7430:           you.
                   7431: 
                   7432:         * Some parts of pkgsrc are only "implicitly documented", that is the
                   7433:           documentation exists only in the mind of the developer who wrote the
                   7434:           code. To get this information, use the cvs annotate command to see
                   7435:           who has written it and ask on the tech-pkg mailing list, so that
                   7436:           others can find your questions later (see above). To be sure that the
                   7437:           developer in charge reads the mail, you may CC him or her.
                   7438: 
1.154     rillig   7439: 24.9. I have a little time to kill. What shall I do?
1.1       dsieger  7440: 
                   7441:       This is not really an FAQ yet, but here's the answer anyway.
                   7442: 
                   7443:         * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
                   7444:           about newer versions of installed packages that are available, but
                   7445:           not yet updated in pkgsrc.
                   7446: 
                   7447:         * Browse pkgsrc/doc/TODO ? it contains a list of suggested new packages
                   7448:           and a list of cleanups and enhancements for pkgsrc that would be nice
                   7449:           to have.
                   7450: 
1.71      wiz      7451:         * Review packages for which review was requested on the tech-pkg
                   7452:           mailing list.
1.1       dsieger  7453: 
1.154     rillig   7454: Chapter 25. GNOME packaging and porting
1.1       dsieger  7455: 
                   7456: Table of Contents
                   7457: 
1.154     rillig   7458: 25.1. Meta packages
                   7459: 25.2. Packaging a GNOME application
                   7460: 25.3. Updating GNOME to a newer version
                   7461: 25.4. Patching guidelines
1.1       dsieger  7462: 
                   7463: Quoting GNOME's web site:
                   7464: 
                   7465:     The GNOME project provides two things: The GNOME desktop environment, an
                   7466:     intuitive and attractive desktop for users, and the GNOME development
                   7467:     platform, an extensive framework for building applications that integrate
                   7468:     into the rest of the desktop.
                   7469: 
                   7470: pkgsrc provides a seamless way to automatically build and install a complete
                   7471: GNOME environment under many different platforms. We can say with confidence
                   7472: that pkgsrc is one of the most advanced build and packaging systems for GNOME
                   7473: due to its included technologies buildlink3, the wrappers and tools framework
                   7474: and automatic configuration file management. Lots of efforts are put into
                   7475: achieving a completely clean deinstallation of installed software components.
                   7476: 
                   7477: Given that pkgsrc is NetBSD's official packaging system, the above also means
                   7478: that great efforts are put into making GNOME work under this operating system.
                   7479: Recently, DragonFly BSD also adopted pkgsrc as its preferred packaging system,
                   7480: contributing lots of portability fixes to make GNOME build and install under
                   7481: it.
                   7482: 
                   7483: This chapter is aimed at pkgsrc developers and other people interested in
                   7484: helping our GNOME porting and packaging efforts. It provides instructions on
                   7485: how to manage the existing packages and some important information regarding
                   7486: their internals.
                   7487: 
                   7488: We need your help!
                   7489: 
                   7490: Should you have some spare cycles to devote to NetBSD, pkgsrc and GNOME and are
                   7491: willing to learn new exciting stuff, please jump straight to the pending work
                   7492: list! There is still a long way to go to get a fully-functional GNOME desktop
                   7493: under NetBSD and we need your help to achieve it!
                   7494: 
1.154     rillig   7495: 25.1. Meta packages
1.1       dsieger  7496: 
                   7497: pkgsrc includes three GNOME-related meta packages:
                   7498: 
                   7499:   * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
                   7500:     includes the necessary bits to get it to boot correctly, although it may
                   7501:     lack important functionality for daily operation. The idea behind this
                   7502:     package is to let end users build their own configurations on top of this
                   7503:     one, first installing this meta package to achieve a functional setup and
                   7504:     then adding individual applications.
                   7505: 
                   7506:   * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
                   7507:     desktop as defined by the GNOME project; this is based on the components
                   7508:     distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
                   7509:     directories of the official FTP server. Developer-only tools found in those
                   7510:     directories are not installed unless required by some other component to
                   7511:     work properly. Similarly, packages from the bindings set (bindings/x.y/
                   7512:     x.y.z/sources) are not pulled in unless required as a dependency for an
                   7513:     end-user component. This package "extends" meta-pkgs/gnome-base.
                   7514: 
                   7515:   * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
                   7516:     component when fetched from the CVS repository. These are required to let
                   7517:     the autogen.sh scripts work appropriately.
                   7518: 
                   7519: In all these packages, the DEPENDS lines are sorted in a way that eases
                   7520: updates: a package may depend on other packages listed before it but not on any
1.25      wiz      7521: listed after it. It is very important to keep this order to ease updates so... 
1.1       dsieger  7522: do not change it to alphabetical sorting!
                   7523: 
1.154     rillig   7524: 25.2. Packaging a GNOME application
1.1       dsieger  7525: 
                   7526: Almost all GNOME applications are written in C and use a common set of tools as
                   7527: their build system. Things get different with the new bindings to other
                   7528: languages (such as Python), but the following will give you a general idea on
                   7529: the minimum required tools:
                   7530: 
                   7531:   * Almost all GNOME applications use the GNU Autotools as their build system.
                   7532:     As a general rule you will need to tell this to your package:
                   7533: 
                   7534:     GNU_CONFIGURE=yes
                   7535:     USE_LIBTOOL=yes
                   7536:     USE_TOOLS+=gmake
                   7537: 
                   7538:   * If the package uses pkg-config to detect dependencies, add this tool to the
                   7539:     list of required utilities:
                   7540: 
                   7541:     USE_TOOLS+=pkg-config
                   7542: 
                   7543:     Also use pkgtools/verifypc at the end of the build process to ensure that
                   7544:     you did not miss to specify any dependency in your package and that the
                   7545:     version requirements are all correct.
                   7546: 
                   7547:   * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
                   7548:     handle dependencies and to force the package to use the latest available
                   7549:     version.
                   7550: 
                   7551:   * If the package uses gtk-doc (a documentation generation utility), do not
                   7552:     add a dependency on it. The tool is rather big and the distfile should come
                   7553:     with pregenerated documentation anyway; if it does not, it is a bug that
                   7554:     you ought to report. For such packages you should disable gtk-doc (unless
                   7555:     it is the default):
                   7556: 
                   7557:     CONFIGURE_ARGS+=--disable-gtk-doc
                   7558: 
                   7559:     The default location of installed HTML files (share/gtk-doc/<package-name>)
                   7560:     is correct and should not be changed unless the package insists on
                   7561:     installing them somewhere else. Otherwise programs as devhelp will not be
                   7562:     able to open them. You can do that with an entry similar to:
                   7563: 
                   7564:     CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...
                   7565: 
                   7566: GNOME uses multiple shared directories and files under the installation prefix
                   7567: to maintain databases. In this context, shared means that those exact same
                   7568: directories and files are used among several different packages, leading to
                   7569: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
                   7570: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
                   7571: your file lists and omitting shared files from them. If you find yourself doing
                   7572: those, your package is most likely incorrect.
                   7573: 
                   7574: The following table lists the common situations that result in using shared
                   7575: directories or files. For each of them, the appropriate solution is given.
1.25      wiz      7576: After applying the solution be sure to regenerate the package's file list with 
1.1       dsieger  7577: make print-PLIST and ensure it is correct.
                   7578: 
1.154     rillig   7579: Table 25.1. PLIST handling for GNOME packages
1.1       dsieger  7580: 
                   7581: +-----------------------------------------------------------------------------+
                   7582: |             If the package...             |             Then...             |
                   7583: |-------------------------------------------+---------------------------------|
1.154     rillig   7584: |                                           |See Section 21.6.10, "Packages   |
1.18      mishka   7585: |Installs OMF files under share/omf.        |installing scrollkeeper/rarian   |
                   7586: |                                           |data files".                     |
1.1       dsieger  7587: |-------------------------------------------+---------------------------------|
1.154     rillig   7588: |Installs icons under the share/icons/      |See Section 21.6.19, "Packages   |
1.1       dsieger  7589: |hicolor hierarchy or updates share/icons/  |installing hicolor theme icons". |
                   7590: |hicolor/icon-theme.cache.                  |                                 |
                   7591: |-------------------------------------------+---------------------------------|
1.154     rillig   7592: |                                           |See Section 21.6.14, "Packages   |
1.1       dsieger  7593: |Installs files under share/mime/packages.  |installing extensions to the MIME|
                   7594: |                                           |database".                       |
                   7595: |-------------------------------------------+---------------------------------|
1.154     rillig   7596: |Installs .desktop files under share/       |See Section 21.6.20, "Packages   |
1.1       dsieger  7597: |applications and these include MIME        |installing desktop files".       |
                   7598: |information.                               |                                 |
                   7599: +-----------------------------------------------------------------------------+
                   7600: 
                   7601: 
1.154     rillig   7602: 25.3. Updating GNOME to a newer version
1.1       dsieger  7603: 
                   7604: When seeing GNOME as a whole, there are two kinds of updates:
                   7605: 
                   7606: Major update
                   7607: 
                   7608:     Given that there is still a very long way for GNOME 3 (if it ever appears),
                   7609:     we consider a major update one that goes from a 2.X version to a 2.Y one,
                   7610:     where Y is even and greater than X. These are hard to achieve because they
                   7611:     introduce lots of changes in the components' code and almost all GNOME
                   7612:     distfiles are updated to newer versions. Some of them can even break API
                   7613:     and ABI compatibility with the previous major version series. As a result,
                   7614:     the update needs to be done all at once to minimize breakage.
                   7615: 
                   7616:     A major update typically consists of around 80 package updates and the
                   7617:     addition of some new ones.
                   7618: 
                   7619: Minor update
                   7620: 
                   7621:     We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
                   7622:     one where Y is greater than X. These are easy to achieve because they do
                   7623:     not update all GNOME components, can be done in an incremental way and do
                   7624:     not break API nor ABI compatibility.
                   7625: 
                   7626:     A minor update typically consists of around 50 package updates, although
                   7627:     the numbers here may vary a lot.
                   7628: 
                   7629: In order to update the GNOME components in pkgsrc to a new stable release
                   7630: (either major or minor), the following steps should be followed:
                   7631: 
                   7632:  1. Get a list of all the tarballs that form the new release by using the
1.19      snj      7633:     following commands. These will leave the full list of the components'
1.1       dsieger  7634:     distfiles into the list.txt file:
                   7635: 
                   7636:     % echo ls "*.tar.bz2" | \
                   7637:         ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
                   7638:         awk '{ print $9 }' >list.txt
                   7639:     % echo ls "*.tar.bz2" | \
                   7640:         ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
                   7641:         awk '{ print $9 }' >>list.txt
                   7642: 
                   7643:  2. Open each meta package's Makefile and bump their version to the release you
                   7644:     are updating them to. The three meta packages should be always consistent
                   7645:     with versioning. Obviously remove any PKGREVISIONs that might be in them.
                   7646: 
                   7647:  3. For each meta package, update all its DEPENDS lines to match the latest
                   7648:     versions as shown by the above commands. Do not list any newer version
                   7649:     (even if found in the FTP) because the meta packages are supposed to list
                   7650:     the exact versions that form a specific GNOME release. Exceptions are
                   7651:     permitted here if a newer version solves a serious issue in the overall
                   7652:     desktop experience; these typically come in the form of a revision bump in
                   7653:     pkgsrc, not in newer versions from the developers.
                   7654: 
                   7655:     Packages not listed in the list.txt file should be updated to the latest
                   7656:     version available (if found in pkgsrc). This is the case, for example, of
                   7657:     the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
                   7658:     package.
                   7659: 
                   7660:  4. Generate a patch from the modified meta packages and extract the list of
                   7661:     "new" lines. This will provide you an outline on what packages need to be
                   7662:     updated in pkgsrc and in what order:
                   7663: 
                   7664:     % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
                   7665: 
                   7666:  5. For major desktop updates it is recommended to zap all your installed
                   7667:     packages and start over from scratch at this point.
                   7668: 
                   7669:  6. Now comes the longest step by far: iterate over the contents of todo.txt
                   7670:     and update the packages listed in it in order. For major desktop updates
                   7671:     none of these should be committed until the entire set is completed because
                   7672:     there are chances of breaking not-yet-updated packages.
                   7673: 
                   7674:  7. Once the packages are up to date and working, commit them to the tree one
                   7675:     by one with appropriate log messages. At the end, commit the three meta
                   7676:     package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
                   7677:     and pkgsrc/doc/TODO files.
                   7678: 
1.154     rillig   7679: 25.4. Patching guidelines
1.1       dsieger  7680: 
                   7681: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
                   7682: it is very important that you always, always, always feed back any portability
                   7683: fixes you do to a GNOME package to the mainstream developers (see
1.154     rillig   7684: Section 13.3.5, "Feedback to the author"). This is the only way to get their
1.1       dsieger  7685: attention on portability issues and to ensure that future versions can be built
                   7686: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
                   7687: updates are. Those developers in charge of issuing major GNOME updates will be
                   7688: grateful if you do that.
                   7689: 
                   7690: The most common places to report bugs are the GNOME's Bugzilla and the
                   7691: freedesktop.org's Bugzilla. Not all components use these to track bugs, but
                   7692: most of them do. Do not be short on your reports: always provide detailed
                   7693: explanations of the current failure, how it can be improved to achieve maximum
                   7694: portability and, if at all possible, provide a patch against CVS head. The more
                   7695: verbose you are, the higher chances of your patch being accepted.
                   7696: 
                   7697: Also, please avoid using preprocessor magic to fix portability issues. While
                   7698: the FreeBSD GNOME people are doing a great job in porting GNOME to their
                   7699: operating system, the official GNOME sources are now plagued by conditionals
                   7700: that check for __FreeBSD__ and similar macros. This hurts portability. Please
1.154     rillig   7701: see our patching guidelines (Section 13.3.4, "Patching guidelines") for more
1.1       dsieger  7702: details.
                   7703: 
                   7704: Part III. The pkgsrc infrastructure internals
                   7705: 
                   7706: This part of the guide deals with everything from the infrastructure that is
                   7707: behind the interfaces described in the developer's guide. A casual package
                   7708: maintainer should not need anything from this part.
                   7709: 
                   7710: Table of Contents
                   7711: 
1.154     rillig   7712: 26. Design of the pkgsrc infrastructure
1.1       dsieger  7713: 
1.154     rillig   7714:     26.1. The meaning of variable definitions
                   7715:     26.2. Avoiding problems before they arise
                   7716:     26.3. Variable evaluation
1.1       dsieger  7717: 
1.154     rillig   7718:         26.3.1. At load time
                   7719:         26.3.2. At runtime
1.1       dsieger  7720: 
1.154     rillig   7721:     26.4. How can variables be specified?
                   7722:     26.5. Designing interfaces for Makefile fragments
1.1       dsieger  7723: 
1.154     rillig   7724:         26.5.1. Procedures with parameters
                   7725:         26.5.2. Actions taken on behalf of parameters
1.1       dsieger  7726: 
1.154     rillig   7727:     26.6. The order in which files are loaded
1.1       dsieger  7728: 
1.154     rillig   7729:         26.6.1. The order in bsd.prefs.mk
                   7730:         26.6.2. The order in bsd.pkg.mk
1.1       dsieger  7731: 
1.154     rillig   7732: 27. Regression tests
1.1       dsieger  7733: 
1.154     rillig   7734:     27.1. Running the regression tests
                   7735:     27.2. Adding a new regression test
1.1       dsieger  7736: 
1.154     rillig   7737:         27.2.1. Overridable functions
                   7738:         27.2.2. Helper functions
1.1       dsieger  7739: 
1.154     rillig   7740: 28. Porting pkgsrc
1.1       dsieger  7741: 
1.154     rillig   7742:     28.1. Porting pkgsrc to a new operating system
1.1       dsieger  7743: 
1.154     rillig   7744: Chapter 26. Design of the pkgsrc infrastructure
1.1       dsieger  7745: 
                   7746: Table of Contents
                   7747: 
1.154     rillig   7748: 26.1. The meaning of variable definitions
                   7749: 26.2. Avoiding problems before they arise
                   7750: 26.3. Variable evaluation
1.1       dsieger  7751: 
1.154     rillig   7752:     26.3.1. At load time
                   7753:     26.3.2. At runtime
1.1       dsieger  7754: 
1.154     rillig   7755: 26.4. How can variables be specified?
                   7756: 26.5. Designing interfaces for Makefile fragments
1.1       dsieger  7757: 
1.154     rillig   7758:     26.5.1. Procedures with parameters
                   7759:     26.5.2. Actions taken on behalf of parameters
1.1       dsieger  7760: 
1.154     rillig   7761: 26.6. The order in which files are loaded
1.1       dsieger  7762: 
1.154     rillig   7763:     26.6.1. The order in bsd.prefs.mk
                   7764:     26.6.2. The order in bsd.pkg.mk
1.1       dsieger  7765: 
                   7766: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
                   7767: fragment needs a properly specified interface. This chapter explains how such
                   7768: an interface looks like.
                   7769: 
1.154     rillig   7770: 26.1. The meaning of variable definitions
1.1       dsieger  7771: 
                   7772: Whenever a variable is defined in the pkgsrc infrastructure, the location and
                   7773: the way of definition provide much information about the intended use of that
                   7774: variable. Additionally, more documentation may be found in a header comment or
                   7775: in this pkgsrc guide.
                   7776: 
                   7777: A special file is mk/defaults/mk.conf, which lists all variables that are
                   7778: intended to be user-defined. They are either defined using the ?= operator or
                   7779: they are left undefined because defining them to anything would effectively
                   7780: mean "yes". All these variables may be overridden by the pkgsrc user in the
                   7781: MAKECONF file.
                   7782: 
                   7783: Outside this file, the following conventions apply: Variables that are defined
                   7784: using the ?= operator may be overridden by a package.
                   7785: 
                   7786: Variables that are defined using the = operator may be used read-only at
                   7787: run-time.
                   7788: 
                   7789: Variables whose name starts with an underscore must not be accessed outside the
                   7790: pkgsrc infrastructure at all. They may change without further notice.
                   7791: 
                   7792: Note
                   7793: 
                   7794: These conventions are currently not applied consistently to the complete pkgsrc
                   7795: infrastructure.
                   7796: 
1.154     rillig   7797: 26.2. Avoiding problems before they arise
1.1       dsieger  7798: 
                   7799: All variables that contain lists of things should default to being empty. Two
                   7800: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
                   7801: variables cannot simply be modified using the += operator in package Makefiles
                   7802: (or other files included by them), since there is no guarantee whether the
                   7803: variable is already set or not, and what its value is. In the case of
                   7804: DISTFILES, the packages "know" the default value and just define it as in the
                   7805: following example.
                   7806: 
                   7807: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   7808: 
                   7809: Because of the selection of this default value, the same value appears in many
                   7810: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
                   7811: value ("c") is so short that it doesn't stand out. Nevertheless it is mentioned
                   7812: in many files.
                   7813: 
1.154     rillig   7814: 26.3. Variable evaluation
1.1       dsieger  7815: 
1.154     rillig   7816: 26.3.1. At load time
1.1       dsieger  7817: 
                   7818: Variable evaluation takes place either at load time or at runtime, depending on
                   7819: the context in which they occur. The contexts where variables are evaluated at
                   7820: load time are:
                   7821: 
                   7822:   * The right hand side of the := and != operators,
                   7823: 
                   7824:   * Make directives like .if or .for,
                   7825: 
                   7826:   * Dependency lines.
                   7827: 
                   7828: A special exception are references to the iteration variables of .for loops,
                   7829: which are expanded inline, no matter in which context they appear.
                   7830: 
                   7831: As the values of variables may change during load time, care must be taken not
                   7832: to evaluate them by accident. Typical examples for variables that should not be
                   7833: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
                   7834: clear, here is an example:
                   7835: 
                   7836: CONFIGURE_ARGS=         # none
                   7837: CFLAGS=                 -O
                   7838: CONFIGURE_ARGS+=        CFLAGS=${CFLAGS:Q}
                   7839: 
                   7840: CONFIGURE_ARGS:=        ${CONFIGURE_ARGS}
                   7841: 
                   7842: CFLAGS+=                -Wall
                   7843: 
                   7844: This code shows how the use of the := operator can quickly lead to unexpected
                   7845: results. The first paragraph is fairly common code. The second paragraph
                   7846: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
                   7847: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
                   7848: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
                   7849: typically occur in completely unrelated files.
                   7850: 
1.154     rillig   7851: 26.3.2. At runtime
1.1       dsieger  7852: 
                   7853: After all the files have been loaded, the values of the variables cannot be
                   7854: changed anymore. Variables that are used in the shell commands are expanded at
                   7855: this point.
                   7856: 
1.154     rillig   7857: 26.4. How can variables be specified?
1.1       dsieger  7858: 
                   7859: There are many ways in which the definition and use of a variable can be
                   7860: restricted in order to detect bugs and violations of the (mostly unwritten)
1.108     rillig   7861: policies. A package can be checked with pkglint -Wall to see whether it meets
                   7862: these rules.
1.1       dsieger  7863: 
1.154     rillig   7864: 26.5. Designing interfaces for Makefile fragments
1.1       dsieger  7865: 
                   7866: Most of the .mk files fall into one of the following classes. Cases where a
                   7867: file falls into more than one class should be avoided as it often leads to
                   7868: subtle bugs.
                   7869: 
1.154     rillig   7870: 26.5.1. Procedures with parameters
1.1       dsieger  7871: 
                   7872: In a traditional imperative programming language some of the .mk files could be
1.23      jakllsch 7873: described as procedures. They take some input parameters and?after
                   7874: inclusion?provide a result in output parameters. Since all variables in
                   7875: Makefiles have global scope care must be taken not to use parameter names that
                   7876: have already another meaning. For example, PKGNAME is a bad choice for a
                   7877: parameter name.
1.1       dsieger  7878: 
                   7879: Procedures are completely evaluated at preprocessing time. That is, when
                   7880: calling a procedure all input parameters must be completely resolvable. For
                   7881: example, CONFIGURE_ARGS should never be an input parameter since it is very
                   7882: likely that further text will be added after calling the procedure, which would
                   7883: effectively apply the procedure to only a part of the variable. Also,
1.108     rillig   7884: references to other variables will be modified after calling the procedure.
1.1       dsieger  7885: 
                   7886: A procedure can declare its output parameters either as suitable for use in
                   7887: preprocessing directives or as only available at runtime. The latter
                   7888: alternative is for variables that contain references to other runtime
                   7889: variables.
                   7890: 
                   7891: Procedures shall be written such that it is possible to call the procedure more
                   7892: than once. That is, the file must not contain multiple-inclusion guards.
                   7893: 
                   7894: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
                   7895: To express that the parameters are evaluated at load time, they should be
                   7896: assigned using the := operator, which should be used only for this purpose.
                   7897: 
1.154     rillig   7898: 26.5.2. Actions taken on behalf of parameters
1.1       dsieger  7899: 
                   7900: Action files take some input parameters and may define runtime variables. They
                   7901: shall not define loadtime variables. There are action files that are included
                   7902: implicitly by the pkgsrc infrastructure, while other must be included
                   7903: explicitly.
                   7904: 
                   7905: An example for action files is mk/subst.mk.
                   7906: 
1.154     rillig   7907: 26.6. The order in which files are loaded
1.1       dsieger  7908: 
                   7909: Package Makefiles usually consist of a set of variable definitions, and include
                   7910: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
                   7911: include various other *.mk files if they need to query the availability of
                   7912: certain features like the type of compiler or the X11 implementation. Due to
                   7913: the heavy use of preprocessor directives like .if and .for, the order in which
                   7914: the files are loaded matters.
                   7915: 
                   7916: This section describes at which point the various files are loaded and gives
                   7917: reasons for that order.
                   7918: 
1.154     rillig   7919: 26.6.1. The order in bsd.prefs.mk
1.1       dsieger  7920: 
                   7921: The very first action in bsd.prefs.mk is to define some essential variables
                   7922: like OPSYS, OS_VERSION and MACHINE_ARCH.
                   7923: 
1.4       rillig   7924: Then, the user settings are loaded from the file specified in MAKECONF, which
                   7925: is usually mk.conf. After that, those variables that have not been overridden
                   7926: by the user are loaded from mk/defaults/mk.conf.
1.1       dsieger  7927: 
                   7928: After the user settings, the system settings and platform settings are loaded,
                   7929: which may override the user settings.
                   7930: 
                   7931: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
                   7932: This only happens when building a package, so the proper variables must be used
                   7933: instead of the direct tool names.
                   7934: 
                   7935: As the last steps, some essential variables from the wrapper and the package
                   7936: system flavor are loaded, as well as the variables that have been cached in
                   7937: earlier phases of a package build.
                   7938: 
1.154     rillig   7939: 26.6.2. The order in bsd.pkg.mk
1.1       dsieger  7940: 
                   7941: First, bsd.prefs.mk is loaded.
                   7942: 
                   7943: Then, the various *-vars.mk files are loaded, which fill default values for
                   7944: those variables that have not been defined by the package. These variables may
                   7945: later be used even in unrelated files.
                   7946: 
                   7947: Then, the file bsd.pkg.error.mk provides the target error-check that is added
                   7948: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
                   7949: DELAYED_WARNING_MSG.
                   7950: 
                   7951: Then, the package-specific hacks from hacks.mk are included.
                   7952: 
                   7953: Then, various other files follow. Most of them don't have any dependencies on
                   7954: what they need to have included before or after them, though some do.
                   7955: 
                   7956: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
                   7957: restricts the use of these variables to all the files that have been included
                   7958: before. Appearances in later files will be silently ignored.
                   7959: 
                   7960: Then, the files for the main targets are included, in the order of later
                   7961: execution, though the actual order should not matter.
                   7962: 
                   7963: At last, some more files are included that don't set any interesting variables
                   7964: but rather just define make targets to be executed.
                   7965: 
1.154     rillig   7966: Chapter 27. Regression tests
1.1       dsieger  7967: 
                   7968: Table of Contents
                   7969: 
1.154     rillig   7970: 27.1. Running the regression tests
                   7971: 27.2. Adding a new regression test
1.1       dsieger  7972: 
1.154     rillig   7973:     27.2.1. Overridable functions
                   7974:     27.2.2. Helper functions
1.1       dsieger  7975: 
                   7976: The pkgsrc infrastructure consists of a large codebase, and there are many
                   7977: corners where every little bit of a file is well thought out, making pkgsrc
                   7978: likely to fail as soon as anything is changed near those parts. To prevent most
                   7979: changes from breaking anything, a suite of regression tests should go along
                   7980: with every important part of the pkgsrc infrastructure. This chapter describes
                   7981: how regression tests work in pkgsrc and how you can add new tests.
                   7982: 
1.154     rillig   7983: 27.1. Running the regression tests
1.1       dsieger  7984: 
1.25      wiz      7985: You first need to install the pkgtools/pkg_regress package, which provides the 
1.1       dsieger  7986: pkg_regress command. Then you can simply run that command, which will run all
                   7987: tests in the regress category.
                   7988: 
1.154     rillig   7989: 27.2. Adding a new regression test
1.1       dsieger  7990: 
                   7991: Every directory in the regress category that contains a file called spec is
                   7992: considered a regression test. This file is a shell program that is included by
                   7993: the pkg_regress command. The following functions can be overridden to suit your
                   7994: needs.
                   7995: 
1.154     rillig   7996: 27.2.1. Overridable functions
1.1       dsieger  7997: 
1.108     rillig   7998: These functions do not take any parameters. Although they are called in "set -e
                   7999: " mode, they don't stop at the first failing command. See this StackOverflow
                   8000: question for details.
1.1       dsieger  8001: 
1.108     rillig   8002: do_setup
1.1       dsieger  8003: 
                   8004:     This function prepares the environment for the test. By default it does
                   8005:     nothing.
                   8006: 
1.108     rillig   8007: do_test
1.1       dsieger  8008: 
                   8009:     This function runs the actual test. By default, it calls TEST_MAKE with the
                   8010:     arguments MAKEARGS_TEST and writes its output including error messages into
                   8011:     the file TEST_OUTFILE.
                   8012: 
1.108     rillig   8013:     When defining this function, make sure that all output that needs to be
                   8014:     checked is written to the correct output file. Example:
                   8015: 
                   8016:     do_test() {
                   8017:             echo "Example output"
                   8018:     } 1>$TEST_OUTFILE 2>&1
                   8019: 
                   8020: check_result
1.1       dsieger  8021: 
                   8022:     This function is run after the test and is typically used to compare the
                   8023:     actual output from the one that is expected. It can make use of the various
1.108     rillig   8024:     helper functions from the next section. Example:
                   8025: 
                   8026:     check_result() {
                   8027:             exit_status 0
                   8028:             output_require "Example"
                   8029:             output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
                   8030:             output_prohibit "no such file or directory"
                   8031:     }
1.1       dsieger  8032: 
1.108     rillig   8033: do_cleanup
1.1       dsieger  8034: 
                   8035:     This function cleans everything up after the test has been run. By default
                   8036:     it does nothing.
                   8037: 
1.154     rillig   8038: 27.2.2. Helper functions
1.1       dsieger  8039: 
1.108     rillig   8040: exit_status expected
1.1       dsieger  8041: 
1.108     rillig   8042:     This function compares the exitcode of the do_test function with its first
                   8043:     parameter. If they differ, the test will fail.
1.1       dsieger  8044: 
1.108     rillig   8045: output_require regex...
1.1       dsieger  8046: 
                   8047:     This function checks for each of its parameters if the output from do_test
1.108     rillig   8048:     matches the extended regular expression. If it does not, the test will
                   8049:     fail. Example:
                   8050: 
                   8051:     output_require "looks fine"
                   8052:     output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
1.1       dsieger  8053: 
                   8054: output_prohibit(regex...)
                   8055: 
                   8056:     This function checks for each of its parameters if the output from do_test
                   8057:     () does not match the extended regular expression. If any of the regular
                   8058:     expressions matches, the test will fail.
                   8059: 
1.154     rillig   8060: Chapter 28. Porting pkgsrc
1.1       dsieger  8061: 
                   8062: Table of Contents
                   8063: 
1.154     rillig   8064: 28.1. Porting pkgsrc to a new operating system
1.1       dsieger  8065: 
                   8066: The pkgsrc system has already been ported to many operating systems, hardware
                   8067: architectures and compilers. This chapter explains the necessary steps to make
                   8068: pkgsrc even more portable.
                   8069: 
1.154     rillig   8070: 28.1. Porting pkgsrc to a new operating system
1.1       dsieger  8071: 
                   8072: To port pkgsrc to a new operating system (called MyOS in this example), you
                   8073: need to touch the following files:
                   8074: 
                   8075: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
                   8076: 
                   8077:     This file contains some basic definitions, for example the name of the C
                   8078:     compiler.
                   8079: 
                   8080: mk/bsd.prefs.mk
                   8081: 
                   8082:     Insert code that defines the variables OPSYS, OS_VERSION, LOWER_OS_VERSION,
                   8083:     LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
                   8084:     that appear in this file.
                   8085: 
                   8086: mk/platform/MyOS.mk
                   8087: 
                   8088:     This file contains the platform-specific definitions that are used by
                   8089:     pkgsrc. Start by copying one of the other files and edit it to your needs.
                   8090: 
                   8091: mk/tools/tools.MyOS.mk
                   8092: 
                   8093:     This file defines the paths to all the tools that are needed by one or the
                   8094:     other package in pkgsrc, as well as by pkgsrc itself. Find out where these
                   8095:     tools are on your platform and add them.
                   8096: 
                   8097: Now, you should be able to build some basic packages, like lang/perl5, shells/
                   8098: bash.
                   8099: 
                   8100: Appendix A. A simple example package: bison
                   8101: 
                   8102: Table of Contents
                   8103: 
                   8104: A.1. files
                   8105: 
                   8106:     A.1.1. Makefile
                   8107:     A.1.2. DESCR
                   8108:     A.1.3. PLIST
                   8109:     A.1.4. Checking a package with pkglint
                   8110: 
                   8111: A.2. Steps for building, installing, packaging
                   8112: 
                   8113: We checked to find a piece of software that wasn't in the packages collection,
1.25      wiz      8114: and picked GNU bison. Quite why someone would want to have bison when Berkeley 
1.1       dsieger  8115: yacc is already present in the tree is beyond us, but it's useful for the
                   8116: purposes of this exercise.
                   8117: 
                   8118: A.1. files
                   8119: 
                   8120: A.1.1. Makefile
                   8121: 
1.2       rillig   8122: # $NetBSD$
1.1       dsieger  8123: #
                   8124: 
                   8125: DISTNAME=       bison-1.25
                   8126: CATEGORIES=     devel
                   8127: MASTER_SITES=   ${MASTER_SITE_GNU}
                   8128: 
1.30      dholland 8129: MAINTAINER=     pkgsrc-users@NetBSD.org
1.1       dsieger  8130: HOMEPAGE=       http://www.gnu.org/software/bison/bison.html
                   8131: COMMENT=        GNU yacc clone
                   8132: 
                   8133: GNU_CONFIGURE=  yes
1.47      wiz      8134: INFO_FILES=     yes
1.1       dsieger  8135: 
                   8136: .include "../../mk/bsd.pkg.mk"
                   8137: 
                   8138: A.1.2. DESCR
                   8139: 
                   8140: GNU version of yacc.  Can make re-entrant parsers, and numerous other
                   8141: improvements.  Why you would want this when Berkeley yacc(1) is part
                   8142: of the NetBSD source tree is beyond me.
                   8143: 
                   8144: A.1.3. PLIST
                   8145: 
1.2       rillig   8146: @comment $NetBSD$
1.1       dsieger  8147: bin/bison
                   8148: man/man1/bison.1.gz
                   8149: share/bison.simple
                   8150: share/bison.hairy
                   8151: 
                   8152: A.1.4. Checking a package with pkglint
                   8153: 
                   8154: The NetBSD package system comes with pkgtools/pkglint which helps to check the
                   8155: contents of these files. After installation it is quite easy to use, just
                   8156: change to the directory of the package you wish to examine and execute pkglint:
                   8157: 
                   8158: $ pkglint
                   8159: looks fine.
                   8160: 
                   8161: Depending on the supplied command line arguments (see pkglint(1)), more checks
                   8162: will be performed. Use e.g. pkglint -Call -Wall for a very thorough check.
                   8163: 
                   8164: A.2. Steps for building, installing, packaging
                   8165: 
                   8166: Create the directory where the package lives, plus any auxiliary directories:
                   8167: 
                   8168: # cd /usr/pkgsrc/lang
                   8169: # mkdir bison
                   8170: # cd bison
                   8171: # mkdir patches
                   8172: 
1.154     rillig   8173: Create Makefile, DESCR and PLIST (see Chapter 13, Package components - files,
1.1       dsieger  8174: directories and contents) then continue with fetching the distfile:
                   8175: 
                   8176: # make fetch
                   8177: >> bison-1.25.tar.gz doesn't seem to exist on this system.
                   8178: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
                   8179: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8180: ftp: Error retrieving file: 500 Internal error
                   8181: 
                   8182: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
                   8183: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8184: ftp: Error retrieving file: 500 Internal error
                   8185: 
                   8186: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
                   8187: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8188: Successfully retrieved file.
                   8189: 
                   8190: Generate the checksum of the distfile into distinfo:
                   8191: 
                   8192: # make makedistinfo
                   8193: 
                   8194: Now compile:
                   8195: 
                   8196: # make
                   8197: >> Checksum OK for bison-1.25.tar.gz.
                   8198: ===>  Extracting for bison-1.25
                   8199: ===>  Patching for bison-1.25
                   8200: ===>   Ignoring empty patch directory
                   8201: ===>  Configuring for bison-1.25
                   8202: creating cache ./config.cache
                   8203: checking for gcc... cc
                   8204: checking whether we are using GNU C... yes
                   8205: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
                   8206: checking how to run the C preprocessor... cc -E
                   8207: checking for minix/config.h... no
                   8208: checking for POSIXized ISC... no
                   8209: checking whether cross-compiling... no
                   8210: checking for ANSI C header files... yes
                   8211: checking for string.h... yes
                   8212: checking for stdlib.h... yes
                   8213: checking for memory.h... yes
                   8214: checking for working const... yes
                   8215: checking for working alloca.h... no
                   8216: checking for alloca... yes
                   8217: checking for strerror... yes
                   8218: updating cache ./config.cache
                   8219: creating ./config.status
                   8220: creating Makefile
                   8221: ===>  Building for bison-1.25
                   8222: 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
                   8223: 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
                   8224: 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
                   8225: 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
                   8226: 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
                   8227: 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
                   8228: 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
                   8229: 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
                   8230: 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
                   8231: 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
                   8232: 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
                   8233: 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
                   8234: 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
                   8235: 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
                   8236: 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
                   8237: 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
                   8238: 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
                   8239: 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
                   8240: 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
                   8241: 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
                   8242: 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
                   8243: 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
                   8244: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
                   8245: rm -f bison.s1
                   8246: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
                   8247: 
                   8248: Everything seems OK, so install the files:
                   8249: 
                   8250: # make install
                   8251: >> Checksum OK for bison-1.25.tar.gz.
                   8252: ===>  Installing for bison-1.25
                   8253: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
                   8254: rm -f /usr/pkg/bin/bison
                   8255: cd /usr/pkg/share; rm -f bison.simple bison.hairy
                   8256: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
                   8257: install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
                   8258: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
                   8259: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
                   8260: cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
                   8261: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
                   8262: ===>  Registering installation for bison-1.25
                   8263: 
                   8264: You can now use bison, and also - if you decide so - remove it with pkg_delete
                   8265: bison. Should you decide that you want a binary package, do this now:
                   8266: 
                   8267: # make package
                   8268: >> Checksum OK for bison-1.25.tar.gz.
                   8269: ===>  Building package for bison-1.25
                   8270: Creating package bison-1.25.tgz
                   8271: Registering depends:.
                   8272: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
                   8273: 
                   8274: Now that you don't need the source and object files any more, clean up:
                   8275: 
                   8276: # make clean
                   8277: ===>  Cleaning for bison-1.25
                   8278: 
                   8279: Appendix B. Build logs
                   8280: 
                   8281: Table of Contents
                   8282: 
                   8283: B.1. Building figlet
                   8284: B.2. Packaging figlet
                   8285: 
                   8286: B.1. Building figlet
                   8287: 
                   8288: # make
                   8289: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   8290: => figlet221.tar.gz doesn't seem to exist on this system.
                   8291: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
                   8292: => [172219 bytes]
                   8293: Connected to ftp.plig.net.
                   8294: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
                   8295: 331 Guest login ok, send your complete e-mail address as password.
                   8296: 230-You are user #5 of 500 simultaneous users allowed.
                   8297: 230-
                   8298: 230-  ___ _             _ _
                   8299: 230- |  _| |_ ___   ___| |_|___   ___ ___ ___
                   8300: 230- |  _|  _| . |_| . | | | . |_| . |  _| . |
                   8301: 230- |_| |_| |  _|_|  _|_|_|_  |_|___|_| |_  |
                   8302: 230-         |_|   |_|     |___|         |___|
                   8303: 230-
                   8304: 230-** Welcome to ftp.plig.org **
                   8305: 230-
                   8306: 230-Please note that all transfers from this FTP site are logged. If you
                   8307: 230-do not like this, please disconnect now.
                   8308: 230-
1.19      snj      8309: 230-This archive is available via
1.1       dsieger  8310: 230-
                   8311: 230-HTTP:  http://ftp.plig.org/
                   8312: 230-FTP:   ftp://ftp.plig.org/     (max 500 connections)
                   8313: 230-RSYNC: rsync://ftp.plig.org/   (max  30 connections)
                   8314: 230-
                   8315: 230-Please email comments, bug reports and requests for packages to be
                   8316: 230-mirrored to ftp-admin@plig.org.
                   8317: 230-
                   8318: 230-
                   8319: 230 Logged in anonymously.
                   8320: Remote system type is UNIX.
                   8321: Using binary mode to transfer files.
                   8322: 200 Type okay.
                   8323: 250 "/pub" is new cwd.
                   8324: 250-"/pub/figlet" is new cwd.
                   8325: 250-
                   8326: 250-Welcome to the figlet archive at ftp.figlet.org
                   8327: 250-
                   8328: 250-    ftp://ftp.figlet.org/pub/figlet/
                   8329: 250-
                   8330: 250-The official FIGlet web page is:
                   8331: 250-    http://www.figlet.org/
                   8332: 250-
                   8333: 250-If you have questions, please mailto:info@figlet.org. If you want to
                   8334: 250-contribute a font or something else, you can email us.
                   8335: 250
                   8336: 250 "/pub/figlet/program" is new cwd.
                   8337: 250 "/pub/figlet/program/unix" is new cwd.
                   8338: local: figlet221.tar.gz remote: figlet221.tar.gz
                   8339: 502 Unimplemented command.
                   8340: 227 Entering Passive Mode (195,40,6,41,246,104)
                   8341: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
                   8342: 38% |**************                       | 65800      64.16 KB/s    00:01 ETA
                   8343: 226 Transfer completed.
                   8344: 172219 bytes received in 00:02 (75.99 KB/s)
                   8345: 221 Goodbye.
                   8346: => Checksum OK for figlet221.tar.gz.
                   8347: ===> Extracting for figlet-2.2.1nb2
                   8348: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
                   8349: ===> Patching for figlet-2.2.1nb2
                   8350: ===> Applying pkgsrc patches for figlet-2.2.1nb2
                   8351: ===> Overriding tools for figlet-2.2.1nb2
                   8352: ===> Creating toolchain wrappers for figlet-2.2.1nb2
                   8353: ===> Configuring for figlet-2.2.1nb2
                   8354: ===> Building for figlet-2.2.1nb2
                   8355: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\"  -DDEFAULTFONTFILE=\"standard.flf\"  figlet.c zipio.c crc.c inflate.c -o figlet
                   8356: chmod a+x figlet
                   8357: gcc -O2 -o chkfont chkfont.c
                   8358: => Unwrapping files-to-be-installed.
                   8359: #
                   8360: # make install
                   8361: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   8362: ===> Installing for figlet-2.2.1nb2
                   8363: install -d -o root -g wheel -m 755 /usr/pkg/bin
                   8364: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
                   8365: mkdir -p /usr/pkg/share/figlet
                   8366: cp figlet /usr/pkg/bin
                   8367: cp chkfont /usr/pkg/bin
                   8368: chmod 555 figlist showfigfonts
                   8369: cp figlist /usr/pkg/bin
                   8370: cp showfigfonts /usr/pkg/bin
                   8371: cp fonts/*.flf /usr/pkg/share/figlet
                   8372: cp fonts/*.flc /usr/pkg/share/figlet
                   8373: cp figlet.6 /usr/pkg/man/man6
                   8374: ===> Registering installation for figlet-2.2.1nb2
                   8375: #
                   8376: 
                   8377: B.2. Packaging figlet
                   8378: 
                   8379: # make package
                   8380: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   8381: ===> Packaging figlet-2.2.1nb2
                   8382: ===> Building binary package for figlet-2.2.1nb2
                   8383: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
                   8384: Using SrcDir value of /usr/pkg
                   8385: Registering depends:.
                   8386: #
                   8387: 
                   8388: Appendix C. Directory layout of the pkgsrc FTP server
                   8389: 
                   8390: Table of Contents
                   8391: 
1.23      jakllsch 8392: C.1. distfiles: The distributed source files
                   8393: C.2. misc: Miscellaneous things
                   8394: C.3. packages: Binary packages
                   8395: C.4. reports: Bulk build reports
1.148     leot     8396: C.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  8397: 
                   8398: As in other big projects, the directory layout of pkgsrc is quite complex for
                   8399: newbies. This chapter explains where you find things on the FTP server. The
                   8400: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
                   8401: different, but inside this directory, everything should look the same, no
                   8402: matter on which server you are. This directory contains some subdirectories,
                   8403: which are explained below.
                   8404: 
1.23      jakllsch 8405: C.1. distfiles: The distributed source files
1.1       dsieger  8406: 
                   8407: The directory distfiles contains lots of archive files from all pkgsrc
                   8408: packages, which are mirrored here. The subdirectories are called after their
                   8409: package names and are used when the distributed files have names that don't
                   8410: explicitly contain a version number or are otherwise too generic (for example
                   8411: release.tar.gz).
                   8412: 
1.23      jakllsch 8413: C.2. misc: Miscellaneous things
1.1       dsieger  8414: 
                   8415: This directory contains things that individual pkgsrc developers find worth
                   8416: publishing.
                   8417: 
1.23      jakllsch 8418: C.3. packages: Binary packages
1.1       dsieger  8419: 
1.3       rillig   8420: This directory contains binary packages for the various platforms that are
                   8421: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
                   8422: The meaning of these variables is:
                   8423: 
                   8424:   * OPSYS is the name of the operating system for which the packages have been
1.9       rillig   8425:     built. The name is taken from the output of the uname command, so it may
                   8426:     differ from the one you are used to hear.
1.3       rillig   8427: 
1.8       rillig   8428:   * ARCH is the hardware architecture of the platform for which the packages
1.10      hubertf  8429:     have been built. It also includes the ABI (Application Binary Interface)
                   8430:     for platforms that have several of them.
1.3       rillig   8431: 
1.8       rillig   8432:   * OSVERSION is the version of the operating system. For version numbers that
                   8433:     change often (for example NetBSD-current), the often-changing part should
                   8434:     be replaced with an x, for example 4.99.x.
1.3       rillig   8435: 
1.23      jakllsch 8436:   * TAG is either 20xxQy for a stable branch, or head for packages built from
1.8       rillig   8437:     the HEAD branch. The latter should only be used when the packages are
                   8438:     updated on a regular basis. Otherwise the date from checking out pkgsrc
                   8439:     should be appended, for example head_20071015.
1.3       rillig   8440: 
                   8441: The rationale for exactly this scheme is that the pkgsrc users looking for
                   8442: binary packages can quickly click through the directories on the server and
                   8443: find the best binary packages for their machines. Since they usually know the
                   8444: operating system and the hardware architecture, OPSYS and ARCH are placed
                   8445: first. After these choices, they can select the best combination of OSVERSION
                   8446: and TAG together, since it is usually the case that packages stay compatible
                   8447: between different version of the operating system.
                   8448: 
                   8449: In each of these directories, there is a whole binary packages collection for a
                   8450: specific platform. It has a directory called All which contains all binary
                   8451: packages. Besides that, there are various category directories that contain
                   8452: symbolic links to the real binary packages.
1.1       dsieger  8453: 
1.23      jakllsch 8454: C.4. reports: Bulk build reports
1.8       rillig   8455: 
                   8456: Here are the reports from bulk builds, for those who want to fix packages that
                   8457: didn't build on some of the platforms. The structure of subdirectories should
1.23      jakllsch 8458: look like the one in Section C.3, "packages: Binary packages".
1.8       rillig   8459: 
1.148     leot     8460: C.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  8461: 
                   8462: These directories contain the "real" pkgsrc, that is the files that define how
                   8463: to create binary packages from source archives.
                   8464: 
1.149     leot     8465: Each of the current, stable and pkgsrc-20xxQy directories share the same
                   8466: structure. They each contain a pkgsrc directory and pkgsrc.tar.{bz,gz,xz} file.
                   8467: 
1.1       dsieger  8468: The directory pkgsrc contains a snapshot of the CVS repository, which is
1.149     leot     8469: updated regularly. The file pkgsrc.tar.{bz,gz,xz} contains the same as the
                   8470: directory, ready to be downloaded as a whole.
1.1       dsieger  8471: 
1.149     leot     8472: The current directory contains files related to the HEAD branch of the CVS
                   8473: repository. In this directory there is an additional file called
                   8474: pkgsrc-readmes.tar.{bz,gz,xz} that contains all pkgsrc READMEs with information
                   8475: about categories and packages.
                   8476: 
                   8477: The stable directory is a symlink to the latest pkgsrc-20xxQy.
                   8478: 
                   8479: The pkgsrc-20xxQy. directories contain files related to the -20xxQy stable
                   8480: branch of the CVS repository. In these directories there is an additional file
                   8481: called pkgsrc-20xxQy.tar.{bz,gz,xz}, which contains the state of pkgsrc when it
                   8482: was branched.
1.148     leot     8483: 
1.154     rillig   8484: Appendix D. Help topics
                   8485: 
                   8486: The following list contains all help topics that are available when running 
                   8487: bmake help topic=:index.
                   8488: 
1.159   ! rillig   8489: #!                                   -lintl
        !          8490: 64bit                                ABI
        !          8491: ACCEPTABLE_LICENSES                  ACROREAD_FONTPATH
        !          8492: ADDITIONAL                           AFAIK
        !          8493: AIX                                  ALLOW_VULNERABLE_PACKAGES
        !          8494: ALL_ENV                              ALSA_PC
        !          8495: ALTERNATIVES_SRC                     AMANDA_TMP
        !          8496: AMANDA_USER                          AMANDA_VAR
        !          8497: APACHE_GROUP                         APACHE_MODULE_NAME
        !          8498: APACHE_MODULE_SRC                    APACHE_MODULE_SRCDIR
        !          8499: APACHE_PKG_PREFIX                    APACHE_SUEXEC_CONFIGURE_ARGS
        !          8500: APACHE_SUEXEC_DOCROOT                APACHE_USER
        !          8501: APPEND_ABI                           APPEND_ELF
        !          8502: ARLA_CACHE                           AUDIT_PACKAGES_FLAGS
        !          8503: AUTOCONF_REQD                        AUTOMAKE_OVERRIDE
        !          8504: AUTOMAKE_REQD                        AUTO_MKDIRS
        !          8505: BDB185_DEFAULT                       BDBBASE
        !          8506: BDB_ACCEPTED                         BDB_DEFAULT
        !          8507: BDB_LIBS                             BDB_TYPE
        !          8508: BIND_DIR                             BIND_GROUP
        !          8509: BIND_USER                            BINPKG_SITES
        !          8510: BIN_INSTALL_FLAGS                    BISON_PKGDATADIR
        !          8511: BLAS_ACCEPTED                        BLAS_LIBS
        !          8512: BLAS_TYPE                            BOOTSTRAP_DEPENDS
        !          8513: BOOTSTRAP_SETUPTOOLS                 BROKEN
        !          8514: BROKEN_EXCEPT_ON_PLATFORM            BROKEN_ON_PLATFORM
        !          8515: BSDSRCDIR                            BSDXSRCDIR
        !          8516: BSD_MAKE_ENV                         BUILDLINK_AUTO_DIRS
        !          8517: BUILDLINK_AUTO_VARS                  BUILDLINK_CFLAGS
        !          8518: BUILDLINK_CONTENTS_FILTER            BUILDLINK_CPPFLAGS
        !          8519: BUILDLINK_DEPMETHOD                  BUILDLINK_FILES
        !          8520: BUILDLINK_FILES_CMD                  BUILDLINK_FNAME_TRANSFORM
        !          8521: BUILDLINK_LDFLAGS                    BUILDLINK_LIBS
        !          8522: BUILDLINK_OPSYS_SUPPORT_PTHREAD      BUILDLINK_PKGNAME
        !          8523: BUILDLINK_PREFIX                     BUILDLINK_RPATHDIRS
        !          8524: BUILDLINK_TREE                       BUILD_DEFS
        !          8525: BUILD_DEFS_EFFECTS                   BUILD_DEPENDS
        !          8526: BUILD_DIRS                           BUILD_ENV_SHELL
        !          8527: BUILD_MAKE_CMD                       BUILD_MAKE_FLAGS
        !          8528: BUILD_TARGET                         BUILTIN_FIND_FILES
        !          8529: BUILTIN_FIND_FILES_VAR               BUILTIN_FIND_GREP
        !          8530: BUILTIN_FIND_HEADERS                 BUILTIN_FIND_HEADERS_VAR
        !          8531: BUILTIN_PKG                          BUILTIN_TEST_CURSES_DEFINES
        !          8532: BUILTIN_TEST_CURSES_FUNCS            BUILTIN_VERSION_SCRIPT
        !          8533: BUILTIN_X11_TYPE                     BUILTIN_X11_VERSION
        !          8534: CACTI_GROUP                          CACTI_USER
        !          8535: CANNA_GROUP                          CANNA_USER
        !          8536: CAT                                  CCACHE_BASE
        !          8537: CCACHE_DIR                           CCACHE_LOGFILE
        !          8538: CC_VERSION                           CC_VERSION_STRING
        !          8539: CDRECORD_CONF                        CDROM_PKG_URL_DIR
        !          8540: CDROM_PKG_URL_HOST                   CHECKOUT_DATE
        !          8541: CHECK_FAKEHOME                       CHECK_FILES
        !          8542: CHECK_FILES_SKIP                     CHECK_FILES_STRICT
        !          8543: CHECK_HEADERS                        CHECK_HEADERS_SKIP
        !          8544: CHECK_INTERPRETER                    CHECK_INTERPRETER_SKIP
        !          8545: CHECK_PERMS                          CHECK_PERMS_AUTOFIX
        !          8546: CHECK_PERMS_SKIP                     CHECK_PORTABILITY
        !          8547: CHECK_PORTABILITY_SKIP               CHECK_RELRO
        !          8548: CHECK_RELRO_SKIP                     CHECK_RELRO_SUPPORTED
        !          8549: CHECK_SHLIBS                         CHECK_SHLIBS_BLACKLIST
        !          8550: CHECK_SHLIBS_SKIP                    CHECK_SHLIBS_SUPPORTED
        !          8551: CHECK_SSP                            CHECK_SSP_SKIP
        !          8552: CHECK_SSP_SUPPORTED                  CHECK_STRIPPED
        !          8553: CHECK_STRIPPED_SKIP                  CHECK_WRKREF
        !          8554: CHECK_WRKREF_EXTRA_DIRS              CHECK_WRKREF_SKIP
        !          8555: CLAMAV_DBDIR                         CLAMAV_GROUP
        !          8556: CLAMAV_USER                          CLANGBASE
        !          8557: CLEANDEPENDS                         CMAKE_DEPENDENCIES_REWRITE
        !          8558: CMAKE_INSTALL_PREFIX                 CMAKE_MODULE_PATH_OVERRIDE
        !          8559: CMAKE_PKGSRC_BUILD_FLAGS             CMAKE_PREFIX_PATH
        !          8560: CMAKE_USE_GNU_INSTALL_DIRS           COMMON_LISP_DOCFILES
        !          8561: COMMON_LISP_EXAMPLES                 COMMON_LISP_EXTRAFILES
        !          8562: COMMON_LISP_PACKAGES                 COMMON_LISP_SYSTEM
        !          8563: COMPILER_RPATH_FLAG                  COMPILER_USE_SYMLINKS
        !          8564: CONFIGURE_ARGS                       CONFIGURE_DIRS
        !          8565: CONFIGURE_ENV                        CONFIGURE_HAS_INFODIR
        !          8566: CONFIGURE_HAS_MANDIR                 CONFIGURE_SCRIPT
        !          8567: CONFIG_SHELL                         CONFIG_SHELL_FLAGS
        !          8568: CONF_FILES                           CONF_FILES_MODE
        !          8569: CONF_FILES_PERMS                     CONSERVER_DEFAULTHOST
        !          8570: CONSERVER_DEFAULTPORT                CP
        !          8571: CPP                                  CPP_PRECOMP_FLAGS
        !          8572: CREATE_WRKDIR_SYMLINK                CROSSBASE
        !          8573: CTFCONVERT                           CTF_FILES_SKIP
        !          8574: CTF_SUPPORTED                        CTYPE
        !          8575: CUPS_GROUP                           CUPS_SYSTEM_GROUPS
        !          8576: CUPS_USER                            CURSES_DEFAULT
        !          8577: CURSES_TYPE                          CVS_EXTRACTDIR
        !          8578: CVS_MODULE                           CVS_PROJECT
        !          8579: CVS_REPOSITORIES                     CVS_ROOT
        !          8580: CVS_ROOT_GNU                         CVS_ROOT_NONGNU
        !          8581: CVS_ROOT_SOURCEFORGE                 CVS_TAG
        !          8582: CXX                                  CYRUS_GROUP
        !          8583: CYRUS_IDLE                           CYRUS_USER
        !          8584: DAEMONTOOLS_GROUP                    DAEMONTOOLS_LOG_USER
        !          8585: DBUS_GROUP                           DBUS_USER
        !          8586: DEFANG_GROUP                         DEFANG_USER
        !          8587: DEFAULT_ACCEPTABLE_LICENSES          DEFAULT_DISTFILES
        !          8588: DEFAULT_IRC_SERVER                   DEFAULT_SERIAL_DEVICE
        !          8589: DEF_UMASK                            DEINSTALLDEPENDS
        !          8590: DEINSTALL_SRC                        DEINSTALL_TEMPLATES
        !          8591: DELAYED_ERROR_MSG                    DELAYED_WARNING_MSG
        !          8592: DEPENDS                              DEPENDS_TARGET
        !          8593: DEPENDS_TYPE                         DESTDIR
        !          8594: DESTDIR_VARNAME                      DIALER_GROUP
        !          8595: DIGEST_REQD                          DISTDIR
        !          8596: DISTFILES                            DISTINFO_FILE
        !          8597: DISTNAME                             DIST_PATH
        !          8598: DIST_SUBDIR                          DJBDNS_AXFR_USER
        !          8599: DJBDNS_CACHE_USER                    DJBDNS_DJBDNS_GROUP
        !          8600: DJBDNS_LOG_USER                      DJBDNS_RBL_USER
        !          8601: DJBDNS_TINY_USER                     DLOPEN_REQUIRE_PTHREADS
        !          8602: DL_AUTO_VARS                         DL_CFLAGS
        !          8603: DL_LDFLAGS                           DL_LIBS
        !          8604: DNS                                  DOWNLOADED_DISTFILE
        !          8605: DT_LAYOUT                            DYNAMIC_SITES_CMD
        !          8606: DYNAMIC_SITES_SCRIPT                 ECHO
        !          8607: ECHO_N                               ELK_GUI
        !          8608: EMACS_TYPE                           EMULDIR
        !          8609: EMULSUBDIR                           EMULSUBDIRSLASH
        !          8610: EMUL_ARCH                            EMUL_DISTRO
        !          8611: EMUL_EXEC_FMT                        EMUL_IS_NATIVE
        !          8612: EMUL_MODULES                         EMUL_OPSYS
        !          8613: EMUL_PKG_FMT                         EMUL_PLATFORM
        !          8614: EMUL_PLATFORMS                       EMUL_PREFER
        !          8615: EMUL_REQD                            EMUL_TYPE
        !          8616: ERROR_MSG                            EXIM_GROUP
        !          8617: EXIM_USER                            EXPORT_SYMBOLS_LDFLAGS
        !          8618: EXTRACTOR                            EXTRACT_CMD
        !          8619: EXTRACT_CMD_DEFAULT                  EXTRACT_DIR
        !          8620: EXTRACT_ELEMENTS                     EXTRACT_ENV
        !          8621: EXTRACT_ONLY                         EXTRACT_OPTS
        !          8622: EXTRACT_SUFX                         EXTRACT_USING
        !          8623: FAILOVER_FETCH                       FAIL_MSG
        !          8624: FAKE_NCURSES                         FAM
        !          8625: FAM_ACCEPTED                         FAM_DEFAULT
        !          8626: FAM_SERVER                           FCPATH
        !          8627: FEATURE_CPPFLAGS                     FEATURE_LDFLAGS
        !          8628: FEATURE_LIBS                         FETCH_AFTER_ARGS
        !          8629: FETCH_BEFORE_ARGS                    FETCH_CMD
        !          8630: FETCH_OUTPUT_ARGS                    FETCH_PROXY
        !          8631: FETCH_RESUME_ARGS                    FETCH_USING
        !          8632: FILES_SUBST                          FILES_SUBST_SED
        !          8633: FIX_SYSTEM_HEADERS                   FLUXBOX_USE_GNOME
        !          8634: FLUXBOX_USE_KDE                      FLUXBOX_USE_XFT
        !          8635: FLUXBOX_USE_XINERAMA                 FONTDIR
        !          8636: FONTS_DIRS                           FONTS_VERBOSE
        !          8637: FOO_HACKS_MK                         FOSSIL_EXTRACTDIR
        !          8638: FOSSIL_REPO                          FOSSIL_REPOSITORIES
        !          8639: FOSSIL_VERSION                       FOX_USE_XUNICODE
        !          8640: FREEWNN_GROUP                        FREEWNN_USER
        !          8641: FTP_PKG_URL_DIR                      FTP_PKG_URL_HOST
        !          8642: GAMEDATAMODE                         GAMEDATA_PERMS
        !          8643: GAMEDIRMODE                          GAMEDIR_PERMS
        !          8644: GAMEGRP                              GAMEMODE
        !          8645: GAMEOWN                              GAMES_GROUP
        !          8646: GAMES_USER                           GCC
        !          8647: GCCBASE                              GCC_REQD
        !          8648: GCC_VERSION_SUFFIX                   GEM_BUILD
        !          8649: GEM_CLEANBUILD                       GEM_CLEANBUILD_EXTENSIONS
        !          8650: GEM_DOCDIR                           GEM_EXTSDIR
        !          8651: GEM_HOME                             GEM_LIBDIR
        !          8652: GEM_NAME                             GEM_PATH
        !          8653: GEM_SPECFILE                         GENERATE_PLIST
        !          8654: GHOSTSCRIPT_REQD                     GITHUB_PROJECT
        !          8655: GITHUB_RELEASE                       GITHUB_TAG
        !          8656: GITHUB_TYPE                          GIT_BRANCH
        !          8657: GIT_ENV                              GIT_EXTRACTDIR
        !          8658: GIT_REPO                             GIT_REPOSITORIES
        !          8659: GIT_REVISION                         GIT_TAG
        !          8660: GNU                                  GNU_CONFIGURE
        !          8661: GNU_CONFIGURE_INFODIR                GNU_CONFIGURE_MANDIR
        !          8662: GNU_CONFIGURE_STRICT                 GODEP_REDIRECTS
        !          8663: GO_BUILD_PATTERN                     GO_DEPS
        !          8664: GO_DIST_BASE                         GO_SRCPATH
        !          8665: GROUP_SPECIFIC_PKGS                  GRUB_NETWORK_CARDS
        !          8666: GRUB_PRESET_COMMAND                  GRUB_SCAN_ARGS
        !          8667: GZIP                                 HASKELL_COMPILER
        !          8668: HASKELL_ENABLE_HADDOCK_DOCUMENTATION HASKELL_ENABLE_LIBRARY_PROFILING
        !          8669: HASKELL_ENABLE_SHARED_LIBRARY        HAS_CONFIGURE
        !          8670: HEADER_TEMPLATES                     HG_REPO
        !          8671: HG_REPOSITORIES                      HG_TAG
        !          8672: HOST_PKGTOOLS_ARGS                   HOST_SPECIFIC_PKGS
        !          8673: HOWL_GROUP                           HOWL_USER
        !          8674: ICCBASE                              ICECAST_CHROOTDIR
        !          8675: ICON_THEMES                          IDOBASE
        !          8676: IGNORE_CCACHE                        IGNORE_INFO_DIRS
        !          8677: IGNORE_INTERACTIVE_FETCH             IMAKE
        !          8678: IMAKEOPTS                            IMAKE_MAKE
        !          8679: IMAKE_MANINSTALL                     IMAP_UW_CCLIENT_MBOX_FMT
        !          8680: IMDICTDIR                            INCOMPAT_CURSES
        !          8681: INFO_DIR                             INFO_FILES
        !          8682: INFO_FILES_VERBOSE                   INFO_MSG
        !          8683: INIT_SYSTEM                          INN_DATA_DIR
        !          8684: INN_GROUP                            INN_USER
        !          8685: INSTALLATION_DIRS                    INSTALLATION_DIRS_FROM_PLIST
        !          8686: INSTALL_ENV                          INSTALL_SH_OVERRIDE
        !          8687: INSTALL_SRC                          INSTALL_TEMPLATES
        !          8688: INSTALL_UNSTRIPPED                   IRCD_HYBRID_IRC_GROUP
        !          8689: IRCD_HYBRID_IRC_USER                 IRCD_HYBRID_MAXCONN
        !          8690: IRCD_HYBRID_NICLEN                   IRCD_HYBRID_SYSLOG_EVENTS
        !          8691: IRCD_HYBRID_SYSLOG_FACILITY          IRCD_HYBRID_TOPICLEN
        !          8692: IRIX                                 IRRD_USE_PGP
        !          8693: JABBERD_GROUP                        JABBERD_LOGDIR
        !          8694: JABBERD_PIDDIR                       JABBERD_SPOOLDIR
        !          8695: JABBERD_USER                         JAKARTA_HOME
        !          8696: JAVA_APP_PATH                        JAVA_APP_TARGETS
        !          8697: JAVA_BINPREFIX                       JAVA_CLASSPATH
        !          8698: JAVA_HOME                            JAVA_LD_LIBRARY_PATH
        !          8699: JAVA_NAME                            JAVA_UNLIMIT
        !          8700: JAVA_WRAPPERS                        JPEG_ACCEPTED
        !          8701: JPEG_DEFAULT                         KERBEROS
        !          8702: KERMIT_SUID_UUCP                     KJS_USE_PCRE
        !          8703: KNEWS_DOMAIN_FILE                    KNEWS_DOMAIN_NAME
        !          8704: KRB5_ACCEPTED                        KRB5_DEFAULT
        !          8705: LANGUAGES                            LAPACK_LIBS
        !          8706: LATEX2HTML_ICONPATH                  LDCONFIG_ADD_CMD
        !          8707: LDCONFIG_REMOVE_CMD                  LEAFNODE_DATA_DIR
        !          8708: LEAFNODE_GROUP                       LEAFNODE_USER
        !          8709: LIBDVDCSS_HOMEPAGE                   LIBDVDCSS_MASTER_SITES
        !          8710: LIBRSVG_TYPE                         LIBTOOL
        !          8711: LIBTOOLIZE_PLIST                     LIBTOOL_M4_OVERRIDE
        !          8712: LIBUSB_TYPE                          LICENSE
        !          8713: LINKER_RPATH_FLAG                    LINK_RPATH_FLAG
        !          8714: LINUX_BASE_NODEPS                    LINUX_BASE_PREFERRED
        !          8715: LINUX_BASE_REQUIRED                  LINUX_LOCALES
        !          8716: LOCALBASE                            LOCALBASE_LOCKTYPE
        !          8717: LOCALPATCHES                         LOVE_DATA
        !          8718: LOVE_GAME                            LOVE_VERSION
        !          8719: LP64PLATFORMS                        MACHINE_PLATFORM
        !          8720: MAILAGENT_DOMAIN                     MAILAGENT_EMAIL
        !          8721: MAILAGENT_FQDN                       MAILAGENT_ORGANIZATION
        !          8722: MAJORDOMO_HOMEDIR                    MAJOR_OS_VERSION
        !          8723: MAKEINFO_ARGS                        MAKE_DIRS
        !          8724: MAKE_DIRS_PERMS                      MAKE_ENV
        !          8725: MAKE_FILE                            MAKE_FLAGS
        !          8726: MAKE_JOBS                            MAKE_JOBS_SAFE
        !          8727: MAKE_PROGRAM                         MANINSTALL
        !          8728: MANZ                                 MASTER_SITES
        !          8729: MASTER_SITE_BACKUP                   MASTER_SITE_CYGWIN
        !          8730: MASTER_SITE_GNOME                    MASTER_SITE_GNU
        !          8731: MASTER_SITE_LOCAL                    MASTER_SITE_MOZILLA
        !          8732: MASTER_SITE_OPENOFFICE               MASTER_SITE_OVERRIDE
        !          8733: MASTER_SITE_PERL_CPAN                MASTER_SITE_SUNSITE
        !          8734: MASTER_SITE_SUSE                     MASTER_SITE_TEX_CTAN
        !          8735: MASTER_SITE_XCONTRIB                 MASTER_SITE_XEMACS
        !          8736: MASTER_SORT                          MASTER_SORT_RANDOM
        !          8737: MASTER_SORT_REGEX                    MECAB_CHARSET
        !          8738: MEDIATOMB_GROUP                      MEDIATOMB_USER
        !          8739: MIPSPROBASE                          MIREDO_GROUP
        !          8740: MIREDO_USER                          MISSING_FEATURES
        !          8741: MKDIR                                MLDONKEY_GROUP
        !          8742: MLDONKEY_HOME                        MLDONKEY_USER
        !          8743: MONOTONE_GROUP                       MONOTONE_USER
        !          8744: MOTIFBASE                            MOTIF_TYPE
        !          8745: MOTIF_TYPE_DEFAULT                   MPI_TYPE
        !          8746: MSGFMT_STRIP_MSGCTXT                 MSGFMT_STRIP_MSGID_PLURAL
        !          8747: MTOOLS_ENABLE_FLOPPYD                MUST
        !          8748: MV                                   MYSQL_CHARSET
        !          8749: MYSQL_DATADIR                        MYSQL_EXTRA_CHARSET
        !          8750: MYSQL_GROUP                          MYSQL_PKGSRCDIR
        !          8751: MYSQL_USER                           MYSQL_VERSIONS_ACCEPTED
        !          8752: MYSQL_VERSION_DEFAULT                NAGIOSCMD_GROUP
        !          8753: NAGIOSDIR                            NAGIOS_GROUP
        !          8754: NAGIOS_USER                          NATIVE_APPEND_ABI
        !          8755: NATIVE_APPEND_ELF                    NATIVE_EXEC_FMT
        !          8756: NATIVE_MACHINE_PLATFORM              NATIVE_OBJECT_FMT
        !          8757: NBPAX_PROGRAM_PREFIX                 NETBSD_LOGIN_NAME
        !          8758: NMH_EDITOR                           NMH_MTA
        !          8759: NMH_PAGER                            NOLOGIN
        !          8760: NONZERO_FILESIZE_P                   NOTE
        !          8761: NOT_FOR_PLATFORM                     NOT_PAX_ASLR_SAFE
        !          8762: NOT_PAX_MPROTECT_SAFE                NO_BUILD
        !          8763: NO_CHECKSUM                          NO_CONFIGURE
        !          8764: NO_SKIP                              NS_PREFERRED
        !          8765: NULLMAILER_GROUP                     NULLMAILER_USER
        !          8766: OASIS                                OASIS_BUILD_ARGS
        !          8767: OBJHOSTNAME                          OBJMACHINE
        !          8768: OCAML_FINDLIB_DIRS                   OCAML_FINDLIB_REGISTER
        !          8769: OCAML_FINDLIB_REGISTER_VERBOSE       OCAML_SITELIBDIR
        !          8770: OCAML_TOPKG_DOCDIR                   OCAML_USE_DUNE
        !          8771: OCAML_USE_FINDLIB                    OCAML_USE_JBUILDER
        !          8772: OCAML_USE_OASIS                      OCAML_USE_OASIS_DYNRUN
        !          8773: OCAML_USE_OPAM                       OCAML_USE_OPT_COMPILER
        !          8774: OCAML_USE_TOPKG                      OMF
        !          8775: ONLY_FOR_COMPILER                    ONLY_FOR_PLATFORM
        !          8776: OPENSSH_CHROOT                       OPENSSH_GROUP
        !          8777: OPENSSH_USER                         OPSYS
        !          8778: OPSYS_EMULDIR                        OSS_TYPE
        !          8779: OSX                                  OSX_TOLERATE_SDK_SKEW
        !          8780: OS_HAVE_ALSA                         OS_HAVE_RCD
        !          8781: OS_VARIANT                           OS_VERSION
        !          8782: OTF_FONTS_DIR                        OVERRIDE_DIRDEPTH
        !          8783: OVERRIDE_GEMSPEC                     OVERRIDE_GNU_CONFIG_SCRIPTS
        !          8784: OVERRIDE_ROCKSPEC                    OWN_DIRS
        !          8785: OWN_DIRS_PERMS                       P4GROUP
        !          8786: P4PORT                               P4ROOT
        !          8787: P4USER                               PACKAGES
        !          8788: PALMOS_DEFAULT_SDK                   PAMBASE
        !          8789: PAM_DEFAULT                          PAPERSIZE
        !          8790: PASSIVE_FETCH                        PATCHDIR
        !          8791: PATCHFILES                           PATCH_ARGS
        !          8792: PATCH_DEBUG                          PATCH_DIST_ARGS
        !          8793: PATCH_DIST_CAT                       PATCH_DIST_STRIP
        !          8794: PATCH_FUZZ_FACTOR                    PATCH_STRIP
        !          8795: PATH                                 PCCBASE
        !          8796: PEAR                                 PEAR_CHANNEL
        !          8797: PEAR_CHANNEL_ALIAS                   PEAR_CHANNEL_VERSION
        !          8798: PEAR_CMD                             PEAR_LIB
        !          8799: PEAR_PACKAGE_XML                     PERL5
        !          8800: PERL5_CONFIGURE                      PERL5_CONFIGURE_DIRS
        !          8801: PERL5_LDFLAGS                        PERL5_LICENSE
        !          8802: PERL5_MODULE_TYPE                    PERL5_PACKLIST
        !          8803: PERL5_PACKLIST_DIR                   PERL5_PERLBASE
        !          8804: PERL5_SITEBASE                       PERL5_USE_PACKLIST
        !          8805: PERL5_VENDORBASE                     PFCTL
        !          8806: PFVAR_H                              PF_VERSION
        !          8807: PGGROUP                              PGHOME
        !          8808: PGPKGSRCDIR                          PGSQL_TYPE
        !          8809: PGSQL_VERSIONS_ACCEPTED              PGSQL_VERSION_DEFAULT
        !          8810: PGUSER                               PG_LIB_EXT
        !          8811: PHP                                  PHPCOMMON_MK
        !          8812: PHPPKGSRCDIR                         PHP_BASE_VERS
        !          8813: PHP_CHECK_INSTALLED                  PHP_EXTENSION_DIR
        !          8814: PHP_INITIAL_TEENY                    PHP_PKG_PREFIX
        !          8815: PHP_VERSION                          PHP_VERSIONS_ACCEPTED
        !          8816: PHP_VERSIONS_INCOMPATIBLE            PHP_VERSION_DEFAULT
        !          8817: PHP_VERSION_REQD                     PILRC_USE_GTK
        !          8818: PKGCONFIG_BASE                       PKGCONFIG_FILE
        !          8819: PKGCONFIG_OVERRIDE                   PKGCONFIG_OVERRIDE_STAGE
        !          8820: PKGDIR                               PKGGNUDIR
        !          8821: PKGINFODIR                           PKGLOCALEDIR
        !          8822: PKGMANDIR                            PKGNAME
        !          8823: PKGNAME_REQD                         PKGPATH
        !          8824: PKGREVISION                          PKGSRC_BLAS_TYPES
        !          8825: PKGSRC_CHANGES                       PKGSRC_COMPILER
        !          8826: PKGSRC_KEEP_BIN_PKGS                 PKGSRC_LOCKTYPE
        !          8827: PKGSRC_MAKE_ENV                      PKGSRC_MESSAGE_RECIPIENTS
        !          8828: PKGSRC_MKPIE                         PKGSRC_MKREPRO
        !          8829: PKGSRC_RUN_TEST                      PKGSRC_SETENV
        !          8830: PKGSRC_SLEEPSECS                     PKGSRC_TODO
        !          8831: PKGSRC_USE_CTF                       PKGSRC_USE_FORTIFY
        !          8832: PKGSRC_USE_RELRO                     PKGSRC_USE_SSP
        !          8833: PKGSRC_USE_STACK_CHECK               PKGTASKS_DATAFILE
        !          8834: PKGTOOLS_ARGS                        PKGTOOLS_ENV
        !          8835: PKG_ALTERNATIVES                     PKG_APACHE
        !          8836: PKG_APACHE_ACCEPTED                  PKG_APACHE_DEFAULT
        !          8837: PKG_BEST_EXISTS                      PKG_BUILD_OPTIONS
        !          8838: PKG_COMPRESSION                      PKG_CONFIG
        !          8839: PKG_CONFIG_PERMS                     PKG_CREATE_USERGROUP
        !          8840: PKG_DB_TMPDIR                        PKG_DEBUG_LEVEL
        !          8841: PKG_DEFAULT_OPTIONS                  PKG_DESTDIR_SUPPORT
        !          8842: PKG_DEVELOPER                        PKG_DISABLED_OPTIONS
        !          8843: PKG_FATAL_ERRORS                     PKG_FC
        !          8844: PKG_FILELIST_CMD                     PKG_GECOS
        !          8845: PKG_GID                              PKG_GROUPS
        !          8846: PKG_GROUPS_VARS                      PKG_HOME
        !          8847: PKG_INIT_SCRIPTS                     PKG_JAVA_HOME
        !          8848: PKG_JVM                              PKG_JVMS_ACCEPTED
        !          8849: PKG_JVM_DEFAULT                      PKG_LEGACY_OPTIONS
        !          8850: PKG_LIBTOOL                          PKG_OPTIONS
        !          8851: PKG_OPTIONS_DEPRECATED_WARNINGS      PKG_OPTIONS_LEGACY_OPTS
        !          8852: PKG_OPTIONS_LEGACY_VARS              PKG_OPTIONS_NONEMPTY_SETS
        !          8853: PKG_OPTIONS_OPTIONAL_GROUPS          PKG_OPTIONS_REQUIRED_GROUPS
        !          8854: PKG_OPTIONS_VAR                      PKG_PHP
        !          8855: PKG_PHP_MAJOR_VERS                   PKG_PHP_VERSION
        !          8856: PKG_RCD_SCRIPTS                      PKG_REFCOUNT_DBDIR
        !          8857: PKG_REGISTER_SHELLS                  PKG_RESUME_TRANSFERS
        !          8858: PKG_SHELL                            PKG_SUGGESTED_OPTIONS
        !          8859: PKG_SUPPORTED_OPTIONS                PKG_SYSCONFBASE
        !          8860: PKG_SYSCONFBASEDIR                   PKG_SYSCONFDIR
        !          8861: PKG_SYSCONFDIR_PERMS                 PKG_SYSCONFSUBDIR
        !          8862: PKG_SYSCONFVAR                       PKG_TOOLS_BIN
        !          8863: PKG_UID                              PKG_UPDATE_FONTS_DB
        !          8864: PKG_USERS                            PKG_USERS_VARS
        !          8865: PKG_VERBOSE                          PLIST
        !          8866: PLIST_AWK                            PLIST_AWK_ENV
        !          8867: PLIST_SRC                            PLIST_SUBST
        !          8868: PLIST_TYPE                           PLIST_VARS
        !          8869: POPTOP_USE_MPPE                      POST_FETCH_HOOK
        !          8870: PREFER                               PREFER_NATIVE
        !          8871: PREFER_NATIVE_PTHREADS               PREFER_PKGSRC
        !          8872: PREFIX                               PREPEND_PATH
        !          8873: PRE_ROOT_CMD                         PRIVILEGED_STAGES
        !          8874: PS                                   PTHREAD_AUTO_VARS
        !          8875: PTHREAD_CFLAGS                       PTHREAD_LDFLAGS
        !          8876: PTHREAD_LIBS                         PTHREAD_OPTS
        !          8877: PTHREAD_TYPE                         PVM_SSH
        !          8878: PYPKGPREFIX                          PYTHON_FOR_BUILD_ONLY
        !          8879: PYTHON_SELF_CONFLICT                 PYTHON_VERSIONED_DEPENDENCIES
        !          8880: PYTHON_VERSIONS_ACCEPTED             PYTHON_VERSIONS_INCOMPATIBLE
        !          8881: PYTHON_VERSION_DEFAULT               PYTHON_VERSION_REQD
        !          8882: PYVERSSUFFIX                         PY_NO_EGG
        !          8883: QMAILDIR                             QMAIL_ALIAS_USER
        !          8884: QMAIL_DAEMON_USER                    QMAIL_LOG_USER
        !          8885: QMAIL_NOFILES_GROUP                  QMAIL_PASSWD_USER
        !          8886: QMAIL_QMAIL_GROUP                    QMAIL_QUEUE_DIR
        !          8887: QMAIL_QUEUE_EXTRA                    QMAIL_QUEUE_USER
        !          8888: QMAIL_REMOTE_USER                    QMAIL_ROOT_USER
        !          8889: QMAIL_SEND_USER                      QPOPPER_FAC
        !          8890: QPOPPER_SPOOL_DIR                    QPOPPER_USER
        !          8891: RAKE_NAME                            RASMOL_DEPTH
        !          8892: RCD_DIR                              RCD_ORDER
        !          8893: RCD_SCRIPTS                          RCD_SCRIPTS_DIR
        !          8894: RCD_SCRIPTS_EXAMPLEDIR               RCD_SCRIPTS_MODE
        !          8895: RCD_SCRIPTS_SHELL                    RCD_SCRIPT_SRC
        !          8896: RCD_SUBR                             RDOC
        !          8897: READLINE_DEFAULT                     READLINE_TYPE
        !          8898: REAL_ROOT_GROUP                      REAL_ROOT_USER
        !          8899: RECURSIVE_MAKE                       RELAY_CTRL_DIR
        !          8900: REPLACE_AWK                          REPLACE_BASH
        !          8901: REPLACE_CSH                          REPLACE_KSH
        !          8902: REPLACE_PERL                         REPLACE_PERL6
        !          8903: REPLACE_PYTHON                       REPLACE_RUBY
        !          8904: REPLACE_RUBY_DIRS                    REPLACE_RUBY_PAT
        !          8905: REPLACE_SH                           REPLACE_TEXLUA
        !          8906: REQD_DIRS                            REQD_DIRS_PERMS
        !          8907: REQD_FILES                           REQD_FILES_MODE
        !          8908: REQD_FILES_PERMS                     RESOLV_AUTO_VARS
        !          8909: RESOLV_LDFLAGS                       RESOLV_LIBS
        !          8910: RM                                   ROCKSPEC_NAME
        !          8911: ROCKSPEC_SPECFILE                    ROOT_CMD
        !          8912: ROOT_GROUP                           ROOT_USER
        !          8913: RPCGEN                               RPM
        !          8914: RPM2PKG_PLIST                        RPM2PKG_PREFIX
        !          8915: RPM2PKG_STAGE                        RPM2PKG_STRIP
        !          8916: RPM2PKG_SUBPREFIX                    RPMFILES
        !          8917: RPMIGNOREPATH                        RPM_DB_PREFIX
        !          8918: RSSH_CVS_PATH                        RSSH_RDIST_PATH
        !          8919: RSSH_RSYNC_PATH                      RSSH_SCP_PATH
        !          8920: RSSH_SFTP_SERVER_PATH                RUBY
        !          8921: RUBYGEM                              RUBYGEM_NAME
        !          8922: RUBYGEM_OPTIONS                      RUBY_ABI_VERSION
        !          8923: RUBY_ARCH                            RUBY_ARCHINC
        !          8924: RUBY_ARCHLIB                         RUBY_BASE
        !          8925: RUBY_BASERIDIR                       RUBY_BUILD_RDOC
        !          8926: RUBY_BUILD_RI                        RUBY_DLEXT
        !          8927: RUBY_DOC                             RUBY_DYNAMIC_DIRS
        !          8928: RUBY_EG                              RUBY_ENCODING_ARG
        !          8929: RUBY_EXTCONF                         RUBY_EXTCONF_CHECK
        !          8930: RUBY_EXTCONF_DEBUG                   RUBY_EXTCONF_MAKEFILE
        !          8931: RUBY_GEM_BASE                        RUBY_INC
        !          8932: RUBY_LIB                             RUBY_LIB_BASE
        !          8933: RUBY_NAME                            RUBY_NOVERSION
        !          8934: RUBY_PKGPREFIX                       RUBY_RAILS
        !          8935: RUBY_RAILS42_VERSION                 RUBY_RAILS51_VERSION
        !          8936: RUBY_RAILS52_VERSION                 RUBY_RAILS_ACCEPTED
        !          8937: RUBY_RAILS_DEFAULT                   RUBY_RAILS_REQD
        !          8938: RUBY_RAILS_STRICT_DEP                RUBY_RIDIR
        !          8939: RUBY_SETUP                           RUBY_SHLIB
        !          8940: RUBY_SHLIBALIAS                      RUBY_SHLIBVER
        !          8941: RUBY_SIMPLE_INSTALL                  RUBY_SITEARCHLIB
        !          8942: RUBY_SITELIB                         RUBY_SITELIB_BASE
        !          8943: RUBY_SITERIDIR                       RUBY_SLEXT
        !          8944: RUBY_SRCDIR                          RUBY_STATICLIB
        !          8945: RUBY_SUFFIX                          RUBY_SYSRIDIR
        !          8946: RUBY_USE_PTHREAD                     RUBY_VENDORARCHLIB
        !          8947: RUBY_VENDORLIB                       RUBY_VENDORLIB_BASE
        !          8948: RUBY_VER                             RUBY_VERSION
        !          8949: RUBY_VERSIONS_ACCEPTED               RUBY_VERSION_DEFAULT
        !          8950: RUBY_VERSION_REQD                    RUBY_VER_DIR
        !          8951: RUN                                  RUN_LDCONFIG
        !          8952: SAWFISH_THEMES                       SCO
        !          8953: SCREWS_GROUP                         SCREWS_USER
        !          8954: SCRIPTS_ENV                          SCROLLKEEPER_DATADIR
        !          8955: SCROLLKEEPER_REBUILDDB               SCROLLKEEPER_UPDATEDB
        !          8956: SDIST_PAWD                           SERIAL_DEVICES
        !          8957: SETGIDGAME                           SETGID_GAMES_PERMS
        !          8958: SETUID_ROOT_PERMS                    SH
        !          8959: SHLIB                                SHORTNAME
        !          8960: SIGN_PACKAGES                        SILC_CLIENT_WITH_PERL
        !          8961: SITE_SPECIFIC_PKGS                   SKIP_DEPENDS
        !          8962: SKIP_PORTABILITY_CHECK               SMF_INSTANCES
        !          8963: SMF_MANIFEST                         SMF_METHODS
        !          8964: SMF_METHOD_SHELL                     SMF_METHOD_SRC
        !          8965: SMF_NAME                             SMF_PREFIX
        !          8966: SMF_SRCDIR                           SNIPROXY_GROUP
        !          8967: SNIPROXY_USER                        SOURCE_BUFFSIZE
        !          8968: SPECIAL_PERMS                        SPECIFIC_PKGS
        !          8969: SSH_SUID                             SSYNC_PAWD
        !          8970: STEP_MSG                             STRIP
        !          8971: STRIP_DBG                            STRIP_DEBUG
        !          8972: STRIP_DEBUG_SUPPORTED                STRIP_FILES_SKIP
        !          8973: SU                                   SUBDIR
        !          8974: SUBST_CLASSES                        SUBST_FILES
        !          8975: SUBST_FILTER_CMD                     SUBST_MESSAGE
        !          8976: SUBST_SED                            SUBST_SHOW_DIFF
        !          8977: SUBST_SKIP_TEXT_CHECK                SUBST_STAGE
        !          8978: SUBST_VARS                           SUNWSPROBASE
        !          8979: SUSE_PREFER                          SU_CMD
        !          8980: SVN_EXTRACTDIR                       SVN_REPO
        !          8981: SVN_REPOSITORIES                     SVN_REVISION
        !          8982: TERMCAP_TYPE                         TERMINFO_DEFAULT
        !          8983: TERMINFO_TYPE                        TEST
        !          8984: TEST_DEPENDS                         TEST_DIRS
        !          8985: TEST_ENV                             TEST_MAKE_CMD
        !          8986: TEST_MAKE_FLAGS                      TEST_TARGET
        !          8987: TEXLIVE_IGNORE_PATTERNS              TEXLIVE_REV
        !          8988: TEXMFSITE                            TEX_FORMATS
        !          8989: TEX_HYPHEN_DAT                       TEX_HYPHEN_DEF
        !          8990: TEX_TEXMF_DIRS                       THTTPD_LOG_FACILITY
        !          8991: TO                                   TOOLS_ALIASES
        !          8992: TOOLS_ARGS                           TOOLS_BROKEN
        !          8993: TOOLS_CMD                            TOOLS_CREATE
        !          8994: TOOLS_DIR                            TOOLS_FAIL
        !          8995: TOOLS_GNU_MISSING                    TOOLS_LDCONFIG
        !          8996: TOOLS_NOOP                           TOOLS_PATH
        !          8997: TOOLS_SCRIPT                         TOOL_DEPENDS
        !          8998: TTF_FONTDIR                          TTF_FONTS_DIR
        !          8999: TYPE                                 UAC_REQD_EXECS
        !          9000: UCSPI_SSL_GROUP                      UCSPI_SSL_USER
        !          9001: UNLIMIT_RESOURCES                    UNPRIVILEGED
        !          9002: UNPRIVILEGED_GROUP                   UNPRIVILEGED_GROUPS
        !          9003: UNPRIVILEGED_USER                    UNWRAP_FILES
        !          9004: UNWRAP_PATTERNS                      UPDATE_GEMSPEC
        !          9005: UPDATE_TARGET                        URI
        !          9006: USA                                  USERGROUP_PHASE
        !          9007: USERPPP_GROUP                        USER_SPECIFIC_PKGS
        !          9008: USE_ABI_DEPENDS                      USE_APR
        !          9009: USE_BSD_MAKEFILE                     USE_BUILTIN
        !          9010: USE_CROSS_COMPILE                    USE_CURSES
        !          9011: USE_CWRAPPERS                        USE_DB185
        !          9012: USE_FEATURES                         USE_GAMESGROUP
        !          9013: USE_GCC_RUNTIME                      USE_IMAKE
        !          9014: USE_JAVA                             USE_JAVA2
        !          9015: USE_LANGUAGES                        USE_LIBTOOL
        !          9016: USE_NATIVE_GCC                       USE_NETBSD_REPO
        !          9017: USE_PKGSRC_GCC                       USE_PKGSRC_GCC_RUNTIME
        !          9018: USE_PKGTASKS                         USE_RUBY_EXTCONF
        !          9019: USE_RUBY_INSTALL                     USE_RUBY_SETUP
        !          9020: USE_RUBY_SETUP_PKG                   USE_TOOLS
        !          9021: UUCP_GROUP                           UUCP_USER
        !          9022: VARBASE                              VARNAME
        !          9023: VIM_EXTRA_OPTS                       WARNING_MSG
        !          9024: WCALC_CGIDIR                         WCALC_CGIPATH
        !          9025: WCALC_HTMLDIR                        WCALC_HTMLPATH
        !          9026: WDM_MANAGERS                         WRAPPER_REORDER_CMDS
        !          9027: WRKDIR                               WRKDIR_BASENAME
        !          9028: WRKDIR_LOCKTYPE                      WRKLOG
        !          9029: WRKOBJDIR                            WRKSRC
        !          9030: WXGTK_ACCEPTED                       WXGTK_DEFAULT
        !          9031: X10_PORT                             X11
        !          9032: X11BASE                              X11_PKGSRCDIR
        !          9033: X11_TYPE                             X509_CERTIFICATE
        !          9034: X509_KEY                             XAW_TYPE
        !          9035: XLOCK_DEFAULT_MODE                   XMKMF_FLAGS
        !          9036: XXX                                  XXXX
        !          9037: YES                                  ZERO_FILESIZE_P
        !          9038: ZSH_STATIC                           __stdc__
        !          9039: _vargroups                           add
        !          9040: all                                  alternatives
        !          9041: aslr                                 asprintf
        !          9042: atlas                                autoconf
        !          9043: automake                             autoreconf
        !          9044: awk                                  bash
        !          9045: big-endian                           bin-install
        !          9046: binpkg-list                          blas
        !          9047: bootstrap-depends                    broken
        !          9048: broken_on_platform                   build
        !          9049: build-env                            buildlink-directories
        !          9050: buildlink-oss-soundcard-h            c
        !          9051: c++                                  ccache
        !          9052: cce                                  cdefs
        !          9053: changes                              changes-entry
        !          9054: changes-entry-noupdate               check
        !          9055: check-clean                          check-files
        !          9056: check-files-clean                    check-vulnerable
        !          9057: checksum                             checksum-phase
        !          9058: clean                                clean-depends
        !          9059: cleandir                             commit
        !          9060: commit-changes-entry                 compact
        !          9061: compiler                             conf
        !          9062: config.guess                         config.sub
        !          9063: configuration                        configure
        !          9064: configure-help                       configure_args
        !          9065: cputime                              create-usergroup
        !          9066: csh                                  ctf
        !          9067: cvs                                  debug
        !          9068: declaration                          declare
        !          9069: defined                              depend
        !          9070: dependencies                         depends
        !          9071: depends-checksum                     depends-fetch
        !          9072: deps                                 describe
        !          9073: destdir                              distclean
        !          9074: distinfo                             dl
        !          9075: dlopen                               do-build
        !          9076: do-buildlink                         do-clean
        !          9077: do-configure-post-hook               do-extract
        !          9078: do-fetch                             do-install
        !          9079: emul                                 emulation
        !          9080: emulator                             endian
        !          9081: enomem                               err
        !          9082: errx                                 etc
        !          9083: feature                              features
        !          9084: fetch                                fetch-list
        !          9085: follows                              forbids
        !          9086: form                                 format
        !          9087: fortify                              fortify_source
        !          9088: fossil                               friend
        !          9089: from                                 fts
        !          9090: fts_close                            fts_open
        !          9091: fts_read                             fts_set
        !          9092: full                                 gcc
        !          9093: getopt_long                          getprogname
        !          9094: gettext                              git
        !          9095: github                               glob
        !          9096: gnu                                  gnu_configure_strict
        !          9097: go                                   go-deps
        !          9098: golang                               guess-license
        !          9099: hashbang                             heimdal
        !          9100: help                                 hg
        !          9101: imake                                increment
        !          9102: interp                               interpreter
        !          9103: intl                                 iso
        !          9104: kerberos                             krb
        !          9105: krb5                                 ksh
        !          9106: lapack                               latex
        !          9107: libnbcompat                          libs
        !          9108: libtool                              licence
        !          9109: license                              lintl
        !          9110: little-endian                        lock
        !          9111: locking                              lvalue
        !          9112: make                                 makesum
        !          9113: memory                               mercurial
        !          9114: meta                                 meta-package
        !          9115: meta_package                         mit-krb5
        !          9116: mk.conf                              mkl
        !          9117: mount                                mprotect
        !          9118: mremap                               nb
        !          9119: nbcompat                             no
        !          9120: obstack                              obstack_ptr_grow
        !          9121: occurs                               only
        !          9122: openblas                             options
        !          9123: options.mk                           order
        !          9124: override                             override-intltool
        !          9125: override-message-intltool            package
        !          9126: parallel                             partial
        !          9127: path                                 pax
        !          9128: paxctl                               pbulk-index
        !          9129: pc                                   perl
        !          9130: perl5                                perms
        !          9131: php                                  pkg-build-options
        !          9132: pkg-config                           pkg_build_options
        !          9133: platform                             plist
        !          9134: post-extract                         post-fetch
        !          9135: post-wrapper                         pre-configure
        !          9136: pre-extract                          pre-fetch
        !          9137: print-go-deps                        print-plist
        !          9138: print-summary-data                   privileged-install-hook
        !          9139: pypi                                 python
        !          9140: readme-all                           regcomp
        !          9141: relro                                rename
        !          9142: reorder                              replace
        !          9143: replace_interpreter                  reproducible
        !          9144: resolv                               root
        !          9145: ruby                                 setenv
        !          9146: setgid                               setprogname
        !          9147: setuid                               sh
        !          9148: show                                 show-all
        !          9149: show-build-defs                      show-depends
        !          9150: show-deps                            show-distfiles
        !          9151: show-downlevel                       show-subdir-var
        !          9152: show-tools                           show-var
        !          9153: show-vars                            snprintf
        !          9154: ssp                                  st_mode
        !          9155: stage-install                        strip
        !          9156: strnlen                              strong
        !          9157: subst                                subversion
        !          9158: sun                                  sunpro
        !          9159: sunwspro                             svn
        !          9160: test                                 tex
        !          9161: texlive                              tmp
        !          9162: tool                                 tools
        !          9163: tools-libtool-m4-override            type
        !          9164: ulimit                               undefined
        !          9165: undo-replace                         unlimit
        !          9166: unprivileged                         unprivileged-install-hook
        !          9167: unstripped                           update
        !          9168: upload                               upload-distfiles
        !          9169: usage                                use_tools
        !          9170: user                                 utimes
        !          9171: vasprintf                            verbose
        !          9172: vsnprintf                            warn
        !          9173: warning                              warnings
        !          9174: warnx                                weak
        !          9175: work                                 wrapper
        !          9176: yes                                   
1.154     rillig   9177: 
                   9178: Appendix E. Editing guidelines for the pkgsrc guide
1.1       dsieger  9179: 
                   9180: Table of Contents
                   9181: 
1.154     rillig   9182: E.1. Make targets
                   9183: E.2. Procedure
1.1       dsieger  9184: 
                   9185: This section contains information on editing the pkgsrc guide itself.
                   9186: 
1.154     rillig   9187: E.1. Make targets
1.1       dsieger  9188: 
                   9189: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
                   9190: files are created from it:
                   9191: 
                   9192:   * pkgsrc/doc/pkgsrc.txt
                   9193: 
                   9194:   * pkgsrc/doc/pkgsrc.html
                   9195: 
1.2       rillig   9196:   * http://www.NetBSD.org/docs/pkgsrc/
1.1       dsieger  9197: 
1.2       rillig   9198:   * http://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the pkgsrc
                   9199:     guide.
1.1       dsieger  9200: 
1.2       rillig   9201:   * http://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
                   9202:     pkgsrc guide.
1.1       dsieger  9203: 
1.154     rillig   9204: E.2. Procedure
1.1       dsieger  9205: 
                   9206: The procedure to edit the pkgsrc guide is:
                   9207: 
                   9208:  1. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46      obache   9209:     other XML-based NetBSD documentation) installed. These are automatically
                   9210:     installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1       dsieger  9211: 
                   9212:  2. Run cd doc/guide to get to the right directory. All further steps will take
                   9213:     place here.
                   9214: 
                   9215:  3. Edit the XML file(s) in files/.
                   9216: 
                   9217:  4. Run bmake to check the pkgsrc guide for valid XML and to build the final
                   9218:     output files. If you get any errors at this stage, you can just edit the
                   9219:     files, as there are only symbolic links in the working directory, pointing
                   9220:     to the files in files/.
                   9221: 
                   9222:  5. (cd files && cvs commit)
                   9223: 
                   9224:  6. Run bmake clean && bmake to regenerate the output files with the proper RCS
                   9225:     Ids.
                   9226: 
                   9227:  7. Run bmake regen to install and commit the files in both pkgsrc/doc and
                   9228:     htdocs.
                   9229: 
                   9230:     Note
                   9231: 
                   9232:     If you have added, removed or renamed some chapters, you need to
                   9233:     synchronize them using cvs add or cvs delete in the htdocs directory.
                   9234: 

CVSweb <webmaster@jp.NetBSD.org>