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

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

CVSweb <webmaster@jp.NetBSD.org>