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

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.184     rillig     17: $NetBSD: pkgsrc.xml,v 1.38 2020/06/20 05:31:10 rillig Exp $
1.1       dsieger    18: 
                     19: Abstract
                     20: 
                     21: pkgsrc is a centralized package management system for Unix-like operating
                     22: systems. This guide provides information for users and developers of pkgsrc. It
                     23: covers installation of binary and source packages, creation of binary and
                     24: source packages and a high-level overview about the infrastructure.
                     25: 
                     26: -------------------------------------------------------------------------------
                     27: 
                     28: Table of Contents
                     29: 
                     30: 1. What is pkgsrc?
                     31: 
                     32:     1.1. Introduction
                     33: 
                     34:         1.1.1. Why pkgsrc?
                     35:         1.1.2. Supported platforms
                     36: 
                     37:     1.2. Overview
                     38:     1.3. Terminology
                     39: 
                     40:         1.3.1. Roles involved in pkgsrc
                     41: 
                     42:     1.4. Typography
                     43: 
                     44: I. The pkgsrc user's guide
                     45: 
1.154     rillig     46:     2. Getting help
                     47:     3. Where to get pkgsrc and how to keep it up-to-date
1.1       dsieger    48: 
1.154     rillig     49:         3.1. Getting pkgsrc for the first time
1.1       dsieger    50: 
1.154     rillig     51:             3.1.1. As tar archive
                     52:             3.1.2. Via anonymous CVS
1.1       dsieger    53: 
1.154     rillig     54:         3.2. Keeping pkgsrc up-to-date
1.1       dsieger    55: 
1.154     rillig     56:             3.2.1. Via tar files
                     57:             3.2.2. Via CVS
1.1       dsieger    58: 
1.154     rillig     59:     4. Using pkgsrc on systems other than NetBSD
1.1       dsieger    60: 
1.154     rillig     61:         4.1. Binary distribution
                     62:         4.2. Bootstrapping pkgsrc
1.1       dsieger    63: 
1.154     rillig     64:     5. Using pkgsrc
1.1       dsieger    65: 
1.154     rillig     66:         5.1. Using binary packages
1.1       dsieger    67: 
1.154     rillig     68:             5.1.1. Finding binary packages
                     69:             5.1.2. Installing binary packages
                     70:             5.1.3. Deinstalling packages
                     71:             5.1.4. Getting information about installed packages
                     72:             5.1.5. Checking for security vulnerabilities in installed packages
                     73:             5.1.6. Finding if newer versions of your installed packages are in
1.1       dsieger    74:                 pkgsrc
1.154     rillig     75:             5.1.7. Other administrative functions
1.1       dsieger    76: 
1.154     rillig     77:         5.2. Building packages from source
1.1       dsieger    78: 
1.154     rillig     79:             5.2.1. Requirements
                     80:             5.2.2. Fetching distfiles
                     81:             5.2.3. How to build and install
1.1       dsieger    82: 
1.154     rillig     83:     6. Configuring pkgsrc
1.1       dsieger    84: 
1.154     rillig     85:         6.1. General configuration
                     86:         6.2. Variables affecting the build process
                     87:         6.3. Variables affecting the installation process
                     88:         6.4. Selecting and configuring the compiler
1.1       dsieger    89: 
1.154     rillig     90:             6.4.1. Selecting the compiler
                     91:             6.4.2. Additional flags to the compiler (CFLAGS)
                     92:             6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger    93: 
1.154     rillig     94:         6.5. Developer/advanced settings
                     95:         6.6. Selecting Build Options
1.1       dsieger    96: 
1.154     rillig     97:     7. Creating binary packages
1.1       dsieger    98: 
1.154     rillig     99:         7.1. Building a single binary package
                    100:         7.2. Settings for creation of binary packages
1.1       dsieger   101: 
1.154     rillig    102:     8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig    103: 
1.154     rillig    104:         8.1. Preparations
1.180     rillig    105:         8.2. Running a bulk build
1.6       rillig    106: 
1.154     rillig    107:             8.2.1. Configuration
1.6       rillig    108: 
1.154     rillig    109:         8.3. Requirements of a full bulk build
1.178     rillig    110:         8.4. Bulk build variants
1.6       rillig    111: 
1.179     rillig    112:             8.4.1. Detect unknown configure options
                    113:             8.4.2. Detect classes of bugs by forcing compiler warnings
1.181     rillig    114:             8.4.3. Force compiler options only in the build phase
                    115:             8.4.4. Use custom directories
                    116:             8.4.5. Turn warnings into errors
                    117:             8.4.6. Reject packages for which pkglint reports errors
                    118:             8.4.7. Reject packages that contain forbidden strings
                    119:             8.4.8. Reject packages whose self-test fails
                    120:             8.4.9. Reject packages that use undefined shell variables
                    121:             8.4.10. Turn off verbose logging
1.178     rillig    122: 
                    123:         8.5. Creating a multiple CD-ROM packages collection
                    124: 
                    125:             8.5.1. Example of cdpack
1.6       rillig    126: 
1.154     rillig    127:     9. Directory layout of the installed files
1.6       rillig    128: 
1.154     rillig    129:         9.1. File system layout in ${LOCALBASE}
                    130:         9.2. File system layout in ${VARBASE}
1.6       rillig    131: 
1.154     rillig    132:     10. Frequently Asked Questions
1.6       rillig    133: 
1.154     rillig    134:         10.1. Are there any mailing lists for pkg-related discussion?
                    135:         10.2. Utilities for package management (pkgtools)
                    136:         10.3. How to use pkgsrc as non-root
                    137:         10.4. How to resume transfers when fetching distfiles?
                    138:         10.5. How can I install/use modular X.org from pkgsrc?
                    139:         10.6. How to fetch files from behind a firewall
                    140:         10.7. How to fetch files from HTTPS sites
                    141:         10.8. How do I tell make fetch to do passive FTP?
                    142:         10.9. How to fetch all distfiles at once
                    143:         10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc"
1.24      wiz       144:             mean?
1.154     rillig    145:         10.11. What does "Could not find bsd.own.mk" mean?
                    146:         10.12. Using 'sudo' with pkgsrc
                    147:         10.13. How do I change the location of configuration files?
                    148:         10.14. Automated security checks
                    149:         10.15. Why do some packages ignore my CFLAGS?
                    150:         10.16. A package does not build. What shall I do?
                    151:         10.17. What does "Makefile appears to contain unresolved cvs/rcs/???
1.24      wiz       152:             merge conflicts" mean?
1.1       dsieger   153: 
                    154: II. The pkgsrc developer's guide
                    155: 
1.154     rillig    156:     11. Getting help
1.184     rillig    157:     12. Package components - files, directories and contents
1.1       dsieger   158: 
1.184     rillig    159:         12.1. Makefile
                    160:         12.2. distinfo
                    161:         12.3. patches/*
1.1       dsieger   162: 
1.184     rillig    163:             12.3.1. Structure of a single patch file
                    164:             12.3.2. Creating patch files
                    165:             12.3.3. Sources where the patch files come from
                    166:             12.3.4. Patching guidelines
                    167:             12.3.5. Feedback to the author
1.1       dsieger   168: 
1.184     rillig    169:         12.4. Other mandatory files
                    170:         12.5. Optional files
1.1       dsieger   171: 
1.184     rillig    172:             12.5.1. Files affecting the binary package
                    173:             12.5.2. Files affecting the build process
                    174:             12.5.3. Files affecting nothing at all
1.1       dsieger   175: 
1.184     rillig    176:         12.6. work*
                    177:         12.7. files/*
1.1       dsieger   178: 
1.184     rillig    179:     13. The build process
1.1       dsieger   180: 
1.184     rillig    181:         13.1. Introduction
                    182:         13.2. Program location
                    183:         13.3. Directories used during the build process
                    184:         13.4. Running a phase
                    185:         13.5. The fetch phase
1.1       dsieger   186: 
1.184     rillig    187:             13.5.1. What to fetch and where to get it from
                    188:             13.5.2. How are the files fetched?
1.1       dsieger   189: 
1.184     rillig    190:         13.6. The checksum phase
                    191:         13.7. The extract phase
                    192:         13.8. The patch phase
                    193:         13.9. The tools phase
                    194:         13.10. The wrapper phase
                    195:         13.11. The configure phase
                    196:         13.12. The build phase
                    197:         13.13. The test phase
                    198:         13.14. The install phase
                    199:         13.15. The package phase
                    200:         13.16. Cleaning up
                    201:         13.17. Other helpful targets
1.1       dsieger   202: 
1.184     rillig    203:     14. Creating a new pkgsrc package from scratch
1.1       dsieger   204: 
1.184     rillig    205:         14.1. Common types of packages
1.1       dsieger   206: 
1.184     rillig    207:             14.1.1. Perl modules
                    208:             14.1.2. Python modules and programs
                    209:             14.1.3. R packages
                    210:             14.1.4. TeXlive packages
1.1       dsieger   211: 
1.184     rillig    212:         14.2. Examples
1.1       dsieger   213: 
1.184     rillig    214:             14.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger   215: 
1.184     rillig    216:     15. Programming in Makefiles
1.1       dsieger   217: 
1.184     rillig    218:         15.1. Caveats
                    219:         15.2. Makefile variables
1.1       dsieger   220: 
1.184     rillig    221:             15.2.1. Naming conventions
1.1       dsieger   222: 
1.184     rillig    223:         15.3. Code snippets
1.1       dsieger   224: 
1.184     rillig    225:             15.3.1. Adding things to a list
                    226:             15.3.2. Echoing a string exactly as-is
                    227:             15.3.3. Passing CFLAGS to GNU configure scripts
                    228:             15.3.4. Handling possibly empty variables
1.1       dsieger   229: 
1.184     rillig    230:     16. Options handling
1.1       dsieger   231: 
1.184     rillig    232:         16.1. Global default options
                    233:         16.2. Converting packages to use bsd.options.mk
                    234:         16.3. Option Names
                    235:         16.4. Determining the options of dependencies
1.1       dsieger   236: 
1.184     rillig    237:     17. Tools needed for building or running
1.1       dsieger   238: 
1.184     rillig    239:         17.1. Tools for pkgsrc builds
                    240:         17.2. Tools needed by packages
                    241:         17.3. Tools provided by platforms
1.1       dsieger   242: 
1.184     rillig    243:     18. Buildlink methodology
1.1       dsieger   244: 
1.184     rillig    245:         18.1. Converting packages to use buildlink3
                    246:         18.2. Writing buildlink3.mk files
1.1       dsieger   247: 
1.184     rillig    248:             18.2.1. Anatomy of a buildlink3.mk file
                    249:             18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
                    250:                 BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
1.1       dsieger   251: 
1.184     rillig    252:         18.3. Writing builtin.mk files
1.1       dsieger   253: 
1.184     rillig    254:             18.3.1. Anatomy of a builtin.mk file
                    255:             18.3.2. Global preferences for native or pkgsrc software
1.1       dsieger   256: 
1.184     rillig    257:     19. PLIST issues
1.1       dsieger   258: 
1.184     rillig    259:         19.1. RCS ID
                    260:         19.2. Semi-automatic PLIST generation
                    261:         19.3. Tweaking output of make print-PLIST
                    262:         19.4. Variable substitution in PLIST
                    263:         19.5. Man page compression
                    264:         19.6. Changing PLIST source with PLIST_SRC
                    265:         19.7. Platform-specific and differing PLISTs
                    266:         19.8. Build-specific PLISTs
                    267:         19.9. Sharing directories between packages
1.1       dsieger   268: 
1.184     rillig    269:     20. The pkginstall framework
1.1       dsieger   270: 
1.184     rillig    271:         20.1. Files and directories outside the installation prefix
1.1       dsieger   272: 
1.184     rillig    273:             20.1.1. Directory manipulation
                    274:             20.1.2. File manipulation
1.1       dsieger   275: 
1.184     rillig    276:         20.2. Configuration files
1.1       dsieger   277: 
1.184     rillig    278:             20.2.1. How PKG_SYSCONFDIR is set
                    279:             20.2.2. Telling the software where configuration files are
                    280:             20.2.3. Patching installations
                    281:             20.2.4. Disabling handling of configuration files
1.1       dsieger   282: 
1.184     rillig    283:         20.3. System startup scripts
1.1       dsieger   284: 
1.184     rillig    285:             20.3.1. Disabling handling of system startup scripts
1.1       dsieger   286: 
1.184     rillig    287:         20.4. System users and groups
                    288:         20.5. System shells
1.1       dsieger   289: 
1.184     rillig    290:             20.5.1. Disabling shell registration
1.1       dsieger   291: 
1.184     rillig    292:         20.6. Fonts
1.1       dsieger   293: 
1.184     rillig    294:             20.6.1. Disabling automatic update of the fonts databases
1.1       dsieger   295: 
1.154     rillig    296:     21. Making your package work
1.1       dsieger   297: 
1.154     rillig    298:         21.1. General operation
1.1       dsieger   299: 
1.154     rillig    300:             21.1.1. How to pull in user-settable variables from mk.conf
                    301:             21.1.2. User interaction
                    302:             21.1.3. Handling licenses
                    303:             21.1.4. Restricted packages
                    304:             21.1.5. Handling dependencies
                    305:             21.1.6. Handling conflicts with other packages
                    306:             21.1.7. Packages that cannot or should not be built
                    307:             21.1.8. Packages which should not be deleted, once installed
                    308:             21.1.9. Handling packages with security problems
                    309:             21.1.10. How to handle incrementing versions when fixing an
1.1       dsieger   310:                 existing package
1.154     rillig    311:             21.1.11. Substituting variable text in the package files (the SUBST
1.1       dsieger   312:                 framework)
                    313: 
1.154     rillig    314:         21.2. The fetch phase
1.1       dsieger   315: 
1.154     rillig    316:             21.2.1. Packages whose distfiles aren't available for plain
1.1       dsieger   317:                 downloading
1.154     rillig    318:             21.2.2. How to handle modified distfiles with the 'old' name
                    319:             21.2.3. Packages hosted on github.com
1.1       dsieger   320: 
1.154     rillig    321:         21.3. The configure phase
1.1       dsieger   322: 
1.154     rillig    323:             21.3.1. Shared libraries - libtool
                    324:             21.3.2. Using libtool on GNU packages that already support libtool
                    325:             21.3.3. GNU Autoconf/Automake
                    326: 
                    327:         21.4. Programming languages
                    328: 
                    329:             21.4.1. C, C++, and Fortran
                    330:             21.4.2. Java
                    331:             21.4.3. Packages containing perl scripts
                    332:             21.4.4. Packages containing shell scripts
                    333:             21.4.5. Other programming languages
                    334: 
                    335:         21.5. The build phase
                    336: 
                    337:             21.5.1. Compiling C and C++ code conditionally
                    338:             21.5.2. How to handle compiler bugs
1.172     rillig    339:             21.5.3. No such file or directory
                    340:             21.5.4. Undefined reference to "..."
                    341:             21.5.5. Running out of memory
1.154     rillig    342: 
                    343:         21.6. The install phase
                    344: 
                    345:             21.6.1. Creating needed directories
                    346:             21.6.2. Where to install documentation
                    347:             21.6.3. Installing highscore files
                    348:             21.6.4. Adding DESTDIR support to packages
                    349:             21.6.5. Packages with hardcoded paths to other interpreters
                    350:             21.6.6. Packages installing perl modules
                    351:             21.6.7. Packages installing info files
                    352:             21.6.8. Packages installing man pages
                    353:             21.6.9. Packages installing GConf data files
                    354:             21.6.10. Packages installing scrollkeeper/rarian data files
                    355:             21.6.11. Packages installing X11 fonts
                    356:             21.6.12. Packages installing GTK2 modules
                    357:             21.6.13. Packages installing SGML or XML data
                    358:             21.6.14. Packages installing extensions to the MIME database
                    359:             21.6.15. Packages using intltool
                    360:             21.6.16. Packages installing startup scripts
                    361:             21.6.17. Packages installing TeX modules
                    362:             21.6.18. Packages supporting running binaries in emulation
                    363:             21.6.19. Packages installing hicolor theme icons
                    364:             21.6.20. Packages installing desktop files
                    365: 
                    366:         21.7. Marking packages as having problems
                    367: 
1.184     rillig    368:     22. GNOME packaging and porting
                    369: 
                    370:         22.1. Meta packages
                    371:         22.2. Packaging a GNOME application
                    372:         22.3. Updating GNOME to a newer version
                    373:         22.4. Patching guidelines
                    374: 
1.154     rillig    375:     23. Submitting and Committing
                    376: 
                    377:         23.1. Submitting binary packages
                    378:         23.2. Submitting source packages (for non-NetBSD-developers)
                    379:         23.3. General notes when adding, updating, or removing packages
                    380:         23.4. Commit Messages
                    381:         23.5. Committing: Adding a package to CVS
                    382:         23.6. Updating a package to a newer version
                    383:         23.7. Renaming a package in pkgsrc
                    384:         23.8. Moving a package in pkgsrc
                    385: 
                    386:     24. Frequently Asked Questions
1.1       dsieger   387: 
                    388: III. The pkgsrc infrastructure internals
                    389: 
1.184     rillig    390:     25. Design of the pkgsrc infrastructure
1.1       dsieger   391: 
1.184     rillig    392:         25.1. The meaning of variable definitions
                    393:         25.2. Avoiding problems before they arise
                    394:         25.3. Variable evaluation
1.1       dsieger   395: 
1.184     rillig    396:             25.3.1. At load time
                    397:             25.3.2. At runtime
1.1       dsieger   398: 
1.184     rillig    399:         25.4. How can variables be specified?
                    400:         25.5. Designing interfaces for Makefile fragments
1.1       dsieger   401: 
1.184     rillig    402:             25.5.1. Procedures with parameters
                    403:             25.5.2. Actions taken on behalf of parameters
1.1       dsieger   404: 
1.184     rillig    405:         25.6. The order in which files are loaded
1.1       dsieger   406: 
1.184     rillig    407:             25.6.1. The order in bsd.prefs.mk
                    408:             25.6.2. The order in bsd.pkg.mk
1.1       dsieger   409: 
1.184     rillig    410:     26. Regression tests
1.1       dsieger   411: 
1.184     rillig    412:         26.1. Running the regression tests
                    413:         26.2. Adding a new regression test
1.1       dsieger   414: 
1.184     rillig    415:             26.2.1. Overridable functions
                    416:             26.2.2. Helper functions
1.1       dsieger   417: 
1.184     rillig    418:     27. Porting pkgsrc
1.1       dsieger   419: 
1.184     rillig    420:         27.1. Porting pkgsrc to a new operating system
1.1       dsieger   421: 
                    422: A. A simple example package: bison
                    423: 
                    424:     A.1. files
                    425: 
                    426:         A.1.1. Makefile
                    427:         A.1.2. DESCR
                    428:         A.1.3. PLIST
                    429:         A.1.4. Checking a package with pkglint
                    430: 
                    431:     A.2. Steps for building, installing, packaging
                    432: 
                    433: B. Build logs
                    434: 
                    435:     B.1. Building figlet
                    436:     B.2. Packaging figlet
                    437: 
                    438: C. Directory layout of the pkgsrc FTP server
                    439: 
1.23      jakllsch  440:     C.1. distfiles: The distributed source files
                    441:     C.2. misc: Miscellaneous things
                    442:     C.3. packages: Binary packages
                    443:     C.4. reports: Bulk build reports
1.148     leot      444:     C.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger   445: 
1.154     rillig    446: D. Help topics
                    447: E. Editing guidelines for the pkgsrc guide
1.1       dsieger   448: 
1.154     rillig    449:     E.1. Make targets
                    450:     E.2. Procedure
1.1       dsieger   451: 
                    452: List of Tables
                    453: 
                    454: 1.1. Platforms supported by pkgsrc
1.184     rillig    455: 12.1. Patching examples
                    456: 22.1. PLIST handling for GNOME packages
1.1       dsieger   457: 
                    458: Chapter 1. What is pkgsrc?
                    459: 
                    460: Table of Contents
                    461: 
                    462: 1.1. Introduction
                    463: 
                    464:     1.1.1. Why pkgsrc?
                    465:     1.1.2. Supported platforms
                    466: 
                    467: 1.2. Overview
                    468: 1.3. Terminology
                    469: 
                    470:     1.3.1. Roles involved in pkgsrc
                    471: 
                    472: 1.4. Typography
                    473: 
                    474: 1.1. Introduction
                    475: 
                    476: There is a lot of software freely available for Unix-based systems, which is
                    477: usually available in form of the source code. Before such software can be used,
                    478: it needs to be configured to the local system, compiled and installed, and this
                    479: is exactly what The NetBSD Packages Collection (pkgsrc) does. pkgsrc also has
                    480: some basic commands to handle binary packages, so that not every user has to
                    481: build the packages for himself, which is a time-costly task.
                    482: 
                    483: pkgsrc currently contains several thousand packages, including:
                    484: 
1.104     sevan     485:   * www/apache24 - The Apache web server
1.1       dsieger   486: 
                    487:   * www/firefox - The Firefox web browser
                    488: 
                    489:   * meta-pkgs/gnome - The GNOME Desktop Environment
                    490: 
1.102     ryoon     491:   * meta-pkgs/kde4 - The K Desktop Environment
1.1       dsieger   492: 
1.108     rillig    493: ? just to name a few.
1.1       dsieger   494: 
                    495: pkgsrc has built-in support for handling varying dependencies, such as pthreads
                    496: and X11, and extended features such as IPv6 support on a range of platforms.
                    497: 
                    498: 1.1.1. Why pkgsrc?
                    499: 
                    500: pkgsrc provides the following key features:
                    501: 
                    502:   * Easy building of software from source as well as the creation and
                    503:     installation of binary packages. The source and latest patches are
                    504:     retrieved from a master or mirror download site, checksum verified, then
                    505:     built on your system. Support for binary-only distributions is available
                    506:     for both native platforms and NetBSD emulated platforms.
                    507: 
                    508:   * All packages are installed in a consistent directory tree, including
                    509:     binaries, libraries, man pages and other documentation.
                    510: 
1.104     sevan     511:   * Tracking of package dependencies automatically, including when performing
                    512:     updates, to ensure required packages are installed. The configuration files
                    513:     of various packages are handled automatically during updates, so local
                    514:     changes are preserved.
1.1       dsieger   515: 
                    516:   * Like NetBSD, pkgsrc is designed with portability in mind and consists of
                    517:     highly portable code. This allows the greatest speed of development when
1.26      spz       518:     porting to a new platform. This portability also ensures that pkgsrc is 
1.1       dsieger   519:     consistent across all platforms.
                    520: 
                    521:   * The installation prefix, acceptable software licenses, international
                    522:     encryption requirements and build-time options for a large number of
                    523:     packages are all set in a simple, central configuration file.
                    524: 
                    525:   * The entire source (not including the distribution files) is freely
                    526:     available under a BSD license, so you may extend and adapt pkgsrc to your
                    527:     needs. Support for local packages and patches is available right out of the
                    528:     box, so you can configure it specifically for your environment.
                    529: 
                    530: The following principles are basic to pkgsrc:
                    531: 
                    532:   * "It should only work if it's right." ? That means, if a package contains
                    533:     bugs, it's better to find them and to complain about them rather than to
                    534:     just install the package and hope that it works. There are numerous checks
1.175     gutterid  535:     in pkgsrc that try to find such bugs: static analysis tools (pkgtools/
1.1       dsieger   536:     pkglint), build-time checks (portability of shell scripts), and
                    537:     post-installation checks (installed files, references to shared libraries,
                    538:     script interpreters).
                    539: 
                    540:   * "If it works, it should work everywhere" ? Like NetBSD has been ported to
                    541:     many hardware architectures, pkgsrc has been ported to many operating
                    542:     systems. Care is taken that packages behave the same on all platforms.
                    543: 
                    544: 1.1.2. Supported platforms
                    545: 
                    546: pkgsrc consists of both a source distribution and a binary distribution for
                    547: these operating systems. After retrieving the required source or binaries, you
                    548: can be up and running with pkgsrc in just minutes!
                    549: 
                    550: pkgsrc was derived from FreeBSD's ports system, and initially developed for
                    551: NetBSD only. Since then, pkgsrc has grown a lot, and now supports the following
                    552: platforms:
                    553: 
                    554: Table 1.1. Platforms supported by pkgsrc
                    555: 
1.92      sevan     556: +-----------------------------------------------------------------------------+
                    557: |               Platform               | Date Support  |        Notes         |
                    558: |                                      |     Added     |                      |
                    559: |--------------------------------------+---------------+----------------------|
                    560: |NetBSD                                |   Aug 1997    |                      |
                    561: |--------------------------------------+---------------+----------------------|
                    562: |Solaris                               |   Mar 1999    |README.Solaris        |
                    563: |--------------------------------------+---------------+----------------------|
                    564: |Linux                                 |   Jun 1999    |README.Linux          |
                    565: |--------------------------------------+---------------+----------------------|
1.118     sevan     566: |Darwin / Mac OS X / OS X / macOS      |   Oct 2001    |README.MacOSX         |
1.92      sevan     567: |--------------------------------------+---------------+----------------------|
                    568: |FreeBSD                               |   Nov 2002    |README.FreeBSD        |
                    569: |--------------------------------------+---------------+----------------------|
                    570: |OpenBSD                               |   Nov 2002    |README.OpenBSD        |
                    571: |--------------------------------------+---------------+----------------------|
                    572: |IRIX                                  |   Dec 2002    |README.IRIX           |
                    573: |                                      |               |README.IRIX5.3        |
                    574: |--------------------------------------+---------------+----------------------|
                    575: |BSD/OS                                |   Dec 2003    |                      |
                    576: |--------------------------------------+---------------+----------------------|
                    577: |AIX                                   |   Dec 2003    |README.AIX            |
                    578: |--------------------------------------+---------------+----------------------|
                    579: |Interix (Microsoft Windows Services   |   Mar 2004    |README.Interix        |
                    580: |for Unix)                             |               |                      |
                    581: |--------------------------------------+---------------+----------------------|
                    582: |DragonFlyBSD                          |   Oct 2004    |                      |
                    583: |--------------------------------------+---------------+----------------------|
                    584: |OSF/1                                 |   Nov 2004    |README.OSF1           |
                    585: |--------------------------------------+---------------+----------------------|
                    586: |HP-UX                                 |   Apr 2007    |README.HPUX           |
                    587: |--------------------------------------+---------------+----------------------|
                    588: |Haiku                                 |   Sep 2010    |README.Haiku          |
                    589: |--------------------------------------+---------------+----------------------|
                    590: |MirBSD                                |   Jan 2011    |                      |
                    591: |--------------------------------------+---------------+----------------------|
                    592: |Minix3                                |   Nov 2011    |README.Minix3         |
                    593: |--------------------------------------+---------------+----------------------|
                    594: |Cygwin                                |   Mar 2013    |README.Cygwin         |
                    595: |--------------------------------------+---------------+----------------------|
                    596: |GNU/kFreeBSD                          |   Jul 2013    |README.GNUkFreeBSD    |
1.104     sevan     597: |--------------------------------------+---------------+----------------------|
                    598: |Bitrig                                |   Jun 2014    |README.Bitrig         |
1.92      sevan     599: +-----------------------------------------------------------------------------+
1.1       dsieger   600: 
                    601: 
                    602: 1.2. Overview
                    603: 
                    604: This document is divided into three parts. The first, The pkgsrc user's guide,
                    605: describes how one can use one of the packages in the Package Collection, either
                    606: by installing a precompiled binary package, or by building one's own copy using
                    607: the NetBSD package system. The second part, The pkgsrc developer's guide,
                    608: explains how to prepare a package so it can be easily built by other NetBSD
                    609: users without knowing about the package's building details. The third part, The
                    610: pkgsrc infrastructure internals is intended for those who want to understand
                    611: how pkgsrc is implemented.
                    612: 
                    613: This document is available in various formats: HTML, PDF, PS, TXT.
                    614: 
                    615: 1.3. Terminology
                    616: 
                    617: There has been a lot of talk about "ports", "packages", etc. so far. Here is a
                    618: description of all the terminology used within this document.
                    619: 
                    620: Package
                    621: 
                    622:     A set of files and building instructions that describe what's necessary to
                    623:     build a certain piece of software using pkgsrc. Packages are traditionally
1.123     wiz       624:     stored under /usr/pkgsrc, but may be stored in any location, referred to as
                    625:     PKGSRCDIR.
1.1       dsieger   626: 
                    627: The NetBSD package system
                    628: 
                    629:     This is the former name of "pkgsrc". It is part of the NetBSD operating
                    630:     system and can be bootstrapped to run on non-NetBSD operating systems as
                    631:     well. It handles building (compiling), installing, and removing of
                    632:     packages.
                    633: 
                    634: Distfile
                    635: 
                    636:     This term describes the file or files that are provided by the author of
                    637:     the piece of software to distribute his work. All the changes necessary to
                    638:     build on NetBSD are reflected in the corresponding package. Usually the
                    639:     distfile is in the form of a compressed tar-archive, but other types are
                    640:     possible, too. Distfiles are usually stored below /usr/pkgsrc/distfiles.
                    641: 
                    642: Port
                    643: 
                    644:     This is the term used by FreeBSD and OpenBSD people for what we call a
                    645:     package. In NetBSD terminology, "port" refers to a different architecture.
                    646: 
                    647: Precompiled/binary package
                    648: 
                    649:     A set of binaries built with pkgsrc from a distfile and stuffed together in
                    650:     a single .tgz file so it can be installed on machines of the same machine
                    651:     architecture without the need to recompile. Packages are usually generated
                    652:     in /usr/pkgsrc/packages; there is also an archive on ftp.NetBSD.org.
                    653: 
                    654:     Sometimes, this is referred to by the term "package" too, especially in the
                    655:     context of precompiled packages.
                    656: 
                    657: Program
                    658: 
                    659:     The piece of software to be installed which will be constructed from all
                    660:     the files in the distfile by the actions defined in the corresponding
                    661:     package.
                    662: 
                    663: 1.3.1. Roles involved in pkgsrc
                    664: 
                    665: pkgsrc users
                    666: 
                    667:     The pkgsrc users are people who use the packages provided by pkgsrc.
                    668:     Typically they are system administrators. The people using the software
                    669:     that is inside the packages (maybe called "end users") are not covered by
                    670:     the pkgsrc guide.
                    671: 
                    672:     There are two kinds of pkgsrc users: Some only want to install pre-built
                    673:     binary packages. Others build the pkgsrc packages from source, either for
                    674:     installing them directly or for building binary packages themselves. For
                    675:     pkgsrc users Part I, "The pkgsrc user's guide" should provide all necessary
                    676:     documentation.
                    677: 
                    678: package maintainers
                    679: 
                    680:     A package maintainer creates packages as described in Part II, "The pkgsrc
                    681:     developer's guide".
                    682: 
                    683: infrastructure developers
                    684: 
                    685:     These people are involved in all those files that live in the mk/ directory
                    686:     and below. Only these people should need to read through Part III, "The
                    687:     pkgsrc infrastructure internals", though others might be curious, too.
                    688: 
                    689: 1.4. Typography
                    690: 
                    691: When giving examples for commands, shell prompts are used to show if the
                    692: command should/can be issued as root, or if "normal" user privileges are
1.115     sevan     693: sufficient. We use a # for root's shell prompt, a % for users' shell prompt,
                    694: assuming they use the C-shell or tcsh and a $ for bourne shell and derivatives.
1.1       dsieger   695: 
                    696: Part I. The pkgsrc user's guide
                    697: 
                    698: Table of Contents
                    699: 
1.154     rillig    700: 2. Getting help
                    701: 3. Where to get pkgsrc and how to keep it up-to-date
1.1       dsieger   702: 
1.154     rillig    703:     3.1. Getting pkgsrc for the first time
1.1       dsieger   704: 
1.154     rillig    705:         3.1.1. As tar archive
                    706:         3.1.2. Via anonymous CVS
1.1       dsieger   707: 
1.154     rillig    708:     3.2. Keeping pkgsrc up-to-date
1.1       dsieger   709: 
1.154     rillig    710:         3.2.1. Via tar files
                    711:         3.2.2. Via CVS
1.1       dsieger   712: 
1.154     rillig    713: 4. Using pkgsrc on systems other than NetBSD
1.1       dsieger   714: 
1.154     rillig    715:     4.1. Binary distribution
                    716:     4.2. Bootstrapping pkgsrc
1.1       dsieger   717: 
1.154     rillig    718: 5. Using pkgsrc
1.1       dsieger   719: 
1.154     rillig    720:     5.1. Using binary packages
1.1       dsieger   721: 
1.154     rillig    722:         5.1.1. Finding binary packages
                    723:         5.1.2. Installing binary packages
                    724:         5.1.3. Deinstalling packages
                    725:         5.1.4. Getting information about installed packages
                    726:         5.1.5. Checking for security vulnerabilities in installed packages
                    727:         5.1.6. Finding if newer versions of your installed packages are in
1.1       dsieger   728:             pkgsrc
1.154     rillig    729:         5.1.7. Other administrative functions
1.1       dsieger   730: 
1.154     rillig    731:     5.2. Building packages from source
1.1       dsieger   732: 
1.154     rillig    733:         5.2.1. Requirements
                    734:         5.2.2. Fetching distfiles
                    735:         5.2.3. How to build and install
1.1       dsieger   736: 
1.154     rillig    737: 6. Configuring pkgsrc
1.1       dsieger   738: 
1.154     rillig    739:     6.1. General configuration
                    740:     6.2. Variables affecting the build process
                    741:     6.3. Variables affecting the installation process
                    742:     6.4. Selecting and configuring the compiler
1.1       dsieger   743: 
1.154     rillig    744:         6.4.1. Selecting the compiler
                    745:         6.4.2. Additional flags to the compiler (CFLAGS)
                    746:         6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger   747: 
1.154     rillig    748:     6.5. Developer/advanced settings
                    749:     6.6. Selecting Build Options
1.1       dsieger   750: 
1.154     rillig    751: 7. Creating binary packages
1.1       dsieger   752: 
1.154     rillig    753:     7.1. Building a single binary package
                    754:     7.2. Settings for creation of binary packages
1.1       dsieger   755: 
1.154     rillig    756: 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig    757: 
1.154     rillig    758:     8.1. Preparations
1.180     rillig    759:     8.2. Running a bulk build
1.6       rillig    760: 
1.154     rillig    761:         8.2.1. Configuration
1.6       rillig    762: 
1.154     rillig    763:     8.3. Requirements of a full bulk build
1.178     rillig    764:     8.4. Bulk build variants
                    765: 
1.179     rillig    766:         8.4.1. Detect unknown configure options
                    767:         8.4.2. Detect classes of bugs by forcing compiler warnings
1.181     rillig    768:         8.4.3. Force compiler options only in the build phase
                    769:         8.4.4. Use custom directories
                    770:         8.4.5. Turn warnings into errors
                    771:         8.4.6. Reject packages for which pkglint reports errors
                    772:         8.4.7. Reject packages that contain forbidden strings
                    773:         8.4.8. Reject packages whose self-test fails
                    774:         8.4.9. Reject packages that use undefined shell variables
                    775:         8.4.10. Turn off verbose logging
1.6       rillig    776: 
1.178     rillig    777:     8.5. Creating a multiple CD-ROM packages collection
                    778: 
                    779:         8.5.1. Example of cdpack
1.6       rillig    780: 
1.154     rillig    781: 9. Directory layout of the installed files
1.6       rillig    782: 
1.154     rillig    783:     9.1. File system layout in ${LOCALBASE}
                    784:     9.2. File system layout in ${VARBASE}
1.6       rillig    785: 
1.154     rillig    786: 10. Frequently Asked Questions
1.6       rillig    787: 
1.154     rillig    788:     10.1. Are there any mailing lists for pkg-related discussion?
                    789:     10.2. Utilities for package management (pkgtools)
                    790:     10.3. How to use pkgsrc as non-root
                    791:     10.4. How to resume transfers when fetching distfiles?
                    792:     10.5. How can I install/use modular X.org from pkgsrc?
                    793:     10.6. How to fetch files from behind a firewall
                    794:     10.7. How to fetch files from HTTPS sites
                    795:     10.8. How do I tell make fetch to do passive FTP?
                    796:     10.9. How to fetch all distfiles at once
                    797:     10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
                    798:     10.11. What does "Could not find bsd.own.mk" mean?
                    799:     10.12. Using 'sudo' with pkgsrc
                    800:     10.13. How do I change the location of configuration files?
                    801:     10.14. Automated security checks
                    802:     10.15. Why do some packages ignore my CFLAGS?
                    803:     10.16. A package does not build. What shall I do?
                    804:     10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24      wiz       805:         conflicts" mean?
1.1       dsieger   806: 
1.154     rillig    807: Chapter 2. Getting help
                    808: 
                    809: To get help when using pkgsrc, the definitive source is this document, the
                    810: pkgsrc guide. If you don't find anything here, there are alternatives:
                    811: 
                    812:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
                    813:     Run bmake help topic=? to get help for any topic, such as a variable name
                    814:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                    815:     like strcasecmp or any other topic.
                    816: 
                    817:     The available help topics are listed in Appendix D, Help topics.
                    818: 
1.163     rillig    819:   * To see the value of a single variable, run bmake show-var VARNAME=X.
                    820: 
                    821:   * To see the values of the most common variables, run bmake show-all. These
                    822:     variables are grouped by topic. To see the variables for a single topic,
                    823:     run bmake show-all-topic, for example bmake show-all-fetch.
                    824: 
1.154     rillig    825:   * The pkgsrc-users mailing list, to which you can subscribe and then ask your
                    826:     questions.
                    827: 
                    828:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                    829:     a specialized chat program such as XChat. Pick any user name and join the
                    830:     channel #pkgsrc.
                    831: 
                    832: Chapter 3. Where to get pkgsrc and how to keep it up-to-date
1.1       dsieger   833: 
                    834: Table of Contents
                    835: 
1.154     rillig    836: 3.1. Getting pkgsrc for the first time
1.1       dsieger   837: 
1.154     rillig    838:     3.1.1. As tar archive
                    839:     3.1.2. Via anonymous CVS
1.1       dsieger   840: 
1.154     rillig    841: 3.2. Keeping pkgsrc up-to-date
1.1       dsieger   842: 
1.154     rillig    843:     3.2.1. Via tar files
                    844:     3.2.2. Via CVS
1.1       dsieger   845: 
                    846: Before you download and extract the files, you need to decide where you want to
                    847: extract them. When using pkgsrc as root user, pkgsrc is usually installed in /
                    848: usr/pkgsrc. You are though free to install the sources and binary packages
                    849: wherever you want in your filesystem, provided that the pathname does not
                    850: contain white-space or other characters that are interpreted specially by the
                    851: shell and some other programs. A safe bet is to use only letters, digits,
                    852: underscores and dashes.
                    853: 
1.154     rillig    854: 3.1. Getting pkgsrc for the first time
1.1       dsieger   855: 
1.25      wiz       856: Before you download any pkgsrc files, you should decide whether you want the 
1.1       dsieger   857: current branch or the stable branch. The latter is forked on a quarterly basis
                    858: from the current branch and only gets modified for security updates. The names
                    859: of the stable branches are built from the year and the quarter, for example
1.174     leot      860: 2020Q1.
1.1       dsieger   861: 
                    862: The second step is to decide how you want to download pkgsrc. You can get it as
1.24      wiz       863: a tar file or via CVS. Both ways are described here.
1.1       dsieger   864: 
1.52      asau      865: Note that tar archive contains CVS working copy. Thus you can switch to using
                    866: CVS at any later time.
1.1       dsieger   867: 
1.154     rillig    868: 3.1.1. As tar archive
1.52      asau      869: 
1.151     sevan     870: The primary download location for all pkgsrc files is https://cdn.NetBSD.org/
                    871: pub/pkgsrc/ or ftp://ftp.NetBSD.org/pub/pkgsrc/ (it points to the same
                    872: location). There are a number of subdirectories for different purposes, which
                    873: are described in detail in Appendix C, Directory layout of the pkgsrc FTP
                    874: server.
1.1       dsieger   875: 
1.52      asau      876: The tar archive for the current branch is in the directory current and is
1.118     sevan     877: called pkgsrc.tar.gz. It is autogenerated weekly.
1.52      asau      878: 
                    879: To save download time we provide bzip2- and xz-compressed archives which are
                    880: published at pkgsrc.tar.bz2 and pkgsrc.tar.xz respectively.
                    881: 
                    882: You can fetch the same files using FTP.
1.1       dsieger   883: 
1.174     leot      884: The tar file for the stable branch 2020Q1 is in the directory pkgsrc-2020Q1 and
1.59      jnemeth   885: is also called pkgsrc.tar.gz.
1.1       dsieger   886: 
1.136     leot      887: To download the latest pkgsrc stable tarball, run:
1.12      weinem    888: 
1.174     leot      889: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/pkgsrc-2020Q1/pkgsrc.tar.gz
1.12      weinem    890: 
1.78      snj       891: If you prefer, you can also fetch it using "wget", "curl", or your web browser.
1.52      asau      892: 
1.12      weinem    893: Then, extract it with:
                    894: 
1.78      snj       895: $ tar -xzf pkgsrc.tar.gz -C /usr
1.12      weinem    896: 
                    897: This will create the directory pkgsrc/ in /usr/ and all the package source will
                    898: be stored under /usr/pkgsrc/.
                    899: 
                    900: To download pkgsrc-current, run:
                    901: 
                    902: $ ftp ftp://ftp.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz
1.1       dsieger   903: 
1.154     rillig    904: 3.1.2. Via anonymous CVS
1.1       dsieger   905: 
1.24      wiz       906: To fetch a specific pkgsrc stable branch, run:
1.1       dsieger   907: 
1.174     leot      908: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -r pkgsrc-2020Q1 -P pkgsrc
1.13      weinem    909: 
1.24      wiz       910: This will create the directory pkgsrc/ in your /usr/ directory and all the
                    911: package source will be stored under /usr/pkgsrc/.
                    912: 
                    913: To fetch the pkgsrc current branch, run:
1.1       dsieger   914: 
1.40      wiz       915: $ cd /usr && cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   916: 
1.30      dholland  917: Refer to the list of available mirrors to choose a faster CVS mirror, if
                    918: needed.
1.1       dsieger   919: 
1.24      wiz       920: If you get error messages from rsh, you need to set CVS_RSH variable. E.g.:
1.1       dsieger   921: 
1.40      wiz       922: $ cd /usr && env CVS_RSH=ssh cvs -q -z2 -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger   923: 
1.24      wiz       924: Refer to documentation on your command shell how to set CVS_RSH=ssh
                    925: permanently. For Bourne shells, you can set it in your .profile or better
                    926: globally in /etc/profile:
                    927: 
                    928: # set CVS remote shell command
                    929: CVS_RSH=ssh
                    930: export CVS_RSH
1.12      weinem    931: 
1.13      weinem    932: By default, CVS doesn't do things like most people would expect it to do. But
                    933: there is a way to convince CVS, by creating a file called .cvsrc in your home
1.12      weinem    934: directory and saving the following lines to it. This file will save you lots of
                    935: headache and some bug reports, so we strongly recommend it. You can find an
                    936: explanation of this file in the CVS documentation.
1.2       rillig    937: 
                    938: # recommended CVS configuration file from the pkgsrc guide
1.155     sevan     939: cvs -q
1.2       rillig    940: checkout -P
1.4       rillig    941: update -dP
                    942: diff -upN
1.2       rillig    943: rdiff -u
1.24      wiz       944: release -d
1.1       dsieger   945: 
1.154     rillig    946: 3.2. Keeping pkgsrc up-to-date
1.1       dsieger   947: 
                    948: The preferred way to keep pkgsrc up-to-date is via CVS (which also works if you
                    949: have first installed it via a tar file). It saves bandwidth and hard disk
                    950: activity, compared to downloading the tar file again.
                    951: 
1.154     rillig    952: 3.2.1. Via tar files
1.1       dsieger   953: 
                    954: Warning
                    955: 
                    956: When updating from a tar file, you first need to completely remove the old
                    957: pkgsrc directory. Otherwise those files that have been removed from pkgsrc in
                    958: the mean time will not be removed on your local disk, resulting in
                    959: inconsistencies. When removing the old files, any changes that you have done to
                    960: the pkgsrc files will be lost after updating. Therefore updating via CVS is
                    961: strongly recommended.
                    962: 
                    963: Note that by default the distfiles and the binary packages are saved in the
                    964: pkgsrc tree, so don't forget to rescue them before updating. You can also
1.78      snj       965: configure pkgsrc to store distfiles and packages in directories outside the
1.154     rillig    966: pkgsrc tree by setting the DISTDIR and PACKAGES variables. See Chapter 6, 
1.78      snj       967: Configuring pkgsrc for the details.
1.1       dsieger   968: 
                    969: To update pkgsrc from a tar file, download the tar file as explained above.
                    970: Then, make sure that you have not made any changes to the files in the pkgsrc
                    971: directory. Remove the pkgsrc directory and extract the new tar file. Done.
                    972: 
1.154     rillig    973: 3.2.2. Via CVS
1.1       dsieger   974: 
1.26      spz       975: To update pkgsrc via CVS, change to the pkgsrc directory and run cvs:
1.12      weinem    976: 
1.26      spz       977: $ cd /usr/pkgsrc && cvs update -dP
                    978: 
                    979: If you get error messages from rsh, you need to set CVS_RSH variable as
                    980: described above. E.g.:
                    981: 
                    982: $ cd /usr/pkgsrc && env CVS_RSH=ssh cvs up -dP
1.1       dsieger   983: 
1.154     rillig    984: 3.2.2.1. Switching between different pkgsrc branches
1.1       dsieger   985: 
                    986: When updating pkgsrc, the CVS program keeps track of the branch you selected.
                    987: But if you, for whatever reason, want to switch from the stable branch to the
                    988: current one, you can do it by adding the option "-A" after the "update"
1.25      wiz       989: keyword. To switch from the current branch back to the stable branch, add the "
1.174     leot      990: -rpkgsrc-2020Q1" option.
1.1       dsieger   991: 
1.154     rillig    992: 3.2.2.2. What happens to my changes when updating?
1.1       dsieger   993: 
                    994: When you update pkgsrc, the CVS program will only touch those files that are
                    995: registered in the CVS repository. That means that any packages that you created
                    996: on your own will stay unmodified. If you change files that are managed by CVS,
                    997: later updates will try to merge your changes with those that have been done by
                    998: others. See the CVS manual, chapter "update" for details.
                    999: 
1.154     rillig   1000: Chapter 4. Using pkgsrc on systems other than NetBSD
1.1       dsieger  1001: 
                   1002: Table of Contents
                   1003: 
1.154     rillig   1004: 4.1. Binary distribution
                   1005: 4.2. Bootstrapping pkgsrc
1.1       dsieger  1006: 
1.154     rillig   1007: 4.1. Binary distribution
1.1       dsieger  1008: 
1.154     rillig   1009: See Section 5.1, "Using binary packages".
1.1       dsieger  1010: 
1.154     rillig   1011: 4.2. Bootstrapping pkgsrc
1.1       dsieger  1012: 
1.44      asau     1013: pkgsrc can be bootstrapped for use in two different modes: privileged and
                   1014: unprivileged one. In unprivileged mode in contrast to privileged one all
1.45      asau     1015: programs are installed under one particular user and cannot utilise privileged
1.44      asau     1016: operations (packages don't create special users and all special file
                   1017: permissions like setuid are ignored).
                   1018: 
1.1       dsieger  1019: Installing the bootstrap kit from source should be as simple as:
                   1020: 
1.60      asau     1021: # env CVS_RSH=ssh cvs -d anoncvs@anoncvs.NetBSD.org:/cvsroot checkout -P pkgsrc
1.1       dsieger  1022: # cd pkgsrc/bootstrap
                   1023: # ./bootstrap
                   1024: 
                   1025: 
1.44      asau     1026: To bootstrap in unprivileged mode pass "--unprivileged" flag to bootstrap
                   1027: 
                   1028: By default, in privileged mode pkgsrc uses /usr/pkg for prefix where programs
1.118     sevan    1029: will be installed in, and /usr/pkg/pkgdb for the package database directory
                   1030: where pkgsrc will do its internal bookkeeping, /var is used as varbase, where
1.44      asau     1031: packages install their persistent data. In unprivileged mode pkgsrc uses ~/pkg
1.118     sevan    1032: for prefix, ~/pkg/pkgdb for the package database, and ~/pkg/var for varbase.
1.44      asau     1033: 
                   1034: You can change default layout using command-line arguments. Run "./bootstrap
                   1035: --help" to get details.
1.1       dsieger  1036: 
                   1037: Note
                   1038: 
                   1039: The bootstrap installs a bmake tool. Use this bmake when building via pkgsrc.
                   1040: For examples in this guide, use bmake instead of "make".
                   1041: 
1.44      asau     1042: Note
                   1043: 
                   1044: It is possible to bootstrap multiple instances of pkgsrc using non-intersecting
                   1045: directories. Use bmake corresponding to the installation you're working with to
                   1046: build and install packages.
                   1047: 
1.154     rillig   1048: Chapter 5. Using pkgsrc
1.1       dsieger  1049: 
                   1050: Table of Contents
                   1051: 
1.154     rillig   1052: 5.1. Using binary packages
1.1       dsieger  1053: 
1.154     rillig   1054:     5.1.1. Finding binary packages
                   1055:     5.1.2. Installing binary packages
                   1056:     5.1.3. Deinstalling packages
                   1057:     5.1.4. Getting information about installed packages
                   1058:     5.1.5. Checking for security vulnerabilities in installed packages
                   1059:     5.1.6. Finding if newer versions of your installed packages are in pkgsrc
                   1060:     5.1.7. Other administrative functions
                   1061: 
                   1062: 5.2. Building packages from source
                   1063: 
                   1064:     5.2.1. Requirements
                   1065:     5.2.2. Fetching distfiles
                   1066:     5.2.3. How to build and install
1.1       dsieger  1067: 
                   1068: Basically, there are two ways of using pkgsrc. The first is to only install the
                   1069: package tools and to use binary packages that someone else has prepared. This
                   1070: is the "pkg" in pkgsrc. The second way is to install the "src" of pkgsrc, too.
                   1071: Then you are able to build your own packages, and you can still use binary
                   1072: packages from someone else.
                   1073: 
1.154     rillig   1074: 5.1. Using binary packages
1.1       dsieger  1075: 
1.151     sevan    1076: On the cdn.NetBSD.org site and mirrors, there are collections of binary
1.9       rillig   1077: packages, ready to be installed. These binary packages have been built using
                   1078: the default settings for the directories, that is:
                   1079: 
                   1080:   * /usr/pkg for LOCALBASE, where most of the files are installed,
                   1081: 
                   1082:   * /usr/pkg/etc for configuration files,
                   1083: 
                   1084:   * /var for VARBASE, where those files are installed that may change after
                   1085:     installation.
                   1086: 
                   1087: If you cannot use these directories for whatever reasons (maybe because you're
                   1088: not root), you cannot use these binary packages, but have to build the packages
1.154     rillig   1089: yourself, which is explained in Section 4.2, "Bootstrapping pkgsrc".
1.1       dsieger  1090: 
1.154     rillig   1091: 5.1.1. Finding binary packages
1.1       dsieger  1092: 
1.5       weinem   1093: To install binary packages, you first need to know from where to get them. The
                   1094: first place where you should look is on the main pkgsrc FTP server in the
                   1095: directory /pub/pkgsrc/packages.
                   1096: 
                   1097: This directory contains binary packages for multiple platforms. First, select
                   1098: your operating system. (Ignore the directories with version numbers attached to
                   1099: it, they just exist for legacy reasons.) Then, select your hardware
                   1100: architecture, and in the third step, the OS version and the "version" of
1.9       rillig   1101: pkgsrc.
                   1102: 
                   1103: In this directory, you often find a file called bootstrap.tar.gz which contains
                   1104: the package management tools. If the file is missing, it is likely that your
                   1105: operating system already provides those tools. Download the file and extract it
                   1106: in the / directory. It will create the directories /usr/pkg (containing the
1.118     sevan    1107: tools for managing binary packages and the database of installed packages).
1.1       dsieger  1108: 
1.154     rillig   1109: 5.1.2. Installing binary packages
1.1       dsieger  1110: 
1.85      wiz      1111: In the directory from the last section, there is a subdirectory called All/,
1.9       rillig   1112: which contains all the binary packages that are available for the platform,
                   1113: excluding those that may not be distributed via FTP or CDROM (depending on
1.24      wiz      1114: which medium you are using).
1.9       rillig   1115: 
                   1116: To install packages directly from an FTP or HTTP server, run the following
                   1117: commands in a Bourne-compatible shell (be sure to su to root first):
                   1118: 
                   1119: # PATH="/usr/pkg/sbin:$PATH"
1.179     rillig   1120: 
                   1121: # PKG_PATH="http://cdn.NetBSD.org/pub/pkgsrc/packages"
1.169     rillig   1122: # PKG_PATH="$PKG_PATH/OPSYS/ARCH/VERSIONS/All/"
1.9       rillig   1123: # export PATH PKG_PATH
                   1124: 
                   1125: Instead of URLs, you can also use local paths, for example if you are
                   1126: installing from a set of CDROMs, DVDs or an NFS-mounted repository. If you want
                   1127: to install packages from multiple sources, you can separate them by a semicolon
                   1128: in PKG_PATH.
                   1129: 
                   1130: After these preparations, installing a package is very easy:
                   1131: 
1.118     sevan    1132: # pkg_add libreoffice
                   1133: # pkg_add ap24-php71-*
1.1       dsieger  1134: 
                   1135: Note that any prerequisite packages needed to run the package in question will
                   1136: be installed, too, assuming they are present where you install from.
                   1137: 
1.25      wiz      1138: Adding packages might install vulnerable packages. Thus you should run 
1.24      wiz      1139: pkg_admin audit regularly, especially after installing new packages, and verify
                   1140: that the vulnerabilities are acceptable for your configuration.
1.1       dsieger  1141: 
                   1142: After you've installed packages, be sure to have /usr/pkg/bin and /usr/pkg/sbin
                   1143: in your PATH so you can actually start the just installed program.
                   1144: 
1.154     rillig   1145: 5.1.3. Deinstalling packages
1.1       dsieger  1146: 
                   1147: To deinstall a package, it does not matter whether it was installed from source
                   1148: code or from a binary package. The pkg_delete command does not know it anyway.
                   1149: To delete a package, you can just run pkg_delete package-name. The package name
                   1150: can be given with or without version number. Wildcards can also be used to
                   1151: deinstall a set of packages, for example *emacs*. Be sure to include them in
                   1152: quotes, so that the shell does not expand them before pkg_delete sees them.
                   1153: 
                   1154: The -r option is very powerful: it removes all the packages that require the
                   1155: package in question and then removes the package itself. For example:
                   1156: 
                   1157: # pkg_delete -r jpeg
                   1158: 
                   1159: 
                   1160: will remove jpeg and all the packages that used it; this allows upgrading the
                   1161: jpeg package.
                   1162: 
1.154     rillig   1163: 5.1.4. Getting information about installed packages
1.1       dsieger  1164: 
                   1165: The pkg_info shows information about installed packages or binary package
                   1166: files.
                   1167: 
1.154     rillig   1168: 5.1.5. Checking for security vulnerabilities in installed packages
1.1       dsieger  1169: 
1.164     leot     1170: The pkgsrc Security Team and Packages Groups maintain a list of known security
                   1171: vulnerabilities to packages which are (or have been) included in pkgsrc. The
1.179     rillig   1172: list is available from the NetBSD FTP site at http://ftp.NetBSD.org/pub/NetBSD/
                   1173: packages/vulns/pkg-vulnerabilities.
1.1       dsieger  1174: 
1.23      jakllsch 1175: Through pkg_admin fetch-pkg-vulnerabilities, this list can be downloaded
                   1176: automatically, and a security audit of all packages installed on a system can
                   1177: take place.
                   1178: 
                   1179: There are two components to auditing. The first step, pkg_admin
                   1180: fetch-pkg-vulnerabilities, is for downloading the list of vulnerabilities from
                   1181: the NetBSD FTP site. The second step, pkg_admin audit, checks to see if any of
                   1182: your installed packages are vulnerable. If a package is vulnerable, you will
                   1183: see output similar to the following:
1.1       dsieger  1184: 
                   1185: Package samba-2.0.9 has a local-root-shell vulnerability, see
1.174     leot     1186:     https://www.samba.org/samba/whatsnew/macroexploit.html
1.1       dsieger  1187: 
1.23      jakllsch 1188: You may wish to have the vulnerabilities file downloaded daily so that it
                   1189: remains current. This may be done by adding an appropriate entry to the root
                   1190: users crontab(5) entry. For example the entry
                   1191: 
1.121     sevan    1192: # Download vulnerabilities file
1.118     sevan    1193: 0 3 * * * /usr/pkg/sbin/pkg_admin fetch-pkg-vulnerabilities >/dev/null 2>&1
1.121     sevan    1194: # Audit the installed packages and email results to root
                   1195: 9 3 * * * /usr/pkg/sbin/pkg_admin audit |mail -s "Installed package audit result" \
                   1196:             root >/dev/null 2>&1
1.118     sevan    1197: 
                   1198: 
                   1199: will update the vulnerability list every day at 3AM, followed by an audit at
                   1200: 3:09AM. The result of the audit are then emailed to root. On NetBSD this may be
                   1201: accomplished instead by adding the following line to /etc/daily.conf:
                   1202: 
                   1203: fetch_pkg_vulnerabilities=YES
                   1204: 
1.23      jakllsch 1205: 
1.118     sevan    1206: to fetch the vulnerability list from the daily security script. The system is
                   1207: set to audit the packages by default but can be set explicitly, if desired (not
1.123     wiz      1208: required), by adding the following line to /etc/security.conf:
1.23      jakllsch 1209: 
1.118     sevan    1210: check_pkg_vulnerabilities=YES
1.23      jakllsch 1211: 
                   1212: 
1.118     sevan    1213: see daily.conf(5) and security.conf(5) for more details.
1.1       dsieger  1214: 
1.154     rillig   1215: 5.1.6. Finding if newer versions of your installed packages are in pkgsrc
1.1       dsieger  1216: 
1.12      weinem   1217: Install pkgtools/lintpkgsrc and run lintpkgsrc with the "-i" argument to check
                   1218: if your packages are up-to-date, e.g.
1.1       dsieger  1219: 
                   1220: % lintpkgsrc -i
                   1221: ...
                   1222: Version mismatch: 'tcsh' 6.09.00 vs 6.10.00
                   1223: 
                   1224: 
                   1225: You can then use make update to update the package on your system and rebuild
                   1226: any dependencies.
                   1227: 
1.154     rillig   1228: 5.1.7. Other administrative functions
1.1       dsieger  1229: 
                   1230: The pkg_admin executes various administrative functions on the package system.
                   1231: 
1.154     rillig   1232: 5.2. Building packages from source
1.1       dsieger  1233: 
                   1234: After obtaining pkgsrc, the pkgsrc directory now contains a set of packages,
1.25      wiz      1235: organized into categories. You can browse the online index of packages, or run 
1.1       dsieger  1236: make readme from the pkgsrc directory to build local README.html files for all
                   1237: packages, viewable with any web browser such as www/lynx or www/firefox.
                   1238: 
                   1239: The default prefix for installed packages is /usr/pkg. If you wish to change
                   1240: this, you should do so by setting LOCALBASE in mk.conf. You should not try to
                   1241: use multiple different LOCALBASE definitions on the same system (inside a
                   1242: chroot is an exception).
                   1243: 
                   1244: The rest of this chapter assumes that the package is already in pkgsrc. If it
                   1245: is not, see Part II, "The pkgsrc developer's guide" for instructions how to
                   1246: create your own packages.
                   1247: 
1.154     rillig   1248: 5.2.1. Requirements
1.1       dsieger  1249: 
                   1250: To build packages from source, you need a working C compiler. On NetBSD, you
                   1251: need to install the "comp" and the "text" distribution sets. If you want to
                   1252: build X11-related packages, the "xbase" and "xcomp" distribution sets are
                   1253: required, too.
                   1254: 
1.154     rillig   1255: 5.2.2. Fetching distfiles
1.1       dsieger  1256: 
                   1257: The first step for building a package is downloading the distfiles (i.e. the
                   1258: unmodified source). If they have not yet been downloaded, pkgsrc will fetch
                   1259: them automatically.
                   1260: 
                   1261: If you have all files that you need in the distfiles directory, you don't need
                   1262: to connect. If the distfiles are on CD-ROM, you can mount the CD-ROM on /cdrom
                   1263: and add:
                   1264: 
                   1265: DISTDIR=/cdrom/pkgsrc/distfiles
                   1266: 
                   1267: to your mk.conf.
                   1268: 
                   1269: By default a list of distribution sites will be randomly intermixed to prevent
                   1270: huge load on servers which holding popular packages (for example,
                   1271: SourceForge.net mirrors). Thus, every time when you need to fetch yet another
                   1272: distfile all the mirrors will be tried in new (random) order. You can turn this
                   1273: feature off by setting MASTER_SORT_RANDOM=NO (for PKG_DEVELOPERs it's already
                   1274: disabled).
                   1275: 
                   1276: You can overwrite some of the major distribution sites to fit to sites that are
                   1277: close to your own. By setting one or two variables you can modify the order in
                   1278: which the master sites are accessed. MASTER_SORT contains a whitespace
                   1279: delimited list of domain suffixes. MASTER_SORT_REGEX is even more flexible, it
                   1280: contains a whitespace delimited list of regular expressions. It has higher
                   1281: priority than MASTER_SORT. Have a look at pkgsrc/mk/defaults/mk.conf to find
                   1282: some examples. This may save some of your bandwidth and time.
                   1283: 
                   1284: You can change these settings either in your shell's environment, or, if you
1.4       rillig   1285: want to keep the settings, by editing the mk.conf file, and adding the
1.1       dsieger  1286: definitions there.
                   1287: 
1.132     wiz      1288: If a package depends on many other packages (such as meta-pkgs/kde4), the build
1.1       dsieger  1289: process may alternate between periods of downloading source, and compiling. To
                   1290: ensure you have all the source downloaded initially you can run the command:
                   1291: 
                   1292: % make fetch-list | sh
                   1293: 
                   1294: which will output and run a set of shell commands to fetch the necessary files
                   1295: into the distfiles directory. You can also choose to download the files
                   1296: manually.
                   1297: 
1.154     rillig   1298: 5.2.3. How to build and install
1.1       dsieger  1299: 
                   1300: Once the software has downloaded, any patches will be applied, then it will be
                   1301: compiled for you. This may take some time depending on your computer, and how
                   1302: many other packages the software depends on and their compile time.
                   1303: 
                   1304: Note
                   1305: 
                   1306: If using bootstrap or pkgsrc on a non-NetBSD system, use the pkgsrc bmake
                   1307: command instead of "make" in the examples in this guide.
                   1308: 
                   1309: For example, type
                   1310: 
                   1311: % cd misc/figlet
                   1312: % make
                   1313: 
                   1314: 
                   1315: at the shell prompt to build the various components of the package.
                   1316: 
                   1317: The next stage is to actually install the newly compiled program onto your
                   1318: system. Do this by entering:
                   1319: 
                   1320: % make install
                   1321: 
                   1322: 
                   1323: while you are still in the directory for whatever package you are installing.
                   1324: 
                   1325: Installing the package on your system may require you to be root. However,
                   1326: pkgsrc has a just-in-time-su feature, which allows you to only become root for
                   1327: the actual installation step.
                   1328: 
                   1329: That's it, the software should now be installed and setup for use. You can now
                   1330: enter:
                   1331: 
                   1332: % make clean
                   1333: 
                   1334: 
                   1335: to remove the compiled files in the work directory, as you shouldn't need them
                   1336: any more. If other packages were also added to your system (dependencies) to
                   1337: allow your program to compile, you can tidy these up also with the command:
                   1338: 
                   1339: % make clean-depends
                   1340: 
                   1341: 
                   1342: Taking the figlet utility as an example, we can install it on our system by
                   1343: building as shown in Appendix B, Build logs.
                   1344: 
                   1345: The program is installed under the default root of the packages tree - /usr/
                   1346: pkg. Should this not conform to your tastes, set the LOCALBASE variable in your
                   1347: environment, and it will use that value as the root of your packages tree. So,
                   1348: to use /usr/local, set LOCALBASE=/usr/local in your environment. Please note
                   1349: that you should use a directory which is dedicated to packages and not shared
                   1350: with other programs (i.e., do not try and use LOCALBASE=/usr). Also, you should
                   1351: not try to add any of your own files or directories (such as src/, obj/, or
                   1352: pkgsrc/) below the LOCALBASE tree. This is to prevent possible conflicts
                   1353: between programs and other files installed by the package system and whatever
                   1354: else may have been installed there.
                   1355: 
1.4       rillig   1356: Some packages look in mk.conf to alter some configuration options at build
1.1       dsieger  1357: time. Have a look at pkgsrc/mk/defaults/mk.conf to get an overview of what will
                   1358: be set there by default. Environment variables such as LOCALBASE can be set in
1.4       rillig   1359: mk.conf to save having to remember to set them each time you want to use
1.1       dsieger  1360: pkgsrc.
                   1361: 
                   1362: Occasionally, people want to "look under the covers" to see what is going on
                   1363: when a package is building or being installed. This may be for debugging
                   1364: purposes, or out of simple curiosity. A number of utility values have been
                   1365: added to help with this.
                   1366: 
                   1367:  1. If you invoke the make(1) command with PKG_DEBUG_LEVEL=2, then a huge
                   1368:     amount of information will be displayed. For example,
                   1369: 
                   1370:     make patch PKG_DEBUG_LEVEL=2
                   1371: 
1.25      wiz      1372:     will show all the commands that are invoked, up to and including the "patch
                   1373:     " stage.
1.1       dsieger  1374: 
                   1375:  2. If you want to know the value of a certain make(1) definition, then the
                   1376:     VARNAME definition should be used, in conjunction with the show-var target.
                   1377:     e.g. to show the expansion of the make(1) variable LOCALBASE:
                   1378: 
                   1379:     % make show-var VARNAME=LOCALBASE
                   1380:     /usr/pkg
                   1381:     %
                   1382: 
                   1383: 
                   1384: If you want to install a binary package that you've either created yourself
                   1385: (see next section), that you put into pkgsrc/packages manually or that is
                   1386: located on a remote FTP server, you can use the "bin-install" target. This
                   1387: target will install a binary package - if available - via pkg_add(1), else do a
                   1388: make package. The list of remote FTP sites searched is kept in the variable
                   1389: BINPKG_SITES, which defaults to ftp.NetBSD.org. Any flags that should be added
                   1390: to pkg_add(1) can be put into BIN_INSTALL_FLAGS. See pkgsrc/mk/defaults/mk.conf
                   1391: for more details.
                   1392: 
                   1393: A final word of warning: If you set up a system that has a non-standard setting
                   1394: for LOCALBASE, be sure to set that before any packages are installed, as you
                   1395: cannot use several directories for the same purpose. Doing so will result in
                   1396: pkgsrc not being able to properly detect your installed packages, and fail
                   1397: miserably. Note also that precompiled binary packages are usually built with
                   1398: the default LOCALBASE of /usr/pkg, and that you should not install any if you
                   1399: use a non-standard LOCALBASE.
                   1400: 
1.154     rillig   1401: Chapter 6. Configuring pkgsrc
1.1       dsieger  1402: 
                   1403: Table of Contents
                   1404: 
1.154     rillig   1405: 6.1. General configuration
                   1406: 6.2. Variables affecting the build process
                   1407: 6.3. Variables affecting the installation process
                   1408: 6.4. Selecting and configuring the compiler
                   1409: 
                   1410:     6.4.1. Selecting the compiler
                   1411:     6.4.2. Additional flags to the compiler (CFLAGS)
                   1412:     6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger  1413: 
1.154     rillig   1414: 6.5. Developer/advanced settings
                   1415: 6.6. Selecting Build Options
1.1       dsieger  1416: 
                   1417: The whole pkgsrc system is configured in a single file, usually called mk.conf.
                   1418: In which directory pkgsrc looks for that file depends on the installation. On
                   1419: NetBSD, when you use make(1) from the base system, it is in the directory /etc
                   1420: /. In all other cases the default location is ${PREFIX}/etc/, depending on
                   1421: where you told the bootstrap program to install the binary packages.
                   1422: 
                   1423: The format of the configuration file is that of the usual BSD-style Makefiles.
                   1424: The whole pkgsrc configuration is done by setting variables in this file. Note
                   1425: that you can define all kinds of variables, and no special error checking (for
1.112     rillig   1426: example for spelling mistakes) takes place.
1.1       dsieger  1427: 
1.154     rillig   1428: 6.1. General configuration
1.1       dsieger  1429: 
1.112     rillig   1430: The following variables apply to all pkgsrc packages. A complete list of the
                   1431: variables that can be configured by the user is available in mk/defaults/
                   1432: mk.conf, together with some comments that describe each variable's intent.
1.1       dsieger  1433: 
                   1434:   * LOCALBASE: Where packages will be installed. The default is /usr/pkg. Do
                   1435:     not mix binary packages with different LOCALBASEs!
                   1436: 
                   1437:   * CROSSBASE: Where "cross" category packages will be installed. The default
                   1438:     is ${LOCALBASE}/cross.
                   1439: 
1.84      wiz      1440:   * X11BASE: Where X11 is installed on the system. The default is /usr/X11R7.
1.1       dsieger  1441: 
                   1442:   * DISTDIR: Where to store the downloaded copies of the original source
                   1443:     distributions used for building pkgsrc packages. The default is $
                   1444:     {PKGSRCDIR}/distfiles.
                   1445: 
                   1446:   * PKG_DBDIR: Where the database about installed packages is stored. The
1.118     sevan    1447:     default is /usr/pkg/pkgdb.
1.1       dsieger  1448: 
                   1449:   * MASTER_SITE_OVERRIDE: If set, override the packages' MASTER_SITES with this
                   1450:     value.
                   1451: 
                   1452:   * MASTER_SITE_BACKUP: Backup location(s) for distribution files and patch
                   1453:     files if not found locally or in ${MASTER_SITES} or ${PATCH_SITES}
1.118     sevan    1454:     respectively. The defaults is ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/$
1.1       dsieger  1455:     {DIST_SUBDIR}/.
                   1456: 
                   1457:   * BINPKG_SITES: List of sites carrying binary pkgs. rel and arch are replaced
                   1458:     with OS release ("2.0", etc.) and architecture ("mipsel", etc.).
                   1459: 
1.23      jakllsch 1460:   * ACCEPTABLE_LICENSES: List of acceptable licenses. License names are
                   1461:     case-sensitive. Whenever you try to build a package whose license is not in
                   1462:     this list, you will get an error message. If the license condition is
                   1463:     simple enough, the error message will include specific instructions on how
                   1464:     to change this variable.
1.1       dsieger  1465: 
1.154     rillig   1466: 6.2. Variables affecting the build process
1.1       dsieger  1467: 
                   1468:   * PACKAGES: The top level directory for the binary packages. The default is $
                   1469:     {PKGSRCDIR}/packages.
                   1470: 
                   1471:   * WRKOBJDIR: The top level directory where, if defined, the separate working
                   1472:     directories will get created, and symbolically linked to from ${WRKDIR}
                   1473:     (see below). This is useful for building packages on several architectures,
                   1474:     then ${PKGSRCDIR} can be NFS-mounted while ${WRKOBJDIR} is local to every
                   1475:     architecture. (It should be noted that PKGSRCDIR should not be set by the
                   1476:     user ? it is an internal definition which refers to the root of the pkgsrc
                   1477:     tree. It is possible to have many pkgsrc tree instances.)
                   1478: 
                   1479:   * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
1.184     rillig   1480:     Section 12.3, "patches/*" for more information.
1.1       dsieger  1481: 
                   1482:   * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
                   1483:     Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
                   1484:     up settings used by builds in /usr/src.
                   1485: 
1.154     rillig   1486: 6.3. Variables affecting the installation process
1.1       dsieger  1487: 
1.143     maya     1488:   * PKGSRC_KEEP_BIN_PKGSRC: By default, binary packages of built packages are
1.150     leot     1489:     preserved in ${PACKAGES}/All. Setting this variable to "no" prevents this.
1.1       dsieger  1490: 
1.107     jnemeth  1491: Packages have to support installation into a subdirectory of WRKDIR. This
                   1492: allows a package to be built, before the actual filesystem is touched. DESTDIR
                   1493: support exists in two variations:
1.4       rillig   1494: 
                   1495:   * Basic DESTDIR support means that the package installation and packaging is
                   1496:     still run as root.
                   1497: 
                   1498:   * Full DESTDIR support can run the complete build, installation and packaging
                   1499:     as normal user. Root privileges are only needed to add packages.
                   1500: 
                   1501: With basic DESTDIR support, make clean needs to be run as root.
                   1502: 
1.17      imil     1503: Considering the foo/bar package, DESTDIR full support can be tested using the
                   1504: following commands
                   1505: 
                   1506: $ id
                   1507: uid=1000(myusername) gid=100(users) groups=100(users),0(wheel)
                   1508: $ mkdir $HOME/packages
                   1509: $ cd $PKGSRCDIR/foo/bar
                   1510: 
                   1511: Verify DESTDIR full support, no root privileges should be needed
                   1512: 
1.66      asau     1513: $ make stage-install
1.17      imil     1514: 
                   1515: Create a package without root privileges
                   1516: 
1.66      asau     1517: $ make PACKAGES=$HOME/packages package
1.17      imil     1518: 
                   1519: For the following command, you must be able to gain root privileges using su(1)
                   1520: 
1.66      asau     1521: $ make PACKAGES=$HOME/packages install
1.17      imil     1522: 
                   1523: Then, as a simple user
                   1524: 
                   1525: $ make clean
                   1526: 
1.154     rillig   1527: 6.4. Selecting and configuring the compiler
1.4       rillig   1528: 
1.154     rillig   1529: 6.4.1. Selecting the compiler
1.1       dsieger  1530: 
                   1531: By default, pkgsrc will use GCC to build packages. This may be overridden by
                   1532: setting the following variables in /etc/mk.conf:
                   1533: 
                   1534: PKGSRC_COMPILER:
                   1535: 
                   1536:     This is a list of values specifying the chain of compilers to invoke when
                   1537:     building packages. Valid values are:
                   1538: 
1.66      asau     1539:       + ccc: Compaq C Compilers (Tru64)
                   1540: 
                   1541:       + ccache: compiler cache (chainable)
                   1542: 
                   1543:       + clang: Clang C and Objective-C compiler
                   1544: 
1.42      asau     1545:       + distcc: distributed C/C++ (chainable)
1.1       dsieger  1546: 
1.66      asau     1547:       + f2c: Fortran 77 to C compiler (chainable)
                   1548: 
                   1549:       + icc: Intel C++ Compiler (Linux)
                   1550: 
                   1551:       + ido: SGI IRIS Development Option cc (IRIX 5)
1.1       dsieger  1552: 
1.42      asau     1553:       + gcc: GNU C/C++ Compiler
1.1       dsieger  1554: 
1.66      asau     1555:       + hp: HP-UX C/aC++ compilers
                   1556: 
1.42      asau     1557:       + mipspro: Silicon Graphics, Inc. MIPSpro (n32/n64)
1.1       dsieger  1558: 
1.66      asau     1559:       + mipspro-ucode: Silicon Graphics, Inc. MIPSpro (o32)
1.1       dsieger  1560: 
1.42      asau     1561:       + sunpro: Sun Microsystems, Inc. WorkShip/Forte/Sun ONE Studio
1.1       dsieger  1562: 
1.118     sevan    1563:       + xlc: IBM's XL C/C++ compiler suite
1.66      asau     1564: 
1.1       dsieger  1565:     The default is "gcc". You can use ccache and/or distcc with an appropriate
                   1566:     PKGSRC_COMPILER setting, e.g. "ccache gcc". This variable should always be
                   1567:     terminated with a value for a real compiler. Note that only one real
                   1568:     compiler should be listed (e.g. "sunpro gcc" is not allowed).
                   1569: 
                   1570: GCC_REQD:
                   1571: 
                   1572:     This specifies the minimum version of GCC to use when building packages. If
                   1573:     the system GCC doesn't satisfy this requirement, then pkgsrc will build and
                   1574:     install one of the GCC packages to use instead.
                   1575: 
1.153     leot     1576: PYTHON_VERSION_DEFAULT:
1.114     maya     1577: 
                   1578:     Specifies which version of python to use when several options are
                   1579:     available.
                   1580: 
                   1581: PKGSRC_FORTRAN:
                   1582: 
1.176     gutterid 1583:     Specifies the Fortran compiler to use. The default is gfortran.
1.114     maya     1584: 
                   1585: GFORTRAN_VERSION:
                   1586: 
                   1587:     If PKGSRC_FORTRAN= gfortran is used, this option specifies which version to
                   1588:     use.
                   1589: 
1.154     rillig   1590: 6.4.2. Additional flags to the compiler (CFLAGS)
1.1       dsieger  1591: 
                   1592: If you wish to set the CFLAGS variable, please make sure to use the += operator
                   1593: instead of the = operator:
                   1594: 
                   1595: CFLAGS+=        -your -flags
                   1596: 
                   1597: Using CFLAGS= (i.e. without the "+") may lead to problems with packages that
1.16      jnemeth  1598: need to add their own flags. You may want to take a look at the devel/cpuflags
1.24      wiz      1599: package if you're interested in optimization specifically for the current CPU.
1.1       dsieger  1600: 
1.154     rillig   1601: 6.4.3. Additional flags to the linker (LDFLAGS)
1.1       dsieger  1602: 
                   1603: If you want to pass flags to the linker, both in the configure step and the
                   1604: build step, you can do this in two ways. Either set LDFLAGS or LIBS. The
                   1605: difference between the two is that LIBS will be appended to the command line,
                   1606: while LDFLAGS come earlier. LDFLAGS is pre-loaded with rpath settings for ELF
                   1607: machines depending on the setting of USE_IMAKE or the inclusion of mk/
                   1608: x11.buildlink3.mk. As with CFLAGS, if you do not wish to override these
                   1609: settings, use the += operator:
                   1610: 
                   1611: LDFLAGS+=        -your -linkerflags
                   1612: 
1.154     rillig   1613: 6.5. Developer/advanced settings
1.1       dsieger  1614: 
                   1615:   * PKG_DEVELOPER: Run some sanity checks that package developers want:
                   1616: 
1.42      asau     1617:       + make sure patches apply with zero fuzz
1.1       dsieger  1618: 
1.42      asau     1619:       + run check-shlibs to see that all binaries will find their shared libs.
1.1       dsieger  1620: 
                   1621:   * PKG_DEBUG_LEVEL: The level of debugging output which is displayed whilst
                   1622:     making and installing the package. The default value for this is 0, which
                   1623:     will not display the commands as they are executed (normal, default, quiet
                   1624:     operation); the value 1 will display all shell commands before their
                   1625:     invocation, and the value 2 will display both the shell commands before
1.112     rillig   1626:     their invocation, as well as their actual execution progress with set -x.
1.1       dsieger  1627: 
1.154     rillig   1628: 6.6. Selecting Build Options
1.1       dsieger  1629: 
                   1630: Some packages have build time options, usually to select between different
                   1631: dependencies, enable optional support for big dependencies or enable
                   1632: experimental features.
                   1633: 
                   1634: To see which options, if any, a package supports, and which options are
                   1635: mutually exclusive, run make show-options, for example:
                   1636: 
                   1637:     The following options are supported by this package:
                   1638:         ssl      Enable SSL support.
                   1639:     Exactly one of the following gecko options is required:
                   1640:         firefox  Use firefox as gecko rendering engine.
                   1641:         mozilla  Use mozilla as gecko rendering engine.
                   1642:     At most one of the following database options may be selected:
                   1643:         mysql    Enable support for MySQL database.
                   1644:         pgsql    Enable support for PostgreSQL database.
                   1645: 
                   1646:     These options are enabled by default: firefox
                   1647:     These options are currently enabled: mozilla ssl
                   1648: 
1.4       rillig   1649: The following variables can be defined in mk.conf to select which options to
                   1650: enable for a package: PKG_DEFAULT_OPTIONS, which can be used to select or
1.1       dsieger  1651: disable options for all packages that support them, and PKG_OPTIONS.pkgbase,
                   1652: which can be used to select or disable options specifically for package pkgbase
                   1653: . Options listed in these variables are selected, options preceded by "-" are
                   1654: disabled. A few examples:
                   1655: 
1.4       rillig   1656: $ grep "PKG.*OPTION" mk.conf
1.1       dsieger  1657: PKG_DEFAULT_OPTIONS=    -arts -dvdread -esound
                   1658: PKG_OPTIONS.kdebase=    debug -sasl
                   1659: PKG_OPTIONS.apache=     suexec
                   1660: 
1.11      rillig   1661: It is important to note that options that were specifically suggested by the
1.19      snj      1662: package maintainer must be explicitly removed if you do not wish to include the
                   1663: option. If you are unsure you can view the current state with make show-options
                   1664: .
1.11      rillig   1665: 
1.1       dsieger  1666: The following settings are consulted in the order given, and the last setting
                   1667: that selects or disables an option is used:
                   1668: 
                   1669:  1. the default options as suggested by the package maintainer
                   1670: 
                   1671:  2. the options implied by the settings of legacy variables (see below)
                   1672: 
                   1673:  3. PKG_DEFAULT_OPTIONS
                   1674: 
                   1675:  4. PKG_OPTIONS.pkgbase
                   1676: 
                   1677: For groups of mutually exclusive options, the last option selected is used, all
                   1678: others are automatically disabled. If an option of the group is explicitly
                   1679: disabled, the previously selected option, if any, is used. It is an error if no
                   1680: option from a required group of options is selected, and building the package
                   1681: will fail.
                   1682: 
                   1683: Before the options framework was introduced, build options were selected by
1.4       rillig   1684: setting a variable (often named USE_FOO) in mk.conf for each option. To ease
                   1685: transition to the options framework for the user, these legacy variables are
                   1686: converted to the appropriate options setting (PKG_OPTIONS.pkgbase)
                   1687: automatically. A warning is issued to prompt the user to update mk.conf to use
                   1688: the options framework directly. Support for the legacy variables will be
1.1       dsieger  1689: removed eventually.
                   1690: 
1.154     rillig   1691: Chapter 7. Creating binary packages
1.1       dsieger  1692: 
                   1693: Table of Contents
                   1694: 
1.154     rillig   1695: 7.1. Building a single binary package
                   1696: 7.2. Settings for creation of binary packages
1.1       dsieger  1697: 
1.154     rillig   1698: 7.1. Building a single binary package
1.1       dsieger  1699: 
                   1700: Once you have built and installed a package, you can create a binary package
                   1701: which can be installed on another system with pkg_add(1). This saves having to
                   1702: build the same package on a group of hosts and wasting CPU time. It also
                   1703: provides a simple means for others to install your package, should you
                   1704: distribute it.
                   1705: 
                   1706: To create a binary package, change into the appropriate directory in pkgsrc,
                   1707: and run make package:
                   1708: 
1.112     rillig   1709: $ cd misc/figlet
                   1710: $ make package
1.1       dsieger  1711: 
                   1712: This will build and install your package (if not already done), and then build
                   1713: a binary package from what was installed. You can then use the pkg_* tools to
                   1714: manipulate it. Binary packages are created by default in /usr/pkgsrc/packages,
                   1715: in the form of a gzipped tar file. See Section B.2, "Packaging figlet" for a
                   1716: continuation of the above misc/figlet example.
                   1717: 
1.154     rillig   1718: See Chapter 23, Submitting and Committing for information on how to submit such
1.1       dsieger  1719: a binary package.
                   1720: 
1.154     rillig   1721: 7.2. Settings for creation of binary packages
1.1       dsieger  1722: 
1.184     rillig   1723: See Section 13.17, "Other helpful targets".
1.6       rillig   1724: 
1.154     rillig   1725: Chapter 8. Creating binary packages for everything in pkgsrc (bulk builds)
1.6       rillig   1726: 
                   1727: Table of Contents
                   1728: 
1.154     rillig   1729: 8.1. Preparations
1.180     rillig   1730: 8.2. Running a bulk build
1.6       rillig   1731: 
1.154     rillig   1732:     8.2.1. Configuration
1.6       rillig   1733: 
1.154     rillig   1734: 8.3. Requirements of a full bulk build
1.178     rillig   1735: 8.4. Bulk build variants
                   1736: 
1.179     rillig   1737:     8.4.1. Detect unknown configure options
                   1738:     8.4.2. Detect classes of bugs by forcing compiler warnings
1.181     rillig   1739:     8.4.3. Force compiler options only in the build phase
                   1740:     8.4.4. Use custom directories
                   1741:     8.4.5. Turn warnings into errors
                   1742:     8.4.6. Reject packages for which pkglint reports errors
                   1743:     8.4.7. Reject packages that contain forbidden strings
                   1744:     8.4.8. Reject packages whose self-test fails
                   1745:     8.4.9. Reject packages that use undefined shell variables
                   1746:     8.4.10. Turn off verbose logging
1.6       rillig   1747: 
1.178     rillig   1748: 8.5. Creating a multiple CD-ROM packages collection
                   1749: 
                   1750:     8.5.1. Example of cdpack
1.6       rillig   1751: 
1.175     gutterid 1752: For a number of reasons, you may want to build binary packages for a large
                   1753: selected set of packages in pkgsrc, or even for all pkgsrc packages. For
1.71      wiz      1754: instance, when you have multiple machines that should run the same software, it
                   1755: is wasted time if they all build their packages themselves from source. Or you
                   1756: may want to build a list of packages you want and check them before deploying
1.175     gutterid 1757: onto production systems. There is a way of getting a set of binary packages:
                   1758: the bulk build system, or pbulk ("p" stands for "parallel"). This chapter
                   1759: describes how to set it up.
1.71      wiz      1760: 
1.154     rillig   1761: 8.1. Preparations
1.71      wiz      1762: 
                   1763: First of all, you have to decide whether you build all packages or a limited
                   1764: set of them. Full bulk builds usually consume a lot more resources, both space
1.175     gutterid 1765: and time, than builds for some practical sets of packages. A number of
                   1766: particularly heavy packages exist that are not actually interesting to a wide
                   1767: audience. (The approximate resource consumption for a full bulk build is given
                   1768: in section Section 8.3, "Requirements of a full bulk build".) For limited bulk
                   1769: builds you need to make a list of packages you want to build. Note that all
                   1770: their dependencies will be built, so you don't need to track them manually.
1.71      wiz      1771: 
                   1772: During bulk builds various packages are installed and deinstalled in /usr/pkg
                   1773: (or whatever LOCALBASE is), so make sure that you don't need any package during
1.112     rillig   1774: the builds. Essentially, you should provide a fresh system, either a chroot
1.71      wiz      1775: environment or something even more restrictive, depending on what the operating
                   1776: system provides, or dedicate the whole physical machine. As a useful side
                   1777: effect this makes sure that bulk builds cannot break anything in your system.
                   1778: There have been numerous cases where certain packages tried to install files
                   1779: outside the LOCALBASE or wanted to edit some files in /etc.
1.6       rillig   1780: 
1.180     rillig   1781: 8.2. Running a bulk build
1.6       rillig   1782: 
1.180     rillig   1783: Running a bulk build works roughly as follows:
1.15      rillig   1784: 
                   1785:   * First, build the pbulk infrastructure in a fresh pkgsrc location.
                   1786: 
                   1787:   * Then, build each of the packages from a clean installation directory using
                   1788:     the infrastructure.
                   1789: 
1.154     rillig   1790: 8.2.1. Configuration
1.6       rillig   1791: 
1.112     rillig   1792: To simplify configuration, we provide the helper script mk/pbulk/pbulk.sh.
1.6       rillig   1793: 
1.68      asau     1794: In order to use it, prepare a clear system (real one, chroot environment, jail,
                   1795: zone, virtual machine). Configure network access to fetch distribution files.
1.112     rillig   1796: Create a user with name "pbulk".
1.68      asau     1797: 
                   1798: Fetch and extract pkgsrc. Use a command like one of these:
                   1799: 
1.151     sevan    1800: # (cd /usr && ftp -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
                   1801: # (cd /usr && fetch -o - https://cdn.NetBSD.org/pub/pkgsrc/current/pkgsrc.tar.gz | tar -zxf-)
1.72      wiz      1802: # (cd /usr && cvs -Q -z3 -d anoncvs@anoncvs.NetBSD.org:/cvsroot get -P pkgsrc)
1.68      asau     1803: 
                   1804: Or any other way that fits (e.g., curl, wget).
                   1805: 
                   1806: Deploy and configure pbulk tools, e.g.:
                   1807: 
1.118     sevan    1808: # sh pbulk.sh -n # use native make, no bootstrap kit needed (for use on NetBSD)
1.68      asau     1809: # sh pbulk.sh -n -c mk.conf.frag # native, apply settings from given mk.conf fragment
                   1810: # sh pbulk.sh -nlc mk.conf.frag # native, apply settings, configure for limited build
                   1811: 
                   1812: Note
                   1813: 
                   1814: mk.conf.frag is a fragment of mk.conf that contains settings you want to apply
                   1815: to packages you build. For instance,
                   1816: 
1.112     rillig   1817: PKG_DEVELOPER=          yes     # perform more checks
                   1818: X11_TYPE=               modular # use pkgsrc X11
                   1819: SKIP_LICENSE_CHECK=     yes     # accept all licences (useful
                   1820:                                 # when building all packages)
1.68      asau     1821: 
                   1822: If configured for limited list, replace the list in /usr/pbulk/etc/pbulk.list
1.112     rillig   1823: with your list of packages, one per line without empty lines or comments. E.g.:
1.68      asau     1824: 
                   1825: www/firefox
                   1826: mail/thunderbird
                   1827: misc/libreoffice4
                   1828: 
1.69      asau     1829: At this point you can also review configuration in /usr/pbulk/etc and make
                   1830: final amendments, if wanted.
                   1831: 
1.68      asau     1832: Start it:
                   1833: 
                   1834: # /usr/pbulk/bin/bulkbuild
                   1835: 
                   1836: After it finishes, you'll have /mnt filled with distribution files, binary
                   1837: packages, and reports, plain text summary in /mnt/bulklog/meta/report.txt
                   1838: 
                   1839: Note
                   1840: 
                   1841: The pbulk.sh script does not cover all possible use cases. While being ready to
                   1842: run, it serves as a good starting point to understand and build more complex
                   1843: setups. The script is kept small enough for better understanding.
                   1844: 
                   1845: Note
                   1846: 
                   1847: The pbulk.sh script supports running unprivileged bulk build and helps
                   1848: configuring distributed bulk builds.
1.15      rillig   1849: 
1.154     rillig   1850: 8.3. Requirements of a full bulk build
1.71      wiz      1851: 
                   1852: A complete bulk build requires lots of disk space. Some of the disk space can
                   1853: be read-only, some other must be writable. Some can be on remote filesystems
                   1854: (such as NFS) and some should be local. Some can be temporary filesystems,
                   1855: others must survive a sudden reboot.
                   1856: 
                   1857:   * 40 GB for the distfiles (read-write, remote, temporary)
                   1858: 
                   1859:   * 30 GB for the binary packages (read-write, remote, permanent)
                   1860: 
                   1861:   * 1 GB for the pkgsrc tree (read-only, remote, permanent)
                   1862: 
                   1863:   * 5 GB for LOCALBASE (read-write, local, temporary)
                   1864: 
                   1865:   * 10 GB for the log files (read-write, remote, permanent)
                   1866: 
                   1867:   * 5 GB for temporary files (read-write, local, temporary)
                   1868: 
1.178     rillig   1869: 8.4. Bulk build variants
                   1870: 
                   1871: To ensure that pkgsrc packages work in different configurations, it makes sense
                   1872: to run non-default bulk builds from time to time. This section lists some ideas
                   1873: for bulk builds that intentionally let packages fail if they don't follow the
                   1874: pkgsrc style.
                   1875: 
1.179     rillig   1876: 8.4.1. Detect unknown configure options
1.178     rillig   1877: 
                   1878: Add the following line to mk.conf.
                   1879: 
                   1880: GNU_CONFIGURE_STRICT=   yes
                   1881: 
                   1882: When a package fails this additional check, the most common cause is that the
                   1883: configure option was valid for an older version of the package but does not
                   1884: apply anymore. In that case, just remove it.
                   1885: 
1.179     rillig   1886: 8.4.2. Detect classes of bugs by forcing compiler warnings
1.178     rillig   1887: 
                   1888: The job of a compiler is not restricted to producing executable code, most
1.179     rillig   1889: compilers also detect typical programming mistakes. The pkgsrc compiler
                   1890: wrappers make it easy to force compiler options when the package is built. This
                   1891: can be used to find typical bugs across all packages that are in pkgsrc. By
                   1892: reporting these bugs upstream, the packages will be more reliable with the next
                   1893: updates.
1.178     rillig   1894: 
1.179     rillig   1895: Add some of the following lines to mk.conf:
1.178     rillig   1896: 
                   1897: CFLAGS+=        -Werror=char-subscripts
1.179     rillig   1898: CFLAGS+=        -Werror=implicit-function-declaration
1.178     rillig   1899: 
1.179     rillig   1900: When a package fails to build using these stricter compiler options, document
                   1901: the circumstances in which the compiler produced the error message. This
                   1902: includes:
1.178     rillig   1903: 
                   1904:   * The platform (MACHINE_PLATFORM)
                   1905: 
                   1906:   * The source file
                   1907: 
                   1908:   * An excerpt of the code. GCC and Clang already do this as part of the
                   1909:     diagnostic.
                   1910: 
1.179     rillig   1911:   * The exact error message from the compiler.
1.178     rillig   1912: 
1.179     rillig   1913: If a package produces these error messages, but the package is fine, record
                   1914: this in your local mk.conf, like this, to skip this check in the next builds:
1.178     rillig   1915: 
1.179     rillig   1916: .if ${PKGPATH} == category/package
1.178     rillig   1917: # Version ${VERSION} failed on ${MACHINE_PLATFORM}:
                   1918: # error message
                   1919: # code
1.179     rillig   1920: # Reason why the code does not need to be fixed.
1.178     rillig   1921: BUILDLINK_TRANSFORM+=   rm:-Werror=char-subscripts
1.179     rillig   1922: .endif
1.178     rillig   1923: 
                   1924: If the error messages from the compiler are valid and the code needs to be
1.179     rillig   1925: fixed, prepare a local patch (see LOCALPATCHES) and report the bug to the
                   1926: upstream authors of the package, providing them with the information you
                   1927: collected above.
1.178     rillig   1928: 
1.179     rillig   1929: Patches that are not essential for the package to work should only be reported
                   1930: upstream but not committed to pkgsrc, to make future updates easier.
                   1931: 
1.181     rillig   1932: 8.4.3. Force compiler options only in the build phase
                   1933: 
                   1934: When adding custom compiler flags via CFLAGS, these apply to all phases of the
                   1935: package build process. Especially in the configure phase, adding -Werror leads
                   1936: to wrong decisions. The GNU configure scripts feed many small test programs to
                   1937: the C compiler to see whether certain headers are available, functions are
                   1938: defined in a library and programs can be run. In many cases these programs
                   1939: would not survive a strict compiler run with -Wall -Wextra -Werror.
                   1940: 
                   1941: The pkgsrc infrastructure is flexible enough to support compiler options being
                   1942: added between the configure and build phases. It's a little more complicated
                   1943: than the other examples in this section but still easy enough.
                   1944: 
                   1945: The basic idea is to use the pkgsrc compiler wrapper to inject the desired
                   1946: compiler options. The compiler wrapper's original task is to hide unwanted
                   1947: directories of include files and to normalize compiler options. It does this by
                   1948: wrapping the compiler command and rewriting the command line. To see this in
                   1949: action, run bmake patch in a package directory and examine the work/.cwrappers/
                   1950: config directory. It contains individual configurations for the C compiler and
                   1951: the related tools. The plan is to find a hook between the configure and build
                   1952: phases, and to modify these configuration files at that point.
                   1953: 
                   1954: To find this hook, have a look at mk/build/build.mk, which contains among
                   1955: others the pre-build-checks-hook. The word checks doesn't quite fit, but the
                   1956: pre-build-hook sounds good enough.
                   1957: 
                   1958: The code to be included in mk.conf is:
                   1959: 
                   1960: # Just a few example options.
                   1961: BUILD_ONLY_CFLAGS=      -Wall -Werror -O2 -DTEMPDIR='"/tmp"'
                   1962: 
                   1963: .if ${BUILD_ONLY_CFLAGS:U:M*}
                   1964: pre-build-checks-hook: add-build-only-cflags
                   1965: 
                   1966: add-build-only-cflags: .PHONY
                   1967:         ${RUN} cd ${CWRAPPERS_CONFIG_DIR};      \
                   1968:         ${TEST} ! -f ${.TARGET} || exit 0;      \
                   1969:         for flag in ${BUILD_ONLY_CFLAGS}; do    \
                   1970:                 ${ECHO} "append=$$flag" >> cc;  \
                   1971:         done;                                   \
                   1972:         > ${.TARGET}
                   1973: .endif
                   1974: 
                   1975: (When editing the mk.conf, make sure that the commands of the
                   1976: add-build-only-cflags target are indented with a tab, not with spaces.)
                   1977: 
                   1978: The condition in the .if statement contains the :U modifier to prevent parse
                   1979: errors if the variable should be undefined, possibly because it is only defined
                   1980: for a subset of the packages. The :M* modifier ensures that there is at least
                   1981: one compiler option, to prevent a syntax error in the shell parser.
                   1982: 
                   1983: The code around the ${.TARGET} variable ensures that the additional compiler
                   1984: options are only appended once, even if bmake build is run multiple times. To
                   1985: do this, it creates a marker file.
                   1986: 
                   1987: To verify that this setup works, run bmake configure in a package directory. Up
                   1988: to now, everything works as usual. Examine the directory work/.cwrappers/config
                   1989: to see that the compiler options from BUILD_ONLY_CFLAGS are not yet added to
                   1990: the file cc. Examine the tail of the work/.work.log file to see that the normal
                   1991: compiler options are used.
                   1992: 
                   1993: Now run bmake build. This will append the options to the file cc and will
                   1994: create the marker file in the same directory. After that, the build starts as
                   1995: usual, but with the added compiler options. Examine the tail of the file work
                   1996: /.work.log to see that the lines starting with [*] don't contain the compiler
                   1997: options, but the corresponding lines starting with <.> do end with these
                   1998: options.
                   1999: 
                   2000: Building packages using this setup variant and fixing the resulting bugs is the
                   2001: same as in Section 8.4.2, "Detect classes of bugs by forcing compiler warnings"
                   2002: .
                   2003: 
                   2004: 8.4.4. Use custom directories
1.178     rillig   2005: 
                   2006: Some directories like PREFIX, VARBASE, PKG_SYSCONFDIR, PKGMANDIR, PKG_INFODIR
                   2007: can be configured in pkgsrc. Set these to arbitrary paths during bootstrap or
                   2008: afterwards in mk.conf.
                   2009: 
                   2010: PREFIX=         /a-random-uuid
                   2011: PKG_SYSCONFDIR= /a-random-uuid
                   2012: VARBASE=        /a-random-uuid
                   2013: PKGMANDIR=      a-random-uuid
                   2014: PKG_INFODIR=    a-random-uuid
                   2015: 
1.181     rillig   2016: 8.4.5. Turn warnings into errors
1.178     rillig   2017: 
                   2018: When building a package, warnings are typically ignored since they just flow by
                   2019: and do not cause the build to fail immediately. To find these warnings,
                   2020: redefine them to errors in mk.conf.
                   2021: 
                   2022: DELAYED_WARNING_MSG=    ${DELAYED_ERROR_MSG} "(was warning)"
                   2023: WARNING_MSG=            ${FAIL_MSG} "(was warning)"
                   2024: 
                   2025: (There are many more classes of warnings in pkgsrc, and most of them can be
                   2026: redefined with a simple definition like above.
                   2027: 
1.179     rillig   2028: If a package suggests to add USE_TOOLS+=perl to the package Makefile, research
1.178     rillig   2029: whether the package actually needs Perl. If it does, add USE_TOOLS+=perl to the
                   2030: package Makefile, and if it doesn't, add TOOLS_BROKEN+=perl.
                   2031: 
1.181     rillig   2032: 8.4.6. Reject packages for which pkglint reports errors
1.178     rillig   2033: 
                   2034: Using pkglint as part of the regular build process is mostly a waste of time.
                   2035: If you want to fix some of the warnings, just run pkglint recursively on the
                   2036: whole pkgsrc tree. This will take a few minutes (up to 10), which is much
                   2037: faster than a complete bulk build.
                   2038: 
1.181     rillig   2039: 8.4.7. Reject packages that contain forbidden strings
1.178     rillig   2040: 
                   2041: To ensure that the binary packages don't contain references to the build
                   2042: directory, there is already CHECK_WRKREF. If that variable includes the item
                   2043: extra, it is possible to define additional patterns that must not appear in any
                   2044: installed file. This is specified in mk.conf.
                   2045: 
                   2046: CHECK_WRKREF=                   extra
                   2047: CHECK_WRKREF_EXTRA_DIRS+=       /usr/local
                   2048: CHECK_WRKREF_EXTRA_DIRS+=       /usr/pkg
                   2049: CHECK_WRKREF_EXTRA_DIRS+=       @[A-Z][A-Z]*@
                   2050: 
                   2051: The above patterns will probably generate many false positives, therefore the
                   2052: results need to be taken with a grain of salt.
                   2053: 
1.181     rillig   2054: 8.4.8. Reject packages whose self-test fails
1.178     rillig   2055: 
                   2056: To run the test suites that come with each package, add this line to mk.conf.
                   2057: 
                   2058: PKGSRC_RUN_TEST=        yes
                   2059: 
                   2060: Be prepared that even the most basic packages fail this test. When doing a bulk
                   2061: build with this, it will often abort in the early phase where the packages are
                   2062: scanned for their dependencies since there are cyclic dependencies. There is
                   2063: still a lot to do in this area.
                   2064: 
1.181     rillig   2065: 8.4.9. Reject packages that use undefined shell variables
1.178     rillig   2066: 
                   2067: To catch typos in the shell snippets from the Makefile fragments, add the -u
                   2068: flag to most of the commands by adding this line to mk.conf.
                   2069: 
                   2070: RUN=    @set -eu;
                   2071: 
1.181     rillig   2072: After that, ensure that none of the bulk build log files (even those for
                   2073: successfully built packages) contains the string parameter not set or whatever
                   2074: error message the command sh -ceu '$undefined' outputs.
                   2075: 
1.178     rillig   2076: See mk/misc/common.mk for the existing definition.
                   2077: 
1.181     rillig   2078: 8.4.10. Turn off verbose logging
1.178     rillig   2079: 
                   2080: The build logs of a package are often quite long. This allows error messages or
                   2081: other interesting details to hide between the noise. To make the actual error
                   2082: message stand out more, add these lines to mk.conf.
                   2083: 
                   2084: GNU_CONFIGURE_QUIET=    yes
                   2085: MAKE_FLAGS+=            -s
                   2086: 
                   2087: The -s option works for both GNU Make and BSD Make. On exotic platforms with
                   2088: their own make, it may be a little different.
                   2089: 
                   2090: 8.5. Creating a multiple CD-ROM packages collection
1.1       dsieger  2091: 
                   2092: After your pkgsrc bulk-build has completed, you may wish to create a CD-ROM set
                   2093: of the resulting binary packages to assist in installing packages on other
                   2094: machines. The pkgtools/cdpack package provides a simple tool for creating the
                   2095: ISO 9660 images. cdpack arranges the packages on the CD-ROMs in a way that
                   2096: keeps all the dependencies for a given package on the same CD as that package.
                   2097: 
1.178     rillig   2098: 8.5.1. Example of cdpack
1.1       dsieger  2099: 
                   2100: Complete documentation for cdpack is found in the cdpack(1) man page. The
                   2101: following short example assumes that the binary packages are left in /usr/
                   2102: pkgsrc/packages/All and that sufficient disk space exists in /u2 to hold the
                   2103: ISO 9660 images.
                   2104: 
                   2105: # mkdir /u2/images
                   2106: # pkg_add /usr/pkgsrc/packages/All/cdpack
                   2107: # cdpack /usr/pkgsrc/packages/All /u2/images
                   2108: 
                   2109: 
                   2110: If you wish to include a common set of files (COPYRIGHT, README, etc.) on each
                   2111: CD in the collection, then you need to create a directory which contains these
1.175     gutterid 2112: files, e.g.:
1.1       dsieger  2113: 
                   2114: # mkdir /tmp/common
                   2115: # echo "This is a README" > /tmp/common/README
                   2116: # echo "Another file" > /tmp/common/COPYING
                   2117: # mkdir /tmp/common/bin
                   2118: # echo "#!/bin/sh" > /tmp/common/bin/myscript
                   2119: # echo "echo Hello world" >> /tmp/common/bin/myscript
                   2120: # chmod 755 /tmp/common/bin/myscript
                   2121: 
                   2122: 
                   2123: Now create the images:
                   2124: 
                   2125: # cdpack -x /tmp/common /usr/pkgsrc/packages/All /u2/images
                   2126: 
                   2127: Each image will contain README, COPYING, and bin/myscript in their root
                   2128: directories.
                   2129: 
1.154     rillig   2130: Chapter 9. Directory layout of the installed files
1.1       dsieger  2131: 
                   2132: Table of Contents
                   2133: 
1.154     rillig   2134: 9.1. File system layout in ${LOCALBASE}
                   2135: 9.2. File system layout in ${VARBASE}
1.1       dsieger  2136: 
                   2137: The files that are installed by pkgsrc are organized in a way that is similar
                   2138: to what you find in the /usr directory of the base system. But some details are
                   2139: different. This is because pkgsrc initially came from FreeBSD and had adopted
                   2140: its file system hierarchy. Later it was largely influenced by NetBSD. But no
                   2141: matter which operating system you are using pkgsrc with, you can expect the
                   2142: same layout for pkgsrc.
                   2143: 
                   2144: There are mainly four root directories for pkgsrc, which are all configurable
                   2145: in the bootstrap/bootstrap script. When pkgsrc has been installed as root, the
                   2146: default locations are:
                   2147: 
                   2148: LOCALBASE=              /usr/pkg
                   2149: PKG_SYSCONFBASE=        /usr/pkg/etc
                   2150: VARBASE=                /var
1.119     sevan    2151: PKG_DBDIR=              /usr/pkg/pkgdb
1.1       dsieger  2152: 
                   2153: In unprivileged mode (when pkgsrc has been installed as any other user), the
                   2154: default locations are:
                   2155: 
                   2156: LOCALBASE=              ${HOME}/pkg
                   2157: PKG_SYSCONFBASE=        ${HOME}/pkg/etc
                   2158: VARBASE=                ${HOME}/pkg/var
1.119     sevan    2159: PKG_DBDIR=              ${HOME}/pkg/pkgdb
1.1       dsieger  2160: 
                   2161: What these four directories are for, and what they look like is explained
                   2162: below.
                   2163: 
1.25      wiz      2164:   * LOCALBASE corresponds to the /usr directory in the base system. It is the "
                   2165:     main" directory where the files are installed and contains the well-known
1.1       dsieger  2166:     subdirectories like bin, include, lib, share and sbin.
                   2167: 
                   2168:   * VARBASE corresponds to /var in the base system. Some programs (especially
                   2169:     games, network daemons) need write access to it during normal operation.
                   2170: 
                   2171:   * PKG_SYSCONFDIR corresponds to /etc in the base system. It contains
                   2172:     configuration files of the packages, as well as pkgsrc's mk.conf itself.
                   2173: 
1.154     rillig   2174: 9.1. File system layout in ${LOCALBASE}
1.1       dsieger  2175: 
                   2176: The following directories exist in a typical pkgsrc installation in $
                   2177: {LOCALBASE}.
                   2178: 
                   2179: bin
                   2180: 
                   2181:     Contains executable programs that are intended to be directly used by the
                   2182:     end user.
                   2183: 
                   2184: emul
                   2185: 
                   2186:     Contains files for the emulation layers of various other operating systems,
                   2187:     especially for NetBSD.
                   2188: 
                   2189: etc (the usual location of ${PKG_SYSCONFDIR})
                   2190: 
                   2191:     Contains the configuration files.
                   2192: 
                   2193: include
                   2194: 
                   2195:     Contains headers for the C and C++ programming languages.
                   2196: 
                   2197: info
                   2198: 
                   2199:     Contains GNU info files of various packages.
                   2200: 
                   2201: lib
                   2202: 
                   2203:     Contains shared and static libraries.
                   2204: 
                   2205: libdata
                   2206: 
                   2207:     Contains data files that don't change after installation. Other data files
                   2208:     belong into ${VARBASE}.
                   2209: 
                   2210: libexec
                   2211: 
                   2212:     Contains programs that are not intended to be used by end users, such as
                   2213:     helper programs or network daemons.
                   2214: 
                   2215: libexec/cgi-bin
                   2216: 
                   2217:     Contains programs that are intended to be executed as CGI scripts by a web
                   2218:     server.
                   2219: 
                   2220: man (the usual value of ${PKGMANDIR})
                   2221: 
                   2222:     Contains brief documentation in form of manual pages.
                   2223: 
                   2224: sbin
                   2225: 
                   2226:     Contains programs that are intended to be used only by the super-user.
                   2227: 
                   2228: share
                   2229: 
                   2230:     Contains platform-independent data files that don't change after
                   2231:     installation.
                   2232: 
                   2233: share/doc
                   2234: 
                   2235:     Contains documentation files provided by the packages.
                   2236: 
                   2237: share/examples
                   2238: 
                   2239:     Contains example files provided by the packages. Among others, the original
                   2240:     configuration files are saved here and copied to ${PKG_SYSCONFDIR} during
                   2241:     installation.
                   2242: 
                   2243: share/examples/rc.d
                   2244: 
                   2245:     Contains the original files for rc.d scripts.
                   2246: 
                   2247: var (the usual location of ${VARBASE})
                   2248: 
                   2249:     Contains files that may be modified after installation.
                   2250: 
1.154     rillig   2251: 9.2. File system layout in ${VARBASE}
1.1       dsieger  2252: 
                   2253: db/pkg (the usual location of ${PKG_DBDIR})
                   2254: 
                   2255:     Contains information about the currently installed packages.
                   2256: 
                   2257: games
                   2258: 
                   2259:     Contains highscore files.
                   2260: 
                   2261: log
                   2262: 
                   2263:     Contains log files.
                   2264: 
                   2265: run
                   2266: 
                   2267:     Contains informational files about daemons that are currently running.
                   2268: 
1.154     rillig   2269: Chapter 10. Frequently Asked Questions
1.1       dsieger  2270: 
                   2271: Table of Contents
                   2272: 
1.154     rillig   2273: 10.1. Are there any mailing lists for pkg-related discussion?
                   2274: 10.2. Utilities for package management (pkgtools)
                   2275: 10.3. How to use pkgsrc as non-root
                   2276: 10.4. How to resume transfers when fetching distfiles?
                   2277: 10.5. How can I install/use modular X.org from pkgsrc?
                   2278: 10.6. How to fetch files from behind a firewall
                   2279: 10.7. How to fetch files from HTTPS sites
                   2280: 10.8. How do I tell make fetch to do passive FTP?
                   2281: 10.9. How to fetch all distfiles at once
                   2282: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
                   2283: 10.11. What does "Could not find bsd.own.mk" mean?
                   2284: 10.12. Using 'sudo' with pkgsrc
                   2285: 10.13. How do I change the location of configuration files?
                   2286: 10.14. Automated security checks
                   2287: 10.15. Why do some packages ignore my CFLAGS?
                   2288: 10.16. A package does not build. What shall I do?
                   2289: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.24      wiz      2290:     conflicts" mean?
1.1       dsieger  2291: 
                   2292: This section contains hints, tips & tricks on special things in pkgsrc that we
                   2293: didn't find a better place for in the previous chapters, and it contains items
                   2294: for both pkgsrc users and developers.
                   2295: 
1.154     rillig   2296: 10.1. Are there any mailing lists for pkg-related discussion?
1.1       dsieger  2297: 
                   2298: The following mailing lists may be of interest to pkgsrc users:
                   2299: 
                   2300:   * pkgsrc-users: This is a general purpose list for most issues regarding
                   2301:     pkgsrc, regardless of platform, e.g. soliciting user help for pkgsrc
                   2302:     configuration, unexpected build failures, using particular packages,
                   2303:     upgrading pkgsrc installations, questions regarding the pkgsrc release
                   2304:     branches, etc. General announcements or proposals for changes that impact
                   2305:     the pkgsrc user community, e.g. major infrastructure changes, new features,
                   2306:     package removals, etc., may also be posted.
                   2307: 
                   2308:   * pkgsrc-bulk: A list where the results of pkgsrc bulk builds are sent and
                   2309:     discussed.
                   2310: 
                   2311:   * pkgsrc-changes: This list is for those who are interested in getting a
                   2312:     commit message for every change committed to pkgsrc. It is also available
                   2313:     in digest form, meaning one daily message containing all commit messages
                   2314:     for changes to the package source tree in that 24 hour period.
                   2315: 
                   2316: To subscribe, do:
                   2317: 
                   2318: % echo subscribe listname | mail majordomo@NetBSD.org
                   2319: 
1.174     leot     2320: Archives for all these mailing lists are available from https://
1.1       dsieger  2321: mail-index.NetBSD.org/.
                   2322: 
1.154     rillig   2323: 10.2. Utilities for package management (pkgtools)
1.1       dsieger  2324: 
                   2325: The directory pkgsrc/pkgtools contains a number of useful utilities for both
                   2326: users and developers of pkgsrc. This section attempts only to make the reader
1.121     sevan    2327: aware of some of the utilities and when they might be useful, and not to
                   2328: duplicate the documentation that comes with each package.
1.1       dsieger  2329: 
                   2330: Utilities used by pkgsrc (automatically installed when needed):
                   2331: 
                   2332:   * pkgtools/x11-links: Symlinks for use by buildlink.
                   2333: 
                   2334: OS tool augmentation (automatically installed when needed):
                   2335: 
1.121     sevan    2336:   * pkgtools/digest: Calculates various kinds of checksums (including SHA3).
1.1       dsieger  2337: 
                   2338:   * pkgtools/libnbcompat: Compatibility library for pkgsrc tools.
                   2339: 
                   2340:   * pkgtools/mtree: Installed on non-BSD systems due to lack of native mtree.
                   2341: 
                   2342:   * pkgtools/pkg_install: Up-to-date replacement for /usr/sbin/pkg_install, or
                   2343:     for use on operating systems where pkg_install is not present.
                   2344: 
                   2345: Utilities used by pkgsrc (not automatically installed):
                   2346: 
                   2347:   * pkgtools/pkg_tarup: Create a binary package from an already-installed
                   2348:     package. Used by make replace to save the old package.
                   2349: 
                   2350:   * pkgtools/dfdisk: Adds extra functionality to pkgsrc, allowing it to fetch
                   2351:     distfiles from multiple locations. It currently supports the following
                   2352:     methods: multiple CD-ROMs and network FTP/HTTP connections.
                   2353: 
                   2354:   * devel/cpuflags: Determine the best compiler flags to optimise code for your
1.24      wiz      2355:     current CPU and compiler.
1.1       dsieger  2356: 
                   2357: Utilities for keeping track of installed packages, being up to date, etc:
                   2358: 
1.65      wiz      2359:   * pkgtools/pkgin: A package update tool similar to apt(1). Download, install,
                   2360:     and upgrade binary packages easily.
                   2361: 
1.1       dsieger  2362:   * pkgtools/pkg_chk: Reports on packages whose installed versions do not match
                   2363:     the latest pkgsrc entries.
                   2364: 
                   2365:   * pkgtools/pkgdep: Makes dependency graphs of packages, to aid in choosing a
                   2366:     strategy for updating.
                   2367: 
                   2368:   * pkgtools/pkgdepgraph: Makes graphs from the output of pkgtools/pkgdep (uses
                   2369:     graphviz).
                   2370: 
1.12      weinem   2371:   * pkgtools/pkglint: The pkglint(1) program checks a pkgsrc entry for errors.
                   2372: 
                   2373:   * pkgtools/lintpkgsrc: The lintpkgsrc(1) program does various checks on the
                   2374:     complete pkgsrc system.
1.1       dsieger  2375: 
                   2376:   * pkgtools/pkgsurvey: Report what packages you have installed.
                   2377: 
                   2378: Utilities for people maintaining or creating individual packages:
                   2379: 
                   2380:   * pkgtools/pkgdiff: Automate making and maintaining patches for a package
                   2381:     (includes pkgdiff, pkgvi, mkpatches, etc.).
                   2382: 
1.65      wiz      2383:   * pkgtools/url2pkg: Aids in converting to pkgsrc.
1.1       dsieger  2384: 
                   2385: Utilities for people maintaining pkgsrc (or: more obscure pkg utilities)
                   2386: 
                   2387:   * pkgtools/pkg_comp: Build packages in a chrooted area.
                   2388: 
                   2389:   * pkgtools/libkver: Spoof kernel version for chrooted cross builds.
                   2390: 
1.154     rillig   2391: 10.3. How to use pkgsrc as non-root
1.1       dsieger  2392: 
1.108     rillig   2393: To install packages from source as a non-root user, download pkgsrc as
1.154     rillig   2394: described in Chapter 3, Where to get pkgsrc and how to keep it up-to-date, cd
1.108     rillig   2395: into that directory and run the command ./bootstrap/bootstrap --unprivileged.
                   2396: 
                   2397: This will install the binary part of pkgsrc to ~/pkg and put the pkgsrc
                   2398: configuration mk.conf into ~/pkg/etc.
                   2399: 
                   2400: For more details, see mk/unprivileged.mk.
1.1       dsieger  2401: 
1.154     rillig   2402: 10.4. How to resume transfers when fetching distfiles?
1.1       dsieger  2403: 
                   2404: By default, resuming transfers in pkgsrc is disabled, but you can enable this
1.4       rillig   2405: feature by adding the option PKG_RESUME_TRANSFERS=YES into mk.conf. If, during
                   2406: a fetch step, an incomplete distfile is found, pkgsrc will try to resume it.
1.1       dsieger  2407: 
1.61      wiz      2408: You can also use a different program than the platform default program by
                   2409: changing the FETCH_USING variable. You can specify the program by using of ftp,
                   2410: fetch, wget or curl. Alternatively, fetching can be disabled by using the value
                   2411: manual. A value of custom disables the system defaults and dependency tracking
                   2412: for the fetch program. In that case you have to provide FETCH_CMD,
                   2413: FETCH_BEFORE_ARGS, FETCH_RESUME_ARGS, FETCH_OUTPUT_ARGS, FETCH_AFTER_ARGS.
1.1       dsieger  2414: 
1.16      jnemeth  2415: For example, if you want to use wget to download, you'll have to use something
                   2416: like:
1.1       dsieger  2417: 
1.16      jnemeth  2418: FETCH_USING=    wget
1.1       dsieger  2419: 
1.154     rillig   2420: 10.5. How can I install/use modular X.org from pkgsrc?
1.1       dsieger  2421: 
1.4       rillig   2422: If you want to use modular X.org from pkgsrc instead of your system's own X11
                   2423: (/usr/X11R6, /usr/openwin, ...) you will have to add the following line into
1.1       dsieger  2424: mk.conf:
                   2425: 
1.4       rillig   2426: X11_TYPE=modular
1.1       dsieger  2427: 
1.154     rillig   2428: 10.6. How to fetch files from behind a firewall
1.1       dsieger  2429: 
                   2430: If you are sitting behind a firewall which does not allow direct connections to
                   2431: Internet hosts (i.e. non-NAT), you may specify the relevant proxy hosts. This
                   2432: is done using an environment variable in the form of a URL, e.g. in Amdahl, the
                   2433: machine "orpheus.amdahl.com" is one of the firewalls, and it uses port 80 as
                   2434: the proxy port number. So the proxy environment variables are:
                   2435: 
                   2436: ftp_proxy=ftp://orpheus.amdahl.com:80/
                   2437: http_proxy=http://orpheus.amdahl.com:80/
                   2438: 
1.154     rillig   2439: 10.7. How to fetch files from HTTPS sites
1.65      wiz      2440: 
                   2441: Some fetch tools are not prepared to support HTTPS by default (for example, the
                   2442: one in NetBSD 6.0), or the one installed by the pkgsrc bootstrap (to avoid an
                   2443: openssl dependency that low in the dependency graph).
                   2444: 
                   2445: Usually you won't notice, because distribution files are mirrored weekly to "
                   2446: ftp.NetBSD.org", but that might not be often enough if you are following
                   2447: pkgsrc-current. In that case, set FETCH_USING in your mk.conf file to "curl" or
                   2448: "wget", which are both compiled with HTTPS support by default. Of course, these
                   2449: tools need to be installed before you can use them this way.
                   2450: 
1.154     rillig   2451: 10.8. How do I tell make fetch to do passive FTP?
1.1       dsieger  2452: 
                   2453: This depends on which utility is used to retrieve distfiles. From bsd.pkg.mk,
                   2454: FETCH_CMD is assigned the first available command from the following list:
                   2455: 
                   2456:   * ${LOCALBASE}/bin/ftp
                   2457: 
                   2458:   * /usr/bin/ftp
                   2459: 
                   2460: On a default NetBSD installation, this will be /usr/bin/ftp, which
                   2461: automatically tries passive connections first, and falls back to active
                   2462: connections if the server refuses to do passive. For the other tools, add the
1.4       rillig   2463: following to your mk.conf file: PASSIVE_FETCH=1.
1.1       dsieger  2464: 
                   2465: Having that option present will prevent /usr/bin/ftp from falling back to
                   2466: active transfers.
                   2467: 
1.154     rillig   2468: 10.9. How to fetch all distfiles at once
1.1       dsieger  2469: 
                   2470: You would like to download all the distfiles in a single batch from work or
                   2471: university, where you can't run a make fetch. There is an archive of distfiles
                   2472: on ftp.NetBSD.org, but downloading the entire directory may not be appropriate.
                   2473: 
                   2474: The answer here is to do a make fetch-list in /usr/pkgsrc or one of its
                   2475: subdirectories, carry the resulting list to your machine at work/school and use
                   2476: it there. If you don't have a NetBSD-compatible ftp(1) (like tnftp) at work,
                   2477: don't forget to set FETCH_CMD to something that fetches a URL:
                   2478: 
                   2479: At home:
                   2480: 
                   2481: % cd /usr/pkgsrc
                   2482: % make fetch-list FETCH_CMD=wget DISTDIR=/tmp/distfiles >/tmp/fetch.sh
                   2483: % scp /tmp/fetch.sh work:/tmp
                   2484: 
                   2485: At work:
                   2486: 
                   2487: % sh /tmp/fetch.sh
                   2488: 
                   2489: then tar up /tmp/distfiles and take it home.
                   2490: 
                   2491: If you have a machine running NetBSD, and you want to get all distfiles (even
                   2492: ones that aren't for your machine architecture), you can do so by using the
                   2493: above-mentioned make fetch-list approach, or fetch the distfiles directly by
                   2494: running:
                   2495: 
                   2496: % make mirror-distfiles
                   2497: 
                   2498: If you even decide to ignore NO_{SRC,BIN}_ON_{FTP,CDROM}, then you can get
                   2499: everything by running:
                   2500: 
                   2501: % make fetch NO_SKIP=yes
                   2502: 
1.154     rillig   2503: 10.10. What does "Don't know how to make /usr/share/tmac/tmac.andoc" mean?
1.1       dsieger  2504: 
                   2505: When compiling the pkgtools/pkg_install package, you get the error from make
                   2506: that it doesn't know how to make /usr/share/tmac/tmac.andoc? This indicates
                   2507: that you don't have installed the "text" set (nroff, ...) from the NetBSD base
                   2508: distribution on your machine. It is recommended to do that to format man pages.
                   2509: 
                   2510: In the case of the pkgtools/pkg_install package, you can get away with setting
1.4       rillig   2511: NOMAN=YES either in the environment or in mk.conf.
1.1       dsieger  2512: 
1.154     rillig   2513: 10.11. What does "Could not find bsd.own.mk" mean?
1.1       dsieger  2514: 
                   2515: You didn't install the compiler set, comp.tgz, when you installed your NetBSD
                   2516: machine. Please get and install it, by extracting it in /:
                   2517: 
                   2518: # cd /
                   2519: # tar --unlink -zxvpf .../comp.tgz
                   2520: 
                   2521: comp.tgz is part of every NetBSD release. Get the one that corresponds to your
                   2522: release (determine via uname -r).
                   2523: 
1.154     rillig   2524: 10.12. Using 'sudo' with pkgsrc
1.1       dsieger  2525: 
                   2526: When installing packages as non-root user and using the just-in-time su(1)
                   2527: feature of pkgsrc, it can become annoying to type in the root password for each
                   2528: required package installed. To avoid this, the sudo package can be used, which
                   2529: does password caching over a limited time. To use it, install sudo (either as
1.4       rillig   2530: binary package or from security/sudo) and then put the following into your
                   2531: mk.conf, somewhere after the definition of the LOCALBASE variable:
1.1       dsieger  2532: 
                   2533: .if exists(${LOCALBASE}/bin/sudo)
                   2534: SU_CMD=        ${LOCALBASE}/bin/sudo /bin/sh -c
                   2535: .endif
                   2536: 
1.154     rillig   2537: 10.13. How do I change the location of configuration files?
1.1       dsieger  2538: 
                   2539: As the system administrator, you can choose where configuration files are
                   2540: installed. The default settings make all these files go into ${PREFIX}/etc or
                   2541: some of its subdirectories; this may be suboptimal depending on your
                   2542: expectations (e.g., a read-only, NFS-exported PREFIX with a need of per-machine
                   2543: configuration of the provided packages).
                   2544: 
                   2545: In order to change the defaults, you can modify the PKG_SYSCONFBASE variable
1.4       rillig   2546: (in mk.conf) to point to your preferred configuration directory; some common
                   2547: examples include /etc or /etc/pkg.
1.1       dsieger  2548: 
                   2549: Furthermore, you can change this value on a per-package basis by setting the
                   2550: PKG_SYSCONFDIR.${PKG_SYSCONFVAR} variable. PKG_SYSCONFVAR's value usually
                   2551: matches the name of the package you would like to modify, that is, the contents
                   2552: of PKGBASE.
                   2553: 
                   2554: Note that after changing these settings, you must rebuild and reinstall any
                   2555: affected packages.
                   2556: 
1.154     rillig   2557: 10.14. Automated security checks
1.1       dsieger  2558: 
                   2559: Please be aware that there can often be bugs in third-party software, and some
                   2560: of these bugs can leave a machine vulnerable to exploitation by attackers. In
                   2561: an effort to lessen the exposure, the NetBSD packages team maintains a database
                   2562: of known-exploits to packages which have at one time been included in pkgsrc.
                   2563: The database can be downloaded automatically, and a security audit of all
1.14      jmcneill 2564: packages installed on a system can take place. To do this, refer to the
                   2565: following two tools (installed as part of the pkgtools/pkg_install package):
1.1       dsieger  2566: 
1.21      snj      2567:  1. pkg_admin fetch-pkg-vulnerabilities, an easy way to download a list of the
                   2568:     security vulnerabilities information. This list is kept up to date by the
1.26      spz      2569:     pkgsrc security team, and is distributed from the NetBSD ftp server:
1.1       dsieger  2570: 
1.177     leot     2571:     https://ftp.NetBSD.org/pub/NetBSD/packages/vulns/pkg-vulnerabilities
1.1       dsieger  2572: 
1.21      snj      2573:  2. pkg_admin audit, an easy way to audit the current machine, checking each
1.24      wiz      2574:     known vulnerability. If a vulnerable package is installed, it will be shown
                   2575:     by output to stdout, including a description of the type of vulnerability,
                   2576:     and a URL containing more information.
1.1       dsieger  2577: 
1.154     rillig   2578: Use of these tools is strongly recommended! See Section 5.1.5, "Checking for
1.121     sevan    2579: security vulnerabilities in installed packages" for instructions on how to
                   2580: automate checking and reporting.
                   2581: 
                   2582: If this database is installed, pkgsrc builds will use it to perform a security
                   2583: check before building any package.
1.1       dsieger  2584: 
1.154     rillig   2585: 10.15. Why do some packages ignore my CFLAGS?
1.1       dsieger  2586: 
                   2587: When you add your own preferences to the CFLAGS variable in your mk.conf, these
                   2588: flags are passed in environment variables to the ./configure scripts and to
                   2589: make(1). Some package authors ignore the CFLAGS from the environment variable
                   2590: by overriding them in the Makefiles of their package.
                   2591: 
                   2592: Currently there is no solution to this problem. If you really need the package
                   2593: to use your CFLAGS you should run make patch in the package directory and then
                   2594: inspect any Makefile and Makefile.in for whether they define CFLAGS explicitly.
                   2595: Usually you can remove these lines. But be aware that some "smart" programmers
                   2596: write so bad code that it only works for the specific combination of CFLAGS
                   2597: they have chosen.
                   2598: 
1.172     rillig   2599: To find out where the CFLAGS are ignored, add the following lines to mk.conf:
                   2600: 
                   2601: CPPFLAGS+=              -Dpkgsrc___CPPFLAGS
                   2602: CFLAGS+=                -Dpkgsrc___CFLAGS
                   2603: CXXFLAGS+=              -Dpkgsrc___CXXFLAGS
                   2604: 
                   2605: Then run bmake show-all-configure show-all-build to see whether the above flags
                   2606: are passed to the actual build commands in general.
                   2607: 
                   2608: To find out whether the flags are passed to individual compiler commands, have
                   2609: a look at the file work/.work.log. In most cases, the flags from the original
                   2610: command lines (the lines starting with [*]) are passed unmodified to the actual
                   2611: compiler (the lines starting with <.>). If the flag is missing from the actual
                   2612: compiler command, it must have been removed by the pkgsrc compiler wrappers.
                   2613: 
1.154     rillig   2614: 10.16. A package does not build. What shall I do?
1.1       dsieger  2615: 
                   2616:  1. Make sure that your copy of pkgsrc is consistent. A case that occurs often
                   2617:     is that people only update pkgsrc in parts, because of performance reasons.
                   2618:     Since pkgsrc is one large system, not a collection of many small systems,
                   2619:     there are sometimes changes that only work when the whole pkgsrc tree is
                   2620:     updated.
                   2621: 
1.25      wiz      2622:  2. Make sure that you don't have any CVS conflicts. Search for "<<<<<<" or "
                   2623:     >>>>>>" in all your pkgsrc files.
1.1       dsieger  2624: 
1.25      wiz      2625:  3. Make sure that you don't have old copies of the packages extracted. Run 
1.1       dsieger  2626:     make clean clean-depends to verify this.
                   2627: 
1.108     rillig   2628:  4. If you are a package developer who wants to invest some work, have a look
1.154     rillig   2629:     at Chapter 21, Making your package work.
1.108     rillig   2630: 
                   2631:  5. If the problem still exists, write a mail to the pkgsrc-users mailing list.
1.1       dsieger  2632: 
1.154     rillig   2633: 10.17. What does "Makefile appears to contain unresolved cvs/rcs/??? merge
1.1       dsieger  2634: conflicts" mean?
                   2635: 
                   2636: You have modified a file from pkgsrc, and someone else has modified that same
                   2637: file afterwards in the CVS repository. Both changes are in the same region of
                   2638: the file, so when you updated pkgsrc, the cvs command marked the conflicting
                   2639: changes in the file. Because of these markers, the file is no longer a valid
                   2640: Makefile.
                   2641: 
                   2642: Have a look at that file, and if you don't need your local changes anymore, you
                   2643: can remove that file and run cvs -q update -dP in that directory to download
                   2644: the current version.
                   2645: 
                   2646: Part II. The pkgsrc developer's guide
                   2647: 
                   2648: This part of the book deals with creating and modifying packages. It starts
                   2649: with a "HOWTO"-like guide on creating a new package. The remaining chapters are
                   2650: more like a reference manual for pkgsrc.
                   2651: 
                   2652: Table of Contents
                   2653: 
1.154     rillig   2654: 11. Getting help
1.184     rillig   2655: 12. Package components - files, directories and contents
1.1       dsieger  2656: 
1.184     rillig   2657:     12.1. Makefile
                   2658:     12.2. distinfo
                   2659:     12.3. patches/*
1.1       dsieger  2660: 
1.184     rillig   2661:         12.3.1. Structure of a single patch file
                   2662:         12.3.2. Creating patch files
                   2663:         12.3.3. Sources where the patch files come from
                   2664:         12.3.4. Patching guidelines
                   2665:         12.3.5. Feedback to the author
1.1       dsieger  2666: 
1.184     rillig   2667:     12.4. Other mandatory files
                   2668:     12.5. Optional files
1.1       dsieger  2669: 
1.184     rillig   2670:         12.5.1. Files affecting the binary package
                   2671:         12.5.2. Files affecting the build process
                   2672:         12.5.3. Files affecting nothing at all
1.1       dsieger  2673: 
1.184     rillig   2674:     12.6. work*
                   2675:     12.7. files/*
1.1       dsieger  2676: 
1.184     rillig   2677: 13. The build process
1.1       dsieger  2678: 
1.184     rillig   2679:     13.1. Introduction
                   2680:     13.2. Program location
                   2681:     13.3. Directories used during the build process
                   2682:     13.4. Running a phase
                   2683:     13.5. The fetch phase
1.1       dsieger  2684: 
1.184     rillig   2685:         13.5.1. What to fetch and where to get it from
                   2686:         13.5.2. How are the files fetched?
1.1       dsieger  2687: 
1.184     rillig   2688:     13.6. The checksum phase
                   2689:     13.7. The extract phase
                   2690:     13.8. The patch phase
                   2691:     13.9. The tools phase
                   2692:     13.10. The wrapper phase
                   2693:     13.11. The configure phase
                   2694:     13.12. The build phase
                   2695:     13.13. The test phase
                   2696:     13.14. The install phase
                   2697:     13.15. The package phase
                   2698:     13.16. Cleaning up
                   2699:     13.17. Other helpful targets
1.1       dsieger  2700: 
1.184     rillig   2701: 14. Creating a new pkgsrc package from scratch
1.1       dsieger  2702: 
1.184     rillig   2703:     14.1. Common types of packages
1.1       dsieger  2704: 
1.184     rillig   2705:         14.1.1. Perl modules
                   2706:         14.1.2. Python modules and programs
                   2707:         14.1.3. R packages
                   2708:         14.1.4. TeXlive packages
1.1       dsieger  2709: 
1.184     rillig   2710:     14.2. Examples
1.1       dsieger  2711: 
1.184     rillig   2712:         14.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  2713: 
1.184     rillig   2714: 15. Programming in Makefiles
1.1       dsieger  2715: 
1.184     rillig   2716:     15.1. Caveats
                   2717:     15.2. Makefile variables
1.1       dsieger  2718: 
1.184     rillig   2719:         15.2.1. Naming conventions
1.1       dsieger  2720: 
1.184     rillig   2721:     15.3. Code snippets
1.1       dsieger  2722: 
1.184     rillig   2723:         15.3.1. Adding things to a list
                   2724:         15.3.2. Echoing a string exactly as-is
                   2725:         15.3.3. Passing CFLAGS to GNU configure scripts
                   2726:         15.3.4. Handling possibly empty variables
1.1       dsieger  2727: 
1.184     rillig   2728: 16. Options handling
1.1       dsieger  2729: 
1.184     rillig   2730:     16.1. Global default options
                   2731:     16.2. Converting packages to use bsd.options.mk
                   2732:     16.3. Option Names
                   2733:     16.4. Determining the options of dependencies
1.1       dsieger  2734: 
1.184     rillig   2735: 17. Tools needed for building or running
1.1       dsieger  2736: 
1.184     rillig   2737:     17.1. Tools for pkgsrc builds
                   2738:     17.2. Tools needed by packages
                   2739:     17.3. Tools provided by platforms
1.1       dsieger  2740: 
1.184     rillig   2741: 18. Buildlink methodology
1.1       dsieger  2742: 
1.184     rillig   2743:     18.1. Converting packages to use buildlink3
                   2744:     18.2. Writing buildlink3.mk files
1.1       dsieger  2745: 
1.184     rillig   2746:         18.2.1. Anatomy of a buildlink3.mk file
                   2747:         18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
                   2748:             pkg in buildlink3.mk files
1.1       dsieger  2749: 
1.184     rillig   2750:     18.3. Writing builtin.mk files
1.1       dsieger  2751: 
1.184     rillig   2752:         18.3.1. Anatomy of a builtin.mk file
                   2753:         18.3.2. Global preferences for native or pkgsrc software
1.1       dsieger  2754: 
1.184     rillig   2755: 19. PLIST issues
1.1       dsieger  2756: 
1.184     rillig   2757:     19.1. RCS ID
                   2758:     19.2. Semi-automatic PLIST generation
                   2759:     19.3. Tweaking output of make print-PLIST
                   2760:     19.4. Variable substitution in PLIST
                   2761:     19.5. Man page compression
                   2762:     19.6. Changing PLIST source with PLIST_SRC
                   2763:     19.7. Platform-specific and differing PLISTs
                   2764:     19.8. Build-specific PLISTs
                   2765:     19.9. Sharing directories between packages
1.1       dsieger  2766: 
1.184     rillig   2767: 20. The pkginstall framework
1.1       dsieger  2768: 
1.184     rillig   2769:     20.1. Files and directories outside the installation prefix
1.1       dsieger  2770: 
1.184     rillig   2771:         20.1.1. Directory manipulation
                   2772:         20.1.2. File manipulation
1.1       dsieger  2773: 
1.184     rillig   2774:     20.2. Configuration files
1.1       dsieger  2775: 
1.184     rillig   2776:         20.2.1. How PKG_SYSCONFDIR is set
                   2777:         20.2.2. Telling the software where configuration files are
                   2778:         20.2.3. Patching installations
                   2779:         20.2.4. Disabling handling of configuration files
1.1       dsieger  2780: 
1.184     rillig   2781:     20.3. System startup scripts
1.1       dsieger  2782: 
1.184     rillig   2783:         20.3.1. Disabling handling of system startup scripts
1.1       dsieger  2784: 
1.184     rillig   2785:     20.4. System users and groups
                   2786:     20.5. System shells
1.1       dsieger  2787: 
1.184     rillig   2788:         20.5.1. Disabling shell registration
1.1       dsieger  2789: 
1.184     rillig   2790:     20.6. Fonts
1.1       dsieger  2791: 
1.184     rillig   2792:         20.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  2793: 
1.154     rillig   2794: 21. Making your package work
1.1       dsieger  2795: 
1.154     rillig   2796:     21.1. General operation
1.1       dsieger  2797: 
1.154     rillig   2798:         21.1.1. How to pull in user-settable variables from mk.conf
                   2799:         21.1.2. User interaction
                   2800:         21.1.3. Handling licenses
                   2801:         21.1.4. Restricted packages
                   2802:         21.1.5. Handling dependencies
                   2803:         21.1.6. Handling conflicts with other packages
                   2804:         21.1.7. Packages that cannot or should not be built
                   2805:         21.1.8. Packages which should not be deleted, once installed
                   2806:         21.1.9. Handling packages with security problems
                   2807:         21.1.10. How to handle incrementing versions when fixing an existing
1.1       dsieger  2808:             package
1.154     rillig   2809:         21.1.11. Substituting variable text in the package files (the SUBST
1.1       dsieger  2810:             framework)
                   2811: 
1.154     rillig   2812:     21.2. The fetch phase
1.1       dsieger  2813: 
1.154     rillig   2814:         21.2.1. Packages whose distfiles aren't available for plain downloading
                   2815:         21.2.2. How to handle modified distfiles with the 'old' name
                   2816:         21.2.3. Packages hosted on github.com
                   2817: 
                   2818:     21.3. The configure phase
                   2819: 
                   2820:         21.3.1. Shared libraries - libtool
                   2821:         21.3.2. Using libtool on GNU packages that already support libtool
                   2822:         21.3.3. GNU Autoconf/Automake
                   2823: 
                   2824:     21.4. Programming languages
                   2825: 
                   2826:         21.4.1. C, C++, and Fortran
                   2827:         21.4.2. Java
                   2828:         21.4.3. Packages containing perl scripts
                   2829:         21.4.4. Packages containing shell scripts
                   2830:         21.4.5. Other programming languages
                   2831: 
                   2832:     21.5. The build phase
                   2833: 
                   2834:         21.5.1. Compiling C and C++ code conditionally
                   2835:         21.5.2. How to handle compiler bugs
1.172     rillig   2836:         21.5.3. No such file or directory
                   2837:         21.5.4. Undefined reference to "..."
                   2838:         21.5.5. Running out of memory
1.154     rillig   2839: 
                   2840:     21.6. The install phase
                   2841: 
                   2842:         21.6.1. Creating needed directories
                   2843:         21.6.2. Where to install documentation
                   2844:         21.6.3. Installing highscore files
                   2845:         21.6.4. Adding DESTDIR support to packages
                   2846:         21.6.5. Packages with hardcoded paths to other interpreters
                   2847:         21.6.6. Packages installing perl modules
                   2848:         21.6.7. Packages installing info files
                   2849:         21.6.8. Packages installing man pages
                   2850:         21.6.9. Packages installing GConf data files
                   2851:         21.6.10. Packages installing scrollkeeper/rarian data files
                   2852:         21.6.11. Packages installing X11 fonts
                   2853:         21.6.12. Packages installing GTK2 modules
                   2854:         21.6.13. Packages installing SGML or XML data
                   2855:         21.6.14. Packages installing extensions to the MIME database
                   2856:         21.6.15. Packages using intltool
                   2857:         21.6.16. Packages installing startup scripts
                   2858:         21.6.17. Packages installing TeX modules
                   2859:         21.6.18. Packages supporting running binaries in emulation
                   2860:         21.6.19. Packages installing hicolor theme icons
                   2861:         21.6.20. Packages installing desktop files
                   2862: 
                   2863:     21.7. Marking packages as having problems
                   2864: 
1.184     rillig   2865: 22. GNOME packaging and porting
                   2866: 
                   2867:     22.1. Meta packages
                   2868:     22.2. Packaging a GNOME application
                   2869:     22.3. Updating GNOME to a newer version
                   2870:     22.4. Patching guidelines
                   2871: 
1.154     rillig   2872: 23. Submitting and Committing
                   2873: 
                   2874:     23.1. Submitting binary packages
                   2875:     23.2. Submitting source packages (for non-NetBSD-developers)
                   2876:     23.3. General notes when adding, updating, or removing packages
                   2877:     23.4. Commit Messages
                   2878:     23.5. Committing: Adding a package to CVS
                   2879:     23.6. Updating a package to a newer version
                   2880:     23.7. Renaming a package in pkgsrc
                   2881:     23.8. Moving a package in pkgsrc
                   2882: 
                   2883: 24. Frequently Asked Questions
                   2884: 
                   2885: Chapter 11. Getting help
                   2886: 
                   2887: To get help when developing pkgsrc, the definitive source is this document, the
                   2888: pkgsrc guide. If you don't find anything here, there are alternatives:
                   2889: 
                   2890:   * The built-in pkgsrc help, which is available after bootstrapping pkgsrc.
                   2891:     Run bmake help topic=? to get help for any topic, such as a variable name
                   2892:     like BUILD_DEFS, a make target like do-build, a missing C or C++ function
                   2893:     like strcasecmp or any other topic.
                   2894: 
                   2895:     The available help topics are listed in Appendix D, Help topics.
                   2896: 
1.163     rillig   2897:   * To see the value of a single variable, run bmake show-var VARNAME=X.
                   2898: 
                   2899:   * To see the values of the most common variables, run bmake show-all. These
                   2900:     variables are grouped by topic. To see the variables for a single topic,
                   2901:     run bmake show-all-topic, for example bmake show-all-fetch.
                   2902: 
1.154     rillig   2903:   * The tech-pkg mailing list, to which you can subscribe and then ask your
                   2904:     questions.
                   2905: 
                   2906:   * The #pkgsrc IRC channel, which is accessible via a web browser or by using
                   2907:     a specialized chat program such as XChat. Pick any user name and join the
                   2908:     channel #pkgsrc.
1.1       dsieger  2909: 
1.184     rillig   2910: Chapter 12. Package components - files, directories and contents
1.1       dsieger  2911: 
                   2912: Table of Contents
                   2913: 
1.184     rillig   2914: 12.1. Makefile
                   2915: 12.2. distinfo
                   2916: 12.3. patches/*
                   2917: 
                   2918:     12.3.1. Structure of a single patch file
                   2919:     12.3.2. Creating patch files
                   2920:     12.3.3. Sources where the patch files come from
                   2921:     12.3.4. Patching guidelines
                   2922:     12.3.5. Feedback to the author
                   2923: 
                   2924: 12.4. Other mandatory files
                   2925: 12.5. Optional files
                   2926: 
                   2927:     12.5.1. Files affecting the binary package
                   2928:     12.5.2. Files affecting the build process
                   2929:     12.5.3. Files affecting nothing at all
1.1       dsieger  2930: 
1.184     rillig   2931: 12.6. work*
                   2932: 12.7. files/*
1.1       dsieger  2933: 
1.184     rillig   2934: Whenever you're preparing a package, there are a number of files involved which
                   2935: are described in the following sections.
1.1       dsieger  2936: 
1.184     rillig   2937: 12.1. Makefile
1.1       dsieger  2938: 
1.184     rillig   2939: Building, installation and creation of a binary package are all controlled by
                   2940: the package's Makefile. The Makefile describes various things about a package,
                   2941: for example from where to get it, how to configure, build, and install it.
1.1       dsieger  2942: 
1.184     rillig   2943: A package Makefile contains several sections that describe the package.
1.1       dsieger  2944: 
1.184     rillig   2945: In the first section there are the following variables, which should appear
                   2946: exactly in the order given here. The order and grouping of the variables is
                   2947: mostly historical and has no further meaning.
1.1       dsieger  2948: 
1.184     rillig   2949:   * DISTNAME is the basename of the distribution file to be downloaded from the
                   2950:     package's website.
1.1       dsieger  2951: 
1.184     rillig   2952:   * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
                   2953:     it if DISTNAME (which is the default) is not a good name for the package in
                   2954:     pkgsrc or DISTNAME is not provided (no distribution file is required).
                   2955:     Usually it is the pkgsrc directory name together with the version number.
                   2956:     It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
                   2957:     is, it starts with a letter or digit, and contains only letters, digits,
                   2958:     dashes, underscores, dots and plus signs.
1.26      spz      2959: 
1.184     rillig   2960:   * CATEGORIES is a list of categories which the package fits in. You can
                   2961:     choose any of the top-level directories of pkgsrc for it.
1.1       dsieger  2962: 
1.184     rillig   2963:     Currently the following values are available for CATEGORIES. If more than
                   2964:     one is used, they need to be separated by spaces:
1.1       dsieger  2965: 
1.184     rillig   2966:     archivers     cross         geography     meta-pkgs     security
                   2967:     audio         databases     graphics      misc          shells
                   2968:     benchmarks    devel         ham           multimedia    sysutils
                   2969:     biology       editors       inputmethod   net           textproc
                   2970:     cad           emulators     lang          news          time
                   2971:     chat          finance       mail          parallel      wm
                   2972:     comms         fonts         math          pkgtools      www
                   2973:     converters    games         mbone         print         x11
1.1       dsieger  2974: 
1.184     rillig   2975:   * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
                   2976:     are discussed in detail in Section 13.5, "The fetch phase".
1.1       dsieger  2977: 
1.184     rillig   2978: The second section contains information about separately downloaded patches, if
                   2979: any.
1.1       dsieger  2980: 
1.184     rillig   2981:   * PATCHFILES: Name(s) of additional files that contain distribution patches.
                   2982:     There is no default. pkgsrc will look for them at PATCH_SITES. They will
                   2983:     automatically be uncompressed before patching if the names end with .gz or
                   2984:     .Z.
1.1       dsieger  2985: 
1.184     rillig   2986:   * PATCH_SITES: Primary location(s) for distribution patch files (see
                   2987:     PATCHFILES above) if not found locally.
1.1       dsieger  2988: 
1.184     rillig   2989:   * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
                   2990:     count to help find the correct files to patch. It defaults to -p0.
1.1       dsieger  2991: 
1.184     rillig   2992: The third section contains the following variables.
1.1       dsieger  2993: 
1.184     rillig   2994:   * MAINTAINER is the email address of the person who feels responsible for
                   2995:     this package, and who is most likely to look at problems or questions
                   2996:     regarding this package which have been reported with send-pr(1). Other
                   2997:     developers may contact the MAINTAINER before making changes to the package,
                   2998:     but are not required to do so. When packaging a new program, set MAINTAINER
                   2999:     to yourself. If you really can't maintain the package for future updates,
                   3000:     set it to <pkgsrc-users@NetBSD.org>.
1.1       dsieger  3001: 
1.184     rillig   3002:   * OWNER should be used instead of MAINTAINER when you do not want other
                   3003:     developers to update or change the package without contacting you first. A
                   3004:     package Makefile should contain one of MAINTAINER or OWNER, but not both.
1.1       dsieger  3005: 
1.184     rillig   3006:   * HOMEPAGE is a URL where users can find more information about the package.
1.1       dsieger  3007: 
1.184     rillig   3008:   * COMMENT is a one-line description of the package (should not include the
                   3009:     package name).
1.1       dsieger  3010: 
1.184     rillig   3011:   * LICENSE indicates the license(s) applicable for the package. See
                   3012:     Section 21.1.3, "Handling licenses" for further details.
1.1       dsieger  3013: 
1.184     rillig   3014: Other variables that affect the build:
1.1       dsieger  3015: 
1.184     rillig   3016:   * WRKSRC: The directory where the interesting distribution files of the
                   3017:     package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
                   3018:     most packages.
1.1       dsieger  3019: 
1.184     rillig   3020:     If a package doesn't create a subdirectory for itself (most GNU software
                   3021:     does, for instance), but extracts itself in the current directory, you
                   3022:     should set WRKSRC=${WRKDIR}.
1.1       dsieger  3023: 
1.184     rillig   3024:     If a package doesn't create a subdirectory with the name of DISTNAME but
                   3025:     some different name, set WRKSRC to point to the proper name in ${WRKDIR},
                   3026:     for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
                   3027:     other examples.
1.17      imil     3028: 
1.184     rillig   3029:     The name of the working directory created by pkgsrc is taken from the
                   3030:     WRKDIR_BASENAME variable. By default, its value is work. If you want to use
                   3031:     the same pkgsrc tree for building different kinds of binary packages, you
                   3032:     can change the variable according to your needs. Two other variables handle
                   3033:     common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
                   3034:     defined in mk.conf, the first component of the host's name is attached to
                   3035:     the directory name. If OBJMACHINE is defined, the platform name is
                   3036:     attached, which might look like work.i386 or work.sparc.
1.17      imil     3037: 
1.184     rillig   3038: Please pay attention to the following gotchas:
1.17      imil     3039: 
1.184     rillig   3040:   * Add MANCOMPRESSED if man pages are installed in compressed form by the
                   3041:     package. For packages using BSD-style makefiles which honor MANZ, there is
                   3042:     MANCOMPRESSED_IF_MANZ.
1.17      imil     3043: 
1.184     rillig   3044:   * Replace /usr/local with "${PREFIX}" in all files (see patches, below).
1.103     wiz      3045: 
1.184     rillig   3046:   * If the package installs any info files, see Section 21.6.7, "Packages
                   3047:     installing info files".
1.103     wiz      3048: 
1.184     rillig   3049: 12.2. distinfo
1.17      imil     3050: 
1.184     rillig   3051: The distinfo file contains the message digest, or checksum, of each distfile
                   3052: needed for the package. This ensures that the distfiles retrieved from the
                   3053: Internet have not been corrupted during transfer or altered by a malign force
                   3054: to introduce a security hole. To provide maximum security, all distfiles are
                   3055: protected using three different message digest algorithms (SHA1, RMD160,
                   3056: SHA512), as well as the file size.
1.17      imil     3057: 
1.184     rillig   3058: The distinfo file also contains the checksums for all the patches found in the
                   3059: patches directory (see Section 12.3, "patches/*"). These checksums ensure that
                   3060: patches are only applied intentionally and that they don't accidentally change,
                   3061: e.g. when merging different changes together. They also make sure that new
                   3062: patches are actually added to CVS and old ones are removed. Too see whether the
                   3063: patches and the distinfo file match, run pkglint after changing the patches.
1.17      imil     3064: 
1.184     rillig   3065: To regenerate the distinfo file, use the make distinfo command.
1.17      imil     3066: 
1.184     rillig   3067: Some packages have different sets of distfiles depending on the platform, for
                   3068: example lang/openjdk8. These are kept in the same distinfo file and care should
                   3069: be taken when upgrading such a package to ensure distfile information is not
                   3070: lost.
1.17      imil     3071: 
1.184     rillig   3072: 12.3. patches/*
1.63      wiz      3073: 
1.184     rillig   3074: Some packages don't work out-of-the box on the various platforms that are
                   3075: supported by pkgsrc. These packages need to be patched to make them work. The
                   3076: patch files can be found in the patches/ directory.
1.17      imil     3077: 
1.184     rillig   3078: In the patch phase, these patches are applied to the files in WRKSRC directory
                   3079: after extracting them, in alphabetic order.
1.160     brook    3080: 
1.184     rillig   3081: 12.3.1. Structure of a single patch file
1.160     brook    3082: 
1.184     rillig   3083: The patch-* files should be in diff -bu format, and apply without a fuzz to
                   3084: avoid problems. (To force patches to apply with fuzz you can set
                   3085: PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
                   3086: a single file, and no file should be patched by more than one patch file. This
                   3087: helps to keep future modifications simple.
1.160     brook    3088: 
1.184     rillig   3089: Each patch file is structured as follows: In the first line, there is the RCS
                   3090: Id of the patch itself. The second line should be empty for aesthetic reasons.
                   3091: After that, there should be a comment for each change that the patch does.
                   3092: There are a number of standard cases:
1.160     brook    3093: 
1.184     rillig   3094:   * Patches for commonly known vulnerabilities should mention the vulnerability
                   3095:     ID (CAN, CVE).
1.160     brook    3096: 
1.184     rillig   3097:   * Patches that change source code should mention the platform and other
                   3098:     environment (for example, the compiler) that the patch is needed for.
1.160     brook    3099: 
1.184     rillig   3100: The patch should be commented so that any developer who knows the code of the
                   3101: application can make some use of the patch. Special care should be taken for
                   3102: the upstream developers, since we generally want that they accept our patches,
                   3103: so we have less work in the future.
1.160     brook    3104: 
1.184     rillig   3105: 12.3.2. Creating patch files
1.160     brook    3106: 
1.184     rillig   3107: One important thing to mention is to pay attention that no RCS IDs get stored
                   3108: in the patch files, as these will cause problems when later checked into the
                   3109: NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
                   3110: avoid these problems.
1.160     brook    3111: 
1.184     rillig   3112: For even more automation, we recommend using mkpatches from the same package to
                   3113: make a whole set of patches. You just have to backup files before you edit them
                   3114: to filename.orig, e.g. with cp -p filename filename.orig or, easier, by using 
                   3115: pkgvi again from the same package. If you upgrade a package this way, you can
                   3116: easily compare the new set of patches with the previously existing one with 
                   3117: patchdiff. The files in patches are replaced by new files, so carefully check
                   3118: if you want to take all the changes.
1.160     brook    3119: 
1.184     rillig   3120: When you have finished a package, remember to generate the checksums for the
                   3121: patch files by using the make makepatchsum command, see Section 12.2,
                   3122: "distinfo".
1.1       dsieger  3123: 
1.184     rillig   3124: When adding a patch that corrects a problem in the distfile (rather than e.g.
                   3125: enforcing pkgsrc's view of where man pages should go), send the patch as a bug
                   3126: report to the maintainer. This benefits non-pkgsrc users of the package, and
                   3127: usually makes it possible to remove the patch in future version.
1.1       dsieger  3128: 
1.184     rillig   3129: The file names of the patch files are usually of the form patch-
                   3130: path_to_file__with__underscores.c. Many packages still use the previous
                   3131: convention patch-[a-z][a-z], but new patches should be of the form containing
                   3132: the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
                   3133: automatically.
1.1       dsieger  3134: 
1.184     rillig   3135: 12.3.3. Sources where the patch files come from
1.1       dsieger  3136: 
1.184     rillig   3137: If you want to share patches between multiple packages in pkgsrc, e.g. because
                   3138: they use the same distfiles, set PATCHDIR to the path where the patch files can
                   3139: be found, e.g.:
1.1       dsieger  3140: 
1.184     rillig   3141: PATCHDIR=       ../../editors/xemacs/patches
1.1       dsieger  3142: 
1.184     rillig   3143: Patch files that are distributed by the author or other maintainers can be
                   3144: listed in PATCHFILES.
1.1       dsieger  3145: 
1.184     rillig   3146: If it is desired to store any patches that should not be committed into pkgsrc,
                   3147: they can be kept outside the pkgsrc tree in the $LOCALPATCHES directory. The
                   3148: directory tree there is expected to have the same "category/package" structure
                   3149: as pkgsrc, and patches are expected to be stored inside these dirs (also known
                   3150: as $LOCALPATCHES/$PKGPATH). For example, if you want to keep a private patch
                   3151: for pkgsrc/graphics/png, keep it in $LOCALPATCHES/graphics/png/mypatch. All
                   3152: files in the named directory are expected to be patch files, and they are
                   3153: applied after pkgsrc patches are applied.
1.1       dsieger  3154: 
1.184     rillig   3155: 12.3.4. Patching guidelines
1.1       dsieger  3156: 
1.184     rillig   3157: When fixing a portability issue in the code do not use preprocessor magic to
                   3158: check for the current operating system nor platform. Doing so hurts portability
                   3159: to other platforms because the OS-specific details are not abstracted
                   3160: appropriately.
1.1       dsieger  3161: 
1.184     rillig   3162: The general rule to follow is: instead of checking for the operating system the
                   3163: application is being built on, check for the specific features you need. For
                   3164: example, instead of assuming that kqueue is available under NetBSD and using
                   3165: the __NetBSD__ macro to conditionalize kqueue support, add a check that detects
                   3166: kqueue itself ? yes, this generally involves patching the configure script.
                   3167: There is absolutely nothing that prevents some OSes from adopting interfaces
                   3168: from other OSes (e.g. Linux implementing kqueue), something that the above
                   3169: checks cannot take into account.
1.1       dsieger  3170: 
1.184     rillig   3171: Of course, checking for features generally involves more work on the
                   3172: developer's side, but the resulting changes are cleaner and there are chances
                   3173: they will work on many other platforms. Not to mention that there are higher
                   3174: chances of being later integrated into the mainstream sources. Remember: It
                   3175: doesn't work unless it is right!
1.1       dsieger  3176: 
1.184     rillig   3177: Some typical examples:
1.121     sevan    3178: 
1.184     rillig   3179: Table 12.1. Patching examples
1.1       dsieger  3180: 
1.184     rillig   3181: +-------------------------------------------------------------------------------------------+
                   3182: |  Where  |        Incorrect         |                       Correct                        |
                   3183: |---------+--------------------------+------------------------------------------------------|
                   3184: |         |case ${target_os} in      |                                                      |
                   3185: |configure|netbsd*) have_kvm=yes ;;  |AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)|
                   3186: |script   |*)       have_kvm=no  ;;  |                                                      |
                   3187: |         |esac                      |                                                      |
                   3188: |---------+--------------------------+------------------------------------------------------|
                   3189: |C source |#if defined(__NetBSD__)   |#if defined(HAVE_SYS_EVENT_H)                         |
                   3190: |file     |#  include <sys/event.h>  |#  include <sys/event.h>                              |
                   3191: |         |#endif                    |#endif                                                |
                   3192: |---------+--------------------------+------------------------------------------------------|
                   3193: |         |int                       |int                                                   |
                   3194: |         |monitor_file(...)         |monitor_file(...)                                     |
                   3195: |         |{                         |{                                                     |
                   3196: |         |#if defined(__NetBSD__)   |#if defined(HAVE_KQUEUE)                              |
                   3197: |C source |        int fd = kqueue();|        int fd = kqueue();                            |
                   3198: |file     |        ...               |        ...                                           |
                   3199: |         |#else                     |#else                                                 |
                   3200: |         |        ...               |        ...                                           |
                   3201: |         |#endif                    |#endif                                                |
                   3202: |         |}                         |}                                                     |
                   3203: +-------------------------------------------------------------------------------------------+
1.1       dsieger  3204: 
                   3205: 
1.184     rillig   3206: 12.3.5. Feedback to the author
1.1       dsieger  3207: 
1.184     rillig   3208: Always, always, always feed back any portability fixes or improvements you do
                   3209: to a package to the mainstream developers. This is the only way to get their
                   3210: attention on portability issues and to ensure that future versions can be built
                   3211: out-of-the box on NetBSD. Furthermore, any user that gets newer distfiles will
                   3212: get the fixes straight from the packaged code.
1.1       dsieger  3213: 
1.184     rillig   3214: This generally involves cleaning up the patches (because sometimes the patches
                   3215: that are added to pkgsrc are quick hacks), filing bug reports in the
                   3216: appropriate trackers for the projects and working with the mainstream authors
                   3217: to accept your changes. It is extremely important that you do it so that the
                   3218: packages in pkgsrc are kept simple and thus further changes can be done without
                   3219: much hassle.
1.1       dsieger  3220: 
1.184     rillig   3221: When you have done this, please add a URL to the upstream bug report to the
                   3222: patch comment.
1.1       dsieger  3223: 
1.184     rillig   3224: Support the idea of free software!
1.1       dsieger  3225: 
1.184     rillig   3226: 12.4. Other mandatory files
1.1       dsieger  3227: 
1.184     rillig   3228: DESCR
1.1       dsieger  3229: 
1.184     rillig   3230:     A multi-line description of the piece of software. This should include any
                   3231:     credits where they are due. Please bear in mind that others do not share
                   3232:     your sense of humour (or spelling idiosyncrasies), and that others will
                   3233:     read everything that you write here.
1.1       dsieger  3234: 
1.184     rillig   3235: PLIST
1.1       dsieger  3236: 
1.184     rillig   3237:     This file governs the files that are installed on your system: all the
                   3238:     binaries, manual pages, etc. There are other directives which may be
                   3239:     entered in this file, to control the creation and deletion of directories,
                   3240:     and the location of inserted files. See Chapter 19, PLIST issues for more
                   3241:     information.
1.1       dsieger  3242: 
1.184     rillig   3243: 12.5. Optional files
1.1       dsieger  3244: 
1.184     rillig   3245: 12.5.1. Files affecting the binary package
1.1       dsieger  3246: 
1.184     rillig   3247: INSTALL
1.1       dsieger  3248: 
1.184     rillig   3249:     This shell script is invoked twice by pkg_add(1). First time after package
                   3250:     extraction and before files are moved in place, the second time after the
                   3251:     files to install are moved in place. This can be used to do any custom
                   3252:     procedures not possible with @exec commands in PLIST. See pkg_add(1) and
                   3253:     pkg_create(1) for more information. See also Section 20.1, "Files and
                   3254:     directories outside the installation prefix". Please note that you can
                   3255:     modify variables in it easily by using FILES_SUBST in the package's
                   3256:     Makefile:
1.1       dsieger  3257: 
1.184     rillig   3258:     FILES_SUBST+=  SOMEVAR="somevalue"
1.1       dsieger  3259: 
1.184     rillig   3260:     replaces "@SOMEVAR@" with "somevalue" in the INSTALL. By default,
                   3261:     substitution is performed for PREFIX, LOCALBASE, X11BASE, VARBASE, and a
                   3262:     few others, type make help topic=FILES_SUBST for a complete list.
1.1       dsieger  3263: 
1.184     rillig   3264: DEINSTALL
1.1       dsieger  3265: 
1.184     rillig   3266:     This script is executed before and after any files are removed. It is this
                   3267:     script's responsibility to clean up any additional messy details around the
                   3268:     package's installation, since all pkg_delete knows is how to delete the
                   3269:     files created in the original distribution. See pkg_delete(1) and
                   3270:     pkg_create(1) for more information. The same methods to replace variables
                   3271:     can be used as for the INSTALL file.
1.1       dsieger  3272: 
1.184     rillig   3273: MESSAGE
1.1       dsieger  3274: 
1.184     rillig   3275:     This file is displayed after installation of the package. Useful for things
                   3276:     like legal notices on almost-free software and hints for updating config
                   3277:     files after installing modules for apache, PHP etc. Please note that you
                   3278:     can modify variables in it easily by using MESSAGE_SUBST in the package's
                   3279:     Makefile:
1.1       dsieger  3280: 
1.184     rillig   3281:     MESSAGE_SUBST+=  SOMEVAR="somevalue"
1.1       dsieger  3282: 
1.184     rillig   3283:     replaces "${SOMEVAR}" with "somevalue" in MESSAGE. By default, substitution
                   3284:     is performed for PKGNAME, PKGBASE, PREFIX, LOCALBASE, X11BASE,
                   3285:     PKG_SYSCONFDIR, ROOT_GROUP, and ROOT_USER.
1.1       dsieger  3286: 
1.184     rillig   3287:     You can display a different or additional files by setting the MESSAGE_SRC
                   3288:     variable. Its default is MESSAGE, if the file exists.
1.1       dsieger  3289: 
1.184     rillig   3290: ALTERNATIVES
1.1       dsieger  3291: 
1.184     rillig   3292:     This file is used by the alternatives framework. It creates, configures,
                   3293:     and destroys generic wrappers used to run programs with similar interfaces.
                   3294:     See pkg_alternatives(8) from pkgtools/pkg_alternatives for more
                   3295:     information.
1.1       dsieger  3296: 
1.184     rillig   3297:     Each line of the file contains two filenames, first the wrapper and then
                   3298:     the alternative provided by the package. Both paths are relative to PREFIX.
1.1       dsieger  3299: 
1.184     rillig   3300: 12.5.2. Files affecting the build process
1.1       dsieger  3301: 
1.184     rillig   3302: Makefile.common
1.1       dsieger  3303: 
1.184     rillig   3304:     This file contains arbitrary things that could also go into a Makefile, but
                   3305:     its purpose is to be used by more than one package. This file should only
                   3306:     be used when the packages that will use the file are known in advance. For
                   3307:     other purposes it is often better to write a *.mk file and give it a good
                   3308:     name that describes what it does.
1.1       dsieger  3309: 
1.184     rillig   3310: buildlink3.mk
1.1       dsieger  3311: 
1.184     rillig   3312:     This file contains the dependency information for the buildlink3 framework
                   3313:     (see Chapter 18, Buildlink methodology).
1.1       dsieger  3314: 
1.184     rillig   3315: hacks.mk
1.1       dsieger  3316: 
1.184     rillig   3317:     This file contains workarounds for compiler bugs and similar things. It is
                   3318:     included automatically by the pkgsrc infrastructure, so you don't need an
                   3319:     extra .include line for it.
1.1       dsieger  3320: 
1.184     rillig   3321: options.mk
1.1       dsieger  3322: 
1.184     rillig   3323:     This file contains the code for the package-specific options (see
                   3324:     Chapter 16, Options handling) that can be selected by the user. If a
                   3325:     package has only one or two options, it is equally acceptable to put the
                   3326:     code directly into the Makefile.
1.1       dsieger  3327: 
1.184     rillig   3328: 12.5.3. Files affecting nothing at all
1.1       dsieger  3329: 
1.184     rillig   3330: README*
1.1       dsieger  3331: 
1.184     rillig   3332:     These files do not take place in the creation of a package and thus are
                   3333:     purely informative to the package developer.
1.1       dsieger  3334: 
1.184     rillig   3335: TODO
1.1       dsieger  3336: 
1.184     rillig   3337:     This file contains things that need to be done to make the package even
                   3338:     better.
1.1       dsieger  3339: 
1.184     rillig   3340: 12.6. work*
1.1       dsieger  3341: 
1.184     rillig   3342: When you type make, the distribution files are unpacked into the directory
                   3343: denoted by WRKDIR. It can be removed by running make clean. Besides the
                   3344: sources, this directory is also used to keep various timestamp files. The
                   3345: directory gets removed completely on clean. The default is ${.CURDIR}/work or $
                   3346: {.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
1.1       dsieger  3347: 
1.184     rillig   3348: 12.7. files/*
1.80      wiz      3349: 
1.184     rillig   3350: If you have any files that you wish to be placed in the package prior to
                   3351: configuration or building, you can place these files here and use a ${CP}
                   3352: command in the "post-extract" target to achieve this.
1.1       dsieger  3353: 
1.184     rillig   3354: If you want to share files in this way with other packages, set the FILESDIR
                   3355: variable to point to the other package's files directory, e.g.:
1.1       dsieger  3356: 
1.184     rillig   3357: FILESDIR=       ../../editors/xemacs/files
1.14      jmcneill 3358: 
1.184     rillig   3359: Chapter 13. The build process
1.1       dsieger  3360: 
1.184     rillig   3361: Table of Contents
1.1       dsieger  3362: 
1.184     rillig   3363: 13.1. Introduction
                   3364: 13.2. Program location
                   3365: 13.3. Directories used during the build process
                   3366: 13.4. Running a phase
                   3367: 13.5. The fetch phase
                   3368: 
                   3369:     13.5.1. What to fetch and where to get it from
                   3370:     13.5.2. How are the files fetched?
                   3371: 
                   3372: 13.6. The checksum phase
                   3373: 13.7. The extract phase
                   3374: 13.8. The patch phase
                   3375: 13.9. The tools phase
                   3376: 13.10. The wrapper phase
                   3377: 13.11. The configure phase
                   3378: 13.12. The build phase
                   3379: 13.13. The test phase
                   3380: 13.14. The install phase
                   3381: 13.15. The package phase
                   3382: 13.16. Cleaning up
                   3383: 13.17. Other helpful targets
1.1       dsieger  3384: 
1.184     rillig   3385: 13.1. Introduction
1.122     leot     3386: 
1.184     rillig   3387: This chapter gives a detailed description on how a package is built. Building a
                   3388: package is separated into different phases (for example fetch, build, install),
                   3389: all of which are described in the following sections. Each phase is split into
                   3390: so-called stages, which take the name of the containing phase, prefixed by one
                   3391: of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
                   3392: actual work is done in the do-* stages.
1.1       dsieger  3393: 
1.184     rillig   3394: Never override the regular targets (like fetch), if you have to, override the
                   3395: do-* ones instead.
1.1       dsieger  3396: 
1.184     rillig   3397: The basic steps for building a program are always the same. First the program's
                   3398: source (distfile) must be brought to the local system and then extracted. After
                   3399: any pkgsrc-specific patches to compile properly are applied, the software can
                   3400: be configured, then built (usually by compiling), and finally the generated
                   3401: binaries, etc. can be put into place on the system.
1.1       dsieger  3402: 
1.184     rillig   3403: To get more details about what is happening at each step, you can set the
                   3404: PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
                   3405: more details about the patch step.
1.1       dsieger  3406: 
1.184     rillig   3407: 13.2. Program location
1.1       dsieger  3408: 
1.184     rillig   3409: Before outlining the process performed by the NetBSD package system in the next
                   3410: section, here's a brief discussion on where programs are installed, and which
                   3411: variables influence this.
1.1       dsieger  3412: 
1.184     rillig   3413: The automatic variable PREFIX indicates where all files of the final program
                   3414: shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
                   3415: pkgs in the cross category. The value of PREFIX needs to be put into the
                   3416: various places in the program's source where paths to these files are encoded.
                   3417: See Section 12.3, "patches/*" and Section 21.3.1, "Shared libraries - libtool"
                   3418: for more details.
1.1       dsieger  3419: 
1.184     rillig   3420: When choosing which of these variables to use, follow the following rules:
1.1       dsieger  3421: 
1.184     rillig   3422:   * PREFIX always points to the location where the current pkg will be
                   3423:     installed. When referring to a pkg's own installation path, use "${PREFIX}"
                   3424:     .
1.1       dsieger  3425: 
1.184     rillig   3426:   * LOCALBASE is where all non-X11 pkgs are installed. If you need to construct
                   3427:     a -I or -L argument to the compiler to find includes and libraries
                   3428:     installed by another non-X11 pkg, use "${LOCALBASE}". The name LOCALBASE
                   3429:     stems from FreeBSD, which installed all packages in /usr/local. As pkgsrc
                   3430:     leaves /usr/local for the system administrator, this variable is a
                   3431:     misnomer.
1.1       dsieger  3432: 
1.184     rillig   3433:   * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
                   3434:     installed. When looking for standard X11 includes (not those installed by a
                   3435:     package), use "${X11BASE}".
1.1       dsieger  3436: 
1.184     rillig   3437:   * X11-based packages using imake must set USE_IMAKE to be installed correctly
                   3438:     under LOCALBASE.
1.1       dsieger  3439: 
1.184     rillig   3440:   * Within ${PREFIX}, packages should install files according to hier(7), with
                   3441:     the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
                   3442:     man.
1.1       dsieger  3443: 
1.184     rillig   3444: 13.3. Directories used during the build process
1.2       rillig   3445: 
1.184     rillig   3446: When building a package, various directories are used to store source files,
                   3447: temporary files, pkgsrc-internal files, and so on. These directories are
                   3448: explained here.
1.1       dsieger  3449: 
1.184     rillig   3450: Some of the directory variables contain relative pathnames. There are two
                   3451: common base directories for these relative directories: PKGSRCDIR/PKGPATH is
                   3452: used for directories that are pkgsrc-specific. WRKSRC is used for directories
                   3453: inside the package itself.
1.1       dsieger  3454: 
1.184     rillig   3455: PKGSRCDIR
1.1       dsieger  3456: 
1.184     rillig   3457:     This is an absolute pathname that points to the pkgsrc root directory.
                   3458:     Generally, you don't need it.
1.1       dsieger  3459: 
1.184     rillig   3460: PKGDIR
1.1       dsieger  3461: 
1.184     rillig   3462:     This is an absolute pathname that points to the current package.
1.1       dsieger  3463: 
1.184     rillig   3464: PKGPATH
1.1       dsieger  3465: 
1.184     rillig   3466:     This is a pathname relative to PKGSRCDIR that points to the current
                   3467:     package.
1.1       dsieger  3468: 
1.184     rillig   3469: WRKDIR
1.1       dsieger  3470: 
1.184     rillig   3471:     This is an absolute pathname pointing to the directory where all work takes
                   3472:     place. The distfiles are extracted to this directory. It also contains
                   3473:     temporary directories and log files used by the various pkgsrc frameworks,
                   3474:     like buildlink or the wrappers.
1.1       dsieger  3475: 
1.184     rillig   3476: WRKSRC
1.1       dsieger  3477: 
1.184     rillig   3478:     This is an absolute pathname pointing to the directory where the distfiles
                   3479:     are extracted. It is usually a direct subdirectory of WRKDIR, and often
                   3480:     it's the only directory entry that isn't hidden. This variable may be
                   3481:     changed by a package Makefile.
1.1       dsieger  3482: 
1.184     rillig   3483: The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
                   3484: defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
                   3485: created in the pkgsrc entry's directory. If users would like to have their
                   3486: pkgsrc trees behave in a read-only manner, then the value of
                   3487: CREATE_WRKDIR_SYMLINK should be set to no.
1.1       dsieger  3488: 
1.184     rillig   3489: 13.4. Running a phase
1.1       dsieger  3490: 
1.184     rillig   3491: You can run a particular phase by typing make phase, where phase is the name of
                   3492: the phase. This will automatically run all phases that are required for this
                   3493: phase. The default phase is build, that is, when you run make without
                   3494: parameters in a package directory, the package will be built, but not
                   3495: installed.
1.1       dsieger  3496: 
1.184     rillig   3497: 13.5. The fetch phase
1.1       dsieger  3498: 
1.184     rillig   3499: The first step in building a package is to fetch the distribution files
                   3500: (distfiles) from the sites that are providing them. This is the task of the 
                   3501: fetch phase.
1.25      wiz      3502: 
1.184     rillig   3503: 13.5.1. What to fetch and where to get it from
1.1       dsieger  3504: 
1.184     rillig   3505: In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
                   3506: name is derived from the DISTNAME variable, is fetched. The more complicated
                   3507: cases are described below.
1.1       dsieger  3508: 
1.184     rillig   3509: The variable DISTFILES specifies the list of distfiles that have to be fetched.
                   3510: Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
                   3511: {EXTRACT_SUFX}, so that most packages don't need to define it at all.
                   3512: EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
                   3513: your package requires additional distfiles to the default one, you cannot just
                   3514: append the additional filenames using the += operator, but you have write for
                   3515: example:
1.1       dsieger  3516: 
1.184     rillig   3517: DISTFILES=      ${DEFAULT_DISTFILES} additional-files.tar.gz
1.1       dsieger  3518: 
1.184     rillig   3519: Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
                   3520: package has multiple DISTFILES or multiple PATCHFILES from different sites, you
                   3521: can set SITES.distfile to the list of URLs where the file distfile (including
                   3522: the suffix) can be found.
1.1       dsieger  3523: 
1.184     rillig   3524: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
                   3525: DISTFILES+=     foo-file.tar.gz
                   3526: SITES.foo-file.tar.gz= \
                   3527: https://www.somewhere.com/somehow/ \
                   3528: https://www.somewhereelse.com/mirror/somehow/
1.1       dsieger  3529: 
1.184     rillig   3530: When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
                   3531: gets the name of each distfile appended to it, without an intermediate slash.
                   3532: Therefore, all site values have to end with a slash or other separator
                   3533: character. This allows for example to set MASTER_SITES to a URL of a CGI script
                   3534: that gets the name of the distfile as a parameter. In this case, the definition
                   3535: would look like:
1.1       dsieger  3536: 
1.184     rillig   3537: MASTER_SITES=   https://www.example.com/download.cgi?file=
1.1       dsieger  3538: 
1.184     rillig   3539: The exception to this rule are URLs starting with a dash. In that case the URL
                   3540: is taken as is, fetched and the result stored under the name of the distfile.
                   3541: You can use this style for the case when the download URL style does not match
                   3542: the above common case. For example, if permanent download URL is a redirector
                   3543: to the real download URL, or the download file name is offered by an HTTP
                   3544: Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
                   3545: created instead of the default v1.0.0.tar.gz.
1.1       dsieger  3546: 
1.184     rillig   3547: DISTNAME=       foo-1.0.0
                   3548: MASTER_SITES=   -https://www.example.com/archive/v1.0.0.tar.gz
1.29      wiz      3549: 
1.184     rillig   3550: There are some predefined values for MASTER_SITES, which can be used in
                   3551: packages. The names of the variables should speak for themselves.
1.29      wiz      3552: 
1.184     rillig   3553: MASTER_SITE_APACHE          MASTER_SITE_BACKUP
                   3554: MASTER_SITE_CRATESIO        MASTER_SITE_CYGWIN
                   3555: MASTER_SITE_DEBIAN          MASTER_SITE_FREEBSD
                   3556: MASTER_SITE_FREEBSD_LOCAL   MASTER_SITE_GENTOO
                   3557: MASTER_SITE_GITHUB          MASTER_SITE_GNOME
                   3558: MASTER_SITE_GNU             MASTER_SITE_GNUSTEP
                   3559: MASTER_SITE_HASKELL_HACKAGE MASTER_SITE_IFARCHIVE
                   3560: MASTER_SITE_KDE             MASTER_SITE_MOZILLA
                   3561: MASTER_SITE_MOZILLA_ALL     MASTER_SITE_MYSQL
                   3562: MASTER_SITE_NETLIB          MASTER_SITE_OPENBSD
                   3563: MASTER_SITE_OPENOFFICE      MASTER_SITE_OSDN
                   3564: MASTER_SITE_PERL_CPAN       MASTER_SITE_PGSQL
                   3565: MASTER_SITE_PYPI            MASTER_SITE_RUBYGEMS
                   3566: MASTER_SITE_R_CRAN          MASTER_SITE_SOURCEFORGE
                   3567: MASTER_SITE_SUNSITE         MASTER_SITE_SUSE
                   3568: MASTER_SITE_TEX_CTAN        MASTER_SITE_XCONTRIB
                   3569: MASTER_SITE_XEMACS          MASTER_SITE_XORG
1.1       dsieger  3570: 
1.184     rillig   3571: Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
                   3572: contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
                   3573: pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
                   3574: source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
                   3575: distfiles/LOCAL_PORTS/.
1.1       dsieger  3576: 
1.184     rillig   3577: If you choose one of these predefined sites, you may want to specify a
                   3578: subdirectory of that site. Since these macros may expand to more than one
                   3579: actual site, you must use the following construct to specify a subdirectory:
1.1       dsieger  3580: 
1.184     rillig   3581: MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
                   3582: MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
1.1       dsieger  3583: 
1.184     rillig   3584: Note the trailing slash after the subdirectory name.
1.1       dsieger  3585: 
1.184     rillig   3586: 13.5.2. How are the files fetched?
1.1       dsieger  3587: 
1.184     rillig   3588: The fetch phase makes sure that all the distfiles exist in a local directory
                   3589: (DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
                   3590: are fetched using commands of the form
1.1       dsieger  3591: 
1.184     rillig   3592: ${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
1.1       dsieger  3593: 
1.184     rillig   3594: where ${site} varies through several possibilities in turn: first,
                   3595: MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
                   3596: defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
                   3597: of MASTER_SITE_BACKUP. The order of all except the first and the last can be
                   3598: optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
                   3599: MASTER_SORT_AWK or MASTER_SORT_REGEX.
1.1       dsieger  3600: 
1.184     rillig   3601: The specific command and arguments used depend on the FETCH_USING parameter.
                   3602: The example above is for FETCH_USING=custom.
1.66      asau     3603: 
1.184     rillig   3604: The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
                   3605: target to mirror the distfiles, if they are freely distributable. Packages
                   3606: setting NO_SRC_ON_FTP (usually to "${RESTRICTED}") will not have their
                   3607: distfiles mirrored.
1.1       dsieger  3608: 
1.184     rillig   3609: 13.6. The checksum phase
1.1       dsieger  3610: 
1.184     rillig   3611: After the distfile(s) are fetched, their checksum is generated and compared
                   3612: with the checksums stored in the distinfo file. If the checksums don't match,
                   3613: the build is aborted. This is to ensure the same distfile is used for building,
                   3614: and that the distfile wasn't changed, e.g. by some malign force, deliberately
                   3615: changed distfiles on the master distribution site or network lossage.
1.1       dsieger  3616: 
1.184     rillig   3617: 13.7. The extract phase
1.1       dsieger  3618: 
1.184     rillig   3619: When the distfiles are present on the local system, they need to be extracted,
                   3620: as they usually come in the form of some compressed archive format.
1.1       dsieger  3621: 
1.184     rillig   3622: By default, all DISTFILES are extracted. If you only need some of them, you can
                   3623: set the EXTRACT_ONLY variable to the list of those files.
1.1       dsieger  3624: 
1.184     rillig   3625: Extracting the files is usually done by a little program, mk/extract/extract,
                   3626: which already knows how to extract various archive formats, so most likely you
                   3627: will not need to change anything here. But if you need, the following variables
                   3628: may help you:
1.1       dsieger  3629: 
1.184     rillig   3630: EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
1.1       dsieger  3631: 
1.184     rillig   3632:     Use these variables to override the default options for an extract command,
                   3633:     which are defined in mk/extract/extract.
1.1       dsieger  3634: 
1.184     rillig   3635: EXTRACT_USING
1.1       dsieger  3636: 
1.184     rillig   3637:     This variable can be set to bsdtar, gtar, nbtar (which is the default
                   3638:     value), pax, or an absolute pathname pointing to the command with which tar
                   3639:     archives should be extracted. It is preferred to choose bsdtar over gtar if
                   3640:     NetBSD's pax-as-tar is not good enough.
1.1       dsieger  3641: 
1.184     rillig   3642: If the extract program doesn't serve your needs, you can also override the
                   3643: EXTRACT_CMD variable, which holds the command used for extracting the files.
                   3644: This command is executed in the ${WRKSRC} directory. During execution of this
                   3645: command, the shell variable extract_file holds the absolute pathname of the
                   3646: file that is going to be extracted.
1.1       dsieger  3647: 
1.184     rillig   3648: And if that still does not suffice, you can override the do-extract target in
                   3649: the package Makefile.
1.1       dsieger  3650: 
1.184     rillig   3651: 13.8. The patch phase
1.1       dsieger  3652: 
1.184     rillig   3653: After extraction, all the patches named by the PATCHFILES, those present in the
                   3654: patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
                   3655: /usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
                   3656: are uncompressed before they are applied, files ending in .orig or .rej are
                   3657: ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
                   3658: Section 12.3, "patches/*" for more details.
1.1       dsieger  3659: 
1.184     rillig   3660: By default patch(1) is given special arguments to make it fail if the expected
                   3661: text from the patch context is not found in the patched file. If that happens,
                   3662: fix the patch file by comparing it with the actual text in the file to be
                   3663: patched.
1.1       dsieger  3664: 
1.184     rillig   3665: 13.9. The tools phase
1.1       dsieger  3666: 
1.184     rillig   3667: This is covered in Chapter 17, Tools needed for building or running.
1.1       dsieger  3668: 
1.184     rillig   3669: 13.10. The wrapper phase
1.1       dsieger  3670: 
1.184     rillig   3671: This phase creates wrapper programs for the compilers and linkers. The
                   3672: following variables can be used to tweak the wrappers.
1.1       dsieger  3673: 
1.184     rillig   3674: ECHO_WRAPPER_MSG
1.1       dsieger  3675: 
1.184     rillig   3676:     The command used to print progress messages. Does nothing by default. Set
                   3677:     to ${ECHO} to see the progress messages.
1.1       dsieger  3678: 
1.184     rillig   3679: WRAPPER_DEBUG
1.1       dsieger  3680: 
1.184     rillig   3681:     This variable can be set to yes (default) or no, depending on whether you
                   3682:     want additional information in the wrapper log file.
1.1       dsieger  3683: 
1.184     rillig   3684: WRAPPER_UPDATE_CACHE
1.1       dsieger  3685: 
1.184     rillig   3686:     This variable can be set to yes or no, depending on whether the wrapper
                   3687:     should use its cache, which will improve the speed. The default value is
                   3688:     yes, but is forced to no if the platform does not support it.
1.1       dsieger  3689: 
1.184     rillig   3690: WRAPPER_REORDER_CMDS
1.1       dsieger  3691: 
1.184     rillig   3692:     A list of reordering commands. A reordering command has the form reorder:l:
                   3693:     lib1:lib2. It ensures that that -llib1 occurs before -llib2.
1.1       dsieger  3694: 
1.184     rillig   3695: 13.11. The configure phase
1.1       dsieger  3696: 
1.184     rillig   3697: Most pieces of software need information on the header files, system calls, and
                   3698: library routines which are available on the platform they run on. The process
                   3699: of determining this information is known as configuration, and is usually
                   3700: automated. In most cases, a script is supplied with the distfiles, and its
                   3701: invocation results in generation of header files, Makefiles, etc.
1.1       dsieger  3702: 
1.184     rillig   3703: If the package contains a configure script, this can be invoked by setting
                   3704: HAS_CONFIGURE to "yes". If the configure script is a GNU autoconf script, you
                   3705: should set GNU_CONFIGURE to "yes" instead. What happens in the configure phase
                   3706: is roughly:
1.1       dsieger  3707: 
1.184     rillig   3708: .for d in ${CONFIGURE_DIRS}
                   3709:         cd ${WRKSRC} \
                   3710:         && cd ${d} \
                   3711:         && env ${CONFIGURE_ENV} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
                   3712: .endfor
1.1       dsieger  3713: 
1.184     rillig   3714: CONFIGURE_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In
                   3715: each of these directories, the configure script is run with the environment
                   3716: CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
                   3717: CONFIGURE_SCRIPT (default: "./configure") and CONFIGURE_ARGS may all be changed
                   3718: by the package.
1.1       dsieger  3719: 
1.184     rillig   3720: If the program uses the Perl way of configuration (mainly Perl modules, but not
                   3721: only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
                   3722: module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
                   3723: (e.g., MAKE_PARAMS+=foo=bar
1.1       dsieger  3724: 
1.184     rillig   3725: If the program uses an Imakefile for configuration, the appropriate steps can
                   3726: be invoked by setting USE_IMAKE to "yes". If you only need xmkmf, add it to
                   3727: USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
                   3728: SCRIPTS_ENV variable.
1.1       dsieger  3729: 
1.184     rillig   3730: If the program uses cmake for configuration, the appropriate steps can be
                   3731: invoked by setting USE_CMAKE to "yes". You can add variables to cmake's
                   3732: environment by adding them to the CONFIGURE_ENV variable and arguments to cmake
                   3733: by adding them to the CMAKE_ARGS variable. The top directory argument is given
                   3734: by the CMAKE_ARG_PATH variable, that defaults to "." (relative to
                   3735: CONFIGURE_DIRS)
1.1       dsieger  3736: 
1.184     rillig   3737: If there is no configure step at all, set NO_CONFIGURE to "yes".
1.1       dsieger  3738: 
1.184     rillig   3739: 13.12. The build phase
1.1       dsieger  3740: 
1.184     rillig   3741: For building a package, a rough equivalent of the following code is executed.
1.154     rillig   3742: 
1.184     rillig   3743: .for d in ${BUILD_DIRS}
                   3744:         cd ${WRKSRC} \
                   3745:         && cd ${d} \
                   3746:         && env ${MAKE_ENV} \
                   3747:             ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
                   3748:                 -f ${MAKE_FILE} \
                   3749:                 ${BUILD_TARGET}
                   3750: .endfor
1.1       dsieger  3751: 
1.184     rillig   3752: BUILD_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In each of
                   3753: these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
                   3754: arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
                   3755: and BUILD_TARGET may all be changed by the package.
1.1       dsieger  3756: 
1.184     rillig   3757: The default value of MAKE_PROGRAM is "gmake" if USE_TOOLS contains "gmake", "
                   3758: make" otherwise. The default value of MAKE_FILE is "Makefile", and BUILD_TARGET
                   3759: defaults to "all".
1.1       dsieger  3760: 
1.184     rillig   3761: If there is no build step at all, set NO_BUILD to "yes".
1.1       dsieger  3762: 
1.184     rillig   3763: 13.13. The test phase
1.1       dsieger  3764: 
1.184     rillig   3765: [TODO]
1.1       dsieger  3766: 
1.184     rillig   3767: 13.14. The install phase
1.1       dsieger  3768: 
1.184     rillig   3769: Once the build stage has completed, the final step is to install the software
                   3770: in public directories, so users can access the programs and files.
1.1       dsieger  3771: 
1.184     rillig   3772: In the install phase, a rough equivalent of the following code is executed.
                   3773: Additionally, before and after this code, much magic is performed to do
                   3774: consistency checks, registering the package, and so on.
1.108     rillig   3775: 
1.184     rillig   3776: .for d in ${INSTALL_DIRS}
                   3777:         cd ${WRKSRC} \
                   3778:         && cd ${d} \
                   3779:         && env ${MAKE_ENV} \
                   3780:             ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
                   3781:                 -f ${MAKE_FILE} \
                   3782:                 ${INSTALL_TARGET}
                   3783: .endfor
1.1       dsieger  3784: 
1.184     rillig   3785: The variable's meanings are analogous to the ones in the build phase.
                   3786: INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is "install" by default,
                   3787: plus "install.man" if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
                   3788: defined.
1.1       dsieger  3789: 
1.184     rillig   3790: In the install phase, the following variables are useful. They are all
                   3791: variations of the install(1) command that have the owner, group and permissions
                   3792: preset. INSTALL is the plain install command. The specialized variants,
                   3793: together with their intended use, are:
1.1       dsieger  3794: 
1.184     rillig   3795: INSTALL_PROGRAM_DIR
1.1       dsieger  3796: 
1.184     rillig   3797:     directories that contain binaries
1.1       dsieger  3798: 
1.184     rillig   3799: INSTALL_SCRIPT_DIR
1.1       dsieger  3800: 
1.184     rillig   3801:     directories that contain scripts
1.1       dsieger  3802: 
1.184     rillig   3803: INSTALL_LIB_DIR
1.1       dsieger  3804: 
1.184     rillig   3805:     directories that contain shared and static libraries
1.1       dsieger  3806: 
1.184     rillig   3807: INSTALL_DATA_DIR
1.108     rillig   3808: 
1.184     rillig   3809:     directories that contain data files
1.108     rillig   3810: 
1.184     rillig   3811: INSTALL_MAN_DIR
1.108     rillig   3812: 
1.184     rillig   3813:     directories that contain man pages
1.108     rillig   3814: 
1.184     rillig   3815: INSTALL_GAME_DIR
1.108     rillig   3816: 
1.184     rillig   3817:     directories that contain data files for games
1.108     rillig   3818: 
1.184     rillig   3819: INSTALL_PROGRAM
1.108     rillig   3820: 
1.184     rillig   3821:     binaries that can be stripped from debugging symbols
1.108     rillig   3822: 
1.184     rillig   3823: INSTALL_SCRIPT
1.108     rillig   3824: 
1.184     rillig   3825:     binaries that cannot be stripped
1.108     rillig   3826: 
1.184     rillig   3827: INSTALL_GAME
1.108     rillig   3828: 
1.184     rillig   3829:     game binaries
1.108     rillig   3830: 
1.184     rillig   3831: INSTALL_LIB
1.108     rillig   3832: 
1.184     rillig   3833:     shared and static libraries
1.108     rillig   3834: 
1.184     rillig   3835: INSTALL_DATA
1.108     rillig   3836: 
1.184     rillig   3837:     data files
1.1       dsieger  3838: 
1.184     rillig   3839: INSTALL_GAME_DATA
1.1       dsieger  3840: 
1.184     rillig   3841:     data files for games
1.108     rillig   3842: 
1.184     rillig   3843: INSTALL_MAN
1.108     rillig   3844: 
1.184     rillig   3845:     man pages
1.1       dsieger  3846: 
1.184     rillig   3847: Some other variables are:
1.1       dsieger  3848: 
1.184     rillig   3849: INSTALL_UNSTRIPPED
1.1       dsieger  3850: 
1.184     rillig   3851:     If set to yes, do not run strip(1) when installing binaries. Any debugging
                   3852:     sections and symbols present in binaries will be preserved.
1.1       dsieger  3853: 
1.184     rillig   3854: INSTALLATION_DIRS
1.1       dsieger  3855: 
1.184     rillig   3856:     A list of directories relative to PREFIX that are created by pkgsrc at the
                   3857:     beginning of the install phase. The package is supposed to create all
                   3858:     needed directories itself before installing files to it and list all other
                   3859:     directories here.
1.1       dsieger  3860: 
1.184     rillig   3861: In the rare cases that a package shouldn't install anything, set NO_INSTALL to 
                   3862: "yes". This is mostly relevant for packages in the regress category.
1.1       dsieger  3863: 
1.184     rillig   3864: 13.15. The package phase
1.121     sevan    3865: 
1.184     rillig   3866: Once the install stage has completed, a binary package of the installed files
                   3867: can be built. These binary packages can be used for quick installation without
                   3868: previous compilation, e.g. by the make bin-install or by using pkg_add.
1.1       dsieger  3869: 
1.184     rillig   3870: By default, the binary packages are created in ${PACKAGES}/All and symlinks are
                   3871: created in ${PACKAGES}/category, one for each category in the CATEGORIES
                   3872: variable. PACKAGES defaults to pkgsrc/packages.
1.1       dsieger  3873: 
1.184     rillig   3874: 13.16. Cleaning up
1.1       dsieger  3875: 
1.184     rillig   3876: Once you're finished with a package, you can clean the work directory by
                   3877: running make clean. If you want to clean the work directories of all
                   3878: dependencies too, use make clean-depends.
1.1       dsieger  3879: 
1.184     rillig   3880: 13.17. Other helpful targets
1.1       dsieger  3881: 
1.184     rillig   3882: pre/post-*
1.1       dsieger  3883: 
1.184     rillig   3884:     For any of the main targets described in the previous section (configure,
                   3885:     build, install, etc.), two auxiliary targets exist with "pre-" and "post-"
                   3886:     used as a prefix for the main target's name. These targets are invoked
                   3887:     before and after the main target is called, allowing extra configuration or
                   3888:     installation steps be performed from a package's Makefile, for example,
                   3889:     which a program's configure script or install target omitted.
                   3890: 
                   3891:     About 5% of the pkgsrc packages define their custom post-extract target,
                   3892:     another 5% define pre-configure, and 10% define post-install. The other pre
                   3893:     /post-* targets are defined even less often.
1.1       dsieger  3894: 
1.184     rillig   3895: do-*
1.182     leot     3896: 
1.184     rillig   3897:     Should one of the main targets do the wrong thing, and should there be no
                   3898:     variable to fix this, you can redefine it with the do-* target. (Note that
                   3899:     redefining the target itself instead of the do-* target is a bad idea, as
                   3900:     the pre-* and post-* targets won't be called anymore, etc.)
1.1       dsieger  3901: 
1.184     rillig   3902:     About 15% of the pkgsrc packages override the default do-install, the other
                   3903:     do-* targets are overridden even less often.
1.1       dsieger  3904: 
1.184     rillig   3905: reinstall
1.1       dsieger  3906: 
1.184     rillig   3907:     If you did a make install and you noticed some file was not installed
                   3908:     properly, you can repeat the installation with this target, which will
                   3909:     ignore the "already installed" flag.
1.1       dsieger  3910: 
1.184     rillig   3911:     This is the default value of DEPENDS_TARGET except in the case of make
                   3912:     update and make package, where the defaults are "package" and "update",
                   3913:     respectively.
1.1       dsieger  3914: 
1.184     rillig   3915: deinstall
1.1       dsieger  3916: 
1.184     rillig   3917:     This target does a pkg_delete(1) in the current directory, effectively
                   3918:     de-installing the package. The following variables can be used to tune the
                   3919:     behaviour:
1.1       dsieger  3920: 
1.184     rillig   3921:     PKG_VERBOSE
1.1       dsieger  3922: 
1.184     rillig   3923:         Add a "-v" to the pkg_delete(1) command.
1.1       dsieger  3924: 
1.184     rillig   3925:     DEINSTALLDEPENDS
1.1       dsieger  3926: 
1.184     rillig   3927:         Remove all packages that require (depend on) the given package. This
                   3928:         can be used to remove any packages that may have been pulled in by a
                   3929:         given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
                   3930:         pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding "-R
                   3931:         " to the pkg_delete(1) command line.
1.1       dsieger  3932: 
1.184     rillig   3933: bin-install
1.1       dsieger  3934: 
1.184     rillig   3935:     Install a binary package from local disk and via FTP from a list of sites
                   3936:     (see the BINPKG_SITES variable), and do a make package if no binary package
                   3937:     is available anywhere. The arguments given to pkg_add can be set via
                   3938:     BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
1.1       dsieger  3939: 
1.184     rillig   3940: install-clean
1.1       dsieger  3941: 
1.184     rillig   3942:     This target removes the state files for the "install" and later phases so
                   3943:     that the "install" target may be re-invoked. This can be used after editing
                   3944:     the PLIST to install the package without rebuilding it.
1.1       dsieger  3945: 
1.184     rillig   3946: build-clean
1.18      mishka   3947: 
1.184     rillig   3948:     This target removes the state files for the "build" and later phases so
                   3949:     that the "build" target may be re-invoked.
1.18      mishka   3950: 
1.184     rillig   3951: update
1.18      mishka   3952: 
1.184     rillig   3953:     This target causes the current package to be updated to the latest version.
                   3954:     The package and all depending packages first get de-installed, then current
                   3955:     versions of the corresponding packages get compiled and installed. This is
                   3956:     similar to manually noting which packages are currently installed, then
                   3957:     performing a series of make deinstall and make install (or whatever
                   3958:     UPDATE_TARGET is set to) for these packages.
1.18      mishka   3959: 
1.184     rillig   3960:     You can use the "update" target to resume package updating in case a
                   3961:     previous make update was interrupted for some reason. However, in this
                   3962:     case, make sure you don't call make clean or otherwise remove the list of
                   3963:     dependent packages in WRKDIR. Otherwise, you lose the ability to
                   3964:     automatically update the current package along with the dependent packages
                   3965:     you have installed.
1.121     sevan    3966: 
1.184     rillig   3967:     Resuming an interrupted make update will only work as long as the package
                   3968:     tree remains unchanged. If the source code for one of the packages to be
                   3969:     updated has been changed, resuming make update will most certainly fail!
1.1       dsieger  3970: 
1.184     rillig   3971:     The following variables can be used either on the command line or in
                   3972:     mk.conf to alter the behaviour of make update:
1.1       dsieger  3973: 
1.184     rillig   3974:     UPDATE_TARGET
1.1       dsieger  3975: 
1.184     rillig   3976:         Install target to recursively use for the updated package and the
                   3977:         dependent packages. Defaults to DEPENDS_TARGET if set, "install"
                   3978:         otherwise for make update. Other good targets are "package" or "
                   3979:         bin-install". Do not set this to "update" or you will get stuck in an
                   3980:         endless loop!
1.1       dsieger  3981: 
1.184     rillig   3982:     NOCLEAN
1.1       dsieger  3983: 
1.184     rillig   3984:         Don't clean up after updating. Useful if you want to leave the work
                   3985:         sources of the updated packages around for inspection or other
                   3986:         purposes. Be sure you eventually clean up the source tree (see the "
                   3987:         clean-update" target below) or you may run into troubles with old
                   3988:         source code still lying around on your next make or make update.
1.1       dsieger  3989: 
1.184     rillig   3990:     REINSTALL
1.1       dsieger  3991: 
1.184     rillig   3992:         Deinstall each package before installing (making DEPENDS_TARGET). This
                   3993:         may be necessary if the "clean-update" target (see below) was called
                   3994:         after interrupting a running make update.
1.1       dsieger  3995: 
1.184     rillig   3996:     DEPENDS_TARGET
1.1       dsieger  3997: 
1.184     rillig   3998:         Allows you to disable recursion and hardcode the target for packages.
                   3999:         The default is "update" for the update target, facilitating a recursive
                   4000:         update of prerequisite packages. Only set DEPENDS_TARGET if you want to
                   4001:         disable recursive updates. Use UPDATE_TARGET instead to just set a
                   4002:         specific target for each package to be installed during make update
                   4003:         (see above).
1.1       dsieger  4004: 
1.184     rillig   4005: clean-update
1.1       dsieger  4006: 
1.184     rillig   4007:     Clean the source tree for all packages that would get updated if make
                   4008:     update was called from the current directory. This target should not be
                   4009:     used if the current package (or any of its depending packages) have already
                   4010:     been de-installed (e.g., after calling make update) or you may lose some
                   4011:     packages you intended to update. As a rule of thumb: only use this target 
                   4012:     before the first time you run make update and only if you have a dirty
                   4013:     package tree (e.g., if you used NOCLEAN).
1.86      wiz      4014: 
1.184     rillig   4015:     If you are unsure about whether your tree is clean, you can either perform
                   4016:     a make clean at the top of the tree, or use the following sequence of
                   4017:     commands from the directory of the package you want to update (before
                   4018:     running make update for the first time, otherwise you lose all the packages
                   4019:     you wanted to update!):
1.86      wiz      4020: 
1.184     rillig   4021:     # make clean-update
                   4022:     # make clean CLEANDEPENDS=YES
                   4023:     # make update
1.86      wiz      4024: 
                   4025: 
1.184     rillig   4026:     The following variables can be used either on the command line or in
                   4027:     mk.conf to alter the behaviour of make clean-update:
1.86      wiz      4028: 
1.184     rillig   4029:     CLEAR_DIRLIST
1.86      wiz      4030: 
1.184     rillig   4031:         After make clean, do not reconstruct the list of directories to update
                   4032:         for this package. Only use this if make update successfully installed
                   4033:         all packages you wanted to update. Normally, this is done automatically
                   4034:         on make update, but may have been suppressed by the NOCLEAN variable
                   4035:         (see above).
1.1       dsieger  4036: 
1.184     rillig   4037: replace
1.1       dsieger  4038: 
1.184     rillig   4039:     Update the installation of the current package. This differs from update in
                   4040:     that it does not replace dependent packages. You will need to install
                   4041:     pkgtools/pkg_tarup for this target to work.
1.1       dsieger  4042: 
1.184     rillig   4043:     Be careful when using this target! There are no guarantees that dependent
                   4044:     packages will still work, in particular they will most certainly break if
                   4045:     you make replace a library package whose shared library major version
                   4046:     changed between your installed version and the new one. For this reason,
                   4047:     this target is not officially supported and only recommended for advanced
                   4048:     users.
1.1       dsieger  4049: 
1.184     rillig   4050: info
1.1       dsieger  4051: 
1.184     rillig   4052:     This target invokes pkg_info(1) for the current package. You can use this
                   4053:     to check which version of a package is installed.
1.86      wiz      4054: 
1.184     rillig   4055: index
1.1       dsieger  4056: 
1.184     rillig   4057:     This is a top-level command, i.e. it should be used in the pkgsrc
                   4058:     directory. It creates a database of all packages in the local pkgsrc tree,
                   4059:     including dependencies, comment, maintainer, and some other useful
                   4060:     information. Individual entries are created by running make describe in the
                   4061:     packages' directories. This index file is saved as pkgsrc/INDEX. It can be
                   4062:     displayed in verbose format by running make print-index. You can search in
                   4063:     it with make search key=something. You can extract a list of all packages
                   4064:     that depend on a particular one by running make show-deps PKG=somepackage.
1.1       dsieger  4065: 
1.184     rillig   4066:     Running this command takes a very long time, some hours even on fast
                   4067:     machines!
1.1       dsieger  4068: 
1.184     rillig   4069: readme
1.1       dsieger  4070: 
1.184     rillig   4071:     This target generates a README.html file, which can be viewed using a
                   4072:     browser such as www/firefox or www/links. The generated files contain
                   4073:     references to any packages which are in the PACKAGES directory on the local
                   4074:     host. The generated files can be made to refer to URLs based on
                   4075:     FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
                   4076:     README.html files which pointed to binary packages on the local machine, in
                   4077:     the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
                   4078:     FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
                   4079:     subdirectories will be searched for all the binary packages.
1.1       dsieger  4080: 
1.184     rillig   4081:     The target can be run at the toplevel or in category directories, in which
                   4082:     case it descends recursively.
1.1       dsieger  4083: 
1.184     rillig   4084: readme-all
1.1       dsieger  4085: 
1.184     rillig   4086:     This is a top-level command, run it in pkgsrc. Use this target to create a
                   4087:     file README-all.html which contains a list of all packages currently
                   4088:     available in the NetBSD Packages Collection, together with the category
                   4089:     they belong to and a short description. This file is compiled from the
                   4090:     pkgsrc/*/README.html files, so be sure to run this after a make readme.
1.1       dsieger  4091: 
1.184     rillig   4092: cdrom-readme
1.1       dsieger  4093: 
1.184     rillig   4094:     This is very much the same as the "readme" target (see above), but is to be
                   4095:     used when generating a pkgsrc tree to be written to a CD-ROM. This target
                   4096:     also produces README.html files, and can be made to refer to URLs based on
                   4097:     CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
1.1       dsieger  4098: 
1.184     rillig   4099: show-distfiles
1.1       dsieger  4100: 
1.184     rillig   4101:     This target shows which distfiles and patchfiles are needed to build the
                   4102:     package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
                   4103:     patches/*).
1.1       dsieger  4104: 
1.184     rillig   4105: show-downlevel
1.1       dsieger  4106: 
1.184     rillig   4107:     This target shows nothing if the package is not installed. If a version of
                   4108:     this package is installed, but is not the version provided in this version
                   4109:     of pkgsrc, then a warning message is displayed. This target can be used to
                   4110:     show which of your installed packages are downlevel, and so the old
                   4111:     versions can be deleted, and the current ones added.
1.1       dsieger  4112: 
1.184     rillig   4113: show-pkgsrc-dir
1.1       dsieger  4114: 
1.184     rillig   4115:     This target shows the directory in the pkgsrc hierarchy from which the
                   4116:     package can be built and installed. This may not be the same directory as
                   4117:     the one from which the package was installed. This target is intended to be
                   4118:     used by people who may wish to upgrade many packages on a single host, and
                   4119:     can be invoked from the top-level pkgsrc Makefile by using the "
                   4120:     show-host-specific-pkgs" target.
1.1       dsieger  4121: 
1.184     rillig   4122: show-installed-depends
1.1       dsieger  4123: 
1.184     rillig   4124:     This target shows which installed packages match the current package's
                   4125:     DEPENDS. Useful if out of date dependencies are causing build problems.
1.1       dsieger  4126: 
1.184     rillig   4127: print-build-depends-list
1.1       dsieger  4128: 
1.184     rillig   4129:     This target shows the list of packages that the current package depends on
                   4130:     for building.
1.1       dsieger  4131: 
1.184     rillig   4132: print-run-depends-list
1.1       dsieger  4133: 
1.184     rillig   4134:     This target shows the list of packages that the current package depends on
                   4135:     for running.
1.1       dsieger  4136: 
1.184     rillig   4137: check-shlibs
1.1       dsieger  4138: 
1.184     rillig   4139:     After a package is installed, check all its binaries and (on ELF platforms)
                   4140:     shared libraries to see if they find the shared libs they need. Run by
                   4141:     default if PKG_DEVELOPER is set in mk.conf.
1.1       dsieger  4142: 
1.184     rillig   4143: print-PLIST
1.1       dsieger  4144: 
1.184     rillig   4145:     After a "make install" from a new or upgraded pkg, this prints out an
                   4146:     attempt to generate a new PLIST from a find -newer work/.extract_done. An
                   4147:     attempt is made to care for shared libs etc., but it is strongly
                   4148:     recommended to review the result before putting it into PLIST. On upgrades,
                   4149:     it's useful to diff the output of this command against an already existing
                   4150:     PLIST file.
1.1       dsieger  4151: 
1.184     rillig   4152:     If the package installs files via tar(1) or other methods that don't update
                   4153:     file access times, be sure to add these files manually to your PLIST, as
                   4154:     the "find -newer" command used by this target won't catch them!
1.56      ryoon    4155: 
1.184     rillig   4156:     See Section 19.3, "Tweaking output of make print-PLIST" for more
                   4157:     information on this target.
1.1       dsieger  4158: 
1.184     rillig   4159: Chapter 14. Creating a new pkgsrc package from scratch
1.1       dsieger  4160: 
1.184     rillig   4161: Table of Contents
1.1       dsieger  4162: 
1.184     rillig   4163: 14.1. Common types of packages
1.1       dsieger  4164: 
1.184     rillig   4165:     14.1.1. Perl modules
                   4166:     14.1.2. Python modules and programs
                   4167:     14.1.3. R packages
                   4168:     14.1.4. TeXlive packages
1.1       dsieger  4169: 
1.184     rillig   4170: 14.2. Examples
1.1       dsieger  4171: 
1.184     rillig   4172:     14.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  4173: 
1.184     rillig   4174: When you find a package that is not yet in pkgsrc, you most likely have a URL
                   4175: from where you can download the source code. Starting with this URL, creating a
                   4176: package involves only a few steps.
1.1       dsieger  4177: 
1.184     rillig   4178:  1. In your mk.conf, set PKG_DEVELOPER=yes to enable the basic quality checks.
1.1       dsieger  4179: 
1.184     rillig   4180:  2. Install the package meta-pkgs/pkg_developer, which among others will
                   4181:     install the utilities url2pkg, pkglint, pkgvi and mkpatches:
1.1       dsieger  4182: 
1.184     rillig   4183:     $ cd /usr/pkgsrc
                   4184:     $ (cd meta-pkgs/pkg_developer && bmake update)
1.1       dsieger  4185: 
1.184     rillig   4186:  3. Choose one of the top-level directories as the category in which you want
                   4187:     to place your package. You can also create a directory of your own (maybe
                   4188:     called local). In that category directory, create another directory for
                   4189:     your package and change into it:
1.1       dsieger  4190: 
1.184     rillig   4191:     $ mkdir category/package
                   4192:     $ cd category/package
1.1       dsieger  4193: 
1.184     rillig   4194:  4. Run the program url2pkg, which will ask you for a URL. Enter the URL of the
                   4195:     distribution file (in most cases a .tar.gz file) and watch how the basic
                   4196:     ingredients of your package are created automatically. The distribution
                   4197:     file is extracted automatically to fill in some details in the Makefile
                   4198:     that would otherwise have to be done manually:
1.1       dsieger  4199: 
1.184     rillig   4200:     $ url2pkg https://www.example.org/packages/package-1.0.tar.gz
1.1       dsieger  4201: 
1.184     rillig   4202:  5. Examine the extracted files to determine the dependencies of your package.
                   4203:     Ideally, this is mentioned in some README file, but things may differ. For
                   4204:     each of these dependencies, look where it exists in pkgsrc, and if there is
                   4205:     a file called buildlink3.mk in that directory, add a line to your package
                   4206:     Makefile which includes that file just before the last line. If the
                   4207:     buildlink3.mk file does not exist, it must be created first. The
                   4208:     buildlink3.mk file makes sure that the package's include files and
                   4209:     libraries are provided.
1.1       dsieger  4210: 
1.184     rillig   4211:     If you just need binaries from a package, add a DEPENDS line to the
                   4212:     Makefile, which specifies the version of the dependency and where it can be
                   4213:     found in pkgsrc. This line should be placed in the third paragraph. If the
                   4214:     dependency is only needed for building the package, but not when using it,
                   4215:     use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The difference
                   4216:     between TOOL_DEPENDS and BUILD_DEPENDS occurs when cross-compiling:
                   4217:     TOOL_DEPENDS are native packages, i.e. packages for the architecture where
                   4218:     the package is built; BUILD_DEPENDS are target packages, i.e. packages for
                   4219:     the architecture for which the package is built. There is also
                   4220:     TEST_DEPENDS, which is used to specify a dependency used only for testing
                   4221:     the resulting package built, using the upstream project's included test
                   4222:     suite. Your package may then look like this:
1.1       dsieger  4223: 
1.184     rillig   4224:     [...]
1.1       dsieger  4225: 
1.184     rillig   4226:     TOOL_DEPENDS+=  libxslt-[0-9]*:../../textproc/libxslt
                   4227:     DEPENDS+=       screen-[0-9]*:../../misc/screen
                   4228:     DEPENDS+=       screen>=4.0:../../misc/screen
1.1       dsieger  4229: 
1.184     rillig   4230:     [...]
1.1       dsieger  4231: 
1.184     rillig   4232:     .include "../../category/package/buildlink3.mk"
                   4233:     .include "../../devel/glib2/buildlink3.mk"
                   4234:     .include "../../mk/bsd.pkg.mk"
1.1       dsieger  4235: 
1.184     rillig   4236:  6. Run pkglint to see what things still need to be done to make your package a
                   4237:     "good" one. If you don't know what pkglint's warnings want to tell you, try
                   4238:     pkglint --explain or pkglint -e, which outputs additional explanations.
1.1       dsieger  4239: 
1.184     rillig   4240:  7. In many cases the package is not yet ready to build. You can find
                   4241:     instructions for the most common cases in the next section, Section 14.1,
                   4242:     "Common types of packages". After you have followed the instructions over
                   4243:     there, you can hopefully continue here.
1.1       dsieger  4244: 
1.184     rillig   4245:  8. Run bmake clean to clean the working directory from the extracted files.
                   4246:     Besides these files, a lot of cache files and other system information has
                   4247:     been saved in the working directory, which may become wrong after you
                   4248:     edited the Makefile.
1.1       dsieger  4249: 
1.184     rillig   4250:  9. Now, run bmake to build the package. For the various things that can go
                   4251:     wrong in this phase, consult Chapter 21, Making your package work.
1.1       dsieger  4252: 
1.184     rillig   4253:     If the extracted files from the package need to be fixed, run multiple
                   4254:     rounds of these commands:
1.1       dsieger  4255: 
1.184     rillig   4256:     $ make
                   4257:     $ pkgvi ${WRKSRC}/some/file/that/does/not/compile
                   4258:     $ mkpatches
                   4259:     $ make mps
                   4260:     $ make clean
1.1       dsieger  4261: 
1.184     rillig   4262: 10. When the package builds fine, the next step is to install the package. Run 
                   4263:     bmake install and hope that everything works.
1.1       dsieger  4264: 
1.184     rillig   4265: 11. Up to now, the file PLIST, which contains a list of the files that are
                   4266:     installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
                   4267:     generate a probably correct list. Check the file using your preferred text
                   4268:     editor to see if the list of files looks plausible.
1.1       dsieger  4269: 
1.184     rillig   4270: 12. Run pkglint again to see if the generated PLIST contains garbage or not.
1.1       dsieger  4271: 
1.184     rillig   4272: 13. When you ran bmake install, the package had been registered in the database
                   4273:     of installed files, but with an empty list of files. To fix this, run bmake
                   4274:     deinstall and bmake install again. Now the package is registered with the
                   4275:     list of files from PLIST.
1.48      wiz      4276: 
1.184     rillig   4277: 14. Run bmake package to create a binary package from the set of installed
                   4278:     files.
1.48      wiz      4279: 
1.184     rillig   4280: 15. Run bmake clean update to run everything from above again in a single step,
                   4281:     making sure that the PLIST is correct and the whole package is created as
                   4282:     intended.
1.48      wiz      4283: 
1.184     rillig   4284: 16. Run pkglint to see if there's anything left to do.
1.48      wiz      4285: 
1.184     rillig   4286: 17. Commit the package to pkgsrc-wip or main pkgsrc; see Chapter 23, Submitting
                   4287:     and Committing.
1.50      wiz      4288: 
1.184     rillig   4289: 14.1. Common types of packages
1.1       dsieger  4290: 
1.184     rillig   4291: 14.1.1. Perl modules
1.1       dsieger  4292: 
1.184     rillig   4293: Simple Perl modules are handled automatically by url2pkg, including
                   4294: dependencies.
1.1       dsieger  4295: 
1.184     rillig   4296: 14.1.2. Python modules and programs
1.1       dsieger  4297: 
1.184     rillig   4298: Python modules and programs packages are easily created using a set of
                   4299: predefined variables.
1.1       dsieger  4300: 
1.184     rillig   4301: If some Python versions are not supported by the software, set the
                   4302: PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
                   4303: supported, e.g.
1.1       dsieger  4304: 
1.184     rillig   4305: PYTHON_VERSIONS_INCOMPATIBLE=       27
1.1       dsieger  4306: 
1.184     rillig   4307: If the packaged software is a Python module, include one of ../../lang/python/
                   4308: egg.mk, ../../lang/python/distutils.mk, or ../../lang/python/extension.mk.
1.1       dsieger  4309: 
1.184     rillig   4310: Most Python packages use either "distutils" or easy-setup/setuptools ("eggs").
                   4311: If the packaged software is using setuptools, you only need to include "../../
                   4312: lang/python/egg.mk". Otherwise, if the software uses "distutils", include "..
                   4313: /../lang/python/distutils.mk", so pkgsrc will use this framework. "distutils"
                   4314: uses a script called setup.py; if the "distutils" driver is not called
                   4315: setup.py, set the PYSETUP variable to the name of the script.
1.1       dsieger  4316: 
1.184     rillig   4317: Either way, the package directory should be called "py-software" and PKGNAME
                   4318: should be set to "${PYPKGPREFIX}-${DISTNAME}", e.g.
1.1       dsieger  4319: 
1.184     rillig   4320: DISTNAME=   foopymodule-1.2.10
                   4321: PKGNAME=    ${PYPKGPREFIX}-${DISTNAME}
1.1       dsieger  4322: 
1.184     rillig   4323: If it is an application, include "../../lang/python/application.mk". In order
                   4324: to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
                   4325: variable and set it to the list of files (paths relative to WRKSRC) that must
                   4326: be corrected. For example:
1.1       dsieger  4327: 
1.184     rillig   4328: REPLACE_PYTHON=   *.py
1.1       dsieger  4329: 
1.184     rillig   4330: Some Python modules have separate distributions for Python-2.x and Python-3.x
                   4331: support. In pkgsrc this is handled by the versioned_dependencies.mk file. Set
                   4332: PYTHON_VERSIONED_DEPENDENCIES to the list of packages that should be depended
                   4333: upon and include "../../lang/python/versioned_dependencies.mk", then the pkgsrc
                   4334: infrastructure will depend on the appropriate package version. For example:
1.1       dsieger  4335: 
1.184     rillig   4336: PYTHON_VERSIONED_DEPENDENCIES=dialog
1.1       dsieger  4337: 
1.184     rillig   4338: Look inside versioned_dependencies.mk for a list of supported packages.
1.1       dsieger  4339: 
1.184     rillig   4340: 14.1.3. R packages
1.1       dsieger  4341: 
1.184     rillig   4342: Simple R packages from CRAN are handled automatically by R2pkg, which is
                   4343: available in pkgtools/R2pkg. Individual packages (and optionally their
                   4344: dependencies) may be created and updated. R packages generally follow the same
                   4345: form, and most of the relevant information needed is contained in a DESCRIPTION
                   4346: file as part of each R package on CRAN. Consequently, R2pkg downloads that
                   4347: information and creates or updates a package in the canonical form. The
                   4348: resulting package should be reviewed for correctness.
1.1       dsieger  4349: 
1.184     rillig   4350: 14.1.4. TeXlive packages
1.1       dsieger  4351: 
1.184     rillig   4352: TeXlive packages from CTAN are handled automatically by texlive2pkg, which is
                   4353: available in pkgtools/texlive2pkg.
1.1       dsieger  4354: 
1.184     rillig   4355: If the TeXlive package name is not known, it may be useful to search CTAN. A "
                   4356: Contained in" field on the package page typically identifies the basename of
                   4357: the package file in the TeXlive archive.
1.1       dsieger  4358: 
1.184     rillig   4359: If the TeXlive package name is known, download the files from the TeXlive
                   4360: archive. For package foo, you will need to download foo.tar.xz. Most TeXlive
                   4361: packages also have associated documentation packages, so download
                   4362: foo.doc.tar.xz at the same time. These files should be placed in the
                   4363: appropriate category directory, which is often but not always print. Then run
                   4364: the following command in the category directory.
1.1       dsieger  4365: 
1.184     rillig   4366: texlive2pkg foo.tar.xz foo.doc.tar.xz
1.1       dsieger  4367: 
1.184     rillig   4368: This will create two packages, tex-foo and tex-foo-doc. Be sure to check that
                   4369: both packages are correct.
1.1       dsieger  4370: 
1.184     rillig   4371: Finally, CTAN currently does not include version information in package
                   4372: filenames and changes their contents periodically when updates occur.
                   4373: Consequently, pkgsrc avoids downloading distfiles directly from CTAN and
                   4374: instead relies on the pkgsrc archives. For each new or updated TeXlive package,
                   4375: e.g., the main one and the corresponding documentation, upload the distfiles
                   4376: with the following command in each package directory.
1.1       dsieger  4377: 
1.184     rillig   4378: make upload-distfiles
1.117     sevan    4379: 
1.184     rillig   4380: 14.2. Examples
1.117     sevan    4381: 
1.184     rillig   4382: 14.2.1. How the www/nvu package came into pkgsrc
1.1       dsieger  4383: 
1.184     rillig   4384: 14.2.1.1. The initial package
1.1       dsieger  4385: 
1.184     rillig   4386: Looking at the file pkgsrc/doc/TODO, I saw that the "nvu" package has not yet
                   4387: been imported into pkgsrc. As the description says it has to do with the web,
                   4388: the obvious choice for the category is "www".
1.1       dsieger  4389: 
1.184     rillig   4390: $ mkdir www/nvu
                   4391: $ cd www/nvu
1.1       dsieger  4392: 
1.184     rillig   4393: The web site says that the sources are available as a tar file, so I fed that
                   4394: URL to the url2pkg program:
1.1       dsieger  4395: 
1.184     rillig   4396: $ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
1.1       dsieger  4397: 
1.184     rillig   4398: My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
                   4399: package name should not have the word "sources" in it. I also filled in the
                   4400: MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
                   4401: that:
1.1       dsieger  4402: 
1.184     rillig   4403: # $NetBSD $
                   4404: #
1.1       dsieger  4405: 
1.184     rillig   4406: DISTNAME=       nvu-1.0-sources
                   4407: PKGNAME=        nvu-1.0
                   4408: CATEGORIES=     www
                   4409: MASTER_SITES=   http://cvs.nvu.com/download/
                   4410: EXTRACT_SUFX=   .tar.bz2
1.1       dsieger  4411: 
1.184     rillig   4412: MAINTAINER=     rillig@NetBSD.org
                   4413: HOMEPAGE=       http://cvs.nvu.com/
                   4414: COMMENT=        Web Authoring System
1.1       dsieger  4415: 
1.184     rillig   4416: # url2pkg-marker (please do not remove this line.)
                   4417: .include "../../mk/bsd.pkg.mk"
1.1       dsieger  4418: 
1.184     rillig   4419: On the first line of output above, an artificial space has been added between
                   4420: NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
                   4421: the guide.
1.1       dsieger  4422: 
1.184     rillig   4423: Then, I quit the editor and watched pkgsrc downloading a large source archive:
1.1       dsieger  4424: 
1.184     rillig   4425: url2pkg> Running "make makesum" ...
                   4426: => Required installed package digest>=20010302: digest-20060826 found
                   4427: => Fetching nvu-1.0-sources.tar.bz2
                   4428: Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
                   4429: 100% |*************************************| 28992 KB  150.77 KB/s00:00 ETA
                   4430: 29687976 bytes retrieved in 03:12 (150.77 KB/s)
                   4431: url2pkg> Running "make extract" ...
                   4432: => Required installed package digest>=20010302: digest-20060826 found
                   4433: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   4434: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   4435: work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
                   4436: ===> Installing dependencies for nvu-1.0
                   4437: ===> Overriding tools for nvu-1.0
                   4438: ===> Extracting for nvu-1.0
                   4439: url2pkg> Adjusting the Makefile.
1.1       dsieger  4440: 
1.184     rillig   4441: Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
1.1       dsieger  4442: 
1.184     rillig   4443: Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
1.1       dsieger  4444: 
1.184     rillig   4445: 14.2.1.2. Fixing all kinds of problems to make the package work
1.1       dsieger  4446: 
1.184     rillig   4447: Now that the package has been extracted, let's see what's inside it. The
                   4448: package has a README.txt, but that only says something about mozilla, so it's
                   4449: probably useless for seeing what dependencies this package has. But since there
                   4450: is a GNU configure script in the package, let's hope that it will complain
                   4451: about everything it needs.
1.1       dsieger  4452: 
1.184     rillig   4453: $ bmake
                   4454: => Required installed package digest>=20010302: digest-20060826 found
                   4455: => Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
                   4456: => Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
                   4457: ===> Patching for nvu-1.0
                   4458: ===> Creating toolchain wrappers for nvu-1.0
                   4459: ===> Configuring for nvu-1.0
                   4460: [...]
                   4461: configure: error: Perl 5.004 or higher is required.
                   4462: [...]
                   4463: WARNING: Please add USE_TOOLS+=perl to the package Makefile.
                   4464: [...]
1.1       dsieger  4465: 
1.184     rillig   4466: That worked quite well. So I opened the package Makefile in my editor, and
                   4467: since it already has a USE_TOOLS line, I just appended "perl" to it. Since the
                   4468: dependencies of the package have changed now, and since a perl wrapper is
                   4469: automatically installed in the "tools" phase, I need to build the package from
                   4470: scratch.
1.1       dsieger  4471: 
1.184     rillig   4472: $ bmake clean
                   4473: ===> Cleaning for nvu-1.0
                   4474: $ bmake
                   4475: [...]
                   4476: *** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
                   4477: GNU Make.  You will not be able to build Mozilla without GNU Make.
                   4478: [...]
1.1       dsieger  4479: 
1.184     rillig   4480: So I added "gmake" to the USE_TOOLS line and tried again (from scratch).
1.1       dsieger  4481: 
1.184     rillig   4482: [...]
                   4483: checking for GTK - version >= 1.2.0... no
                   4484: *** Could not run GTK test program, checking why...
                   4485: [...]
1.1       dsieger  4486: 
1.184     rillig   4487: Now to the other dependencies. The first question is: Where is the GTK package
                   4488: hidden in pkgsrc?
1.1       dsieger  4489: 
1.184     rillig   4490: $ echo ../../*/gtk*
                   4491: [many packages ...]
                   4492: $ echo ../../*/gtk
                   4493: ../../x11/gtk
                   4494: $ echo ../../*/gtk2
                   4495: ../../x11/gtk2
                   4496: $ echo ../../*/gtk2/bui*
                   4497: ../../x11/gtk2/buildlink3.mk
1.1       dsieger  4498: 
1.184     rillig   4499: The first try was definitely too broad. The second one had exactly one result,
                   4500: which is very good. But there is one pitfall with GNOME packages. Before GNOME
                   4501: 2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
                   4502: able to continue to use these packages, the GNOME 2 packages were imported as
                   4503: separate packages, and their names usually have a "2" appended. So I checked
                   4504: whether this was the case here, and indeed it was.
1.1       dsieger  4505: 
1.184     rillig   4506: Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
                   4507: easy. I just inserted an .include line before the last line of the package
                   4508: Makefile, so that it now looks like this:
1.1       dsieger  4509: 
1.184     rillig   4510: [...]
                   4511: .include "../../x11/gtk2/buildlink3.mk"
                   4512: .include "../../mk/bsd.pkg.mk
1.1       dsieger  4513: 
1.184     rillig   4514: After another bmake clean && bmake, the answer was:
1.108     rillig   4515: 
1.184     rillig   4516: [...]
                   4517: checking for gtk-config... /home/roland/pkg/bin/gtk-config
                   4518: checking for GTK - version >= 1.2.0... no
                   4519: *** Could not run GTK test program, checking why...
                   4520: *** The test program failed to compile or link. See the file config.log for the
                   4521: *** exact error that occured. This usually means GTK was incorrectly installed
                   4522: *** or that you have moved GTK since it was installed. In the latter case, you
                   4523: *** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
                   4524: configure: error: Test for GTK failed.
                   4525: [...]
1.1       dsieger  4526: 
1.184     rillig   4527: In this particular case, the assumption that "every package prefers GNOME 2"
                   4528: had been wrong. The first of the lines above told me that this package really
                   4529: wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
                   4530: it would have looked for pkg-config instead of gtk-config. So I changed the x11
                   4531: /gtk2 to x11/gtk in the package Makefile, and tried again.
1.1       dsieger  4532: 
1.184     rillig   4533: [...]
                   4534: cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\"  [...]
                   4535: In file included from xpidl.c:42:
                   4536: xpidl.h:53:24: libIDL/IDL.h: No such file or directory
                   4537: In file included from xpidl.c:42:
                   4538: xpidl.h:132: error: parse error before "IDL_ns"
                   4539: [...]
1.1       dsieger  4540: 
1.184     rillig   4541: The package still does not find all of its dependencies. Now the question is:
                   4542: Which package provides the libIDL/IDL.h header file?
1.1       dsieger  4543: 
1.184     rillig   4544: $ echo ../../*/*idl*
                   4545: ../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
                   4546: $ echo ../../*/*IDL*
                   4547: ../../net/libIDL
1.1       dsieger  4548: 
1.184     rillig   4549: Let's take the one from the second try. So I included the ../../net/libIDL/
                   4550: buildlink3.mk file and tried again. But the error didn't change. After digging
                   4551: through some of the code, I concluded that the build process of the package was
                   4552: broken and couldn't have ever worked, but since the Mozilla source tree is
                   4553: quite large, I didn't want to fix it. So I added the following to the package
                   4554: Makefile and tried again:
1.1       dsieger  4555: 
1.184     rillig   4556: CPPFLAGS+=              -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
                   4557: BUILDLINK_TRANSFORM+=   l:IDL:IDL-2
1.1       dsieger  4558: 
1.184     rillig   4559: The latter line is needed because the package expects the library libIDL.so,
                   4560: but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
                   4561: that on the fly.
1.1       dsieger  4562: 
1.184     rillig   4563: The next problem was related to a recent change of the FreeType interface. I
                   4564: looked up in www/seamonkey which patch files were relevant for this issue and
                   4565: copied them to the patches directory. Then I retried, fixed the patches so that
                   4566: they applied cleanly and retried again. This time, everything worked.
1.1       dsieger  4567: 
1.184     rillig   4568: 14.2.1.3. Installing the package
1.1       dsieger  4569: 
1.184     rillig   4570: $ bmake CHECK_FILES=no install
                   4571: [...]
                   4572: $ bmake print-PLIST >PLIST
                   4573: $ bmake deinstall
                   4574: $ bmake install
1.1       dsieger  4575: 
1.184     rillig   4576: Chapter 15. Programming in Makefiles
1.1       dsieger  4577: 
1.184     rillig   4578: Table of Contents
1.1       dsieger  4579: 
1.184     rillig   4580: 15.1. Caveats
                   4581: 15.2. Makefile variables
1.1       dsieger  4582: 
1.184     rillig   4583:     15.2.1. Naming conventions
1.1       dsieger  4584: 
1.184     rillig   4585: 15.3. Code snippets
1.1       dsieger  4586: 
1.184     rillig   4587:     15.3.1. Adding things to a list
                   4588:     15.3.2. Echoing a string exactly as-is
                   4589:     15.3.3. Passing CFLAGS to GNU configure scripts
                   4590:     15.3.4. Handling possibly empty variables
1.1       dsieger  4591: 
1.184     rillig   4592: Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
                   4593: part of the pkgsrc system. Using the make(1) system as a programming language
                   4594: for a big system like pkgsrc requires some discipline to keep the code correct
                   4595: and understandable.
1.1       dsieger  4596: 
1.184     rillig   4597: The basic ingredients for Makefile programming are variables and shell
                   4598: commands. Among these shell commands may even be more complex ones like awk(1)
                   4599: programs. To make sure that every shell command runs as intended it is
                   4600: necessary to quote all variables correctly when they are used.
1.1       dsieger  4601: 
1.184     rillig   4602: This chapter describes some patterns that appear quite often in Makefiles,
                   4603: including the pitfalls that come along with them.
1.1       dsieger  4604: 
1.184     rillig   4605: 15.1. Caveats
1.1       dsieger  4606: 
1.184     rillig   4607:   * When you are creating a file as a target of a rule, always write the data
                   4608:     to a temporary file first and finally rename that file. Otherwise there
                   4609:     might occur an error in the middle of generating the file, and when the
                   4610:     user runs make(1) for the second time, the file exists and will not be
                   4611:     regenerated properly. Example:
1.1       dsieger  4612: 
1.184     rillig   4613:     wrong:
                   4614:             @echo "line 1" > ${.TARGET}
                   4615:             @echo "line 2" >> ${.TARGET}
                   4616:             @false
1.1       dsieger  4617: 
1.184     rillig   4618:     correct:
                   4619:             @echo "line 1" > ${.TARGET}.tmp
                   4620:             @echo "line 2" >> ${.TARGET}.tmp
                   4621:             @false
                   4622:             @mv ${.TARGET}.tmp ${.TARGET}
1.1       dsieger  4623: 
1.184     rillig   4624:     When you run make wrong twice, the file wrong will exist, although there
                   4625:     was an error message in the first run. On the other hand, running make
                   4626:     correct gives an error message twice, as expected.
1.1       dsieger  4627: 
1.184     rillig   4628:     You might remember that make(1) sometimes removes ${.TARGET} in case of
                   4629:     error, but this only happens when it is interrupted, for example by
                   4630:     pressing Ctrl+C. This does not happen when one of the commands fails (like
                   4631:     false(1) above).
1.1       dsieger  4632: 
1.184     rillig   4633: 15.2. Makefile variables
1.1       dsieger  4634: 
1.184     rillig   4635: Makefile variables contain strings that can be processed using the five
                   4636: operators =, +=, ?=, := and !=, which are described in the make(1) man page.
1.1       dsieger  4637: 
1.184     rillig   4638: When a variable's value is parsed from a Makefile, the hash character # and the
                   4639: backslash character \ are handled specially. If a backslash is the last
                   4640: character in a line, that backslash is removed from the line and the line
                   4641: continues with the next line of the file.
1.1       dsieger  4642: 
1.184     rillig   4643: The # character starts a comment that reaches until the end of the line. To get
                   4644: an actual # character, such as in a URL, write \# instead.
1.1       dsieger  4645: 
1.184     rillig   4646: The evaluation of variables either happens immediately or lazy. It happens
                   4647: immediately when the variable occurs on the right-hand side of the := or the !=
                   4648: operator, in a .if condition or a .for loop. In the other cases, it is
                   4649: evaluated lazily.
1.1       dsieger  4650: 
1.184     rillig   4651: Some of the modifiers split the string into words and then operate on the
                   4652: words, others operate on the string as a whole. When a string is split into
                   4653: words, double quotes and single quotes are interpreted as delimiters, just like
                   4654: in sh(1).
1.1       dsieger  4655: 
1.184     rillig   4656: 15.2.1. Naming conventions
1.1       dsieger  4657: 
1.184     rillig   4658:   * All variable names starting with an underscore are reserved for use by the
                   4659:     pkgsrc infrastructure. They shall not be used by packages.
1.1       dsieger  4660: 
1.184     rillig   4661:   * In .for loops you should use lowercase variable names for the iteration
                   4662:     variables.
1.1       dsieger  4663: 
1.184     rillig   4664:   * All list variables should have a plural name, such as PKG_OPTIONS or
                   4665:     DISTFILES.
1.1       dsieger  4666: 
1.184     rillig   4667: 15.3. Code snippets
1.1       dsieger  4668: 
1.184     rillig   4669: 15.3.1. Adding things to a list
1.1       dsieger  4670: 
1.184     rillig   4671: When adding a string that possibly contains whitespace or quotes to a list
                   4672: (example 1), it must be quoted using the :Q modifier.
1.1       dsieger  4673: 
1.184     rillig   4674: When adding another list to a list (example 2), it must not be quoted, since
                   4675: its elements are already quoted.
1.1       dsieger  4676: 
1.184     rillig   4677: STRING=         foo * bar `date`
                   4678: LIST=           # empty
                   4679: ANOTHER_LIST=   a=b c=d
1.1       dsieger  4680: 
1.184     rillig   4681: LIST+=          ${STRING:Q}       # 1
                   4682: LIST+=          ${ANOTHER_LIST}   # 2
1.1       dsieger  4683: 
1.184     rillig   4684: 15.3.2. Echoing a string exactly as-is
1.1       dsieger  4685: 
1.184     rillig   4686: Echoing a string containing special characters needs special work.
1.1       dsieger  4687: 
1.184     rillig   4688: STRING=         foo bar <    > * `date` $$HOME ' "
                   4689: EXAMPLE_ENV=    string=${STRING:Q} x=multiple\ quoted\ words
1.1       dsieger  4690: 
1.184     rillig   4691: all:
                   4692:         echo ${STRING}                  # 1
                   4693:         echo ${STRING:Q}                # 2
                   4694:         printf '%s\n' ${STRING:Q}''     # 3
                   4695:         env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"'   # 4
1.1       dsieger  4696: 
1.184     rillig   4697: Example 1 leads to a syntax error in the shell, as the characters are just
                   4698: copied.
1.1       dsieger  4699: 
1.184     rillig   4700: Example 2 quotes the string so that the shell interprets it correctly. But the
                   4701: echo command may additionally interpret strings with a leading dash or those
                   4702: containing backslashes.
1.1       dsieger  4703: 
1.184     rillig   4704: Example 3 can handle arbitrary strings, since printf(1) only interprets the
                   4705: format string, but not the next argument. The trailing single quotes handle the
                   4706: case when the string is empty. In that case, the :Q modifier would result in an
                   4707: empty string too, which would then be skipped by the shell. For printf(1) this
                   4708: doesn't make a difference, but other programs may care.
1.1       dsieger  4709: 
1.184     rillig   4710: In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
                   4711: has already been done when adding elements to the list.
1.1       dsieger  4712: 
1.184     rillig   4713: 15.3.3. Passing CFLAGS to GNU configure scripts
1.1       dsieger  4714: 
1.184     rillig   4715: When passing CFLAGS or similar variables to a GNU-style configure script
                   4716: (especially those that call other configure scripts), it must not have leading
                   4717: or trailing whitespace, since otherwise the configure script gets confused. To
                   4718: trim leading and trailing whitespace, use the :M modifier, as in the following
                   4719: example:
1.1       dsieger  4720: 
1.184     rillig   4721: CPPFLAGS=               # empty
                   4722: CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX}\"
                   4723: CPPFLAGS+=              ${MY_CPPFLAGS}
1.1       dsieger  4724: 
1.184     rillig   4725: CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
1.1       dsieger  4726: 
1.184     rillig   4727: all:
                   4728:         echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
                   4729:         echo x${CONFIGURE_ARGS:Q}x      # properly trimmed
1.1       dsieger  4730: 
1.184     rillig   4731: In this example, CPPFLAGS has both leading and trailing whitespace because the
                   4732: += operator always adds a space.
1.1       dsieger  4733: 
1.184     rillig   4734: 15.3.4. Handling possibly empty variables
1.1       dsieger  4735: 
1.184     rillig   4736: When a possibly empty variable is used in a shell program, it may lead to a
                   4737: syntax error.
1.1       dsieger  4738: 
1.184     rillig   4739: EGFILES=        # empty
1.1       dsieger  4740: 
1.184     rillig   4741: install-examples:   # produces a syntax error in the shell
                   4742:         for egfile in ${EGFILES}; do            \
                   4743:                 echo "Installing $$egfile";     \
                   4744:         done
1.1       dsieger  4745: 
1.184     rillig   4746: The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
                   4747: with an empty string by make(1). To fix this syntax error, use one of the
                   4748: snippets below.
1.1       dsieger  4749: 
1.184     rillig   4750: EMPTY=          # empty
1.1       dsieger  4751: 
1.184     rillig   4752: install-examples:
                   4753:         for egfile in ${EGFILES} ""; do         \
                   4754:                 [ -n "$$egfile" ] || continue;  \
                   4755:                 echo "Installing $$egfile";     \
                   4756:         done
1.1       dsieger  4757: 
1.184     rillig   4758: In this case, an empty string is appended to the iteration list (to prevent the
                   4759: syntax error) and filtered out later.
1.1       dsieger  4760: 
1.184     rillig   4761: EGFILES=        # empty
1.1       dsieger  4762: 
1.184     rillig   4763: install-examples:
                   4764: .for egfile in ${EGFILES}
                   4765:         echo "Installing ${egfile}"
                   4766: .endfor
1.1       dsieger  4767: 
1.184     rillig   4768: If one of the filenames contains special characters, it should be enclosed in
                   4769: single or double quotes.
1.1       dsieger  4770: 
1.184     rillig   4771: To have a shell command test whether a make variable is empty, use the
                   4772: following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
1.1       dsieger  4773: 
1.184     rillig   4774: Chapter 16. Options handling
1.1       dsieger  4775: 
                   4776: Table of Contents
                   4777: 
1.184     rillig   4778: 16.1. Global default options
                   4779: 16.2. Converting packages to use bsd.options.mk
                   4780: 16.3. Option Names
                   4781: 16.4. Determining the options of dependencies
1.1       dsieger  4782: 
                   4783: Many packages have the ability to be built to support different sets of
                   4784: features. bsd.options.mk is a framework in pkgsrc that provides generic
                   4785: handling of those options that determine different ways in which the packages
                   4786: can be built. It's possible for the user to specify exactly which sets of
                   4787: options will be built into a package or to allow a set of global default
                   4788: options apply.
                   4789: 
1.7       rillig   4790: There are two broad classes of behaviors that one might want to control via
                   4791: options. One is whether some particular feature is enabled in a program that
                   4792: will be built anyway, often by including or not including a dependency on some
                   4793: other package. The other is whether or not an additional program will be built
                   4794: as part of the package. Generally, it is better to make a split package for
                   4795: such additional programs instead of using options, because it enables binary
                   4796: packages to be built which can then be added separately. For example, the foo
                   4797: package might have minimal dependencies (those packages without which foo
                   4798: doesn't make sense), and then the foo-gfoo package might include the GTK
                   4799: frontend program gfoo. This is better than including a gtk option to foo that
                   4800: adds gfoo, because either that option is default, in which case binary users
                   4801: can't get foo without gfoo, or not default, in which case they can't get gfoo.
                   4802: With split packages, they can install foo without having GTK, and later decide
                   4803: to install gfoo (pulling in GTK at that time). This is an advantage to source
                   4804: users too, avoiding the need for rebuilds.
                   4805: 
                   4806: Plugins with widely varying dependencies should usually be split instead of
                   4807: options.
                   4808: 
                   4809: It is often more work to maintain split packages, especially if the upstream
                   4810: package does not support this. The decision of split vs. option should be made
                   4811: based on the likelihood that users will want or object to the various pieces,
                   4812: the size of the dependencies that are included, and the amount of work.
                   4813: 
                   4814: A further consideration is licensing. Non-free parts, or parts that depend on
                   4815: non-free dependencies (especially plugins) should almost always be split if
                   4816: feasible.
                   4817: 
1.184     rillig   4818: 16.1. Global default options
1.1       dsieger  4819: 
                   4820: Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
                   4821: the options that should be built into every package if that option is
1.4       rillig   4822: supported. This variable should be set in mk.conf.
1.1       dsieger  4823: 
1.184     rillig   4824: 16.2. Converting packages to use bsd.options.mk
1.1       dsieger  4825: 
                   4826: The following example shows how bsd.options.mk should be used by the
                   4827: hypothetical ``wibble'' package, either in the package Makefile, or in a file,
                   4828: e.g. options.mk, that is included by the main package Makefile.
                   4829: 
                   4830: PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
                   4831: PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
                   4832: PKG_OPTIONS_OPTIONAL_GROUPS=    database
                   4833: PKG_OPTIONS_GROUP.database=     mysql pgsql
                   4834: PKG_SUGGESTED_OPTIONS=          wibble-foo
                   4835: PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
                   4836: PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
                   4837: 
                   4838: .include "../../mk/bsd.prefs.mk"
                   4839: 
                   4840: # this package was previously named wibble2
                   4841: .if defined(PKG_OPTIONS.wibble2)
                   4842: PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
                   4843: PKG_OPTIONS_DEPRECATED_WARNINGS+= \
                   4844:         "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
                   4845: .endif
                   4846: 
                   4847: .include "../../mk/bsd.options.mk"
                   4848: 
                   4849: # Package-specific option-handling
                   4850: 
                   4851: ###
                   4852: ### FOO support
                   4853: ###
                   4854: .if !empty(PKG_OPTIONS:Mwibble-foo)
                   4855: CONFIGURE_ARGS+=    --enable-foo
                   4856: .endif
                   4857: 
                   4858: ###
                   4859: ### LDAP support
                   4860: ###
                   4861: .if !empty(PKG_OPTIONS:Mldap)
                   4862: .  include "../../databases/openldap-client/buildlink3.mk"
                   4863: CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
                   4864: .endif
                   4865: 
                   4866: ###
                   4867: ### database support
                   4868: ###
                   4869: .if !empty(PKG_OPTIONS:Mmysql)
                   4870: .  include "../../mk/mysql.buildlink3.mk"
                   4871: .endif
                   4872: .if !empty(PKG_OPTIONS:Mpgsql)
                   4873: .  include "../../mk/pgsql.buildlink3.mk"
                   4874: .endif
                   4875: 
                   4876: The first section contains the information about which build options are
                   4877: supported by the package, and any default options settings if needed.
                   4878: 
                   4879:  1. PKG_OPTIONS_VAR is the name of the make(1) variable that the user can set
                   4880:     to override the default options. It should be set to PKG_OPTIONS.pkgbase.
                   4881:     Do not set it to PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined at
                   4882:     the point where the options are processed.
                   4883: 
                   4884:  2. PKG_SUPPORTED_OPTIONS is a list of build options supported by the package.
                   4885: 
                   4886:  3. PKG_OPTIONS_OPTIONAL_GROUPS is a list of names of groups of mutually
                   4887:     exclusive options. The options in each group are listed in
                   4888:     PKG_OPTIONS_GROUP.groupname. The most specific setting of any option from
                   4889:     the group takes precedence over all other options in the group. Options
                   4890:     from the groups will be automatically added to PKG_SUPPORTED_OPTIONS.
                   4891: 
                   4892:  4. PKG_OPTIONS_REQUIRED_GROUPS is like PKG_OPTIONS_OPTIONAL_GROUPS, but
                   4893:     building the packages will fail if no option from the group is selected.
                   4894: 
                   4895:  5. PKG_OPTIONS_NONEMPTY_SETS is a list of names of sets of options. At least
                   4896:     one option from each set must be selected. The options in each set are
                   4897:     listed in PKG_OPTIONS_SET.setname. Options from the sets will be
                   4898:     automatically added to PKG_SUPPORTED_OPTIONS. Building the package will
                   4899:     fail if no option from the set is selected.
                   4900: 
                   4901:  6. PKG_SUGGESTED_OPTIONS is a list of build options which are enabled by
                   4902:     default.
                   4903: 
                   4904:  7. PKG_OPTIONS_LEGACY_VARS is a list of "USE_VARIABLE:option" pairs that map
1.4       rillig   4905:     legacy mk.conf variables to their option counterparts. Pairs should be
1.1       dsieger  4906:     added with "+=" to keep the listing of global legacy variables. A warning
                   4907:     will be issued if the user uses a legacy variable.
                   4908: 
                   4909:  8. PKG_OPTIONS_LEGACY_OPTS is a list of "old-option:new-option" pairs that map
                   4910:     options that have been renamed to their new counterparts. Pairs should be
                   4911:     added with "+=" to keep the listing of global legacy options. A warning
                   4912:     will be issued if the user uses a legacy option.
                   4913: 
                   4914:  9. PKG_LEGACY_OPTIONS is a list of options implied by deprecated variables
                   4915:     used. This can be used for cases that neither PKG_OPTIONS_LEGACY_VARS nor
                   4916:     PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when PKG_OPTIONS_VAR is renamed.
                   4917: 
                   4918: 10. PKG_OPTIONS_DEPRECATED_WARNINGS is a list of warnings about deprecated
                   4919:     variables or options used, and what to use instead.
                   4920: 
                   4921: A package should never modify PKG_DEFAULT_OPTIONS or the variable named in
                   4922: PKG_OPTIONS_VAR. These are strictly user-settable. To suggest a default set of
                   4923: options, use PKG_SUGGESTED_OPTIONS.
                   4924: 
                   4925: PKG_OPTIONS_VAR must be defined before including bsd.options.mk. If none of
                   4926: PKG_SUPPORTED_OPTIONS, PKG_OPTIONS_OPTIONAL_GROUPS, and
                   4927: PKG_OPTIONS_REQUIRED_GROUPS are defined (as can happen with platform-specific
                   4928: options if none of them is supported on the current platform), PKG_OPTIONS is
                   4929: set to the empty list and the package is otherwise treated as not using the
                   4930: options framework.
                   4931: 
                   4932: After the inclusion of bsd.options.mk, the variable PKG_OPTIONS contains the
                   4933: list of selected build options, properly filtered to remove unsupported and
                   4934: duplicate options.
                   4935: 
                   4936: The remaining sections contain the logic that is specific to each option. The
                   4937: correct way to check for an option is to check whether it is listed in
                   4938: PKG_OPTIONS:
                   4939: 
                   4940: .if !empty(PKG_OPTIONS:Moption)
                   4941: 
1.184     rillig   4942: 16.3. Option Names
1.1       dsieger  4943: 
                   4944: Options that enable similar features in different packages (like optional
                   4945: support for a library) should use a common name in all packages that support it
                   4946: (like the name of the library). If another package already has an option with
                   4947: the same meaning, use the same name.
                   4948: 
                   4949: Options that enable features specific to one package, where it's unlikely that
                   4950: another (unrelated) package has the same (or a similar) optional feature,
                   4951: should use a name prefixed with pkgname-.
                   4952: 
                   4953: If a group of related packages share an optional feature specific to that
                   4954: group, prefix it with the name of the "main" package (e. g.
                   4955: djbware-errno-hack).
                   4956: 
                   4957: For new options, add a line to mk/defaults/options.description. Lines have two
                   4958: fields, separated by tab. The first field is the option name, the second its
                   4959: description. The description should be a whole sentence (starting with an
                   4960: uppercase letter and ending with a period) that describes what enabling the
                   4961: option does. E. g. "Enable ispell support." The file is sorted by option names.
                   4962: 
1.184     rillig   4963: 16.4. Determining the options of dependencies
1.7       rillig   4964: 
                   4965: When writing buildlink3.mk files, it is often necessary to list different
                   4966: dependencies based on the options with which the package was built. For
                   4967: querying these options, the file pkgsrc/mk/pkg-build-options.mk should be used.
                   4968: A typical example looks like this:
                   4969: 
                   4970: pkgbase := libpurple
                   4971: .include "../../mk/pkg-build-options.mk"
                   4972: 
                   4973: .if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
                   4974: ...
                   4975: .endif
                   4976: 
                   4977: Including pkg-build-options.mk here will set the variable
                   4978: PKG_BUILD_OPTIONS.libpurple to the build options of the libpurple package,
                   4979: which can then be queried like PKG_OPTIONS in the options.mk file. See the file
                   4980: pkg-build-options.mk for more details.
                   4981: 
1.184     rillig   4982: Chapter 17. Tools needed for building or running
                   4983: 
                   4984: Table of Contents
                   4985: 
                   4986: 17.1. Tools for pkgsrc builds
                   4987: 17.2. Tools needed by packages
                   4988: 17.3. Tools provided by platforms
                   4989: 
                   4990: The USE_TOOLS definition is used both internally by pkgsrc and also for
                   4991: individual packages to define what commands are needed for building a package
                   4992: (like TOOL_DEPENDS) or for later run-time of an installed packaged (such as
                   4993: DEPENDS). If the native system provides an adequate tool, then in many cases, a
                   4994: pkgsrc package will not be used.
                   4995: 
                   4996: When building a package, the replacement tools are made available in a
                   4997: directory (as symlinks or wrapper scripts) that is early in the executable
                   4998: search path. Just like the buildlink system, this helps with consistent builds.
                   4999: 
                   5000: A tool may be needed to help build a specific package. For example, perl, GNU
                   5001: make (gmake) or yacc may be needed.
                   5002: 
                   5003: Also a tool may be needed, for example, because the native system's supplied
                   5004: tool may be inefficient for building a package with pkgsrc. For example, a
                   5005: package may need GNU awk, bison (instead of yacc) or a better sed.
                   5006: 
                   5007: The tools used by a package can be listed by running make show-tools.
                   5008: 
                   5009: 17.1. Tools for pkgsrc builds
                   5010: 
                   5011: The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
                   5012: standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
                   5013: seen by running: make show-var VARNAME=USE_TOOLS.
                   5014: 
                   5015: If a package needs a specific program to build then the USE_TOOLS variable can
                   5016: be used to define the tools needed.
                   5017: 
                   5018: 17.2. Tools needed by packages
                   5019: 
                   5020: In the following examples, the :run means that it is needed at run-time (and
                   5021: becomes a DEPENDS). The default is a build dependency which can be set with
                   5022: :build. (So in this example, it is the same as gmake:build and
                   5023: pkg-config:build.)
                   5024: 
                   5025: USE_TOOLS+=     gmake perl:run pkg-config
                   5026: 
                   5027: When using the tools framework, a TOOLS_PATH.foo variable is defined which
                   5028: contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
                   5029: could be "/bin/bash" on Linux systems.
                   5030: 
                   5031: If you always need a pkgsrc version of the tool at run-time, then just use
                   5032: DEPENDS instead.
                   5033: 
                   5034: 17.3. Tools provided by platforms
                   5035: 
                   5036: When improving or porting pkgsrc to a new platform, have a look at (or create)
                   5037: the corresponding platform specific make file fragment under pkgsrc/mk/tools/
                   5038: tools.${OPSYS}.mk which defines the name of the common tools. For example:
                   5039: 
                   5040: .if exists(/usr/bin/bzcat)
                   5041: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
                   5042: .elif exists(/usr/bin/bzip2)
                   5043: TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
                   5044: .endif
                   5045: 
                   5046: TOOLS_PLATFORM.true?=           true                    # shell builtin
                   5047: 
                   5048: Chapter 18. Buildlink methodology
1.1       dsieger  5049: 
                   5050: Table of Contents
                   5051: 
1.184     rillig   5052: 18.1. Converting packages to use buildlink3
                   5053: 18.2. Writing buildlink3.mk files
                   5054: 
                   5055:     18.2.1. Anatomy of a buildlink3.mk file
                   5056:     18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
                   5057:         buildlink3.mk files
                   5058: 
                   5059: 18.3. Writing builtin.mk files
                   5060: 
                   5061:     18.3.1. Anatomy of a builtin.mk file
                   5062:     18.3.2. Global preferences for native or pkgsrc software
                   5063: 
                   5064: Buildlink is a framework in pkgsrc that controls what headers and libraries are
                   5065: seen by a package's configure and build processes. This is implemented in a two
                   5066: step process:
                   5067: 
                   5068:  1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
                   5069:     default is a subdirectory of WRKDIR.
                   5070: 
                   5071:  2. Create wrapper scripts that are used in place of the normal compiler tools
                   5072:     that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
                   5073:     references to BUILDLINK_DIR. The wrapper scripts also make native compiler
                   5074:     on some operating systems look like GCC, so that packages that expect GCC
                   5075:     won't require modifications to build with those native compilers.
                   5076: 
                   5077: This normalizes the environment in which a package is built so that the package
                   5078: may be built consistently despite what other software may be installed. Please
                   5079: note that the normal system header and library paths, e.g. /usr/include, /usr/
                   5080: lib, etc., are always searched -- buildlink3 is designed to insulate the
                   5081: package build from non-system-supplied software.
                   5082: 
                   5083: 18.1. Converting packages to use buildlink3
1.1       dsieger  5084: 
1.184     rillig   5085: The process of converting packages to use the buildlink3 framework ("bl3ifying"
                   5086: ) is fairly straightforward. The things to keep in mind are:
1.1       dsieger  5087: 
1.184     rillig   5088:  1. Ensure that the build always calls the wrapper scripts instead of the
                   5089:     actual toolchain. Some packages are tricky, and the only way to know for
                   5090:     sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
                   5091:     invoked.
1.1       dsieger  5092: 
1.184     rillig   5093:  2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
                   5094:     standalone shells, etc., because the code to symlink files into $
                   5095:     {BUILDLINK_DIR} looks for files relative to "pkg_info -qp pkgname".
1.1       dsieger  5096: 
1.184     rillig   5097:  3. Remember that only the buildlink3.mk files that you list in a package's
                   5098:     Makefile are added as dependencies for that package.
1.1       dsieger  5099: 
1.184     rillig   5100: If a dependency on a particular package is required for its libraries and
                   5101: headers, then we replace:
1.1       dsieger  5102: 
1.184     rillig   5103: DEPENDS+=       foo>=1.1.0:../../category/foo
1.1       dsieger  5104: 
1.184     rillig   5105: with
1.1       dsieger  5106: 
1.184     rillig   5107: .include "../../category/foo/buildlink3.mk"
1.1       dsieger  5108: 
1.184     rillig   5109: The buildlink3.mk files usually define the required dependencies. If you need a
                   5110: newer version of the dependency when using buildlink3.mk files, then you can
                   5111: define it in your Makefile; for example:
1.1       dsieger  5112: 
1.184     rillig   5113: BUILDLINK_API_DEPENDS.foo+=   foo>=1.1.0
                   5114: .include "../../category/foo/buildlink3.mk"
1.1       dsieger  5115: 
1.184     rillig   5116: There are several buildlink3.mk files in pkgsrc/mk that handle special package
                   5117: issues:
1.1       dsieger  5118: 
1.184     rillig   5119:   * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
                   5120:     implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
1.1       dsieger  5121: 
1.184     rillig   5122:   * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
                   5123:     this will take care to install the devel/ncurses package.
1.1       dsieger  5124: 
1.184     rillig   5125:   * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
                   5126:     a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
                   5127:     implementation.
1.1       dsieger  5128: 
1.184     rillig   5129:   * motif.buildlink3.mk checks for a system-provided Motif installation or adds
                   5130:     a dependency on x11/lesstif or x11/motif. The user can set MOTIF_TYPE to "
                   5131:     dt", "lesstif" or "motif" to choose which Motif version will be used.
1.1       dsieger  5132: 
1.184     rillig   5133:   * readline.buildlink3.mk checks for a system-provided GNU readline or
                   5134:     editline (libedit) installation, or adds a dependency on devel/readline,
                   5135:     devel/editline. The user can set READLINE_DEFAULT to choose readline
                   5136:     implementation. If your package really needs GNU readline library, its
                   5137:     Makefile should include devel/readline/buildlink3.mk instead of
                   5138:     readline.buildlink3.mk.
1.1       dsieger  5139: 
1.184     rillig   5140:   * oss.buildlink3.mk defines several variables that may be used by packages
                   5141:     that use the Open Sound System (OSS) API.
1.1       dsieger  5142: 
1.184     rillig   5143:   * pgsql.buildlink3.mk will accept any of the Postgres versions in the
                   5144:     variable PGSQL_VERSIONS_ACCEPTED and default to the version
                   5145:     PGSQL_VERSION_DEFAULT. See the file for more information.
1.1       dsieger  5146: 
1.184     rillig   5147:   * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
                   5148:     pthreads or adds a dependency on devel/pth as needed.
1.1       dsieger  5149: 
1.184     rillig   5150:   * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
                   5151:     widgets library.
1.1       dsieger  5152: 
1.184     rillig   5153: The comments in those buildlink3.mk files provide a more complete description
                   5154: of how to use them properly.
1.1       dsieger  5155: 
1.184     rillig   5156: 18.2. Writing buildlink3.mk files
1.1       dsieger  5157: 
1.184     rillig   5158: A package's buildlink3.mk file is included by Makefiles to indicate the need to
                   5159: compile and link against header files and libraries provided by the package. A
                   5160: buildlink3.mk file should always provide enough information to add the correct
                   5161: type of dependency relationship and include any other buildlink3.mk files that
                   5162: it needs to find headers and libraries that it needs in turn.
1.1       dsieger  5163: 
1.184     rillig   5164: To generate an initial buildlink3.mk file for further editing, Rene Hexel's
                   5165: pkgtools/createbuildlink package is highly recommended. For most packages, the
                   5166: following command will generate a good starting point for buildlink3.mk files:
1.1       dsieger  5167: 
1.184     rillig   5168: % cd pkgsrc/category/pkgdir
                   5169: % createbuildlink >buildlink3.mk
1.1       dsieger  5170: 
                   5171: 
1.184     rillig   5172: 18.2.1. Anatomy of a buildlink3.mk file
1.1       dsieger  5173: 
1.184     rillig   5174: The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
                   5175: tiff:
1.14      jmcneill 5176: 
1.184     rillig   5177: # $NetBSD: buildlink3.mk,v 1.16 2009/03/20 19:24:45 joerg Exp $
1.1       dsieger  5178: 
1.184     rillig   5179: BUILDLINK_TREE+=        tiff
1.1       dsieger  5180: 
1.184     rillig   5181: .if !defined(TIFF_BUILDLINK3_MK)
                   5182: TIFF_BUILDLINK3_MK:=
1.1       dsieger  5183: 
1.184     rillig   5184: BUILDLINK_API_DEPENDS.tiff+=    tiff>=3.6.1
                   5185: BUILDLINK_ABI_DEPENDS.tiff+=    tiff>=3.7.2nb1
                   5186: BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
1.1       dsieger  5187: 
1.184     rillig   5188: .include "../../devel/zlib/buildlink3.mk"
                   5189: .include "../../graphics/jpeg/buildlink3.mk"
                   5190: .endif # TIFF_BUILDLINK3_MK
1.1       dsieger  5191: 
1.184     rillig   5192: BUILDLINK_TREE+=        -tiff
1.1       dsieger  5193: 
1.184     rillig   5194: The header and footer manipulate BUILDLINK_TREE, which is common across all
                   5195: buildlink3.mk files and is used to track the dependency tree.
1.1       dsieger  5196: 
1.184     rillig   5197: The main section is protected from multiple inclusion and controls how the
                   5198: dependency on pkg is added. Several important variables are set in the section:
1.1       dsieger  5199: 
1.185   ! wiz      5200:   * BUILDLINK_API_DEPENDS.pkg is the dependency version recorded in the
1.184     rillig   5201:     installed package; this should always be set using += to ensure that we're
                   5202:     appending to any pre-existing list of values. This variable should be set
1.185   ! wiz      5203:     to the last version of the package that had an backwards-incompatible API
1.184     rillig   5204:     change.
1.1       dsieger  5205: 
1.184     rillig   5206:   * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
1.1       dsieger  5207: 
1.184     rillig   5208:   * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
                   5209:     BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
                   5210:     is selected by setting BUILDLINK_DEPMETHOD.pkg to "build". By default, the
                   5211:     full dependency is used.
1.1       dsieger  5212: 
1.184     rillig   5213:   * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
                   5214:     of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
                   5215:     library search paths. These default to "include" and "lib" respectively.
1.1       dsieger  5216: 
1.184     rillig   5217:   * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
                   5218:     to add to CPPFLAGS, which are passed on to the configure and build phases.
                   5219:     The "-I" option should be avoided and instead be handled using
                   5220:     BUILDLINK_INCDIRS.pkg as above.
1.66      asau     5221: 
1.184     rillig   5222: The following variables are all optionally defined within this second section
                   5223: (protected against multiple inclusion) and control which package files are
                   5224: symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
                   5225: symlinking:
1.23      jakllsch 5226: 
1.184     rillig   5227:   * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
                   5228:     {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
                   5229:     *.h.
1.1       dsieger  5230: 
1.184     rillig   5231:   * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
                   5232:     to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
                   5233:     resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
                   5234:     takes the +CONTENTS of a pkg and filters it through $
                   5235:     {BUILDLINK_CONTENTS_FILTER.pkg}.
1.1       dsieger  5236: 
1.184     rillig   5237:   * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
                   5238:     filters +CONTENTS input into a list of files relative to $
                   5239:     {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
                   5240:     outputs the contents of the include and lib directories in the package
                   5241:     +CONTENTS.
1.1       dsieger  5242: 
1.184     rillig   5243:   * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
                   5244:     used to transform the name of the source filename into a destination
                   5245:     filename, e.g. -e "s|/curses.h|/ncurses.h|g".
1.1       dsieger  5246: 
1.184     rillig   5247: This section can additionally include any buildlink3.mk needed for pkg's
                   5248: library dependencies. Including these buildlink3.mk files means that the
                   5249: headers and libraries for these dependencies are also symlinked into $
                   5250: {BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
                   5251: are only added for directly include buildlink3.mk files.
1.1       dsieger  5252: 
1.184     rillig   5253: When providing a buildlink3.mk and including other buildlink3.mk files in it,
                   5254: please only add necessary ones, i.e., those whose libraries or header files are
                   5255: automatically exposed when the package is use.
1.1       dsieger  5256: 
1.184     rillig   5257: In particular, if only an executable (bin/foo) is linked against a library,
                   5258: that library does not need to be propagated in the buildlink3.mk file.
1.1       dsieger  5259: 
1.184     rillig   5260: The following steps should help you decide if a buildlink3.mk file needs to be
                   5261: included:
1.1       dsieger  5262: 
1.184     rillig   5263:   * Look at the installed header files: What headers do they include? The
                   5264:     packages providing these files must be buildlinked.
1.1       dsieger  5265: 
1.184     rillig   5266:   * Run ldd on all installed libraries and look against what other libraries
                   5267:     they link. Some of the packages providing these probably need to be
                   5268:     buildlinked; however, it's not automatic, since e.g. GTK on some systems
                   5269:     pulls in the X libraries, so they will show up in the ldd output, while on
                   5270:     others (like OS X) it won't. ldd output can thus only be used as a hint.
1.1       dsieger  5271: 
1.184     rillig   5272: 18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
                   5273: buildlink3.mk files
1.16      jnemeth  5274: 
1.185   ! wiz      5275: Both variables set lower bounds for a version of this package. The two
        !          5276: variables differ in that one describes source compatibility (API) and the other
        !          5277: binary compatibility (ABI). The difference is that a change in the API breaks
        !          5278: compilation of programs while changes in the ABI stop compiled programs from
        !          5279: running.
        !          5280: 
        !          5281: The BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk should be changed
        !          5282: very rarely. (One possible scenario: If all packages using this package need a
        !          5283: higher version than defined in the buildlink3.mk, BUILDLINK_API_DEPENDS.pkg
        !          5284: could be updated to that higher version.)
        !          5285: 
        !          5286: On the other hand, changes to BUILDLINK_ABI_DEPENDS.pkg are more common. The
        !          5287: variable will need to be updated every time the major version of one of its
        !          5288: shared libraries is changed, or any other change where a binary built against
        !          5289: the previous version of the package will not run against the new version any
        !          5290: longer.
        !          5291: 
        !          5292: In such a case, the package's BUILDLINK_ABI_DEPENDS.pkg must be increased to
        !          5293: require the new package version. Then the PKGREVISION of all packages foo that
        !          5294: depend on this package need to be increased, and if they have buildlink3.mk
        !          5295: files, BUILDLINK_ABI_DEPENDS.foo in their buildlink3.mk files must be increased
        !          5296: to the new version as well. This is required so that a package will pull in the
        !          5297: versions of the packages that use the new ABI and that the packages'
        !          5298: PKGREVISIONs uniquely identify the packages built against the new ABI. The
        !          5299: pkgtools/revbump package can help with these updates.
1.1       dsieger  5300: 
1.184     rillig   5301: See Section 21.1.5, "Handling dependencies" for more information about
1.185   ! wiz      5302: dependencies on other packages, including the BUILDLINK_API_DEPENDS
        !          5303: definitions.
1.1       dsieger  5304: 
1.184     rillig   5305: Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
1.185   ! wiz      5306: BUILDLINK_ABI_DEPENDS.pkg in a buildlink3.mk file as we don't want to cause
        !          5307: unneeded package deletions and rebuilds. In many cases, new versions of
        !          5308: packages work just fine with older dependencies.
1.1       dsieger  5309: 
1.184     rillig   5310: Also it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
                   5311: BUILDLINK_API_DEPENDS.pkg.
1.1       dsieger  5312: 
1.184     rillig   5313: 18.3. Writing builtin.mk files
1.1       dsieger  5314: 
1.184     rillig   5315: Some packages in pkgsrc install headers and libraries that coincide with
                   5316: headers and libraries present in the base system. Aside from a buildlink3.mk
                   5317: file, these packages should also include a builtin.mk file that includes the
                   5318: necessary checks to decide whether using the built-in software or the pkgsrc
                   5319: software is appropriate.
1.1       dsieger  5320: 
1.184     rillig   5321: The only requirements of a builtin.mk file for pkg are:
1.1       dsieger  5322: 
1.184     rillig   5323:  1. It should set USE_BUILTIN.pkg to either "yes" or "no" after it is included.
1.1       dsieger  5324: 
1.184     rillig   5325:  2. It should not override any USE_BUILTIN.pkg which is already set before the
                   5326:     builtin.mk file is included.
1.1       dsieger  5327: 
1.184     rillig   5328:  3. It should be written to allow multiple inclusion. This is very important
                   5329:     and takes careful attention to Makefile coding.
1.1       dsieger  5330: 
1.184     rillig   5331: 18.3.1. Anatomy of a builtin.mk file
1.1       dsieger  5332: 
1.184     rillig   5333: The following is the recommended template for builtin.mk files:
1.1       dsieger  5334: 
1.184     rillig   5335: .if !defined(IS_BUILTIN.foo)
                   5336: #
                   5337: # IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
                   5338: # genuinely exists in the system or not.
                   5339: #
                   5340: IS_BUILTIN.foo?=        no
1.1       dsieger  5341: 
1.184     rillig   5342: # BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
                   5343: # version can be determined.
                   5344: #
                   5345: .  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
                   5346: BUILTIN_PKG.foo?=       foo-1.0
                   5347: .  endif
                   5348: .endif  # IS_BUILTIN.foo
1.1       dsieger  5349: 
1.184     rillig   5350: .if !defined(USE_BUILTIN.foo)
                   5351: USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
                   5352: .  if defined(BUILTIN_PKG.foo)
                   5353: .    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
                   5354: .      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
                   5355: USE_BUILTIN.foo!=                                                       \
                   5356:         ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}            \
                   5357:         && ${ECHO} "yes" || ${ECHO} "no"
                   5358: .      endif
                   5359: .    endfor
                   5360: .  endif
                   5361: .endif  # USE_BUILTIN.foo
1.1       dsieger  5362: 
1.184     rillig   5363: CHECK_BUILTIN.foo?=     no
                   5364: .if !empty(CHECK_BUILTIN.foo:M[nN][oO])
                   5365: #
                   5366: # Here we place code that depends on whether USE_BUILTIN.foo is set to
                   5367: # "yes" or "no".
                   5368: #
                   5369: .endif  # CHECK_BUILTIN.foo
1.1       dsieger  5370: 
1.184     rillig   5371: The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
                   5372: base system. This should not be a base system software with similar
                   5373: functionality to pkg; it should only be "yes" if the actual package is included
                   5374: as part of the base system. This variable is only used internally within the
                   5375: builtin.mk file.
1.1       dsieger  5376: 
1.184     rillig   5377: The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
                   5378: system if it exists (if IS_BUILTIN.pkg is "yes"). This variable is only used
                   5379: internally within the builtin.mk file.
1.1       dsieger  5380: 
1.184     rillig   5381: The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
                   5382: The code in this section must make the determination whether the built-in
                   5383: software is adequate to satisfy the dependencies listed in
                   5384: BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
                   5385: against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg 
                   5386: must be set to the correct value by the end of the builtin.mk file. Note that
                   5387: USE_BUILTIN.pkg may be "yes" even if IS_BUILTIN.pkg is "no" because we may make
                   5388: the determination that the built-in version of the software is similar enough
                   5389: to be used as a replacement.
1.1       dsieger  5390: 
1.184     rillig   5391: The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
                   5392: the value of USE_BUILTIN.pkg set in the previous section. This typically
                   5393: includes, e.g., adding additional dependency restrictions and listing
                   5394: additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
1.1       dsieger  5395: 
1.184     rillig   5396: 18.3.2. Global preferences for native or pkgsrc software
1.1       dsieger  5397: 
1.184     rillig   5398: When building packages, it's possible to choose whether to set a global
                   5399: preference for using either the built-in (native) version or the pkgsrc version
                   5400: of software to satisfy a dependency. This is controlled by setting
                   5401: PREFER_PKGSRC and PREFER_NATIVE. These variables take values of either "yes", "
                   5402: no", or a list of packages. PREFER_PKGSRC tells pkgsrc to use the pkgsrc
                   5403: versions of software, while PREFER_NATIVE tells pkgsrc to use the built-in
                   5404: versions. Preferences are determined by the most specific instance of the
                   5405: package in either PREFER_PKGSRC or PREFER_NATIVE. If a package is specified in
                   5406: neither or in both variables, then PREFER_PKGSRC has precedence over
                   5407: PREFER_NATIVE. For example, to require using pkgsrc versions of software for
                   5408: all but the most basic bits on a NetBSD system, you can set:
1.1       dsieger  5409: 
1.184     rillig   5410: PREFER_PKGSRC=  yes
                   5411: PREFER_NATIVE=  getopt skey tcp_wrappers
1.1       dsieger  5412: 
1.184     rillig   5413: A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
                   5414: it is simply ignored in that list.
1.1       dsieger  5415: 
1.184     rillig   5416: Setting PREFER_NATIVE should be performed straight after bootstrap and
                   5417: PREFER_PKGSRC during bootstrap. Switching between settings globally at a later
                   5418: date can introduce complications with dependency resolution. This is caused by
                   5419: packages built with the opposite preference being installed alongside each
                   5420: other.
1.1       dsieger  5421: 
1.184     rillig   5422: # ./bootstrap --prefer-pkgsrc yes
1.1       dsieger  5423: 
1.184     rillig   5424: Chapter 19. PLIST issues
1.1       dsieger  5425: 
1.184     rillig   5426: Table of Contents
1.1       dsieger  5427: 
1.184     rillig   5428: 19.1. RCS ID
                   5429: 19.2. Semi-automatic PLIST generation
                   5430: 19.3. Tweaking output of make print-PLIST
                   5431: 19.4. Variable substitution in PLIST
                   5432: 19.5. Man page compression
                   5433: 19.6. Changing PLIST source with PLIST_SRC
                   5434: 19.7. Platform-specific and differing PLISTs
                   5435: 19.8. Build-specific PLISTs
                   5436: 19.9. Sharing directories between packages
1.1       dsieger  5437: 
1.184     rillig   5438: The PLIST file contains a package's "packing list", i.e. a list of files that
                   5439: belong to the package (relative to the ${PREFIX} directory it's been installed
                   5440: in) plus some additional statements - see the pkg_create(1) man page for a full
                   5441: list. This chapter addresses some issues that need attention when dealing with
                   5442: the PLIST file (or files, see below!).
1.1       dsieger  5443: 
1.184     rillig   5444: 19.1. RCS ID
1.1       dsieger  5445: 
1.184     rillig   5446: Be sure to add a RCS ID line as the first thing in any PLIST file you write:
1.1       dsieger  5447: 
1.184     rillig   5448: @comment $NetBSD $
1.1       dsieger  5449: 
1.184     rillig   5450: An artificial space has been added between NetBSD and $, this is a workaround
                   5451: here to prevent CVS expanding to the filename of the guide. When adding the RCS
                   5452: ID the space should be omitted.
1.38      wiz      5453: 
1.184     rillig   5454: 19.2. Semi-automatic PLIST generation
1.1       dsieger  5455: 
1.184     rillig   5456: You can use the make print-PLIST command to output a PLIST that matches any new
                   5457: files since the package was extracted. See Section 13.17, "Other helpful
                   5458: targets" for more information on this target.
1.11      rillig   5459: 
1.184     rillig   5460: 19.3. Tweaking output of make print-PLIST
1.1       dsieger  5461: 
1.184     rillig   5462: The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
                   5463: used to filter the output of print-PLIST. You can append any chunk of AWK
                   5464: scripting you like to it, but be careful with quoting.
1.1       dsieger  5465: 
1.184     rillig   5466: For example, to get all files inside the libdata/foo directory removed from the
                   5467: resulting PLIST:
1.1       dsieger  5468: 
1.184     rillig   5469: PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
1.1       dsieger  5470: 
1.185   ! wiz      5471: The PRINT_PLIST_AWK transformations are evaluated after the file list and
        !          5472: directory list are sorted. EARLY_PRINT_PLIST_AWK is like PRINT_PLIST_AWK except
        !          5473: it operates before the file list and directory list are sorted.
        !          5474: 
1.184     rillig   5475: 19.4. Variable substitution in PLIST
1.1       dsieger  5476: 
1.184     rillig   5477: A number of variables are substituted automatically in PLISTs when a package is
                   5478: installed on a system. This includes the following variables:
1.1       dsieger  5479: 
1.184     rillig   5480: ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
1.1       dsieger  5481: 
1.184     rillig   5482:     Some packages like emacs and perl embed information about which
                   5483:     architecture they were built on into the pathnames where they install their
                   5484:     files. To handle this case, PLIST will be preprocessed before actually
                   5485:     used, and the symbol "${MACHINE_ARCH}" will be replaced by what uname -p
                   5486:     gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
                   5487:     PLIST somewhere - use this on packages that have GNU autoconf-created
                   5488:     configure scripts.
1.1       dsieger  5489: 
1.184     rillig   5490:     Legacy note
1.1       dsieger  5491: 
1.184     rillig   5492:     There used to be a symbol "$ARCH" that was replaced by the output of uname
                   5493:     -m, but that's no longer supported and has been removed.
1.1       dsieger  5494: 
1.184     rillig   5495: ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
1.1       dsieger  5496: 
1.184     rillig   5497:     Some packages want to embed the OS name and version into some paths. To do
                   5498:     this, use these variables in the PLIST:
1.1       dsieger  5499: 
1.184     rillig   5500:       + ${OPSYS} - output of "uname -s"
1.1       dsieger  5501: 
1.184     rillig   5502:       + ${LOWER_OPSYS} - lowercase common name (eg. "solaris")
1.1       dsieger  5503: 
1.184     rillig   5504:       + ${OS_VERSION} - "uname -r"
1.1       dsieger  5505: 
1.184     rillig   5506: For a list of values which are replaced by default, the output of make help
                   5507: topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
                   5508: PLIST_SUBST should help.
1.1       dsieger  5509: 
1.184     rillig   5510: If you want to change other variables not listed above, you can add variables
                   5511: and their expansions to this variable in the following way, similar to
                   5512: MESSAGE_SUBST (see Section 12.5, "Optional files"):
1.1       dsieger  5513: 
1.184     rillig   5514: PLIST_SUBST+=   SOMEVAR="somevalue"
1.1       dsieger  5515: 
1.184     rillig   5516: This replaces all occurrences of "${SOMEVAR}" in the PLIST with "somevalue".
1.1       dsieger  5517: 
1.184     rillig   5518: The PLIST_VARS variable can be used to simplify the common case of
                   5519: conditionally including some PLIST entries. It can be done by adding
                   5520: PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
                   5521: entry should be included. This will substitute "${PLIST.foo}" in the PLIST with
                   5522: either """" or ""@comment "". For example, in Makefile:
1.1       dsieger  5523: 
1.184     rillig   5524: PLIST_VARS+=    foo
                   5525: .if condition
                   5526: PLIST.foo=      yes
                   5527: .else
1.1       dsieger  5528: 
1.184     rillig   5529: And then in PLIST:
1.1       dsieger  5530: 
1.184     rillig   5531: @comment $NetBSD $
                   5532: bin/bar
                   5533: man/man1/bar.1
                   5534: ${PLIST.foo}bin/foo
                   5535: ${PLIST.foo}man/man1/foo.1
                   5536: ${PLIST.foo}share/bar/foo.data
1.1       dsieger  5537: 
1.184     rillig   5538: An artificial space has been added between NetBSD and $, this is a workaround
                   5539: here to prevent CVS expanding to the filename of the guide. When adding the RCS
                   5540: ID the space should be ommited.
1.1       dsieger  5541: 
1.184     rillig   5542: 19.5. Man page compression
1.1       dsieger  5543: 
1.184     rillig   5544: Man pages should be installed in compressed form if MANZ is set (in
                   5545: bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
                   5546: suffix ".gz" is appended/removed automatically for man pages according to MANZ
                   5547: and MANCOMPRESSED being set or not, see above for details. This modification of
                   5548: the PLIST file is done on a copy of it, not PLIST itself.
1.100     leot     5549: 
1.184     rillig   5550: 19.6. Changing PLIST source with PLIST_SRC
1.100     leot     5551: 
1.184     rillig   5552: To use one or more files as source for the PLIST used in generating the binary
                   5553: package, set the variable PLIST_SRC to the names of that file(s). The files are
                   5554: later concatenated using cat(1), and the order of things is important. The
                   5555: default for PLIST_SRC is ${PKGDIR}/PLIST.
1.1       dsieger  5556: 
1.184     rillig   5557: 19.7. Platform-specific and differing PLISTs
1.1       dsieger  5558: 
1.184     rillig   5559: Some packages decide to install a different set of files based on the operating
                   5560: system being used. These differences can be automatically handled by using the
                   5561: following files:
1.1       dsieger  5562: 
1.184     rillig   5563:   * PLIST.common
1.1       dsieger  5564: 
1.184     rillig   5565:   * PLIST.${OPSYS}
1.1       dsieger  5566: 
1.184     rillig   5567:   * PLIST.${MACHINE_ARCH}
1.1       dsieger  5568: 
1.184     rillig   5569:   * PLIST.${OPSYS}-${MACHINE_ARCH}
1.1       dsieger  5570: 
1.184     rillig   5571:   * PLIST.common_end
1.1       dsieger  5572: 
1.184     rillig   5573: 19.8. Build-specific PLISTs
1.1       dsieger  5574: 
1.184     rillig   5575: Some packages decide to generate hard-to-guess file names during installation
                   5576: that are hard to wire down.
1.1       dsieger  5577: 
1.184     rillig   5578: In such cases, you can set the GENERATE_PLIST variable to shell code terminated
                   5579: (with a semicolon) that will output PLIST entries which will be appended to the
                   5580: PLIST
1.1       dsieger  5581: 
1.184     rillig   5582: You can find one example in editors/xemacs:
1.1       dsieger  5583: 
1.184     rillig   5584: GENERATE_PLIST+=        ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
1.1       dsieger  5585: 
1.184     rillig   5586: which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
1.1       dsieger  5587: 
1.184     rillig   5588: 19.9. Sharing directories between packages
1.1       dsieger  5589: 
1.184     rillig   5590: A "shared directory" is a directory where multiple (and unrelated) packages
                   5591: install files. These directories were problematic because you had to add
                   5592: special tricks in the PLIST to conditionally remove them, or have some
                   5593: centralized package handle them.
1.106     tnn      5594: 
1.184     rillig   5595: In pkgsrc, it is now easy: Each package should create directories and install
                   5596: files as needed; pkg_delete will remove any directories left empty after
                   5597: uninstalling a package.
1.106     tnn      5598: 
1.184     rillig   5599: If a package needs an empty directory to work, create the directory during
                   5600: installation as usual, and also add an entry to the PLIST:
1.1       dsieger  5601: 
1.184     rillig   5602: @pkgdir path/to/empty/directory
1.1       dsieger  5603: 
1.184     rillig   5604: or take a look at MAKE_DIRS and OWN_DIRS.
1.1       dsieger  5605: 
1.184     rillig   5606: Chapter 20. The pkginstall framework
1.1       dsieger  5607: 
1.184     rillig   5608: Table of Contents
1.1       dsieger  5609: 
1.184     rillig   5610: 20.1. Files and directories outside the installation prefix
1.1       dsieger  5611: 
1.184     rillig   5612:     20.1.1. Directory manipulation
                   5613:     20.1.2. File manipulation
1.1       dsieger  5614: 
1.184     rillig   5615: 20.2. Configuration files
1.1       dsieger  5616: 
1.184     rillig   5617:     20.2.1. How PKG_SYSCONFDIR is set
                   5618:     20.2.2. Telling the software where configuration files are
                   5619:     20.2.3. Patching installations
                   5620:     20.2.4. Disabling handling of configuration files
1.1       dsieger  5621: 
1.184     rillig   5622: 20.3. System startup scripts
1.1       dsieger  5623: 
1.184     rillig   5624:     20.3.1. Disabling handling of system startup scripts
1.1       dsieger  5625: 
1.184     rillig   5626: 20.4. System users and groups
                   5627: 20.5. System shells
1.1       dsieger  5628: 
1.184     rillig   5629:     20.5.1. Disabling shell registration
1.1       dsieger  5630: 
1.184     rillig   5631: 20.6. Fonts
1.1       dsieger  5632: 
1.184     rillig   5633:     20.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  5634: 
1.184     rillig   5635: This chapter describes the framework known as pkginstall, whose key features
                   5636: are:
1.1       dsieger  5637: 
1.184     rillig   5638:   * Generic installation and manipulation of directories and files outside the
                   5639:     pkgsrc-handled tree, LOCALBASE.
1.1       dsieger  5640: 
1.184     rillig   5641:   * Automatic handling of configuration files during installation, provided
                   5642:     that packages are correctly designed.
1.1       dsieger  5643: 
1.184     rillig   5644:   * Generation and installation of system startup scripts.
1.1       dsieger  5645: 
1.184     rillig   5646:   * Registration of system users and groups.
1.1       dsieger  5647: 
1.184     rillig   5648:   * Registration of system shells.
1.1       dsieger  5649: 
1.184     rillig   5650:   * Automatic updating of fonts databases.
1.1       dsieger  5651: 
1.184     rillig   5652: The following sections inspect each of the above points in detail.
1.1       dsieger  5653: 
1.184     rillig   5654: You may be thinking that many of the things described here could be easily done
                   5655: with simple code in the package's post-installation target (post-install). This
                   5656: is incorrect, as the code in them is only executed when building from source.
                   5657: Machines using binary packages could not benefit from it at all (as the code
                   5658: itself could be unavailable). Therefore, the only way to achieve any of the
                   5659: items described above is by means of the installation scripts, which are
                   5660: automatically generated by pkginstall.
1.1       dsieger  5661: 
1.184     rillig   5662: 20.1. Files and directories outside the installation prefix
1.95      wiz      5663: 
1.184     rillig   5664: As you already know, the PLIST file holds a list of files and directories that
                   5665: belong to a package. The names used in it are relative to the installation
                   5666: prefix (${PREFIX}), which means that it cannot register files outside this
                   5667: directory (absolute path names are not allowed). Despite this restriction, some
                   5668: packages need to install files outside this location; e.g., under ${VARBASE} or
                   5669: ${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
                   5670: installation time by using installation scripts.
1.95      wiz      5671: 
1.184     rillig   5672: The generic installation scripts are shell scripts that can contain arbitrary
                   5673: code. The list of scripts to execute is taken from the INSTALL_FILE variable,
                   5674: which defaults to INSTALL. A similar variable exists for package removal
                   5675: (DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
                   5676: commands, so they have the potential to create and manage files anywhere in the
                   5677: file system.
1.95      wiz      5678: 
1.184     rillig   5679: Using these general installation files is not recommended, but may be needed in
                   5680: some special cases. One reason for avoiding them is that the user has to trust
                   5681: the packager that there is no unwanted or simply erroneous code included in the
                   5682: installation script. Also, previously there were many similar scripts for the
                   5683: same functionality, and fixing a common error involved finding and changing all
                   5684: of them.
1.95      wiz      5685: 
1.184     rillig   5686: The pkginstall framework offers another, standardized way. It provides generic
                   5687: scripts to abstract the manipulation of such files and directories based on
                   5688: variables set in the package's Makefile. The rest of this section describes
                   5689: these variables.
1.1       dsieger  5690: 
1.184     rillig   5691: 20.1.1. Directory manipulation
1.1       dsieger  5692: 
1.184     rillig   5693: The following variables can be set to request the creation of directories
                   5694: anywhere in the file system:
1.1       dsieger  5695: 
1.184     rillig   5696:   * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
                   5697:     and should attempt to be destroyed by the installation scripts. The
                   5698:     difference between the two is that the latter prompts the administrator to
                   5699:     remove any directories that may be left after deinstallation (because they
                   5700:     were not empty), while the former does not. Example:
1.1       dsieger  5701: 
1.184     rillig   5702:     MAKE_DIRS+=             ${VARBASE}/foo/private
1.1       dsieger  5703: 
1.184     rillig   5704:   * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
                   5705:     which directories should be created and should attempt to be destroyed by
                   5706:     the installation scripts. Each tuple holds the following values, separated
                   5707:     by spaces: the directory name, its owner, its group and its numerical mode.
                   5708:     For example:
1.1       dsieger  5709: 
1.184     rillig   5710:     MAKE_DIRS_PERMS+=       ${VARBASE}/foo/private \
                   5711:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  5712: 
1.184     rillig   5713:     The difference between the two is exactly the same as their non-PERMS
                   5714:     counterparts.
1.1       dsieger  5715: 
1.184     rillig   5716: 20.1.2. File manipulation
1.1       dsieger  5717: 
1.184     rillig   5718: Creating non-empty files outside the installation prefix is tricky because the
                   5719: PLIST forces all files to be inside it. To overcome this problem, the only
                   5720: solution is to extract the file in the known place (i.e., inside the
                   5721: installation prefix) and copy it to the appropriate location during
                   5722: installation (done by the installation scripts generated by pkginstall). We
                   5723: will call the former the master file in the following paragraphs, which
                   5724: describe the variables that can be used to automatically and consistently
                   5725: handle files outside the installation prefix:
1.1       dsieger  5726: 
1.184     rillig   5727:   * CONF_FILES and REQD_FILES are pairs of master and target files. During
                   5728:     installation time, the master file is copied to the target one if and only
                   5729:     if the latter does not exist. Upon deinstallation, the target file is
                   5730:     removed provided that it was not modified by the installation.
1.1       dsieger  5731: 
1.184     rillig   5732:     The difference between the two is that the latter prompts the administrator
                   5733:     to remove any files that may be left after deinstallation (because they
                   5734:     were not empty), while the former does not.
1.1       dsieger  5735: 
1.184     rillig   5736:   * CONF_FILES_PERMS and REQD_FILES_PERMS contain tuples describing master
                   5737:     files as well as their target locations. For each of them, it also
                   5738:     specifies their owner, their group and their numeric permissions, in this
                   5739:     order. For example:
1.1       dsieger  5740: 
1.184     rillig   5741:     REQD_FILES_PERMS+=      ${PREFIX}/share/somefile ${VARBASE}/somefile \
                   5742:                             ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
1.1       dsieger  5743: 
1.184     rillig   5744:     The difference between the two is exactly the same as their non-PERMS
                   5745:     counterparts.
1.1       dsieger  5746: 
1.184     rillig   5747: 20.2. Configuration files
1.1       dsieger  5748: 
1.184     rillig   5749: Configuration files are special in the sense that they are installed in their
                   5750: own specific directory, PKG_SYSCONFDIR, and need special treatment during
                   5751: installation (most of which is automated by pkginstall). The main concept you
                   5752: must bear in mind is that files marked as configuration files are automatically
                   5753: copied to the right place (somewhere inside PKG_SYSCONFDIR) during installation
                   5754: if and only if they didn't exist before. Similarly, they will not be removed if
                   5755: they have local modifications. This ensures that administrators never lose any
                   5756: custom changes they may have made.
1.1       dsieger  5757: 
1.184     rillig   5758: 20.2.1. How PKG_SYSCONFDIR is set
1.1       dsieger  5759: 
1.184     rillig   5760: As said before, the PKG_SYSCONFDIR variable specifies where configuration files
                   5761: shall be installed. Its contents are set based upon the following variables:
1.1       dsieger  5762: 
1.184     rillig   5763:   * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
                   5764:     etc although it may be overridden by the user to point to his preferred
                   5765:     location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
1.1       dsieger  5766: 
1.184     rillig   5767:   * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
                   5768:     configuration files for the package being built shall be installed. The
                   5769:     definition of this variable only makes sense in the package's Makefile
                   5770:     (i.e., it is not user-customizable).
1.1       dsieger  5771: 
1.184     rillig   5772:     As an example, consider the Apache package, www/apache24, which places its
                   5773:     configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
                   5774:     should be set in the package Makefile.
1.1       dsieger  5775: 
1.184     rillig   5776:   * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
                   5777:     package's configuration directory (if different from PKG_SYSCONFBASE). It
                   5778:     defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
1.1       dsieger  5779: 
1.184     rillig   5780:   * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
                   5781:     configuration files for the package identified by PKG_SYSCONFVAR's shall be
                   5782:     placed.
1.1       dsieger  5783: 
1.184     rillig   5784: Based on the above variables, pkginstall determines the value of
                   5785: PKG_SYSCONFDIR, which is the only variable that can be used within a package to
                   5786: refer to its configuration directory. The algorithm used to set its value is
                   5787: basically the following:
1.1       dsieger  5788: 
1.184     rillig   5789:  1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
1.1       dsieger  5790: 
1.184     rillig   5791:  2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
                   5792:     package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
                   5793:     {PKG_SYSCONFSUBDIR}.
1.1       dsieger  5794: 
1.184     rillig   5795:  3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
1.1       dsieger  5796: 
1.184     rillig   5797: It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
                   5798: OWN_DIRS. See Section 20.1.1, "Directory manipulation" what this means. This
                   5799: does not apply to subdirectories of ${PKG_SYSCONFDIR}, they still have to be
                   5800: created with OWN_DIRS or MAKE_DIRS.
1.1       dsieger  5801: 
1.184     rillig   5802: 20.2.2. Telling the software where configuration files are
1.1       dsieger  5803: 
1.184     rillig   5804: Given that pkgsrc (and users!) expect configuration files to be in a known
                   5805: place, you need to teach each package where it shall install its files. In some
                   5806: cases you will have to patch the package Makefiles to achieve it. If you are
                   5807: lucky, though, it may be as easy as passing an extra flag to the configuration
                   5808: script; this is the case of GNU Autoconf- generated files:
1.1       dsieger  5809: 
1.184     rillig   5810: CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
1.1       dsieger  5811: 
1.184     rillig   5812: Note that this specifies where the package has to look for its configuration
                   5813: files, not where they will be originally installed (although the difference is
                   5814: never explicit, unfortunately).
1.1       dsieger  5815: 
1.184     rillig   5816: 20.2.3. Patching installations
1.1       dsieger  5817: 
1.184     rillig   5818: As said before, pkginstall automatically handles configuration files. This
                   5819: means that the packages themselves must not touch the contents of $
                   5820: {PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
                   5821: will, out of the box, mess with the contents of that directory. So what is the
                   5822: correct procedure to fix this issue?
1.1       dsieger  5823: 
1.184     rillig   5824: You must teach the package (usually by manually patching it) to install any
                   5825: configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
                   5826: This way, the PLIST registers them and the administrator always has the
                   5827: original copies available.
1.1       dsieger  5828: 
1.184     rillig   5829: Once the required configuration files are in place (i.e., under the examples
                   5830: hierarchy), the pkginstall framework can use them as master copies during the
                   5831: package installation to update what is in ${PKG_SYSCONFDIR}. To achieve this,
                   5832: the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
                   5833: Section 20.1.2, "File manipulation" for information about their syntax and
                   5834: their purpose. Here is an example, taken from the mail/mutt package:
1.1       dsieger  5835: 
1.184     rillig   5836: EGDIR=        ${PREFIX}/share/doc/mutt/samples
                   5837: CONF_FILES=   ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
1.1       dsieger  5838: 
1.184     rillig   5839: Note that the EGDIR variable is specific to that package and has no meaning
                   5840: outside it.
1.1       dsieger  5841: 
1.184     rillig   5842: 20.2.4. Disabling handling of configuration files
1.1       dsieger  5843: 
1.184     rillig   5844: The automatic copying of config files can be toggled by setting the environment
                   5845: variable PKG_CONFIG prior to package installation.
1.1       dsieger  5846: 
1.184     rillig   5847: 20.3. System startup scripts
1.1       dsieger  5848: 
1.184     rillig   5849: System startup scripts are special files because they must be installed in a
                   5850: place known by the underlying OS, usually outside the installation prefix.
                   5851: Therefore, the same rules described in Section 20.1, "Files and directories
                   5852: outside the installation prefix" apply, and the same solutions can be used.
                   5853: However, pkginstall provides a special mechanism to handle these files.
1.1       dsieger  5854: 
1.184     rillig   5855: In order to provide system startup scripts, the package has to:
1.1       dsieger  5856: 
1.184     rillig   5857:  1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
                   5858:     Considering the print/cups package as an example, it has a cupsd.sh in its
                   5859:     files directory.
1.95      wiz      5860: 
1.184     rillig   5861:  2. Tell pkginstall to handle it, appending the name of the script, without its
                   5862:     extension, to the RCD_SCRIPTS variable. Continuing the previous example:
1.95      wiz      5863: 
1.184     rillig   5864:     RCD_SCRIPTS+=   cupsd
1.95      wiz      5865: 
1.184     rillig   5866: Once this is done, pkginstall will do the following steps for each script in an
                   5867: automated fashion:
1.95      wiz      5868: 
1.184     rillig   5869:  1. Process the file found in the files directory applying all the
                   5870:     substitutions described in the FILES_SUBST variable.
1.1       dsieger  5871: 
1.184     rillig   5872:  2. Copy the script from the files directory to the examples hierarchy, $
                   5873:     {PREFIX}/share/examples/rc.d/. Note that this master file must be
                   5874:     explicitly registered in the PLIST.
1.1       dsieger  5875: 
1.184     rillig   5876:  3. Add code to the installation scripts to copy the startup script from the
                   5877:     examples hierarchy into the system-wide startup scripts directory.
1.1       dsieger  5878: 
1.184     rillig   5879: 20.3.1. Disabling handling of system startup scripts
1.1       dsieger  5880: 
1.184     rillig   5881: The automatic copying of config files can be toggled by setting the environment
                   5882: variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
                   5883: will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
                   5884: rc.d/, no matter what the value of this variable is.
1.1       dsieger  5885: 
1.184     rillig   5886: 20.4. System users and groups
1.1       dsieger  5887: 
1.184     rillig   5888: If a package needs to create special users and/or groups during installation,
                   5889: it can do so by using the pkginstall framework.
1.1       dsieger  5890: 
1.184     rillig   5891: Users can be created by adding entries to the PKG_USERS variable. Each entry
                   5892: has the following syntax:
1.1       dsieger  5893: 
1.184     rillig   5894: user:group
1.1       dsieger  5895: 
1.184     rillig   5896: Further specification of user details may be done by setting per-user
                   5897: variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
                   5898: user's description or comment. PKG_HOME.user is the user's home directory, and
                   5899: defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
                   5900: and defaults to /sbin/nologin if not specified.
1.1       dsieger  5901: 
1.184     rillig   5902: Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
                   5903: whose syntax is:
1.1       dsieger  5904: 
1.184     rillig   5905: group
1.1       dsieger  5906: 
1.184     rillig   5907: The numeric GID of the group may be set by defining PKG_GID.group.
1.1       dsieger  5908: 
1.184     rillig   5909: If a package needs to create the users and groups at an earlier stage, then it
                   5910: can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
                   5911: the phase before which the users and groups are created. In this case, the
                   5912: numeric UIDs and GIDs of the created users and groups are automatically
                   5913: hardcoded into the final installation scripts.
1.1       dsieger  5914: 
1.184     rillig   5915: 20.5. System shells
1.1       dsieger  5916: 
1.184     rillig   5917: Packages that install system shells should register them in the shell database,
                   5918: /etc/shells, to make things easier to the administrator. This must be done from
                   5919: the installation scripts to keep binary packages working on any system.
                   5920: pkginstall provides an easy way to accomplish this task.
1.1       dsieger  5921: 
1.184     rillig   5922: When a package provides a shell interpreter, it has to set the PKG_SHELL
                   5923: variable to its absolute file name. This will add some hooks to the
                   5924: installation scripts to handle it. Consider the following example, taken from
                   5925: shells/zsh:
1.1       dsieger  5926: 
1.184     rillig   5927: PKG_SHELL=      ${PREFIX}/bin/zsh
1.1       dsieger  5928: 
1.184     rillig   5929: 20.5.1. Disabling shell registration
1.1       dsieger  5930: 
1.184     rillig   5931: The automatic registration of shell interpreters can be disabled by the
                   5932: administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
1.1       dsieger  5933: 
1.184     rillig   5934: 20.6. Fonts
1.1       dsieger  5935: 
1.184     rillig   5936: Packages that install X11 fonts should update the database files that index the
                   5937: fonts within each fonts directory. This can easily be accomplished within the
                   5938: pkginstall framework.
1.1       dsieger  5939: 
1.184     rillig   5940: When a package installs X11 fonts, it must list the directories in which fonts
                   5941: are installed in the FONTS_DIRS.type variables, where type can be one of "ttf",
                   5942: "type1" or "x11". This will add hooks to the installation scripts to run the
                   5943: appropriate commands to update the fonts database files within each of those
                   5944: directories. For convenience, if the directory path is relative, it is taken to
                   5945: be relative to the package's installation prefix. Consider the following
                   5946: example, taken from fonts/dbz-ttf:
1.1       dsieger  5947: 
1.184     rillig   5948: FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
1.1       dsieger  5949: 
1.184     rillig   5950: 20.6.1. Disabling automatic update of the fonts databases
1.1       dsieger  5951: 
1.184     rillig   5952: The automatic update of fonts databases can be disabled by the administrator by
                   5953: setting the PKG_UPDATE_FONTS_DB environment variable to NO.
1.1       dsieger  5954: 
1.154     rillig   5955: Chapter 21. Making your package work
1.1       dsieger  5956: 
                   5957: Table of Contents
                   5958: 
1.154     rillig   5959: 21.1. General operation
1.1       dsieger  5960: 
1.154     rillig   5961:     21.1.1. How to pull in user-settable variables from mk.conf
                   5962:     21.1.2. User interaction
                   5963:     21.1.3. Handling licenses
                   5964:     21.1.4. Restricted packages
                   5965:     21.1.5. Handling dependencies
                   5966:     21.1.6. Handling conflicts with other packages
                   5967:     21.1.7. Packages that cannot or should not be built
                   5968:     21.1.8. Packages which should not be deleted, once installed
                   5969:     21.1.9. Handling packages with security problems
                   5970:     21.1.10. How to handle incrementing versions when fixing an existing
1.1       dsieger  5971:         package
1.154     rillig   5972:     21.1.11. Substituting variable text in the package files (the SUBST
1.1       dsieger  5973:         framework)
                   5974: 
1.154     rillig   5975: 21.2. The fetch phase
1.1       dsieger  5976: 
1.154     rillig   5977:     21.2.1. Packages whose distfiles aren't available for plain downloading
                   5978:     21.2.2. How to handle modified distfiles with the 'old' name
                   5979:     21.2.3. Packages hosted on github.com
                   5980: 
                   5981: 21.3. The configure phase
                   5982: 
                   5983:     21.3.1. Shared libraries - libtool
                   5984:     21.3.2. Using libtool on GNU packages that already support libtool
                   5985:     21.3.3. GNU Autoconf/Automake
                   5986: 
                   5987: 21.4. Programming languages
                   5988: 
                   5989:     21.4.1. C, C++, and Fortran
                   5990:     21.4.2. Java
                   5991:     21.4.3. Packages containing perl scripts
                   5992:     21.4.4. Packages containing shell scripts
                   5993:     21.4.5. Other programming languages
                   5994: 
                   5995: 21.5. The build phase
                   5996: 
                   5997:     21.5.1. Compiling C and C++ code conditionally
                   5998:     21.5.2. How to handle compiler bugs
1.172     rillig   5999:     21.5.3. No such file or directory
                   6000:     21.5.4. Undefined reference to "..."
                   6001:     21.5.5. Running out of memory
1.154     rillig   6002: 
                   6003: 21.6. The install phase
                   6004: 
                   6005:     21.6.1. Creating needed directories
                   6006:     21.6.2. Where to install documentation
                   6007:     21.6.3. Installing highscore files
                   6008:     21.6.4. Adding DESTDIR support to packages
                   6009:     21.6.5. Packages with hardcoded paths to other interpreters
                   6010:     21.6.6. Packages installing perl modules
                   6011:     21.6.7. Packages installing info files
                   6012:     21.6.8. Packages installing man pages
                   6013:     21.6.9. Packages installing GConf data files
                   6014:     21.6.10. Packages installing scrollkeeper/rarian data files
                   6015:     21.6.11. Packages installing X11 fonts
                   6016:     21.6.12. Packages installing GTK2 modules
                   6017:     21.6.13. Packages installing SGML or XML data
                   6018:     21.6.14. Packages installing extensions to the MIME database
                   6019:     21.6.15. Packages using intltool
                   6020:     21.6.16. Packages installing startup scripts
                   6021:     21.6.17. Packages installing TeX modules
                   6022:     21.6.18. Packages supporting running binaries in emulation
                   6023:     21.6.19. Packages installing hicolor theme icons
                   6024:     21.6.20. Packages installing desktop files
1.1       dsieger  6025: 
1.154     rillig   6026: 21.7. Marking packages as having problems
1.1       dsieger  6027: 
1.154     rillig   6028: 21.1. General operation
1.1       dsieger  6029: 
                   6030: One appealing feature of pkgsrc is that it runs on many different platforms. As
                   6031: a result, it is important to ensure, where possible, that packages in pkgsrc
                   6032: are portable. This chapter mentions some particular details you should pay
                   6033: attention to while working on pkgsrc.
                   6034: 
1.154     rillig   6035: 21.1.1. How to pull in user-settable variables from mk.conf
1.1       dsieger  6036: 
                   6037: The pkgsrc user can configure pkgsrc by overriding several variables in the
1.4       rillig   6038: file pointed to by MAKECONF, which is mk.conf by default. When you want to use
                   6039: those variables in the preprocessor directives of make(1) (for example .if or
                   6040: .for), you need to include the file ../../mk/bsd.prefs.mk before, which in turn
                   6041: loads the user preferences.
1.1       dsieger  6042: 
                   6043: But note that some variables may not be completely defined after ../../mk/
                   6044: bsd.prefs.mk has been included, as they may contain references to variables
1.108     rillig   6045: that are not yet defined. In shell commands (the lines in Makefile that are
                   6046: indented with a tab) this is no problem, since variables are only expanded when
                   6047: they are used. But in the preprocessor directives mentioned above and in
                   6048: dependency lines (of the form target: dependencies) the variables are expanded
                   6049: at load time.
1.1       dsieger  6050: 
                   6051: Note
                   6052: 
1.108     rillig   6053: To check whether a variable can be used at load time, run pkglint -Wall on your
                   6054: package.
1.1       dsieger  6055: 
1.154     rillig   6056: 21.1.2. User interaction
1.1       dsieger  6057: 
                   6058: Occasionally, packages require interaction from the user, and this can be in a
                   6059: number of ways:
                   6060: 
                   6061:   * When fetching the distfiles, some packages require user interaction such as
                   6062:     entering username/password or accepting a license on a web page.
                   6063: 
                   6064:   * When extracting the distfiles, some packages may ask for passwords.
                   6065: 
                   6066:   * help to configure the package before it is built
                   6067: 
                   6068:   * help during the build process
                   6069: 
                   6070:   * help during the installation of a package
                   6071: 
1.108     rillig   6072: A package can set the INTERACTIVE_STAGE variable to define which stages need
                   6073: interaction. This should be done in the package's Makefile, e.g.:
1.1       dsieger  6074: 
                   6075: INTERACTIVE_STAGE=      configure install
                   6076: 
                   6077: The user can then decide to skip this package by setting the BATCH variable.
1.108     rillig   6078: Packages that require interaction are also excluded from bulk builds.
1.1       dsieger  6079: 
1.154     rillig   6080: 21.1.3. Handling licenses
1.1       dsieger  6081: 
                   6082: Authors of software can choose the licence under which software can be copied.
1.111     sevan    6083: The Free Software Foundation has declared some licenses "Free", and the Open
                   6084: Source Initiative has a definition of "Open Source".
                   6085: 
                   6086: By default, pkgsrc allows packages with Free or Open Source licenses to be
                   6087: built. To allow packages with other licenses to be built as well, the pkgsrc
                   6088: user needs to add these licenses to the ACCEPTABLE_LICENSES variable in mk.conf
                   6089: . Note that this variable only affects which packages may be built, while the
                   6090: license terms often also restrict the actual use of the package and its
                   6091: redistribution.
1.1       dsieger  6092: 
                   6093: One might want to only install packages with a BSD license, or the GPL, and not
1.20      jnemeth  6094: the other. The free licenses are added to the default ACCEPTABLE_LICENSES
1.111     sevan    6095: variable. The pkgsrc user can override the default by setting the
                   6096: ACCEPTABLE_LICENSES variable with "=" instead of "+=". The licenses accepted by
                   6097: default are defined in the DEFAULT_ACCEPTABLE_LICENSES variable in the file
                   6098: pkgsrc/mk/license.mk.
1.1       dsieger  6099: 
                   6100: The license tag mechanism is intended to address copyright-related issues
                   6101: surrounding building, installing and using a package, and not to address
1.20      jnemeth  6102: redistribution issues (see RESTRICTED and NO_SRC_ON_FTP, etc.). Packages with
                   6103: redistribution restrictions should set these tags.
1.1       dsieger  6104: 
                   6105: Denoting that a package may be copied according to a particular license is done
                   6106: by placing the license in pkgsrc/licenses and setting the LICENSE variable to a
                   6107: string identifying the license, e.g. in graphics/xv:
                   6108: 
                   6109: LICENSE=        xv-license
                   6110: 
                   6111: When trying to build, the user will get a notice that the package is covered by
                   6112: a license which has not been placed in the ACCEPTABLE_LICENSES variable:
                   6113: 
                   6114: % make
                   6115: ===> xv-3.10anb9 has an unacceptable license: xv-license.
                   6116: ===>     To view the license, enter "/usr/bin/make show-license".
                   6117: ===>     To indicate acceptance, add this line to your /etc/mk.conf:
                   6118: ===>     ACCEPTABLE_LICENSES+=xv-license
                   6119: *** Error code 1
                   6120: 
                   6121: The license can be viewed with make show-license, and if the user so chooses,
1.4       rillig   6122: the line printed above can be added to mk.conf to convey to pkgsrc that it
1.1       dsieger  6123: should not in the future fail because of that license:
                   6124: 
                   6125: ACCEPTABLE_LICENSES+=xv-license
                   6126: 
1.111     sevan    6127: The use of LICENSE=shareware, LICENSE=no-commercial-use, and similar language
                   6128: is deprecated because it does not crisply refer to a particular license text.
                   6129: Another problem with such usage is that it does not enable a user to tell
                   6130: pkgsrc to proceed for a single package without also telling pkgsrc to proceed
                   6131: for all packages with that tag.
                   6132: 
1.154     rillig   6133: 21.1.3.1. Adding a package with a new license
1.1       dsieger  6134: 
1.49      rodent   6135: When adding a package with a new license, the following steps are required:
                   6136: 
1.111     sevan    6137:  1. Check whether the license qualifies as Free or Open Source by referencing
                   6138:     Various Licenses and Comments about Them and Licenses by Name | Open Source
                   6139:     Initiative. If this is the case, the filename in pkgsrc/licenses/ does not
                   6140:     need the -license suffix, and the license name should be added to:
1.49      rodent   6141: 
                   6142:       + DEFAULT_ACCEPTABLE_LICENSES in pkgsrc/mk/license.mk
                   6143: 
                   6144:       + default_acceptable_licenses in pkgsrc/pkgtools/pkg_install/files/lib/
                   6145:         license.c
                   6146: 
                   6147:  2. The license text should be added to pkgsrc/licenses for displaying. A list
                   6148:     of known licenses can be seen in this directory.
1.1       dsieger  6149: 
1.154     rillig   6150: 21.1.3.2. Change to the license
1.1       dsieger  6151: 
1.111     sevan    6152: When the license changes (in a way other than formatting), make sure that the
                   6153: new license has a different name (e.g., append the version number if it exists,
                   6154: or the date). Just because a user told pkgsrc to build programs under a
                   6155: previous version of a license does not mean that pkgsrc should build programs
                   6156: under the new licenses. The higher-level point is that pkgsrc does not evaluate
                   6157: licenses for reasonableness; the only test is a mechanistic test of whether a
                   6158: particular text has been approved by either of two bodies (FSF or OSI).
1.1       dsieger  6159: 
1.154     rillig   6160: 21.1.4. Restricted packages
1.1       dsieger  6161: 
1.111     sevan    6162: Some licenses restrict how software may be re-distributed. By declaring the
                   6163: restrictions, package tools can automatically refrain from e.g. placing binary
                   6164: packages on FTP sites.
                   6165: 
                   6166: There are four possible restrictions, which are the cross product of sources
                   6167: (distfiles) and binaries not being placed on FTP sites and CD-ROMs. Because
                   6168: this is rarely the exact language in any license, and because non-Free licenses
                   6169: tend to be different from each other, pkgsrc adopts a definition of FTP and
                   6170: CD-ROM. "FTP" means making the source or binary file available over the
                   6171: Internet at no charge. "CD-ROM" means making the source or binary available on
                   6172: some kind of media, together with other source and binary packages, which is
                   6173: sold for a distribution charge.
1.1       dsieger  6174: 
                   6175: In order to encode these restrictions, the package system defines five make
                   6176: variables that can be set to note these restrictions:
                   6177: 
                   6178:   * RESTRICTED
                   6179: 
                   6180:     This variable should be set whenever a restriction exists (regardless of
                   6181:     its kind). Set this variable to a string containing the reason for the
                   6182:     restriction. It should be understood that those wanting to understand the
                   6183:     restriction will have to read the license, and perhaps seek advice of
                   6184:     counsel.
                   6185: 
                   6186:   * NO_BIN_ON_CDROM
                   6187: 
                   6188:     Binaries may not be placed on CD-ROM containing other binary packages, for
                   6189:     which a distribution charge may be made. In this case, set this variable to
                   6190:     ${RESTRICTED}.
                   6191: 
                   6192:   * NO_BIN_ON_FTP
                   6193: 
                   6194:     Binaries may not made available on the Internet without charge. In this
                   6195:     case, set this variable to ${RESTRICTED}. If this variable is set, binary
                   6196:     packages will not be included on ftp.NetBSD.org.
                   6197: 
                   6198:   * NO_SRC_ON_CDROM
                   6199: 
                   6200:     Distfiles may not be placed on CD-ROM, together with other distfiles, for
                   6201:     which a fee may be charged. In this case, set this variable to $
                   6202:     {RESTRICTED}.
                   6203: 
                   6204:   * NO_SRC_ON_FTP
                   6205: 
                   6206:     Distfiles may not made available via FTP at no charge. In this case, set
                   6207:     this variable to ${RESTRICTED}. If this variable is set, the distfile(s)
                   6208:     will not be mirrored on ftp.NetBSD.org.
                   6209: 
1.111     sevan    6210: Please note that packages will be removed from pkgsrc when the distfiles are
1.33      wiz      6211: not distributable and cannot be obtained for a period of one full quarter
1.111     sevan    6212: branch. Packages with manual/interactive fetch must have a maintainer and it is
                   6213: his/her responsibility to ensure this.
1.33      wiz      6214: 
1.154     rillig   6215: 21.1.5. Handling dependencies
1.1       dsieger  6216: 
1.175     gutterid 6217: Your package may depend on some other package being present, and there are
                   6218: various ways of expressing this dependency. pkgsrc supports the DEPENDS,
                   6219: BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS definitions, the USE_TOOLS
                   6220: definition, as well as dependencies via buildlink3.mk, which is the preferred
                   6221: way to handle dependencies, and which uses the variables named above. See
1.184     rillig   6222: Chapter 18, Buildlink methodology for more information.
1.175     gutterid 6223: 
                   6224: The basic difference is that the DEPENDS definition registers that
                   6225: pre-requisite in the binary package so it will be pulled in when the binary
                   6226: package is later installed, whilst the BUILD_DEPENDS, TOOL_DEPENDS, and
                   6227: TEST_DEPENDS definitions do not, marking a dependency that is only needed for
1.184     rillig   6228: building or testing the resulting package. See also Chapter 14, Creating a new
1.175     gutterid 6229: pkgsrc package from scratch for more information.
                   6230: 
                   6231: This means that if you only need a package present whilst you are building or
                   6232: testing, it should be noted as a TOOL_DEPENDS, BUILD_DEPENDS, or TEST_DEPENDS.
                   6233: When cross-compiling, TOOL_DEPENDS are native packages, i.e. packages for the
                   6234: architecture where the package is built; BUILD_DEPENDS are target packages,
                   6235: i.e., packages for the architecture for which the package is built.
1.1       dsieger  6236: 
1.175     gutterid 6237: The format for a DEPENDS, BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS
                   6238: definition is:
1.1       dsieger  6239: 
                   6240: <pre-req-package-name>:../../<category>/<pre-req-package>
                   6241: 
                   6242: Please note that the "pre-req-package-name" may include any of the wildcard
                   6243: version numbers recognized by pkg_info(1).
                   6244: 
1.55      wiz      6245:  1. If your package needs another package's binaries or libraries to build and
1.1       dsieger  6246:     run, and if that package has a buildlink3.mk file available, use it:
                   6247: 
                   6248:     .include "../../graphics/jpeg/buildlink3.mk"
                   6249: 
1.55      wiz      6250:  2. If your package needs another package's binaries or libraries only for
                   6251:     building, and if that package has a buildlink3.mk file available, use it:
                   6252: 
                   6253:     .include "../../graphics/jpeg/buildlink3.mk"
                   6254: 
                   6255:     but set BUILDLINK_DEPMETHOD.jpeg?=build to make it a build dependency only.
                   6256:     This case is rather rare.
                   6257: 
                   6258:  3. If your package needs binaries from another package to build, use the
1.156     leot     6259:     TOOL_DEPENDS definition:
                   6260: 
                   6261:     TOOL_DEPENDS+= itstool-[0-9]*:../../textproc/itstool
1.1       dsieger  6262: 
1.156     leot     6263:  4. If your package needs static libraries to link against, header files to
                   6264:     include, etc. from another package to build, use the BUILD_DEPENDS
                   6265:     definition.
1.1       dsieger  6266: 
1.156     leot     6267:  5. If your package needs a library with which to link and there is no
1.26      spz      6268:     buildlink3.mk file available, create one. Using DEPENDS won't be sufficient
                   6269:     because the include files and libraries will be hidden from the compiler.
1.1       dsieger  6270: 
1.156     leot     6271:  6. If your package needs some executable to be able to run correctly and if
1.26      spz      6272:     there's no buildlink3.mk file, this is specified using the DEPENDS
                   6273:     variable. The print/lyx package needs to be able to execute the latex
1.129     wiz      6274:     binary from the tex-latex-bin package when it runs, and that is specified:
1.1       dsieger  6275: 
1.129     wiz      6276:     DEPENDS+=        tex-latex-bin-[0-9]*:../../print/tex-latex-bin
1.1       dsieger  6277: 
1.175     gutterid 6278:  7. If your package includes a test suite that has extra dependencies only
                   6279:     required for this purpose (frequently this can be run as a "make test"
                   6280:     target), use the TEST_DEPENDS variable.
                   6281: 
                   6282:  8. You can use wildcards in package dependencies. Note that such wildcard
1.26      spz      6283:     dependencies are retained when creating binary packages. The dependency is
                   6284:     checked when installing the binary package and any package which matches
                   6285:     the pattern will be used. Wildcard dependencies should be used with care.
1.1       dsieger  6286: 
                   6287:     The "-[0-9]*" should be used instead of "-*" to avoid potentially ambiguous
                   6288:     matches such as "tk-postgresql" matching a "tk-*" DEPENDS.
                   6289: 
                   6290:     Wildcards can also be used to specify that a package will only build
                   6291:     against a certain minimum version of a pre-requisite:
                   6292: 
1.26      spz      6293:     DEPENDS+=       ImageMagick>=6.0:../../graphics/ImageMagick
1.1       dsieger  6294: 
1.26      spz      6295:     This means that the package will build using version 6.0 of ImageMagick or
                   6296:     newer. Such a dependency may be warranted if, for example, the command line
                   6297:     options of an executable have changed.
                   6298: 
1.183     wiz      6299:     If you need to depend on minimum versions of libraries, set
                   6300:     BUILDLINK_API_DEPENDS.pkg to the appropriate pattern before including its
                   6301:     buildlink3.mk file, e.g.
                   6302: 
                   6303:     BUILDLINK_API_DEPENDS.jpeg+=    jpeg>=9.0
                   6304:     .include "../../graphics/jpeg/buildlink3.mk"
1.1       dsieger  6305: 
                   6306:     For security fixes, please update the package vulnerabilities file. See
1.154     rillig   6307:     Section 21.1.9, "Handling packages with security problems" for more
1.1       dsieger  6308:     information.
                   6309: 
                   6310: If your package needs files from another package to build, add the relevant
                   6311: distribution files to DISTFILES, so they will be extracted automatically. See
                   6312: the print/ghostscript package for an example. (It relies on the jpeg sources
                   6313: being present in source form during the build.)
                   6314: 
1.154     rillig   6315: 21.1.6. Handling conflicts with other packages
1.1       dsieger  6316: 
                   6317: Your package may conflict with other packages a user might already have
                   6318: installed on his system, e.g. if your package installs the same set of files as
1.80      wiz      6319: another package in the pkgsrc tree or has the same PKGNAME.
1.1       dsieger  6320: 
1.142     leot     6321: For example, x11/libXaw3d and x11/Xaw-Xpm install the same shared library, thus
                   6322: you set in pkgsrc/x11/libXaw3d/Makefile:
1.1       dsieger  6323: 
1.142     leot     6324: CONFLICTS=      Xaw-Xpm-[0-9]*
1.1       dsieger  6325: 
                   6326: 
1.142     leot     6327: and in pkgsrc/x11/Xaw-Xpm/Makefile:
1.1       dsieger  6328: 
1.142     leot     6329: CONFLICTS=      libXaw3d-[0-9]*
1.1       dsieger  6330: 
1.142     leot     6331: 
                   6332: pkg_add(1) is able to detect attempts to install packages that conflict with
                   6333: existing packages and abort. However, in many situations this is too late in
                   6334: the process. Binary package managers will not know about the conflict until
                   6335: they attempt to install the package after already downloading it and all its
                   6336: dependencies. Users may also waste time building a package and its dependencies
                   6337: only to find out at the end that it conflicts with another package they have
                   6338: installed.
                   6339: 
                   6340: To avoid these issues CONFLICTS entries should be added in all cases where it
                   6341: is known that packages conflict with each other. These CONFLICTS entries are
                   6342: exported in pkg_summary(5) files and consumed by binary package managers to
                   6343: inform users that packages cannot be installed onto the target system.
1.1       dsieger  6344: 
1.154     rillig   6345: 21.1.7. Packages that cannot or should not be built
1.1       dsieger  6346: 
                   6347: There are several reasons why a package might be instructed to not build under
                   6348: certain circumstances. If the package builds and runs on most platforms, the
1.83      dholland 6349: exceptions should be noted with BROKEN_ON_PLATFORM. If the package builds and
                   6350: runs on a small handful of platforms, set BROKEN_EXCEPT_ON_PLATFORM instead.
                   6351: Both BROKEN_ON_PLATFORM and BROKEN_EXCEPT_ON_PLATFORM are OS triples
                   6352: (OS-version-platform) that can use glob-style wildcards.
                   6353: 
1.114     maya     6354: If a package is not appropriate for some platforms (as opposed to merely
1.83      dholland 6355: broken), a different set of variables should be used as this affects failure
                   6356: reporting and statistics. If the package is appropriate for most platforms, the
                   6357: exceptions should be noted with NOT_FOR_PLATFORM. If the package is appropriate
                   6358: for only a small handful of platforms (often exactly one), set
                   6359: ONLY_FOR_PLATFORM instead. Both ONLY_FOR_PLATFORM and NOT_FOR_PLATFORM are OS
                   6360: triples (OS-version-platform) that can use glob-style wildcards.
1.1       dsieger  6361: 
                   6362: Some packages are tightly bound to a specific version of an operating system,
                   6363: e.g. LKMs or sysutils/lsof. Such binary packages are not backwards compatible
                   6364: with other versions of the OS, and should be uploaded to a version specific
                   6365: directory on the FTP server. Mark these packages by setting OSVERSION_SPECIFIC
                   6366: to "yes". This variable is not currently used by any of the package system
                   6367: internals, but may be used in the future.
                   6368: 
                   6369: If the package should be skipped (for example, because it provides
                   6370: functionality already provided by the system), set PKG_SKIP_REASON to a
                   6371: descriptive message. If the package should fail because some preconditions are
                   6372: not met, set PKG_FAIL_REASON to a descriptive message.
                   6373: 
1.154     rillig   6374: 21.1.8. Packages which should not be deleted, once installed
1.1       dsieger  6375: 
                   6376: To ensure that a package may not be deleted, once it has been installed, the
                   6377: PKG_PRESERVE definition should be set in the package Makefile. This will be
1.25      wiz      6378: carried into any binary package that is made from this pkgsrc entry. A "
                   6379: preserved" package will not be deleted using pkg_delete(1) unless the "-f"
1.1       dsieger  6380: option is used.
                   6381: 
1.154     rillig   6382: 21.1.9. Handling packages with security problems
1.1       dsieger  6383: 
                   6384: When a vulnerability is found, this should be noted in localsrc/security/
1.32      wiz      6385: advisories/pkg-vulnerabilities, and after committing that file, ask
                   6386: pkgsrc-security@NetBSD.org to update the file on ftp.NetBSD.org.
1.1       dsieger  6387: 
                   6388: After fixing the vulnerability by a patch, its PKGREVISION should be increased
                   6389: (this is of course not necessary if the problem is fixed by using a newer
1.32      wiz      6390: release of the software), and the pattern in the pkg-vulnerabilities file must
                   6391: be updated.
1.1       dsieger  6392: 
                   6393: Also, if the fix should be applied to the stable pkgsrc branch, be sure to
                   6394: submit a pullup request!
                   6395: 
                   6396: Binary packages already on ftp.NetBSD.org will be handled semi-automatically by
                   6397: a weekly cron job.
                   6398: 
1.154     rillig   6399: 21.1.10. How to handle incrementing versions when fixing an existing package
1.1       dsieger  6400: 
                   6401: When making fixes to an existing package it can be useful to change the version
                   6402: number in PKGNAME. To avoid conflicting with future versions by the original
                   6403: author, a "nb1", "nb2", ... suffix can be used on package versions by setting
                   6404: PKGREVISION=1 (2, ...). The "nb" is treated like a "." by the package tools.
                   6405: e.g.
                   6406: 
                   6407: DISTNAME=       foo-17.42
                   6408: PKGREVISION=    9
                   6409: 
                   6410: will result in a PKGNAME of "foo-17.42nb9". If you want to use the original
                   6411: value of PKGNAME without the "nbX" suffix, e.g. for setting DIST_SUBDIR, use
                   6412: PKGNAME_NOREV.
                   6413: 
                   6414: When a new release of the package is released, the PKGREVISION should be
                   6415: removed, e.g. on a new minor release of the above package, things should be
                   6416: like:
                   6417: 
                   6418: DISTNAME=       foo-17.43
                   6419: 
                   6420: PKGREVISION should be incremented for any non-trivial change in the resulting
                   6421: binary package. Without a PKGREVISION bump, someone with the previous version
                   6422: installed has no way of knowing that their package is out of date. Thus,
                   6423: changes without increasing PKGREVISION are essentially labeled "this is so
                   6424: trivial that no reasonable person would want to upgrade", and this is the rough
                   6425: test for when increasing PKGREVISION is appropriate. Examples of changes that
                   6426: do not merit increasing PKGREVISION are:
                   6427: 
1.14      jmcneill 6428:   * Changing HOMEPAGE, MAINTAINER, OWNER, or comments in Makefile.
1.1       dsieger  6429: 
                   6430:   * Changing build variables if the resulting binary package is the same.
                   6431: 
                   6432:   * Changing DESCR.
                   6433: 
                   6434:   * Adding PKG_OPTIONS if the default options don't change.
                   6435: 
                   6436: Examples of changes that do merit an increase to PKGREVISION include:
                   6437: 
                   6438:   * Security fixes
                   6439: 
                   6440:   * Changes or additions to a patch file
                   6441: 
                   6442:   * Changes to the PLIST
                   6443: 
1.12      weinem   6444:   * A dependency is changed or renamed.
                   6445: 
1.1       dsieger  6446: PKGREVISION must also be incremented when dependencies have ABI changes.
                   6447: 
1.154     rillig   6448: 21.1.11. Substituting variable text in the package files (the SUBST framework)
1.1       dsieger  6449: 
1.180     rillig   6450: When you want to replace the same text in multiple files, or multiple times in
                   6451: the same file, it is cumbersome to maintain a patch file for this. This is
                   6452: where the SUBST framework steps in. It provides an easy-to-use interface for
                   6453: replacing text in files. It just needs the following information:
1.172     rillig   6454: 
1.180     rillig   6455:   * In which phase of the package build cycle should the replacement happen?
1.172     rillig   6456: 
1.180     rillig   6457:   * In which files should the replacement happen?
1.172     rillig   6458: 
                   6459:   * Which text should be replaced with what?
                   6460: 
1.180     rillig   6461: This information is encoded in a block of SUBST variables. A minimal example
                   6462: is:
                   6463: 
                   6464: SUBST_CLASSES+=         paths
                   6465: SUBST_STAGE.paths=      pre-configure
                   6466: SUBST_FILES.paths=      src/*.c
                   6467: SUBST_SED.paths=        -e 's,/usr/local,${PREFIX},g'
                   6468: 
                   6469: Translated into English, it means: In the pre-configure stage (that is, after
                   6470: applying the patches from the patches/ directory and before running the
                   6471: configure script and the portability check), replace the text /usr/local with
                   6472: the content of the variable PREFIX.
                   6473: 
                   6474: Each SUBST block starts by appending an identifier to SUBST_CLASSES (note the +
                   6475: =). This identifier can be chosen freely by the package. If there should ever
                   6476: be duplicate identifiers, the pkgsrc infrastructure will catch this and fail
                   6477: early, so don't worry about name collisions.
                   6478: 
                   6479: Except for SUBST_CLASSES, all variables in a SUBST block are parameterized
                   6480: using this identifier. In the remainder of this section, these parameterized
                   6481: variables are written as SUBST_STAGE.*.
                   6482: 
                   6483: SUBST_CLASSES+=         paths
                   6484: SUBST_STAGE.paths=      pre-configure
                   6485: SUBST_MESSAGE.paths=    Fixing absolute paths.
                   6486: SUBST_FILES.paths=      src/*.c
                   6487: SUBST_FILES.paths+=     scripts/*.sh
                   6488: SUBST_SED.paths=        -e 's,"/usr/local,"${PREFIX},g'
                   6489: SUBST_SED.paths+=       -e 's,"/var/log,"${VARBASE}/log,g'
                   6490: SUBST_VARS.paths=       LOCALBASE PREFIX PKGVERSION
                   6491: 
                   6492: To get a complete picture about the SUBST substitutions, run bmake
                   6493: show-all-subst. If something doesn't work as expected, run pkglint on the
                   6494: package, which detects several typical mistakes surrounding the SUBST blocks.
                   6495: For any questions that might remain after this, have a look at mk/subst.mk.
                   6496: 
                   6497: 21.1.11.1. Choosing the time where the substitutions happen
                   6498: 
                   6499: The SUBST_STAGE.* is one of {pre,do,post}-
                   6500: {extract,patch,configure,build,test,install}. Of these, pre-configure is used
                   6501: most often, by far. The most popular stages are, in chronological order:
                   6502: 
                   6503: post-extract
                   6504: 
                   6505:     The substitutions are applied immediately after the distfiles are
                   6506:     extracted. Running bmake extract on the package will leave no traces of the
                   6507:     original files.
                   6508: 
                   6509:     When the substitution applies to files for which there is also a patch in
                   6510:     the patches/ directory, this means that the patches will be computed based
                   6511:     on the result of the substitution. When these patches are sent to the
                   6512:     upstream maintainer later, to be fixed in the upstream package, these
                   6513:     patches may no longer match what the upstream author is used to. Because of
                   6514:     this, pre-configure is often a better choice.
                   6515: 
                   6516: pre-configure
                   6517: 
                   6518:     The substitutions are applied after the patches from the patches/
                   6519:     directory. This makes it possible to run bmake patch on the package, after
                   6520:     which the patches can be edited using the tools pkgvi and mkpatches from
                   6521:     the pkgtools/pkgdiff package.
                   6522: 
                   6523:     When updating the patches, it is helpful to explicitly separate the bmake
                   6524:     patch from the bmake configure, and to only edit the patches between these
                   6525:     commands. Otherwise the substitutions from the SUBST block will end up in
                   6526:     the patch file. When this happens in really obvious ways, pkglint will
                   6527:     complain about patches that contain a hard-coded /usr/pkg instead of the
                   6528:     correct and intended @PREFIX@, but it can only detect these really obvious
                   6529:     cases.
                   6530: 
                   6531: do-configure
                   6532: 
                   6533:     This stage should only be used if the package defines a pre-configure
                   6534:     action itself, and the substitution must happen after that. Typical
                   6535:     examples are packages that use the pre-configure stage to regenerate the
                   6536:     GNU configure script from configure.ac.
                   6537: 
                   6538: post-configure
                   6539: 
                   6540:     This stage is used to fix up any mistakes by the configure stage.
                   6541: 
                   6542: pre-build
                   6543: 
                   6544:     This stage should only be used for substitutions that are clearly related
                   6545:     to building the package, not for fixing the configuration. Substitutions
                   6546:     for pathnames (such as replacing /usr/local with ${PREFIX}) or user names
                   6547:     (such as replacing @MY_USER@ with the actual username) belong in
                   6548:     pre-configure or post-configure instead.
                   6549: 
                   6550: post-build
                   6551: 
                   6552:     Just as with pre-build, this stage should only be used for substitutions
                   6553:     that are clearly related to building the package, not for fixing the
                   6554:     configuration. Substitutions for pathnames (such as replacing /usr/local
                   6555:     with ${PREFIX}) or user names (such as replacing @MY_USER@ with the actual
                   6556:     username) belong in pre-configure or post-configure instead.
                   6557: 
                   6558:     A typical use is to update pkg-config files to include the rpath compiler
                   6559:     options.
                   6560: 
                   6561: pre-install
                   6562: 
                   6563:     In general, the install phase should be as simple as possible. As with the
                   6564:     pre-build and post-build stages, it should not be used to fix pathnames or
                   6565:     user names, these belong in pre-configure instead. There are only few
                   6566:     legitimate use cases for applying substitutions in this stage.
                   6567: 
1.181     rillig   6568: 21.1.11.2. Choosing the files where the substitutions happen
1.180     rillig   6569: 
                   6570: The SUBST_FILES.* variable contains a list of filename patterns. These patterns
                   6571: are relative to WRKSRC since that is where most substitutions happen. A typical
                   6572: example is:
                   6573: 
                   6574: SUBST_FILES.path=       Makefile */Makefile */*/Makefile *.[ch]
                   6575: 
                   6576: The above patterns, especially the last, are quite broad. The SUBST
                   6577: implementation checks that each filename pattern that is mentioned here has an
                   6578: effect. For example, if none of the */*/Makefile files contains the patterns to
                   6579: be found and substituted, that filename pattern is redundant and should be left
1.181     rillig   6580: out. By default, the SUBST framework will complain with an error message. If
                   6581: the text to be substituted occurs in some of the files from a single pattern,
                   6582: but not in all of them, that is totally ok, and the SUBST framework will only
                   6583: print an INFO message for those files.
1.180     rillig   6584: 
                   6585: If there is a good reason for having redundant filename patterns, set
1.181     rillig   6586: SUBST_NOOP_OK.* to yes.
1.180     rillig   6587: 
                   6588: Another popular way of choosing the files for the substitutions is via a shell
                   6589: command, like this:
                   6590: 
1.181     rillig   6591: C_FILES_CMD=            cd ${WRKSRC} && ${FIND} . -name '*.c'
1.180     rillig   6592: SUBST_FILES.path=       ${C_FILES_CMD:sh}
                   6593: 
                   6594: The variable name C_FILES_CMD in this example is freely chosen and independent
                   6595: of the SUBST framework.
                   6596: 
                   6597: In this variant, the SUBST_FILES.* variable lists each file individually.
                   6598: Thereby chances are higher that there are filename patterns in which no
                   6599: substitution happens. Since the SUBST framework cannot know whether the
                   6600: filename patterns in SUBST_FILES.* have been explicitly listed in the Makefile
                   6601: (where any redundant filename pattern would be suspicious) or been generated by
                   6602: a shell command (in which redundant filename patterns are more likely and to be
                   6603: expected), it will complain about these redundant filename patterns. Therefore,
                   6604: SUBST blocks that use a shell command to generate the list of filename patterns
                   6605: often need to set SUBST_NOOP_OK.* to yes.
                   6606: 
                   6607: 21.1.11.3. Choosing what to substitute
                   6608: 
                   6609: In most cases, the substitutions are given using one or more sed(1) commands,
                   6610: like this:
                   6611: 
                   6612: SUBST_SED.path=         -e 's|/usr/local|${PREFIX}|g'
                   6613: 
                   6614: Each of the sed commands needs to be preceded by the -e option and should be
                   6615: specified on a line of its own, to avoid hiding short sed commands at the end
                   6616: of a line.
                   6617: 
                   6618: Since the sed commands often contain shell metacharacters as the separator (the
                   6619: | in the above example), it is common to enclose them in single quotes.
                   6620: 
                   6621: A common substitution is to replace placeholders of the form @VARNAME@ with
                   6622: their pkgsrc counterpart variable ${VARNAME}. A typical example is:
                   6623: 
                   6624: SUBST_VARS.path=        PREFIX
                   6625: 
1.181     rillig   6626: This type of substitutions is typically done by the GNU configure scripts
                   6627: during the do-configure stage, but in some cases these need to be overridden.
                   6628: The same pattern is also used when a package defines patches that replace
                   6629: previously hard-coded paths like /usr/local with a @PREFIX@ placeholder first,
                   6630: which then gets substituted by the actual ${PREFIX} in the pre-configure stage.
                   6631: In many of these cases, it works equally well to just use the SUBST framework
                   6632: to directly replace /usr/local with ${PREFIX}, thereby omitting the
                   6633: intermediate patch file.
1.180     rillig   6634: 
                   6635: If the above is not flexible enough, it is possible to not use sed at all for
                   6636: the substitution but to specify an entirely different command, like this:
                   6637: 
                   6638: SUBST_FILTER_CMD.path=  LC_ALL=C ${TR} -d '\r'
1.1       dsieger  6639: 
1.180     rillig   6640: This is used for the few remaining packages in which the distributed files use
                   6641: Windows-style line endings that need to be converted to UNIX-style line
                   6642: endings.
1.1       dsieger  6643: 
1.180     rillig   6644: 21.1.11.4. Other SUBST variables
1.172     rillig   6645: 
1.180     rillig   6646: When a SUBST block is applied during a package build, a message is logged. The
                   6647: default message is fine for most purposes but can be overridden by setting
                   6648: SUBST_MESSAGE.* to an individual message.
1.1       dsieger  6649: 
1.154     rillig   6650: 21.2. The fetch phase
1.1       dsieger  6651: 
1.154     rillig   6652: 21.2.1. Packages whose distfiles aren't available for plain downloading
1.1       dsieger  6653: 
                   6654: If you need to download from a dynamic URL you can set DYNAMIC_MASTER_SITES and
                   6655: a make fetch will call files/getsite.sh with the name of each file to download
                   6656: as an argument, expecting it to output the URL of the directory from which to
                   6657: download it. graphics/ns-cult3d is an example of this usage.
                   6658: 
                   6659: If the download can't be automated, because the user must submit personal
                   6660: information to apply for a password, or must pay for the source, or whatever,
                   6661: you can set FETCH_MESSAGE to a list of lines that are displayed to the user
                   6662: before aborting the build. Example:
                   6663: 
                   6664: FETCH_MESSAGE=  "Please download the files"
                   6665: FETCH_MESSAGE+= "    "${DISTFILES:Q}
                   6666: FETCH_MESSAGE+= "manually from "${MASTER_SITES:Q}"."
                   6667: 
1.154     rillig   6668: 21.2.2. How to handle modified distfiles with the 'old' name
1.1       dsieger  6669: 
                   6670: Sometimes authors of a software package make some modifications after the
                   6671: software was released, and they put up a new distfile without changing the
                   6672: package's version number. If a package is already in pkgsrc at that time, the
                   6673: checksum will no longer match. The contents of the new distfile should be
                   6674: compared against the old one before changing anything, to make sure the
                   6675: distfile was really updated on purpose, and that no trojan horse or so crept
                   6676: in. Please mention that the distfiles were compared and what was found in your
1.54      rodent   6677: commit message.
                   6678: 
                   6679: Then, the correct way to work around this is to set DIST_SUBDIR to a unique
1.109     wiz      6680: directory name, usually based on PKGNAME_NOREV (but take care with python or
                   6681: ruby packages, where PKGNAME includes a variable prefix). All DISTFILES and
                   6682: PATCHFILES for this package will be put in that subdirectory of the local
1.154     rillig   6683: distfiles directory. (See Section 21.1.10, "How to handle incrementing versions
1.109     wiz      6684: when fixing an existing package" for more details.) In case this happens more
                   6685: often, PKGNAME can be used (thus including the nbX suffix) or a date stamp can
                   6686: be appended, like ${PKGNAME_NOREV}-YYYYMMDD.
1.54      rodent   6687: 
                   6688: DIST_SUBDIR is also used when a distfile's name does not contain a version and
                   6689: the distfile is apt to change. In cases where the likelihood of this is very
                   6690: small, DIST_SUBDIR might not be required. Additionally, DIST_SUBDIR must not be
                   6691: removed unless the distfile name changes, even if a package is being moved or
                   6692: renamed.
                   6693: 
                   6694: Do not forget regenerating the distinfo file after that, since it contains the
                   6695: DIST_SUBDIR path in the filenames. Also, increase the PKGREVISION if the
                   6696: installed package is different. Furthermore, a mail to the package's authors
                   6697: seems appropriate telling them that changing distfiles after releases without
                   6698: changing the file names is not good practice.
1.1       dsieger  6699: 
1.154     rillig   6700: 21.2.3. Packages hosted on github.com
1.88      tnn      6701: 
1.90      tnn      6702: Helper methods exist for packages hosted on github.com which will often have
                   6703: distfile names that clash with other packages, for example 1.0.tar.gz. Use one
                   6704: of the three recipes from below:
1.88      tnn      6705: 
1.154     rillig   6706: 21.2.3.1. Fetch based on a tagged release
1.88      tnn      6707: 
1.174     leot     6708: If your distfile URL looks similar to https://github.com/username/
                   6709: exampleproject/archive/v1.0.zip, then you are packaging a tagged release.
1.88      tnn      6710: 
                   6711: DISTNAME=       exampleproject-1.0
1.90      tnn      6712: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6713: #GITHUB_PROJECT=        # can be omitted if same as DISTNAME
                   6714: GITHUB_TAG=     v${PKGVERSION_NOREV}
1.88      tnn      6715: EXTRACT_SUFX=   .zip
                   6716: 
1.154     rillig   6717: 21.2.3.2. Fetch based on a specific commit
1.88      tnn      6718: 
1.174     leot     6719: If your distfile URL looks similar to https://github.com?/example?/example?/
1.169     rillig   6720: archive?/988881adc9fc3655077dc2d4d757d480b5ea0e11.tar.gz, then you are
                   6721: packaging a specific commit not tied to a release.
1.88      tnn      6722: 
                   6723: DISTNAME=       example-1.0
1.107     jnemeth  6724: MASTER_SITES=   ${MASTER_SITE_GITHUB:=example/}
1.90      tnn      6725: #GITHUB_PROJECT=        # can be omitted if same as DISTNAME
                   6726: GITHUB_TAG=     988881adc9fc3655077dc2d4d757d480b5ea0e11
1.88      tnn      6727: 
1.154     rillig   6728: 21.2.3.3. Fetch based on release
1.88      tnn      6729: 
1.174     leot     6730: If your distfile URL looks similar to https://github.com?/username/
1.169     rillig   6731: exampleproject?/releases?/download?/rel-1.6?/offensive-1.6.zip, then you are
                   6732: packaging a release.
1.88      tnn      6733: 
1.90      tnn      6734: DISTNAME=       offensive-1.6
1.88      tnn      6735: PKGNAME=        ${DISTNAME:S/offensive/proper/}
1.90      tnn      6736: MASTER_SITES=   ${MASTER_SITE_GITHUB:=username/}
                   6737: GITHUB_PROJECT= exampleproject
                   6738: GITHUB_RELEASE= rel-${PKGVERSION_NOREV} # usually just set this to ${DISTNAME}
                   6739: EXTRACT_SUFX=   .zip
1.88      tnn      6740: 
1.154     rillig   6741: 21.3. The configure phase
1.1       dsieger  6742: 
1.154     rillig   6743: 21.3.1. Shared libraries - libtool
1.1       dsieger  6744: 
                   6745: pkgsrc supports many different machines, with different object formats like
                   6746: a.out and ELF, and varying abilities to do shared library and dynamic loading
                   6747: at all. To accompany this, varying commands and options have to be passed to
                   6748: the compiler, linker, etc. to get the Right Thing, which can be pretty annoying
                   6749: especially if you don't have all the machines at your hand to test things. The
                   6750: devel/libtool pkg can help here, as it just "knows" how to build both static
                   6751: and dynamic libraries from a set of source files, thus being
                   6752: platform-independent.
                   6753: 
                   6754: Here's how to use libtool in a package in seven simple steps:
                   6755: 
                   6756:  1. Add USE_LIBTOOL=yes to the package Makefile.
                   6757: 
                   6758:  2. For library objects, use "${LIBTOOL} --mode=compile ${CC}" in place of "$
                   6759:     {CC}". You could even add it to the definition of CC, if only libraries are
                   6760:     being built in a given Makefile. This one command will build both PIC and
                   6761:     non-PIC library objects, so you need not have separate shared and
                   6762:     non-shared library rules.
                   6763: 
                   6764:  3. For the linking of the library, remove any "ar", "ranlib", and "ld
                   6765:     -Bshareable" commands, and instead use:
                   6766: 
                   6767:     ${LIBTOOL} --mode=link \
                   6768:         ${CC} -o ${.TARGET:.a=.la} \
                   6769:             ${OBJS:.o=.lo} \
                   6770:             -rpath ${PREFIX}/lib \
                   6771:             -version-info major:minor
                   6772: 
                   6773:     Note that the library is changed to have a .la extension, and the objects
                   6774:     are changed to have a .lo extension. Change OBJS as necessary. This
                   6775:     automatically creates all of the .a, .so.major.minor, and ELF symlinks (if
                   6776:     necessary) in the build directory. Be sure to include "-version-info",
                   6777:     especially when major and minor are zero, as libtool will otherwise strip
                   6778:     off the shared library version.
                   6779: 
                   6780:     From the libtool manual:
                   6781: 
                   6782:     So, libtool library versions are described by three integers:
                   6783: 
                   6784:     CURRENT
                   6785:     The most recent interface number that this library implements.
                   6786: 
                   6787:     REVISION
                   6788:     The implementation number of the CURRENT interface.
                   6789: 
                   6790:     AGE
                   6791:     The difference between the newest and oldest interfaces that
                   6792:     this library implements.  In other words, the library implements
                   6793:     all the interface numbers in the range from number `CURRENT -
                   6794:     AGE' to `CURRENT'.
                   6795: 
                   6796:     If two libraries have identical CURRENT and AGE numbers, then the
                   6797:     dynamic linker chooses the library with the greater REVISION number.
                   6798: 
                   6799:     The "-release" option will produce different results for a.out and ELF
1.25      wiz      6800:     (excluding symlinks) in only one case. An ELF library of the form "
                   6801:     libfoo-release.so.x.y" will have a symlink of "libfoo.so.x.y" on an a.out
1.1       dsieger  6802:     platform. This is handled automatically.
                   6803: 
                   6804:     The "-rpath argument" is the install directory of the library being built.
                   6805: 
                   6806:     In the PLIST, include only the .la file, the other files will be added
                   6807:     automatically.
                   6808: 
                   6809:  4. When linking shared object (.so) files, i.e. files that are loaded via
                   6810:     dlopen(3), NOT shared libraries, use "-module -avoid-version" to prevent
                   6811:     them getting version tacked on.
                   6812: 
                   6813:     The PLIST file gets the foo.so entry.
                   6814: 
                   6815:  5. When linking programs that depend on these libraries before they are
                   6816:     installed, preface the cc(1) or ld(1) line with "${LIBTOOL} --mode=link",
                   6817:     and it will find the correct libraries (static or shared), but please be
                   6818:     aware that libtool will not allow you to specify a relative path in -L
                   6819:     (such as "-L../somelib"), because it expects you to change that argument to
                   6820:     be the .la file. e.g.
                   6821: 
                   6822:     ${LIBTOOL} --mode=link ${CC} -o someprog -L../somelib -lsomelib
                   6823: 
                   6824:     should be changed to:
                   6825: 
                   6826:     ${LIBTOOL} --mode=link ${CC} -o someprog ../somelib/somelib.la
                   6827: 
                   6828:     and it will do the right thing with the libraries.
                   6829: 
                   6830:  6. When installing libraries, preface the install(1) or cp(1) command with "$
                   6831:     {LIBTOOL} --mode=install", and change the library name to .la. e.g.
                   6832: 
1.23      jakllsch 6833:     ${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} ${SOMELIB:.a=.la} ${PREFIX}/lib
1.1       dsieger  6834: 
                   6835:     This will install the static .a, shared library, any needed symlinks, and
                   6836:     run ldconfig(8).
                   6837: 
                   6838:  7. In your PLIST, include only the .la file (this is a change from previous
                   6839:     behaviour).
                   6840: 
1.154     rillig   6841: 21.3.2. Using libtool on GNU packages that already support libtool
1.1       dsieger  6842: 
                   6843: Add USE_LIBTOOL=yes to the package Makefile. This will override the package's
                   6844: own libtool in most cases. For older libtool using packages, libtool is made by
                   6845: ltconfig script during the do-configure step; you can check the libtool script
                   6846: location by doing make configure; find work*/ -name libtool.
                   6847: 
                   6848: LIBTOOL_OVERRIDE specifies which libtool scripts, relative to WRKSRC, to
                   6849: override. By default, it is set to "libtool */libtool */*/libtool". If this
                   6850: does not match the location of the package's libtool script(s), set it as
                   6851: appropriate.
                   6852: 
                   6853: If you do not need *.a static libraries built and installed, then use
                   6854: SHLIBTOOL_OVERRIDE instead.
                   6855: 
                   6856: If your package makes use of the platform-independent library for loading
                   6857: dynamic shared objects, that comes with libtool (libltdl), you should include
                   6858: devel/libltdl/buildlink3.mk.
                   6859: 
                   6860: Some packages use libtool incorrectly so that the package may not work or build
                   6861: in some circumstances. Some of the more common errors are:
                   6862: 
                   6863:   * The inclusion of a shared object (-module) as a dependent library in an
                   6864:     executable or library. This in itself isn't a problem if one of two things
                   6865:     has been done:
                   6866: 
                   6867:      1. The shared object is named correctly, i.e. libfoo.la, not foo.la
                   6868: 
                   6869:      2. The -dlopen option is used when linking an executable.
                   6870: 
                   6871:   * The use of libltdl without the correct calls to initialisation routines.
                   6872:     The function lt_dlinit() should be called and the macro
                   6873:     LTDL_SET_PRELOADED_SYMBOLS included in executables.
                   6874: 
1.154     rillig   6875: 21.3.3. GNU Autoconf/Automake
1.1       dsieger  6876: 
                   6877: If a package needs GNU autoconf or automake to be executed to regenerate the
                   6878: configure script and Makefile.in makefile templates, then they should be
                   6879: executed in a pre-configure target.
                   6880: 
                   6881: For packages that need only autoconf:
                   6882: 
                   6883: AUTOCONF_REQD=  2.50            # if default version is not good enough
                   6884: USE_TOOLS+=     autoconf        # use "autoconf213" for autoconf-2.13
                   6885: ...
                   6886: 
                   6887: pre-configure:
                   6888:         cd ${WRKSRC} && autoconf
                   6889: 
                   6890: ...
                   6891: 
                   6892: and for packages that need automake and autoconf:
                   6893: 
                   6894: AUTOMAKE_REQD=  1.7.1           # if default version is not good enough
                   6895: USE_TOOLS+=     automake        # use "automake14" for automake-1.4
                   6896: ...
                   6897: 
                   6898: pre-configure:
                   6899:         set -e; cd ${WRKSRC}; \
                   6900:         aclocal; autoheader; automake -a --foreign -i; autoconf
                   6901: 
                   6902: ...
                   6903: 
                   6904: Packages which use GNU Automake will almost certainly require GNU Make.
                   6905: 
                   6906: There are times when the configure process makes additional changes to the
                   6907: generated files, which then causes the build process to try to re-execute the
                   6908: automake sequence. This is prevented by touching various files in the configure
                   6909: stage. If this causes problems with your package you can set AUTOMAKE_OVERRIDE=
                   6910: NO in the package Makefile.
                   6911: 
1.154     rillig   6912: 21.4. Programming languages
1.1       dsieger  6913: 
1.154     rillig   6914: 21.4.1. C, C++, and Fortran
1.1       dsieger  6915: 
                   6916: Compilers for the C, C++, and Fortran languages comes with the NetBSD base
                   6917: system. By default, pkgsrc assumes that a package is written in C and will hide
1.184     rillig   6918: all other compilers (via the wrapper framework, see Chapter 18, Buildlink
1.1       dsieger  6919: methodology).
                   6920: 
                   6921: To declare which language's compiler a package needs, set the USE_LANGUAGES
                   6922: variable. Allowed values currently are "c", "c++", and "fortran" (and any
                   6923: combination). The default is "c". Packages using GNU configure scripts, even if
                   6924: written in C++, usually need a C compiler for the configure phase.
                   6925: 
1.154     rillig   6926: 21.4.2. Java
1.1       dsieger  6927: 
                   6928: If a program is written in Java, use the Java framework in pkgsrc. The package
                   6929: must include ../../mk/java-vm.mk. This Makefile fragment provides the following
                   6930: variables:
                   6931: 
                   6932:   * USE_JAVA defines if a build dependency on the JDK is added. If USE_JAVA is
                   6933:     set to "run", then there is only a runtime dependency on the JDK. The
                   6934:     default is "yes", which also adds a build dependency on the JDK.
                   6935: 
                   6936:   * Set USE_JAVA2 to declare that a package needs a Java2 implementation. The
                   6937:     supported values are "yes", "1.4", and "1.5". "yes" accepts any Java2
                   6938:     implementation, "1.4" insists on versions 1.4 or above, and "1.5" only
                   6939:     accepts versions 1.5 or above. This variable is not set by default.
                   6940: 
1.25      wiz      6941:   * PKG_JAVA_HOME is automatically set to the runtime location of the used Java
                   6942:     implementation dependency. It may be used to set JAVA_HOME to a good value
                   6943:     if the program needs this variable to be defined.
                   6944: 
1.154     rillig   6945: 21.4.3. Packages containing perl scripts
1.1       dsieger  6946: 
                   6947: If your package contains interpreted perl scripts, add "perl" to the USE_TOOLS
                   6948: variable and set REPLACE_PERL to ensure that the proper interpreter path is
                   6949: set. REPLACE_PERL should contain a list of scripts, relative to WRKSRC, that
1.74      wiz      6950: you want adjusted. Every occurrence of */bin/perl in a she-bang line will be
                   6951: replaced with the full path to the perl executable.
1.1       dsieger  6952: 
                   6953: If a particular version of perl is needed, set the PERL5_REQD variable to the
                   6954: version number. The default is "5.0".
                   6955: 
1.154     rillig   6956: See Section 21.6.6, "Packages installing perl modules" for information about
1.1       dsieger  6957: handling perl modules.
                   6958: 
1.154     rillig   6959: 21.4.4. Packages containing shell scripts
1.41      wiz      6960: 
                   6961: REPLACE_SH, REPLACE_BASH, REPLACE_CSH, and REPLACE_KSH can be used to replace
                   6962: shell hash bangs in files. Please use the appropriate one, prefering REPLACE_SH
1.74      wiz      6963: in case this shell is sufficient. Each should contain a list of scripts,
                   6964: relative to WRKSRC, that you want adjusted. Every occurrence of the matching
                   6965: shell in a she-bang line will be replaced with the full path to the shell
                   6966: executable. When using REPLACE_BASH, don't forget to add bash to USE_TOOLS.
1.41      wiz      6967: 
1.154     rillig   6968: 21.4.5. Other programming languages
1.1       dsieger  6969: 
                   6970: Currently, there is no special handling for other languages in pkgsrc. If a
                   6971: compiler package provides a buildlink3.mk file, include that, otherwise just
                   6972: add a (build) dependency on the appropriate compiler package.
                   6973: 
1.154     rillig   6974: 21.5. The build phase
1.1       dsieger  6975: 
                   6976: The most common failures when building a package are that some platforms do not
                   6977: provide certain header files, functions or libraries, or they provide the
                   6978: functions in a library that the original package author didn't know. To work
                   6979: around this, you can rewrite the source code in most cases so that it does not
                   6980: use the missing functions or provides a replacement function.
                   6981: 
1.154     rillig   6982: 21.5.1. Compiling C and C++ code conditionally
1.1       dsieger  6983: 
                   6984: If a package already comes with a GNU configure script, the preferred way to
                   6985: fix the build failure is to change the configure script, not the code. In the
                   6986: other cases, you can utilize the C preprocessor, which defines certain macros
                   6987: depending on the operating system and hardware architecture it compiles for.
                   6988: These macros can be queried using for example #if defined(__i386). Almost every
                   6989: operating system, hardware architecture and compiler has its own macro. For
                   6990: example, if the macros __GNUC__, __i386__ and __NetBSD__ are all defined, you
                   6991: know that you are using NetBSD on an i386 compatible CPU, and your compiler is
                   6992: GCC.
                   6993: 
                   6994: The list of the following macros for hardware and operating system depends on
                   6995: the compiler that is used. For example, if you want to conditionally compile
                   6996: code on Solaris, don't use __sun__, as the SunPro compiler does not define it.
                   6997: Use __sun instead.
                   6998: 
1.154     rillig   6999: 21.5.1.1. C preprocessor macros to identify the operating system
1.1       dsieger  7000: 
                   7001: To distinguish between 4.4 BSD-derived systems and the rest of the world, you
                   7002: should use the following code.
                   7003: 
                   7004: #include <sys/param.h>
                   7005: #if (defined(BSD) && BSD >= 199306)
                   7006: /* BSD-specific code goes here */
                   7007: #else
                   7008: /* non-BSD-specific code goes here */
                   7009: #endif
                   7010: 
                   7011: If this distinction is not fine enough, you can also test for the following
                   7012: macros.
                   7013: 
1.46      obache   7014: Cygwin      __CYGWIN__
                   7015: DragonFly   __DragonFly__
1.1       dsieger  7016: FreeBSD     __FreeBSD__
1.46      obache   7017: Haiku       __HAIKU__
1.1       dsieger  7018: Interix     __INTERIX
                   7019: IRIX        __sgi (TODO: get a definite source for this)
                   7020: Linux       linux, __linux, __linux__
1.83      dholland 7021: Mac OS X    __APPLE__
1.46      obache   7022: MirBSD      __MirBSD__ (__OpenBSD__ is also defined)
                   7023: Minix3      __minix
1.1       dsieger  7024: NetBSD      __NetBSD__
                   7025: OpenBSD     __OpenBSD__
                   7026: Solaris     sun, __sun
                   7027: 
1.154     rillig   7028: 21.5.1.2. C preprocessor macros to identify the hardware architecture
1.1       dsieger  7029: 
                   7030: i386        i386, __i386, __i386__
                   7031: MIPS        __mips
                   7032: SPARC       sparc, __sparc
                   7033: 
1.154     rillig   7034: 21.5.1.3. C preprocessor macros to identify the compiler
1.1       dsieger  7035: 
                   7036: GCC         __GNUC__ (major version), __GNUC_MINOR__
                   7037: MIPSpro     _COMPILER_VERSION (0x741 for MIPSpro 7.41)
                   7038: SunPro      __SUNPRO_C (0x570 for Sun C 5.7)
                   7039: SunPro C++  __SUNPRO_CC (0x580 for Sun C++ 5.8)
                   7040: 
1.154     rillig   7041: 21.5.2. How to handle compiler bugs
1.1       dsieger  7042: 
                   7043: Some source files trigger bugs in the compiler, based on combinations of
                   7044: compiler version and architecture and almost always relation to optimisation
                   7045: being enabled. Common symptoms are gcc internal errors or never finishing
                   7046: compiling a file.
                   7047: 
                   7048: Typically, a workaround involves testing the MACHINE_ARCH and compiler version,
1.87      tnn      7049: disabling optimisation for that combination of file, MACHINE_ARCH and compiler.
                   7050: 
                   7051: This used to be a big problem in the past, but is rarely needed now as compiler
                   7052: technology has matured. If you still need to add a compiler specific
                   7053: workaround, please do so in the file hacks.mk and describe the symptom and
                   7054: compiler version as detailed as possible.
1.1       dsieger  7055: 
1.172     rillig   7056: 21.5.3. No such file or directory
                   7057: 
                   7058: Compilation sometimes fails with an error message like this:
                   7059: 
                   7060: .../x11/gtk3/work/gtk+-3.24.12/gdk/gdktypes.h:35:10:
                   7061:     fatal error: pango/pango.h: No such file or directory
                   7062: 
                   7063: The proper way to fix this problem depends on the type of the header, which is
                   7064: described in the following sections.
                   7065: 
                   7066: 21.5.3.1. Headers from other packages
                   7067: 
                   7068: If the header name looks like it comes from a different package, that other
                   7069: package should be included via the buildlink3 framework.
                   7070: 
                   7071: First, look whether the header is somewhere in the buildlink3 directory below
                   7072: WRKDIR. In the above case of the missing Pango header:
                   7073: 
                   7074: $ find work/.buildlink/ -print | grep -F pango/pango.h
                   7075: 
                   7076: In the case of Pango, the output is:
                   7077: 
                   7078: work/.buildlink/include/pango-1.0/pango/pango.h
                   7079: 
                   7080: If the pango/pango.h file were placed directly in the .buildlink directory, it
                   7081: would have been found automatically. There is an extra pango-1.0 path component
                   7082: though, which means that the compiler command line must contain an option of
                   7083: the form -I${BUILDLINK3_PREFIX.pango}/include/pango-1.0. In most cases this
                   7084: option is generated by the configure script, which can be examined using:
                   7085: 
                   7086: $ $ grep -o '[-]I[^[:space:]]*/pango[^[:space:]]*' work/*/Makefile
                   7087: -I/usr/pkg/include/pango-1.0
                   7088: -I/usr/pkg/include/pango-1.0
                   7089: -I/usr/pkg/include/pango-1.0
                   7090: -I/usr/pkg/include/pango-1.0
                   7091: -I/usr/pkg/include/pango-1.0
                   7092: 
                   7093: This looks good. These options are transformed by the buildlink wrapper to
                   7094: refer to the correct path inside work/.buildlink.
                   7095: 
                   7096: Since the compilation fails though, examine the compiler command lines in work
                   7097: /.work.log to see whether the -I option is included in the particular command
                   7098: line.
                   7099: 
                   7100: To further analyze the situation, run bmake build-env, which sets up an
                   7101: interactive, realistic environment including all the pkgsrc wrapper commands
                   7102: and environment variables. From there, try to compile some simple example
                   7103: programs that use the header.
                   7104: 
                   7105: 21.5.3.2. Headers generated during the build
                   7106: 
                   7107: If the name of the header seems to come from the package itself, and if the
                   7108: build is run with parallel jobs, the package may have some undeclared
                   7109: dependencies between the .c and the .h files, and a C file is compiled before
                   7110: its required header is generated.
                   7111: 
                   7112: To see whether the build runs with parallel jobs, run bmake show-all-build |
                   7113: grep JOBS. Its output looks like this:
                   7114: 
                   7115:   usr   MAKE_JOBS=              7
                   7116:   pkg   MAKE_JOBS_SAFE          # undefined
                   7117:   def   _MAKE_JOBS_N=           7
                   7118: 
                   7119: In this case the pkgsrc user has asked pkgsrc to build packages with 7 jobs in
                   7120: parallel (MAKE_JOBS). The package could have disabled parallel builds by
                   7121: setting MAKE_JOBS_SAFE to no, but in this case it hasn't.
                   7122: 
                   7123: To see whether the build failure is caused by parallel builds, first save the
                   7124: exact error message and a bit of context, maybe you need it later for reporting
                   7125: a bug. Next, run:
                   7126: 
                   7127: MAKE_JOBS_SAFE=no bmake clean build
                   7128: 
                   7129: If that succeeds, file a bug report against the pkgsrc package, including the
                   7130: exact error message and the contents of your mk.conf file.
                   7131: 
1.173     rillig   7132: 21.5.3.3. Symlinks
                   7133: 
                   7134: Pkgsrc does not work reliably if any of LOCALBASE, VARBASE or WRKDIR contains a
                   7135: symlink. Since 2019Q2, the pkgsrc bootstrap program prevents installing pkgsrc
                   7136: in symlink-based directories. Existing pkgsrc installations are not checked for
                   7137: symlinks though.
                   7138: 
                   7139: The "No such file or directory" error messages are a typical symptom of
                   7140: symlinks, and it's quite difficult to find out that this is the actual cause.
                   7141: 
                   7142: 21.5.3.4. Stale working directories
                   7143: 
                   7144: When building a hierarchy of packages, it may happen that one package is built
                   7145: and then pkgsrc is updated. This situation can provoke various hard to diagnose
                   7146: build errors. To clean up the situation:
                   7147: 
                   7148: $ (cd ../../ && test -f mk/bsd.pkg.mk && rm -rf */*/work)
                   7149: 
                   7150: (The test for bsd.pkg.mk just prevents running this command in the wrong
                   7151: directory.)
                   7152: 
                   7153: If you have set WRKOBJDIR in mk.conf, remove that directory as well.
                   7154: 
                   7155: 21.5.3.5. Other possible reasons
                   7156: 
                   7157: On platforms other than BSD, third-party packages are installed in /usr/
                   7158: include, together with the base system. This means that pkgsrc cannot
                   7159: distinguish between headers provided by the base system (which it needs) and
                   7160: headers from third-party packages (which are often included in pkgsrc as well).
                   7161: This can lead to subtle version mismatches.
                   7162: 
                   7163: In pkgsrc installations that have been active for several years, it may happen
                   7164: that some files are manually deleted. To exclude this unlikely reason, run 
                   7165: pkg_admin check.
                   7166: 
                   7167: It may help to run pkg_admin rebuild-tree to check/fix dependencies.
                   7168: 
                   7169: If all of the above doesn't help, see Chapter 2, Getting help for contact
                   7170: information. Be prepared to describe what you have tried so far and what any
                   7171: error messages were.
                   7172: 
1.172     rillig   7173: 21.5.4. Undefined reference to "..."
1.1       dsieger  7174: 
                   7175: This error message often means that a package did not link to a shared library
                   7176: it needs. The following functions are known to cause this error message over
                   7177: and over.
                   7178: 
                   7179: +-----------------------------------------------------+
                   7180: |        Function         |Library |Affected platforms|
                   7181: |-------------------------+--------+------------------|
                   7182: |accept, bind, connect    |-lsocket|Solaris           |
                   7183: |-------------------------+--------+------------------|
                   7184: |crypt                    |-lcrypt |DragonFly, NetBSD |
                   7185: |-------------------------+--------+------------------|
                   7186: |dlopen, dlsym            |-ldl    |Linux             |
                   7187: |-------------------------+--------+------------------|
                   7188: |gethost*                 |-lnsl   |Solaris           |
                   7189: |-------------------------+--------+------------------|
                   7190: |inet_aton                |-lresolv|Solaris           |
                   7191: |-------------------------+--------+------------------|
                   7192: |nanosleep, sem_*, timer_*|-lrt    |Solaris           |
                   7193: |-------------------------+--------+------------------|
                   7194: |openpty                  |-lutil  |Linux             |
                   7195: +-----------------------------------------------------+
                   7196: 
                   7197: To fix these linker errors, it is often sufficient to say LIBS.OperatingSystem+
                   7198: = -lfoo to the package Makefile and then say bmake clean; bmake.
                   7199: 
1.172     rillig   7200: 21.5.4.1. Special issue: The SunPro compiler
1.1       dsieger  7201: 
                   7202: When you are using the SunPro compiler, there is another possibility. That
                   7203: compiler cannot handle the following code:
                   7204: 
                   7205: extern int extern_func(int);
                   7206: 
                   7207: static inline int
                   7208: inline_func(int x)
                   7209: {
                   7210:         return extern_func(x);
                   7211: }
                   7212: 
                   7213: int main(void)
                   7214: {
                   7215:         return 0;
                   7216: }
                   7217: 
                   7218: It generates the code for inline_func even if that function is never used. This
                   7219: code then refers to extern_func, which can usually not be resolved. To solve
                   7220: this problem you can try to tell the package to disable inlining of functions.
                   7221: 
1.172     rillig   7222: 21.5.5. Running out of memory
1.1       dsieger  7223: 
                   7224: Sometimes packages fail to build because the compiler runs into an operating
                   7225: system specific soft limit. With the UNLIMIT_RESOURCES variable pkgsrc can be
1.94      wiz      7226: told to unlimit the resources. Currently, the allowed values are any
                   7227: combination of "cputime", "datasize", "memorysize", and "stacksize". Setting
                   7228: this variable is similar to running the shell builtin ulimit command to raise
                   7229: the maximum data segment size or maximum stack size of a process, respectively,
                   7230: to their hard limits.
1.1       dsieger  7231: 
1.154     rillig   7232: 21.6. The install phase
1.1       dsieger  7233: 
1.154     rillig   7234: 21.6.1. Creating needed directories
1.1       dsieger  7235: 
                   7236: The BSD-compatible install supplied with some operating systems cannot create
                   7237: more than one directory at a time. As such, you should call ${INSTALL_*_DIR}
                   7238: like this:
                   7239: 
                   7240: ${INSTALL_DATA_DIR} ${PREFIX}/dir1
                   7241: ${INSTALL_DATA_DIR} ${PREFIX}/dir2
                   7242: 
                   7243: You can also just append "dir1 dir2" to the INSTALLATION_DIRS variable, which
                   7244: will automatically do the right thing.
                   7245: 
1.154     rillig   7246: 21.6.2. Where to install documentation
1.1       dsieger  7247: 
                   7248: In general, documentation should be installed into ${PREFIX}/share/doc/$
                   7249: {PKGBASE} or ${PREFIX}/share/doc/${PKGNAME} (the latter includes the version
                   7250: number of the package).
                   7251: 
                   7252: Many modern packages using GNU autoconf allow to set the directory where HTML
                   7253: documentation is installed with the "--with-html-dir" option. Sometimes using
                   7254: this flag is needed because otherwise the documentation ends up in ${PREFIX}/
                   7255: share/doc/html or other places.
                   7256: 
                   7257: An exception to the above is that library API documentation generated with the
                   7258: textproc/gtk-doc tools, for use by special browsers (devhelp) should be left at
                   7259: their default location, which is ${PREFIX}/share/gtk-doc. Such documentation
                   7260: can be recognized from files ending in .devhelp or .devhelp2. (It is also
                   7261: acceptable to install such files in ${PREFIX}/share/doc/${PKGBASE} or ${PREFIX}
                   7262: /share/doc/${PKGNAME}; the .devhelp* file must be directly in that directory
                   7263: then, no additional subdirectory level is allowed in this case. This is usually
                   7264: achieved by using "--with-html-dir=${PREFIX}/share/doc". ${PREFIX}/share/
                   7265: gtk-doc is preferred though.)
                   7266: 
1.154     rillig   7267: 21.6.3. Installing highscore files
1.1       dsieger  7268: 
                   7269: Certain packages, most of them in the games category, install a score file that
                   7270: allows all users on the system to record their highscores. In order for this to
                   7271: work, the binaries need to be installed setgid and the score files owned by the
1.36      wiz      7272: appropriate group and/or owner (traditionally the "games" user/group). Set
                   7273: USE_GAMESGROUP to yes to support this. The following variables, documented in
                   7274: more detail in mk/defaults/mk.conf, control this behaviour: GAMEDATAMODE,
1.100     leot     7275: GAMEDIRMODE, GAMES_GROUP, GAMEMODE, GAME_USER. Other useful variables are:
                   7276: GAMEDIR_PERMS, GAMEDATA_PERMS and SETGID_GAMES_PERMS.
                   7277: 
                   7278: An example that illustrates some of the variables described above is games/
                   7279: moon-buggy. OWN_DIRS_PERMS is used to properly set directory permissions of the
                   7280: directory where the scorefile is saved, REQD_FILES_PERMS is used to create a
                   7281: dummy scorefile (mbscore) with the proper permissions and SPECIAL_PERMS is used
                   7282: to install setgid the game binary:
                   7283: 
                   7284: USE_GAMESGROUP=         yes
                   7285: 
                   7286: BUILD_DEFS+=            VARBASE
                   7287: 
                   7288: OWN_DIRS_PERMS+=        ${VARBASE}/games/moon-buggy ${GAMEDIR_PERMS}
                   7289: REQD_FILES_PERMS+=      /dev/null ${VARBASE}/games/moon-buggy/mbscore ${GAMEDATA_PERMS}
                   7290: SPECIAL_PERMS+=         ${PREFIX}/bin/moon-buggy ${SETGID_GAMES_PERMS}
                   7291: 
                   7292: Various INSTALL_* variables are also available: INSTALL_GAME to install setgid
                   7293: game binaries, INSTALL_GAME_DIR to install game directories that are needed to
                   7294: be accessed by setgid games and INSTALL_GAME_DATA to install scorefiles.
1.1       dsieger  7295: 
1.14      jmcneill 7296: A package should therefore never hard code file ownership or access permissions
1.100     leot     7297: but rely on *_PERMS as described above or alternatively on INSTALL_GAME,
                   7298: INSTALL_GAME_DATA and INSTALL_GAME_DIR to set these correctly.
1.1       dsieger  7299: 
1.154     rillig   7300: 21.6.4. Adding DESTDIR support to packages
1.4       rillig   7301: 
1.14      jmcneill 7302: DESTDIR support means that a package installs into a staging directory, not the
                   7303: final location of the files. Then a binary package is created which can be used
                   7304: for installation as usual. There are two ways: Either the package must install
1.25      wiz      7305: as root ("destdir") or the package can install as non-root user ("user-destdir"
                   7306: ).
1.14      jmcneill 7307: 
1.113     leot     7308:   * PKG_DESTDIR_SUPPORT has to be set to "destdir" or "user-destdir". By
                   7309:     default PKG_DESTDIR_SUPPORT is set to "user-destdir" to help catching more
                   7310:     potential packaging problems. If bsd.prefs.mk is included in the Makefile,
                   7311:     PKG_DESTDIR_SUPPORT needs to be set before the inclusion.
1.14      jmcneill 7312: 
1.4       rillig   7313:   * All installation operations have to be prefixed with ${DESTDIR}.
                   7314: 
                   7315:   * automake gets this DESTDIR mostly right automatically. Many manual rules
                   7316:     and pre/post-install often are incorrect; fix them.
                   7317: 
1.17      imil     7318:   * If files are installed with special owner/group use SPECIAL_PERMS.
1.4       rillig   7319: 
                   7320:   * In general, packages should support UNPRIVILEGED to be able to use DESTDIR.
                   7321: 
1.154     rillig   7322: 21.6.5. Packages with hardcoded paths to other interpreters
1.1       dsieger  7323: 
                   7324: Your package may also contain scripts with hardcoded paths to other
                   7325: interpreters besides (or as well as) perl. To correct the full pathname to the
                   7326: script interpreter, you need to set the following definitions in your Makefile
                   7327: (we shall use tclsh in this example):
                   7328: 
                   7329: REPLACE_INTERPRETER+=   tcl
                   7330: REPLACE.tcl.old=        .*/bin/tclsh
                   7331: REPLACE.tcl.new=        ${PREFIX}/bin/tclsh
                   7332: REPLACE_FILES.tcl=      # list of tcl scripts which need to be fixed,
                   7333: # relative to ${WRKSRC}, just as in REPLACE_PERL
                   7334: 
                   7335: Note
                   7336: 
                   7337: Before March 2006, these variables were called _REPLACE.* and _REPLACE_FILES.*.
                   7338: 
1.154     rillig   7339: 21.6.6. Packages installing perl modules
1.1       dsieger  7340: 
                   7341: Makefiles of packages providing perl5 modules should include the Makefile
                   7342: fragment ../../lang/perl5/module.mk. It provides a do-configure target for the
                   7343: standard perl configuration for such modules as well as various hooks to tune
                   7344: this configuration. See comments in this file for details.
                   7345: 
                   7346: Perl5 modules will install into different places depending on the version of
                   7347: perl used during the build process. To address this, pkgsrc will append lines
                   7348: to the PLIST corresponding to the files listed in the installed .packlist file
                   7349: generated by most perl5 modules. This is invoked by defining PERL5_PACKLIST to
1.48      wiz      7350: a space-separated list of packlist files relative to PERL5_PACKLIST_DIR
                   7351: (PERL5_INSTALLVENDORARCH by default), e.g.:
1.1       dsieger  7352: 
1.48      wiz      7353: PERL5_PACKLIST= auto/Pg/.packlist
1.1       dsieger  7354: 
1.48      wiz      7355: The perl5 config variables installarchlib, installscript, installvendorbin,
                   7356: installvendorscript, installvendorarch, installvendorlib, installvendorman1dir,
                   7357: and installvendorman3dir represent those locations in which components of perl5
                   7358: modules may be installed, provided as variable with uppercase and prefixed with
                   7359: PERL5_, e.g. PERL5_INSTALLARCHLIB and may be used by perl5 packages that don't
                   7360: have a packlist. These variables are also substituted for in the PLIST as
                   7361: uppercase prefixed with PERL5_SUB_.
1.1       dsieger  7362: 
1.154     rillig   7363: 21.6.7. Packages installing info files
1.1       dsieger  7364: 
                   7365: Some packages install info files or use the "makeinfo" or "install-info"
                   7366: commands. INFO_FILES should be defined in the package Makefile so that INSTALL
                   7367: and DEINSTALL scripts will be generated to handle registration of the info
                   7368: files in the Info directory file. The "install-info" command used for the info
                   7369: files registration is either provided by the system, or by a special purpose
                   7370: package automatically added as dependency if needed.
                   7371: 
                   7372: PKGINFODIR is the directory under ${PREFIX} where info files are primarily
                   7373: located. PKGINFODIR defaults to "info" and can be overridden by the user.
                   7374: 
                   7375: The info files for the package should be listed in the package PLIST; however
                   7376: any split info files need not be listed.
                   7377: 
                   7378: A package which needs the "makeinfo" command at build time must add "makeinfo"
                   7379: to USE_TOOLS in its Makefile. If a minimum version of the "makeinfo" command is
                   7380: needed it should be noted with the TEXINFO_REQD variable in the package
                   7381: Makefile. By default, a minimum version of 3.12 is required. If the system does
                   7382: not provide a makeinfo command or if it does not match the required minimum, a
                   7383: build dependency on the devel/gtexinfo package will be added automatically.
                   7384: 
                   7385: The build and installation process of the software provided by the package
                   7386: should not use the install-info command as the registration of info files is
1.25      wiz      7387: the task of the package INSTALL script, and it must use the appropriate 
1.1       dsieger  7388: makeinfo command.
                   7389: 
                   7390: To achieve this goal, the pkgsrc infrastructure creates overriding scripts for
                   7391: the install-info and makeinfo commands in a directory listed early in PATH.
                   7392: 
                   7393: The script overriding install-info has no effect except the logging of a
                   7394: message. The script overriding makeinfo logs a message and according to the
                   7395: value of TEXINFO_REQD either runs the appropriate makeinfo command or exit on
                   7396: error.
                   7397: 
1.154     rillig   7398: 21.6.8. Packages installing man pages
1.1       dsieger  7399: 
                   7400: All packages that install manual pages should install them into the same
                   7401: directory, so that there is one common place to look for them. In pkgsrc, this
                   7402: place is ${PREFIX}/${PKGMANDIR}, and this expression should be used in
1.25      wiz      7403: packages. The default for PKGMANDIR is "man". Another often-used value is "
                   7404: share/man".
1.1       dsieger  7405: 
                   7406: Note
                   7407: 
                   7408: The support for a custom PKGMANDIR is far from complete.
                   7409: 
                   7410: The PLIST files can just use man/ as the top level directory for the man page
                   7411: file entries, and the pkgsrc framework will convert as needed. In all other
                   7412: places, the correct PKGMANDIR must be used.
                   7413: 
                   7414: Packages that are configured with GNU_CONFIGURE set as "yes", by default will
                   7415: use the ./configure --mandir switch to set where the man pages should be
                   7416: installed. The path is GNU_CONFIGURE_MANDIR which defaults to ${PREFIX}/$
                   7417: {PKGMANDIR}.
                   7418: 
                   7419: Packages that use GNU_CONFIGURE but do not use --mandir, can set
                   7420: CONFIGURE_HAS_MANDIR to "no". Or if the ./configure script uses a non-standard
                   7421: use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
                   7422: 
1.184     rillig   7423: See Section 19.5, "Man page compression" for information on installation of
1.1       dsieger  7424: compressed manual pages.
                   7425: 
1.154     rillig   7426: 21.6.9. Packages installing GConf data files
1.1       dsieger  7427: 
1.7       rillig   7428: If a package installs .schemas or .entries files, used by GConf, you need to
1.1       dsieger  7429: take some extra steps to make sure they get registered in the database:
                   7430: 
1.7       rillig   7431:  1. Include ../../devel/GConf/schemas.mk instead of its buildlink3.mk file.
                   7432:     This takes care of rebuilding the GConf database at installation and
                   7433:     deinstallation time, and tells the package where to install GConf data
1.1       dsieger  7434:     files using some standard configure arguments. It also disallows any access
                   7435:     to the database directly from the package.
                   7436: 
                   7437:  2. Ensure that the package installs its .schemas files under ${PREFIX}/share/
                   7438:     gconf/schemas. If they get installed under ${PREFIX}/etc, you will need to
                   7439:     manually patch the package.
                   7440: 
                   7441:  3. Check the PLIST and remove any entries under the etc/gconf directory, as
1.154     rillig   7442:     they will be handled automatically. See Section 10.13, "How do I change the
1.1       dsieger  7443:     location of configuration files?" for more information.
                   7444: 
1.7       rillig   7445:  4. Define the GCONF_SCHEMAS variable in your Makefile with a list of all
1.1       dsieger  7446:     .schemas files installed by the package, if any. Names must not contain any
                   7447:     directories in them.
                   7448: 
1.7       rillig   7449:  5. Define the GCONF_ENTRIES variable in your Makefile with a list of all
1.1       dsieger  7450:     .entries files installed by the package, if any. Names must not contain any
                   7451:     directories in them.
                   7452: 
1.154     rillig   7453: 21.6.10. Packages installing scrollkeeper/rarian data files
1.1       dsieger  7454: 
1.18      mishka   7455: If a package installs .omf files, used by scrollkeeper/rarian, you need to take
                   7456: some extra steps to make sure they get registered in the database:
1.1       dsieger  7457: 
1.18      mishka   7458:  1. Include ../../mk/omf-scrollkeeper.mk instead of rarian's buildlink3.mk
                   7459:     file. This takes care of rebuilding the scrollkeeper database at
                   7460:     installation and deinstallation time, and disallows any access to it
                   7461:     directly from the package.
1.1       dsieger  7462: 
                   7463:  2. Check the PLIST and remove any entries under the libdata/scrollkeeper
                   7464:     directory, as they will be handled automatically.
                   7465: 
                   7466:  3. Remove the share/omf directory from the PLIST. It will be handled by
1.18      mishka   7467:     rarian. (make print-PLIST does this automatically.)
1.1       dsieger  7468: 
1.154     rillig   7469: 21.6.11. Packages installing X11 fonts
1.1       dsieger  7470: 
                   7471: If a package installs font files, you will need to rebuild the fonts database
                   7472: in the directory where they get installed at installation and deinstallation
                   7473: time. This can be automatically done by using the pkginstall framework.
                   7474: 
                   7475: You can list the directories where fonts are installed in the FONTS_DIRS.type
                   7476: variables, where type can be one of "ttf", "type1" or "x11". Also make sure
                   7477: that the database file fonts.dir is not listed in the PLIST.
                   7478: 
                   7479: Note that you should not create new directories for fonts; instead use the
                   7480: standard ones to avoid that the user needs to manually configure his X server
                   7481: to find them.
                   7482: 
1.154     rillig   7483: 21.6.12. Packages installing GTK2 modules
1.1       dsieger  7484: 
                   7485: If a package installs GTK2 immodules or loaders, you need to take some extra
                   7486: steps to get them registered in the GTK2 database properly:
                   7487: 
                   7488:  1. Include ../../x11/gtk2/modules.mk instead of its buildlink3.mk file. This
                   7489:     takes care of rebuilding the database at installation and deinstallation
                   7490:     time.
                   7491: 
                   7492:  2. Set GTK2_IMMODULES=YES if your package installs GTK2 immodules.
                   7493: 
                   7494:  3. Set GTK2_LOADERS=YES if your package installs GTK2 loaders.
                   7495: 
                   7496:  4. Patch the package to not touch any of the GTK2 databases directly. These
                   7497:     are:
                   7498: 
1.42      asau     7499:       + libdata/gtk-2.0/gdk-pixbuf.loaders
1.1       dsieger  7500: 
1.42      asau     7501:       + libdata/gtk-2.0/gtk.immodules
1.1       dsieger  7502: 
                   7503:  5. Check the PLIST and remove any entries under the libdata/gtk-2.0 directory,
                   7504:     as they will be handled automatically.
                   7505: 
1.154     rillig   7506: 21.6.13. Packages installing SGML or XML data
1.1       dsieger  7507: 
                   7508: If a package installs SGML or XML data files that need to be registered in
                   7509: system-wide catalogs (like DTDs, sub-catalogs, etc.), you need to take some
                   7510: extra steps:
                   7511: 
                   7512:  1. Include ../../textproc/xmlcatmgr/catalogs.mk in your Makefile, which takes
                   7513:     care of registering those files in system-wide catalogs at installation and
                   7514:     deinstallation time.
                   7515: 
                   7516:  2. Set SGML_CATALOGS to the full path of any SGML catalogs installed by the
                   7517:     package.
                   7518: 
                   7519:  3. Set XML_CATALOGS to the full path of any XML catalogs installed by the
                   7520:     package.
                   7521: 
                   7522:  4. Set SGML_ENTRIES to individual entries to be added to the SGML catalog.
                   7523:     These come in groups of three strings; see xmlcatmgr(1) for more
                   7524:     information (specifically, arguments recognized by the 'add' action). Note
                   7525:     that you will normally not use this variable.
                   7526: 
                   7527:  5. Set XML_ENTRIES to individual entries to be added to the XML catalog. These
                   7528:     come in groups of three strings; see xmlcatmgr(1) for more information
                   7529:     (specifically, arguments recognized by the 'add' action). Note that you
                   7530:     will normally not use this variable.
                   7531: 
1.154     rillig   7532: 21.6.14. Packages installing extensions to the MIME database
1.1       dsieger  7533: 
                   7534: If a package provides extensions to the MIME database by installing .xml files
                   7535: inside ${PREFIX}/share/mime/packages, you need to take some extra steps to
                   7536: ensure that the database is kept consistent with respect to these new files:
                   7537: 
                   7538:  1. Include ../../databases/shared-mime-info/mimedb.mk (avoid using the
                   7539:     buildlink3.mk file from this same directory, which is reserved for
                   7540:     inclusion from other buildlink3.mk files). It takes care of rebuilding the
                   7541:     MIME database at installation and deinstallation time, and disallows any
                   7542:     access to it directly from the package.
                   7543: 
1.25      wiz      7544:  2. Check the PLIST and remove any entries under the share/mime directory, 
1.1       dsieger  7545:     except for files saved under share/mime/packages. The former are handled
                   7546:     automatically by the update-mime-database program, but the latter are
                   7547:     package-dependent and must be removed by the package that installed them in
                   7548:     the first place.
                   7549: 
                   7550:  3. Remove any share/mime/* directories from the PLIST. They will be handled by
                   7551:     the shared-mime-info package.
                   7552: 
1.154     rillig   7553: 21.6.15. Packages using intltool
1.1       dsieger  7554: 
                   7555: If a package uses intltool during its build, add intltool to the USE_TOOLS,
                   7556: which forces it to use the intltool package provided by pkgsrc, instead of the
                   7557: one bundled with the distribution file.
                   7558: 
                   7559: This tracks intltool's build-time dependencies and uses the latest available
                   7560: version; this way, the package benefits of any bug fixes that may have appeared
                   7561: since it was released.
                   7562: 
1.154     rillig   7563: 21.6.16. Packages installing startup scripts
1.1       dsieger  7564: 
                   7565: If a package contains a rc.d script, it won't be copied into the startup
                   7566: directory by default, but you can enable it, by adding the option
1.4       rillig   7567: PKG_RCD_SCRIPTS=YES in mk.conf. This option will copy the scripts into /etc/
                   7568: rc.d when a package is installed, and it will automatically remove the scripts
                   7569: when the package is deinstalled.
1.1       dsieger  7570: 
1.154     rillig   7571: 21.6.17. Packages installing TeX modules
1.1       dsieger  7572: 
                   7573: If a package installs TeX packages into the texmf tree, the ls-R database of
                   7574: the tree needs to be updated.
                   7575: 
                   7576: Note
                   7577: 
1.23      jakllsch 7578: Except the main TeX packages such as kpathsea, packages should install files
                   7579: into ${PREFIX}/share/texmf-dist, not ${PREFIX}/share/texmf.
1.1       dsieger  7580: 
1.23      jakllsch 7581:  1. Include ../../print/kpathsea/texmf.mk. This takes care of rebuilding the
                   7582:     ls-R database at installation and deinstallation time.
1.1       dsieger  7583: 
1.23      jakllsch 7584:  2. If your package installs files into a texmf tree other than the one at $
                   7585:     {PREFIX}/share/texmf-dist, set TEX_TEXMF_DIRS to the list of all texmf
                   7586:     trees that need database update.
1.1       dsieger  7587: 
                   7588:     If your package also installs font map files that need to be registered
1.30      dholland 7589:     using updmap, include ../../print/tex-tetex/map.mk and set TEX_MAP_FILES
                   7590:     and/or TEX_MIXEDMAP_FILES to the list of all such font map files. Then 
                   7591:     updmap will be run automatically at installation/deinstallation to enable/
                   7592:     disable font map files for TeX output drivers.
1.1       dsieger  7593: 
                   7594:  3. Make sure that none of ls-R databases are included in PLIST, as they will
1.30      dholland 7595:     be removed only by the kpathsea package.
1.1       dsieger  7596: 
1.154     rillig   7597: 21.6.18. Packages supporting running binaries in emulation
1.1       dsieger  7598: 
                   7599: There are some packages that provide libraries and executables for running
                   7600: binaries from a one operating system on a different one (if the latter supports
                   7601: it). One example is running Linux binaries on NetBSD.
                   7602: 
                   7603: The pkgtools/rpm2pkg helps in extracting and packaging Linux rpm packages.
                   7604: 
                   7605: The CHECK_SHLIBS can be set to no to avoid the check-shlibs target, which tests
                   7606: if all libraries for each installed executable can be found by the dynamic
                   7607: linker. Since the standard dynamic linker is run, this fails for emulation
                   7608: packages, because the libraries used by the emulation are not in the standard
                   7609: directories.
                   7610: 
1.154     rillig   7611: 21.6.19. Packages installing hicolor theme icons
1.1       dsieger  7612: 
                   7613: If a package installs images under the share/icons/hicolor and/or updates the
                   7614: share/icons/hicolor/icon-theme.cache database, you need to take some extra
                   7615: steps to make sure that the shared theme directory is handled appropriately and
                   7616: that the cache database is rebuilt:
                   7617: 
                   7618:  1. Include ../../graphics/hicolor-icon-theme/buildlink3.mk.
                   7619: 
                   7620:  2. Check the PLIST and remove the entry that refers to the theme cache.
                   7621: 
                   7622:  3. Ensure that the PLIST does not remove the shared icon directories from the
                   7623:     share/icons/hicolor hierarchy because they will be handled automatically.
                   7624: 
                   7625: The best way to verify that the PLIST is correct with respect to the last two
                   7626: points is to regenerate it using make print-PLIST.
                   7627: 
1.154     rillig   7628: 21.6.20. Packages installing desktop files
1.1       dsieger  7629: 
                   7630: If a package installs .desktop files under share/applications and these include
1.54      rodent   7631: MIME information (MimeType key), you need to take extra steps to ensure that
                   7632: they are registered into the MIME database:
1.1       dsieger  7633: 
                   7634:  1. Include ../../sysutils/desktop-file-utils/desktopdb.mk.
                   7635: 
                   7636:  2. Check the PLIST and remove the entry that refers to the share/applications/
                   7637:     mimeinfo.cache file. It will be handled automatically.
                   7638: 
                   7639: The best way to verify that the PLIST is correct with respect to the last point
                   7640: is to regenerate it using make print-PLIST.
                   7641: 
1.154     rillig   7642: 21.7. Marking packages as having problems
1.1       dsieger  7643: 
1.23      jakllsch 7644: In some cases one does not have the time to solve a problem immediately. In
                   7645: this case, one can plainly mark a package as broken. For this, one just sets
                   7646: the variable BROKEN to the reason why the package is broken (similar to the
1.162     rillig   7647: PKG_FAIL_REASON variable). A user trying to build the package will immediately
                   7648: be shown this message, and the build will not be even tried.
1.1       dsieger  7649: 
1.23      jakllsch 7650: BROKEN packages are removed from pkgsrc in irregular intervals.
1.1       dsieger  7651: 
1.184     rillig   7652: Chapter 22. GNOME packaging and porting
                   7653: 
                   7654: Table of Contents
                   7655: 
                   7656: 22.1. Meta packages
                   7657: 22.2. Packaging a GNOME application
                   7658: 22.3. Updating GNOME to a newer version
                   7659: 22.4. Patching guidelines
                   7660: 
                   7661: Quoting GNOME's web site:
                   7662: 
                   7663:     The GNOME project provides two things: The GNOME desktop environment, an
                   7664:     intuitive and attractive desktop for users, and the GNOME development
                   7665:     platform, an extensive framework for building applications that integrate
                   7666:     into the rest of the desktop.
                   7667: 
                   7668: pkgsrc provides a seamless way to automatically build and install a complete
                   7669: GNOME environment under many different platforms. We can say with confidence
                   7670: that pkgsrc is one of the most advanced build and packaging systems for GNOME
                   7671: due to its included technologies buildlink3, the wrappers and tools framework
                   7672: and automatic configuration file management. Lots of efforts are put into
                   7673: achieving a completely clean deinstallation of installed software components.
                   7674: 
                   7675: Given that pkgsrc is NetBSD's official packaging system, the above also means
                   7676: that great efforts are put into making GNOME work under this operating system.
                   7677: Recently, DragonFly BSD also adopted pkgsrc as its preferred packaging system,
                   7678: contributing lots of portability fixes to make GNOME build and install under
                   7679: it.
                   7680: 
                   7681: This chapter is aimed at pkgsrc developers and other people interested in
                   7682: helping our GNOME porting and packaging efforts. It provides instructions on
                   7683: how to manage the existing packages and some important information regarding
                   7684: their internals.
                   7685: 
                   7686: We need your help!
                   7687: 
                   7688: Should you have some spare cycles to devote to NetBSD, pkgsrc and GNOME and are
                   7689: willing to learn new exciting stuff, please jump straight to the pending work
                   7690: list! There is still a long way to go to get a fully-functional GNOME desktop
                   7691: under NetBSD and we need your help to achieve it!
                   7692: 
                   7693: 22.1. Meta packages
                   7694: 
                   7695: pkgsrc includes three GNOME-related meta packages:
                   7696: 
                   7697:   * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
                   7698:     includes the necessary bits to get it to boot correctly, although it may
                   7699:     lack important functionality for daily operation. The idea behind this
                   7700:     package is to let end users build their own configurations on top of this
                   7701:     one, first installing this meta package to achieve a functional setup and
                   7702:     then adding individual applications.
                   7703: 
                   7704:   * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
                   7705:     desktop as defined by the GNOME project; this is based on the components
                   7706:     distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
                   7707:     directories of the official FTP server. Developer-only tools found in those
                   7708:     directories are not installed unless required by some other component to
                   7709:     work properly. Similarly, packages from the bindings set (bindings/x.y/
                   7710:     x.y.z/sources) are not pulled in unless required as a dependency for an
                   7711:     end-user component. This package "extends" meta-pkgs/gnome-base.
                   7712: 
                   7713:   * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
                   7714:     component when fetched from the CVS repository. These are required to let
                   7715:     the autogen.sh scripts work appropriately.
                   7716: 
                   7717: In all these packages, the DEPENDS lines are sorted in a way that eases
                   7718: updates: a package may depend on other packages listed before it but not on any
                   7719: listed after it. It is very important to keep this order to ease updates so... 
                   7720: do not change it to alphabetical sorting!
                   7721: 
                   7722: 22.2. Packaging a GNOME application
                   7723: 
                   7724: Almost all GNOME applications are written in C and use a common set of tools as
                   7725: their build system. Things get different with the new bindings to other
                   7726: languages (such as Python), but the following will give you a general idea on
                   7727: the minimum required tools:
                   7728: 
                   7729:   * Almost all GNOME applications use the GNU Autotools as their build system.
                   7730:     As a general rule you will need to tell this to your package:
                   7731: 
                   7732:     GNU_CONFIGURE=yes
                   7733:     USE_LIBTOOL=yes
                   7734:     USE_TOOLS+=gmake
                   7735: 
                   7736:   * If the package uses pkg-config to detect dependencies, add this tool to the
                   7737:     list of required utilities:
                   7738: 
                   7739:     USE_TOOLS+=pkg-config
                   7740: 
                   7741:     Also use pkgtools/verifypc at the end of the build process to ensure that
                   7742:     you did not miss to specify any dependency in your package and that the
                   7743:     version requirements are all correct.
                   7744: 
                   7745:   * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
                   7746:     handle dependencies and to force the package to use the latest available
                   7747:     version.
                   7748: 
                   7749:   * If the package uses gtk-doc (a documentation generation utility), do not
                   7750:     add a dependency on it. The tool is rather big and the distfile should come
                   7751:     with pregenerated documentation anyway; if it does not, it is a bug that
                   7752:     you ought to report. For such packages you should disable gtk-doc (unless
                   7753:     it is the default):
                   7754: 
                   7755:     CONFIGURE_ARGS+=--disable-gtk-doc
                   7756: 
                   7757:     The default location of installed HTML files (share/gtk-doc/<package-name>)
                   7758:     is correct and should not be changed unless the package insists on
                   7759:     installing them somewhere else. Otherwise programs as devhelp will not be
                   7760:     able to open them. You can do that with an entry similar to:
1.1       dsieger  7761: 
1.184     rillig   7762:     CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...
1.1       dsieger  7763: 
1.184     rillig   7764: GNOME uses multiple shared directories and files under the installation prefix
                   7765: to maintain databases. In this context, shared means that those exact same
                   7766: directories and files are used among several different packages, leading to
                   7767: conflicts in the PLIST. pkgsrc currently includes functionality to handle the
                   7768: most common cases, so you have to forget about using @unexec ${RMDIR} lines in
                   7769: your file lists and omitting shared files from them. If you find yourself doing
                   7770: those, your package is most likely incorrect.
1.1       dsieger  7771: 
1.184     rillig   7772: The following table lists the common situations that result in using shared
                   7773: directories or files. For each of them, the appropriate solution is given.
                   7774: After applying the solution be sure to regenerate the package's file list with 
                   7775: make print-PLIST and ensure it is correct.
1.1       dsieger  7776: 
1.184     rillig   7777: Table 22.1. PLIST handling for GNOME packages
1.1       dsieger  7778: 
1.184     rillig   7779: +-----------------------------------------------------------------------------+
                   7780: |             If the package...             |             Then...             |
                   7781: |-------------------------------------------+---------------------------------|
                   7782: |                                           |See Section 21.6.10, "Packages   |
                   7783: |Installs OMF files under share/omf.        |installing scrollkeeper/rarian   |
                   7784: |                                           |data files".                     |
                   7785: |-------------------------------------------+---------------------------------|
                   7786: |Installs icons under the share/icons/      |See Section 21.6.19, "Packages   |
                   7787: |hicolor hierarchy or updates share/icons/  |installing hicolor theme icons". |
                   7788: |hicolor/icon-theme.cache.                  |                                 |
                   7789: |-------------------------------------------+---------------------------------|
                   7790: |                                           |See Section 21.6.14, "Packages   |
                   7791: |Installs files under share/mime/packages.  |installing extensions to the MIME|
                   7792: |                                           |database".                       |
                   7793: |-------------------------------------------+---------------------------------|
                   7794: |Installs .desktop files under share/       |See Section 21.6.20, "Packages   |
                   7795: |applications and these include MIME        |installing desktop files".       |
                   7796: |information.                               |                                 |
                   7797: +-----------------------------------------------------------------------------+
1.1       dsieger  7798: 
                   7799: 
1.184     rillig   7800: 22.3. Updating GNOME to a newer version
1.1       dsieger  7801: 
1.184     rillig   7802: When seeing GNOME as a whole, there are two kinds of updates:
1.1       dsieger  7803: 
1.184     rillig   7804: Major update
1.1       dsieger  7805: 
1.184     rillig   7806:     Given that there is still a very long way for GNOME 3 (if it ever appears),
                   7807:     we consider a major update one that goes from a 2.X version to a 2.Y one,
                   7808:     where Y is even and greater than X. These are hard to achieve because they
                   7809:     introduce lots of changes in the components' code and almost all GNOME
                   7810:     distfiles are updated to newer versions. Some of them can even break API
                   7811:     and ABI compatibility with the previous major version series. As a result,
                   7812:     the update needs to be done all at once to minimize breakage.
1.1       dsieger  7813: 
1.184     rillig   7814:     A major update typically consists of around 80 package updates and the
                   7815:     addition of some new ones.
1.1       dsieger  7816: 
1.184     rillig   7817: Minor update
1.1       dsieger  7818: 
1.184     rillig   7819:     We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
                   7820:     one where Y is greater than X. These are easy to achieve because they do
                   7821:     not update all GNOME components, can be done in an incremental way and do
                   7822:     not break API nor ABI compatibility.
1.1       dsieger  7823: 
1.184     rillig   7824:     A minor update typically consists of around 50 package updates, although
                   7825:     the numbers here may vary a lot.
1.1       dsieger  7826: 
1.184     rillig   7827: In order to update the GNOME components in pkgsrc to a new stable release
                   7828: (either major or minor), the following steps should be followed:
1.1       dsieger  7829: 
1.184     rillig   7830:  1. Get a list of all the tarballs that form the new release by using the
                   7831:     following commands. These will leave the full list of the components'
                   7832:     distfiles into the list.txt file:
1.1       dsieger  7833: 
1.184     rillig   7834:     % echo ls "*.tar.bz2" | \
                   7835:         ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
                   7836:         awk '{ print $9 }' >list.txt
                   7837:     % echo ls "*.tar.bz2" | \
                   7838:         ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
                   7839:         awk '{ print $9 }' >>list.txt
1.1       dsieger  7840: 
1.184     rillig   7841:  2. Open each meta package's Makefile and bump their version to the release you
                   7842:     are updating them to. The three meta packages should be always consistent
                   7843:     with versioning. Obviously remove any PKGREVISIONs that might be in them.
1.1       dsieger  7844: 
1.184     rillig   7845:  3. For each meta package, update all its DEPENDS lines to match the latest
                   7846:     versions as shown by the above commands. Do not list any newer version
                   7847:     (even if found in the FTP) because the meta packages are supposed to list
                   7848:     the exact versions that form a specific GNOME release. Exceptions are
                   7849:     permitted here if a newer version solves a serious issue in the overall
                   7850:     desktop experience; these typically come in the form of a revision bump in
                   7851:     pkgsrc, not in newer versions from the developers.
1.1       dsieger  7852: 
1.184     rillig   7853:     Packages not listed in the list.txt file should be updated to the latest
                   7854:     version available (if found in pkgsrc). This is the case, for example, of
                   7855:     the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
                   7856:     package.
1.1       dsieger  7857: 
1.184     rillig   7858:  4. Generate a patch from the modified meta packages and extract the list of
                   7859:     "new" lines. This will provide you an outline on what packages need to be
                   7860:     updated in pkgsrc and in what order:
1.1       dsieger  7861: 
1.184     rillig   7862:     % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
1.1       dsieger  7863: 
1.184     rillig   7864:  5. For major desktop updates it is recommended to zap all your installed
                   7865:     packages and start over from scratch at this point.
1.1       dsieger  7866: 
1.184     rillig   7867:  6. Now comes the longest step by far: iterate over the contents of todo.txt
                   7868:     and update the packages listed in it in order. For major desktop updates
                   7869:     none of these should be committed until the entire set is completed because
                   7870:     there are chances of breaking not-yet-updated packages.
1.1       dsieger  7871: 
1.184     rillig   7872:  7. Once the packages are up to date and working, commit them to the tree one
                   7873:     by one with appropriate log messages. At the end, commit the three meta
                   7874:     package updates and all the corresponding changes to the doc/CHANGES-<YEAR>
                   7875:     and pkgsrc/doc/TODO files.
1.1       dsieger  7876: 
1.184     rillig   7877: 22.4. Patching guidelines
1.1       dsieger  7878: 
1.184     rillig   7879: GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
                   7880: it is very important that you always, always, always feed back any portability
                   7881: fixes you do to a GNOME package to the mainstream developers (see
                   7882: Section 12.3.5, "Feedback to the author"). This is the only way to get their
                   7883: attention on portability issues and to ensure that future versions can be built
                   7884: out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
                   7885: updates are. Those developers in charge of issuing major GNOME updates will be
                   7886: grateful if you do that.
1.1       dsieger  7887: 
1.184     rillig   7888: The most common places to report bugs are the GNOME's Bugzilla and the
                   7889: freedesktop.org's Bugzilla. Not all components use these to track bugs, but
                   7890: most of them do. Do not be short on your reports: always provide detailed
                   7891: explanations of the current failure, how it can be improved to achieve maximum
                   7892: portability and, if at all possible, provide a patch against CVS head. The more
                   7893: verbose you are, the higher chances of your patch being accepted.
1.1       dsieger  7894: 
1.184     rillig   7895: Also, please avoid using preprocessor magic to fix portability issues. While
                   7896: the FreeBSD GNOME people are doing a great job in porting GNOME to their
                   7897: operating system, the official GNOME sources are now plagued by conditionals
                   7898: that check for __FreeBSD__ and similar macros. This hurts portability. Please
                   7899: see our patching guidelines (Section 12.3.4, "Patching guidelines") for more
                   7900: details.
1.1       dsieger  7901: 
1.154     rillig   7902: Chapter 23. Submitting and Committing
1.1       dsieger  7903: 
                   7904: Table of Contents
                   7905: 
1.154     rillig   7906: 23.1. Submitting binary packages
                   7907: 23.2. Submitting source packages (for non-NetBSD-developers)
                   7908: 23.3. General notes when adding, updating, or removing packages
                   7909: 23.4. Commit Messages
                   7910: 23.5. Committing: Adding a package to CVS
                   7911: 23.6. Updating a package to a newer version
                   7912: 23.7. Renaming a package in pkgsrc
                   7913: 23.8. Moving a package in pkgsrc
1.1       dsieger  7914: 
1.154     rillig   7915: 23.1. Submitting binary packages
1.1       dsieger  7916: 
                   7917: Our policy is that we accept binaries only from pkgsrc developers to guarantee
                   7918: that the packages don't contain any trojan horses etc. This is not to annoy
                   7919: anyone but rather to protect our users! You're still free to put up your
                   7920: home-made binary packages and tell the world where to get them. NetBSD
1.154     rillig   7921: developers doing bulk builds and wanting to upload them please see Chapter 8, 
1.66      asau     7922: Creating binary packages for everything in pkgsrc (bulk builds).
1.1       dsieger  7923: 
1.154     rillig   7924: 23.2. Submitting source packages (for non-NetBSD-developers)
1.1       dsieger  7925: 
                   7926: First, check that your package is complete, compiles and runs well; see
1.184     rillig   7927: Chapter 14, Creating a new pkgsrc package from scratch and the rest of this
                   7928: document. Next, generate an uuencoded gzipped tar(1) archive that contains all
                   7929: files that make up the package. Finally, send this package to the pkgsrc bug
                   7930: tracking system, either with the send-pr(1) command, or if you don't have that,
                   7931: go to the web page https://www.NetBSD.org/support/send-pr.html, which contains
                   7932: some instructions and a link to a form where you can submit packages. The
                   7933: sysutils/gtk-send-pr package is also available as a substitute for either of
                   7934: the above two tools.
1.1       dsieger  7935: 
                   7936: In the form of the problem report, the category should be "pkg", the synopsis
                   7937: should include the package name and version number, and the description field
                   7938: should contain a short description of your package (contents of the COMMENT
1.25      wiz      7939: variable or DESCR file are OK). The uuencoded package data should go into the "
                   7940: fix" field.
1.1       dsieger  7941: 
                   7942: If you want to submit several packages, please send a separate PR for each one,
                   7943: it's easier for us to track things that way.
                   7944: 
                   7945: Alternatively, you can also import new packages into pkgsrc-wip ("pkgsrc
1.174     leot     7946: work-in-progress"); see the homepage at https://pkgsrc.org/wip/ for details.
1.1       dsieger  7947: 
1.154     rillig   7948: 23.3. General notes when adding, updating, or removing packages
1.1       dsieger  7949: 
                   7950: Please note all package additions, updates, moves, and removals in pkgsrc/doc/
                   7951: CHANGES-YYYY. It's very important to keep this file up to date and conforming
                   7952: to the existing format, because it will be used by scripts to automatically
                   7953: update pages on www.NetBSD.org and other sites. Additionally, check the pkgsrc/
                   7954: doc/TODO file and remove the entry for the package you updated or removed, in
                   7955: case it was mentioned there.
                   7956: 
                   7957: When the PKGREVISION of a package is bumped, the change should appear in pkgsrc
                   7958: /doc/CHANGES-YYYY if it is security related or otherwise relevant. Mass bumps
                   7959: that result from a dependency being updated should not be mentioned. In all
                   7960: other cases it's the developer's decision.
                   7961: 
                   7962: There is a make target that helps in creating proper CHANGES-YYYY entries: make
                   7963: changes-entry. It uses the optional CTYPE and NETBSD_LOGIN_NAME variables. The
                   7964: general usage is to first make sure that your CHANGES-YYYY file is up-to-date
                   7965: (to avoid having to resolve conflicts later-on) and then to cd to the package
                   7966: directory. For package updates, make changes-entry is enough. For new packages,
                   7967: or package moves or removals, set the CTYPE variable on the command line to
1.4       rillig   7968: "Added", "Moved", or "Removed". You can set NETBSD_LOGIN_NAME in mk.conf if
1.23      jakllsch 7969: your local login name is not the same as your NetBSD login name. The target
                   7970: also automatically removes possibly existing entries for the package in the
                   7971: TODO file. Don't forget to commit the changes, e.g. by using make
1.66      asau     7972: commit-changes-entry! If you are not using a checkout directly from
1.23      jakllsch 7973: cvs.NetBSD.org, but e.g. a local copy of the repository, you can set
                   7974: USE_NETBSD_REPO=yes. This makes the cvs commands use the main repository.
1.1       dsieger  7975: 
1.154     rillig   7976: 23.4. Commit Messages
1.130     wiz      7977: 
                   7978: For several years, there have been mirrors of pkgsrc in fossil, git, and hg.
                   7979: Standard practise when using these tools is to make the first line of a commit
                   7980: message function as a summary that can be read without the rest, such as is
                   7981: commonly done with "git log --oneline". For this reason, we have the following
                   7982: guidelines for pkgsrc commit messages:
                   7983: 
1.131     wiz      7984:   * Start the commit message with a line that explains the big picture in 65
1.130     wiz      7985:     characters or less. When a commit is for one package, include the name of
                   7986:     the package. For updates, include the version to which it is updated.
                   7987: 
                   7988:   * Leave the next line empty.
                   7989: 
                   7990:   * Then come the details for the commit (changes in that package, reason for a
                   7991:     change) and any relevant PRs. Wrap this section.
                   7992: 
                   7993: Here is an example:
                   7994: 
                   7995:   libxslt: update to 1.0.30
                   7996: 
                   7997:   Changes since 1.0.29:
                   7998:   ...
                   7999: 
                   8000: 
                   8001: Here is another example:
                   8002: 
                   8003:   mk/bsd.pkg.mk: enable SSP by default on NetBSD
                   8004: 
                   8005:   (rationale)
                   8006: 
                   8007: 
                   8008: Commit messages are final: no "cvs admin" is allowed on the pkgsrc repository
                   8009: to change commit messages.
                   8010: 
1.154     rillig   8011: 23.5. Committing: Adding a package to CVS
1.1       dsieger  8012: 
                   8013: This section is only of interest for pkgsrc developers with write access to the
1.34      wiz      8014: pkgsrc repository.
                   8015: 
                   8016: When the package is finished, "cvs add" the files. Start by adding the
                   8017: directory and then files in the directory. Don't forget to add the new package
                   8018: to the category's Makefile. Make sure you don't forget any files; you can check
                   8019: by running "cvs status". An example:
                   8020: 
                   8021: $ cd .../pkgsrc/category
                   8022: $ cvs add pkgname
                   8023: $ cd pkgname
                   8024: $ cvs add DESCR Makefile PLIST distinfo buildlink3.mk patches
                   8025: $ cvs add patches/p*
                   8026: $ cvs status | less
1.35      wiz      8027: $ cvs commit
1.34      wiz      8028: $ cd ..
                   8029: $ vi Makefile # add SUBDIRS+=pkgname line
1.35      wiz      8030: $ cvs commit Makefile
1.66      asau     8031: $ cd pkgname
1.73      jnemeth  8032: $ make CTYPE=Added commit-changes-entry
1.1       dsieger  8033: 
                   8034: The commit message of the initial import should include part of the DESCR file,
                   8035: so people reading the mailing lists know what the package is/does.
                   8036: 
1.34      wiz      8037: Also mention the new package in pkgsrc/doc/CHANGES-20xx.
                   8038: 
                   8039: Previously, "cvs import" was suggested, but it was much easier to get wrong
                   8040: than "cvs add".
1.1       dsieger  8041: 
1.154     rillig   8042: 23.6. Updating a package to a newer version
1.1       dsieger  8043: 
                   8044: Please always put a concise, appropriate and relevant summary of the changes
                   8045: between old and new versions into the commit log when updating a package. There
                   8046: are various reasons for this:
                   8047: 
                   8048:   * A URL is volatile, and can change over time. It may go away completely or
                   8049:     its information may be overwritten by newer information.
                   8050: 
                   8051:   * Having the change information between old and new versions in our CVS
                   8052:     repository is very useful for people who use either cvs or anoncvs.
                   8053: 
                   8054:   * Having the change information between old and new versions in our CVS
                   8055:     repository is very useful for people who read the pkgsrc-changes mailing
                   8056:     list, so that they can make tactical decisions about when to upgrade the
                   8057:     package.
                   8058: 
                   8059: Please also recognize that, just because a new version of a package has been
                   8060: released, it should not automatically be upgraded in the CVS repository. We
                   8061: prefer to be conservative in the packages that are included in pkgsrc -
                   8062: development or beta packages are not really the best thing for most places in
                   8063: which pkgsrc is used. Please use your judgement about what should go into
                   8064: pkgsrc, and bear in mind that stability is to be preferred above new and
                   8065: possibly untested features.
                   8066: 
1.154     rillig   8067: 23.7. Renaming a package in pkgsrc
1.21      snj      8068: 
                   8069: Renaming packages is not recommended.
                   8070: 
1.175     gutterid 8071: When renaming packages, be sure to fix any references to the old name in other
1.21      snj      8072: Makefiles, options, buildlink files, etc.
                   8073: 
1.175     gutterid 8074: Also, when renaming a package, please add the package name and version pattern
1.167     leot     8075: (s) of the previous package to SUPERSEDES. This may be repeated for multiple
                   8076: renames. The new package would be an exact replacement. Example:
                   8077: 
                   8078: SUPERSEDES+=    p5-IO-Compress-Zlib<2.017
                   8079: SUPERSEDES+=    optcomp-[0-9]*
1.21      snj      8080: 
                   8081: Note that "successor" in the CHANGES-YYYY file doesn't necessarily mean that it
                   8082: supersedes, as that successor may not be an exact replacement but is a
                   8083: suggestion for the replaced functionality.
                   8084: 
1.154     rillig   8085: 23.8. Moving a package in pkgsrc
1.21      snj      8086: 
                   8087: It is preferred that packages are not renamed or moved, but if needed please
                   8088: follow these steps.
1.1       dsieger  8089: 
                   8090:  1. Make a copy of the directory somewhere else.
                   8091: 
                   8092:  2. Remove all CVS dirs.
                   8093: 
                   8094:     Alternatively to the first two steps you can also do:
                   8095: 
                   8096:     % cvs -d user@cvs.NetBSD.org:/cvsroot export -D today pkgsrc/category/package
                   8097: 
                   8098:     and use that for further work.
                   8099: 
1.25      wiz      8100:  3. Fix CATEGORIES and any DEPENDS paths that just did "../package" instead of 
1.1       dsieger  8101:     "../../category/package".
                   8102: 
1.21      snj      8103:  4. In the modified package's Makefile, consider setting PREV_PKGPATH to the
                   8104:     previous category/package pathname. The PREV_PKGPATH can be used by tools
                   8105:     for doing an update using pkgsrc building; for example, it can search the
                   8106:     pkg_summary(5) database for PREV_PKGPATH (if no SUPERSEDES) and then use
                   8107:     the corresponding new PKGPATH for that moved package. Note that it may have
                   8108:     multiple matches, so the tool should also check on the PKGBASE too. The
                   8109:     PREV_PKGPATH probably has no value unless SUPERSEDES is not set, i.e.
                   8110:     PKGBASE stays the same.
                   8111: 
                   8112:  5. cvs import the modified package in the new place.
1.1       dsieger  8113: 
1.21      snj      8114:  6. Check if any package depends on it:
1.1       dsieger  8115: 
                   8116:     % cd /usr/pkgsrc
                   8117:     % grep /package */*/Makefile* */*/buildlink*
                   8118: 
1.21      snj      8119:  7. Fix paths in packages from step 5 to point to new location.
1.1       dsieger  8120: 
1.21      snj      8121:  8. cvs rm (-f) the package at the old location.
1.1       dsieger  8122: 
1.21      snj      8123:  9. Remove from oldcategory/Makefile.
1.1       dsieger  8124: 
1.21      snj      8125: 10. Add to newcategory/Makefile.
1.1       dsieger  8126: 
1.21      snj      8127: 11. Commit the changed and removed files:
1.1       dsieger  8128: 
                   8129:     % cvs commit oldcategory/package oldcategory/Makefile newcategory/Makefile
                   8130: 
                   8131:     (and any packages from step 5, of course).
                   8132: 
1.154     rillig   8133: Chapter 24. Frequently Asked Questions
1.1       dsieger  8134: 
                   8135: This section contains the answers to questions that may arise when you are
                   8136: writing a package. If you don't find your question answered here, first have a
                   8137: look in the other chapters, and if you still don't have the answer, ask on the
                   8138: pkgsrc-users mailing list.
                   8139: 
1.154     rillig   8140: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
                   8141: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
                   8142: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
                   8143: 24.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1       dsieger  8144:     BUILDLINK_LIBS?
1.154     rillig   8145: 24.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
                   8146: 24.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1       dsieger  8147:     the := inside it.
1.154     rillig   8148: 24.7. Which mailing lists are there for package developers?
                   8149: 24.8. Where is the pkgsrc documentation?
                   8150: 24.9. I have a little time to kill. What shall I do?
1.1       dsieger  8151: 
1.154     rillig   8152: 24.1. What is the difference between MAKEFLAGS, .MAKEFLAGS and MAKE_FLAGS?
1.1       dsieger  8153: 
                   8154:       MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make
                   8155:       (1), while MAKE_FLAGS are the flags that are passed to the MAKE_PROGRAM
                   8156:       when building the package. [FIXME: What is .MAKEFLAGS for?]
                   8157: 
1.154     rillig   8158: 24.2. What is the difference between MAKE, GMAKE and MAKE_PROGRAM?
1.1       dsieger  8159: 
                   8160:       MAKE is the path to the make(1) program that is used in the pkgsrc
                   8161:       infrastructure. GMAKE is the path to GNU Make, but you need to say
                   8162:       USE_TOOLS+=gmake to use that. MAKE_PROGRAM is the path to the Make
                   8163:       program that is used for building the package.
                   8164: 
1.154     rillig   8165: 24.3. What is the difference between CC, PKG_CC and PKGSRC_COMPILER?
1.1       dsieger  8166: 
                   8167:       CC is the path to the real C compiler, which can be configured by the
                   8168:       pkgsrc user. PKG_CC is the path to the compiler wrapper. PKGSRC_COMPILER
                   8169:       is not a path to a compiler, but the type of compiler that should be
                   8170:       used. See mk/compiler.mk for more information about the latter variable.
                   8171: 
1.154     rillig   8172: 24.4. What is the difference between BUILDLINK_LDFLAGS, BUILDLINK_LDADD and
1.1       dsieger  8173:       BUILDLINK_LIBS?
                   8174: 
                   8175:       [FIXME]
                   8176: 
1.154     rillig   8177: 24.5. Why does make show-var VARNAME=BUILDLINK_PREFIX.foo say it's empty?
1.1       dsieger  8178: 
1.25      wiz      8179:       For optimization reasons, some variables are only available in the "
                   8180:       wrapper" phase and later. To "simulate" the wrapper phase, append 
1.1       dsieger  8181:       PKG_PHASE=wrapper to the above command.
                   8182: 
1.154     rillig   8183: 24.6. What does ${MASTER_SITE_SOURCEFORGE:=package/} mean? I don't understand
1.1       dsieger  8184:       the := inside it.
                   8185: 
1.108     rillig   8186:       The := is not really an assignment operator, although it looks like it.
                   8187:       Instead, it is a degenerate form of ${LIST:old_string=new_string}, which
                   8188:       is documented in the make(1) man page and which is commonly used in the
                   8189:       form ${SRCS:.c=.o}. In the case of MASTER_SITE_*, old_string is the empty
                   8190:       string and new_string is package/. That's where the : and the = fall
                   8191:       together.
1.1       dsieger  8192: 
1.154     rillig   8193: 24.7. Which mailing lists are there for package developers?
1.1       dsieger  8194: 
                   8195:       tech-pkg
                   8196: 
                   8197:           This is a list for technical discussions related to pkgsrc
                   8198:           development, e.g. soliciting feedback for changes to pkgsrc
                   8199:           infrastructure, proposed new features, questions related to porting
                   8200:           pkgsrc to a new platform, advice for maintaining a package, patches
                   8201:           that affect many packages, help requests moved from pkgsrc-users when
                   8202:           an infrastructure bug is found, etc.
                   8203: 
                   8204:       pkgsrc-bugs
                   8205: 
                   8206:           All bug reports in category "pkg" sent with send-pr(1) appear here.
                   8207:           Please do not report your bugs here directly; use one of the other
                   8208:           mailing lists.
                   8209: 
1.154     rillig   8210: 24.8. Where is the pkgsrc documentation?
1.1       dsieger  8211: 
                   8212:       There are many places where you can find documentation about pkgsrc:
                   8213: 
                   8214:         * The pkgsrc guide (this document) is a collection of chapters that
                   8215:           explain large parts of pkgsrc, but some chapters tend to be outdated.
                   8216:           Which ones they are is hard to say.
                   8217: 
1.174     leot     8218:         * On the mailing list archives (see https://mail-index.NetBSD.org/),
                   8219:           you can find discussions about certain features, announcements of new
1.1       dsieger  8220:           parts of the pkgsrc infrastructure and sometimes even announcements
                   8221:           that a certain feature has been marked as obsolete. The benefit here
                   8222:           is that each message has a date appended to it.
                   8223: 
                   8224:         * Many of the files in the mk/ directory start with a comment that
                   8225:           describes the purpose of the file and how it can be used by the
                   8226:           pkgsrc user and package authors. An easy way to find this
                   8227:           documentation is to run bmake help.
                   8228: 
                   8229:         * The CVS log messages are a rich source of information, but they tend
                   8230:           to be highly abbreviated, especially for actions that occur often.
                   8231:           Some contain a detailed description of what has changed, but they are
                   8232:           geared towards the other pkgsrc developers, not towards an average
                   8233:           pkgsrc user. They also only document changes, so if you don't know
                   8234:           what has been before, these messages may not be worth too much to
                   8235:           you.
                   8236: 
                   8237:         * Some parts of pkgsrc are only "implicitly documented", that is the
                   8238:           documentation exists only in the mind of the developer who wrote the
                   8239:           code. To get this information, use the cvs annotate command to see
                   8240:           who has written it and ask on the tech-pkg mailing list, so that
                   8241:           others can find your questions later (see above). To be sure that the
                   8242:           developer in charge reads the mail, you may CC him or her.
                   8243: 
1.154     rillig   8244: 24.9. I have a little time to kill. What shall I do?
1.1       dsieger  8245: 
                   8246:       This is not really an FAQ yet, but here's the answer anyway.
                   8247: 
                   8248:         * Run pkg_chk -N (from the pkgtools/pkg_chk package). It will tell you
                   8249:           about newer versions of installed packages that are available, but
                   8250:           not yet updated in pkgsrc.
                   8251: 
                   8252:         * Browse pkgsrc/doc/TODO ? it contains a list of suggested new packages
                   8253:           and a list of cleanups and enhancements for pkgsrc that would be nice
                   8254:           to have.
                   8255: 
1.71      wiz      8256:         * Review packages for which review was requested on the tech-pkg
                   8257:           mailing list.
1.1       dsieger  8258: 
                   8259: Part III. The pkgsrc infrastructure internals
                   8260: 
                   8261: This part of the guide deals with everything from the infrastructure that is
                   8262: behind the interfaces described in the developer's guide. A casual package
                   8263: maintainer should not need anything from this part.
                   8264: 
                   8265: Table of Contents
                   8266: 
1.184     rillig   8267: 25. Design of the pkgsrc infrastructure
1.1       dsieger  8268: 
1.184     rillig   8269:     25.1. The meaning of variable definitions
                   8270:     25.2. Avoiding problems before they arise
                   8271:     25.3. Variable evaluation
1.1       dsieger  8272: 
1.184     rillig   8273:         25.3.1. At load time
                   8274:         25.3.2. At runtime
1.1       dsieger  8275: 
1.184     rillig   8276:     25.4. How can variables be specified?
                   8277:     25.5. Designing interfaces for Makefile fragments
1.1       dsieger  8278: 
1.184     rillig   8279:         25.5.1. Procedures with parameters
                   8280:         25.5.2. Actions taken on behalf of parameters
1.1       dsieger  8281: 
1.184     rillig   8282:     25.6. The order in which files are loaded
1.1       dsieger  8283: 
1.184     rillig   8284:         25.6.1. The order in bsd.prefs.mk
                   8285:         25.6.2. The order in bsd.pkg.mk
1.1       dsieger  8286: 
1.184     rillig   8287: 26. Regression tests
1.1       dsieger  8288: 
1.184     rillig   8289:     26.1. Running the regression tests
                   8290:     26.2. Adding a new regression test
1.1       dsieger  8291: 
1.184     rillig   8292:         26.2.1. Overridable functions
                   8293:         26.2.2. Helper functions
1.1       dsieger  8294: 
1.184     rillig   8295: 27. Porting pkgsrc
1.1       dsieger  8296: 
1.184     rillig   8297:     27.1. Porting pkgsrc to a new operating system
1.1       dsieger  8298: 
1.184     rillig   8299: Chapter 25. Design of the pkgsrc infrastructure
1.1       dsieger  8300: 
                   8301: Table of Contents
                   8302: 
1.184     rillig   8303: 25.1. The meaning of variable definitions
                   8304: 25.2. Avoiding problems before they arise
                   8305: 25.3. Variable evaluation
1.1       dsieger  8306: 
1.184     rillig   8307:     25.3.1. At load time
                   8308:     25.3.2. At runtime
1.1       dsieger  8309: 
1.184     rillig   8310: 25.4. How can variables be specified?
                   8311: 25.5. Designing interfaces for Makefile fragments
1.1       dsieger  8312: 
1.184     rillig   8313:     25.5.1. Procedures with parameters
                   8314:     25.5.2. Actions taken on behalf of parameters
1.1       dsieger  8315: 
1.184     rillig   8316: 25.6. The order in which files are loaded
1.1       dsieger  8317: 
1.184     rillig   8318:     25.6.1. The order in bsd.prefs.mk
                   8319:     25.6.2. The order in bsd.pkg.mk
1.1       dsieger  8320: 
                   8321: The pkgsrc infrastructure consists of many small Makefile fragments. Each such
                   8322: fragment needs a properly specified interface. This chapter explains how such
                   8323: an interface looks like.
                   8324: 
1.184     rillig   8325: 25.1. The meaning of variable definitions
1.1       dsieger  8326: 
                   8327: Whenever a variable is defined in the pkgsrc infrastructure, the location and
                   8328: the way of definition provide much information about the intended use of that
                   8329: variable. Additionally, more documentation may be found in a header comment or
                   8330: in this pkgsrc guide.
                   8331: 
                   8332: A special file is mk/defaults/mk.conf, which lists all variables that are
                   8333: intended to be user-defined. They are either defined using the ?= operator or
                   8334: they are left undefined because defining them to anything would effectively
                   8335: mean "yes". All these variables may be overridden by the pkgsrc user in the
                   8336: MAKECONF file.
                   8337: 
                   8338: Outside this file, the following conventions apply: Variables that are defined
                   8339: using the ?= operator may be overridden by a package.
                   8340: 
                   8341: Variables that are defined using the = operator may be used read-only at
                   8342: run-time.
                   8343: 
                   8344: Variables whose name starts with an underscore must not be accessed outside the
                   8345: pkgsrc infrastructure at all. They may change without further notice.
                   8346: 
                   8347: Note
                   8348: 
                   8349: These conventions are currently not applied consistently to the complete pkgsrc
                   8350: infrastructure.
                   8351: 
1.184     rillig   8352: 25.2. Avoiding problems before they arise
1.1       dsieger  8353: 
                   8354: All variables that contain lists of things should default to being empty. Two
                   8355: examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
                   8356: variables cannot simply be modified using the += operator in package Makefiles
                   8357: (or other files included by them), since there is no guarantee whether the
                   8358: variable is already set or not, and what its value is. In the case of
                   8359: DISTFILES, the packages "know" the default value and just define it as in the
                   8360: following example.
                   8361: 
                   8362: DISTFILES=      ${DISTNAME}${EXTRACT_SUFX} additional-files.tar.gz
                   8363: 
                   8364: Because of the selection of this default value, the same value appears in many
                   8365: package Makefiles. Similarly for USE_LANGUAGES, but in this case the default
                   8366: value ("c") is so short that it doesn't stand out. Nevertheless it is mentioned
                   8367: in many files.
                   8368: 
1.184     rillig   8369: 25.3. Variable evaluation
1.1       dsieger  8370: 
1.184     rillig   8371: 25.3.1. At load time
1.1       dsieger  8372: 
                   8373: Variable evaluation takes place either at load time or at runtime, depending on
                   8374: the context in which they occur. The contexts where variables are evaluated at
                   8375: load time are:
                   8376: 
                   8377:   * The right hand side of the := and != operators,
                   8378: 
                   8379:   * Make directives like .if or .for,
                   8380: 
                   8381:   * Dependency lines.
                   8382: 
                   8383: A special exception are references to the iteration variables of .for loops,
                   8384: which are expanded inline, no matter in which context they appear.
                   8385: 
                   8386: As the values of variables may change during load time, care must be taken not
                   8387: to evaluate them by accident. Typical examples for variables that should not be
                   8388: evaluated at load time are DEPENDS and CONFIGURE_ARGS. To make the effect more
                   8389: clear, here is an example:
                   8390: 
                   8391: CONFIGURE_ARGS=         # none
                   8392: CFLAGS=                 -O
                   8393: CONFIGURE_ARGS+=        CFLAGS=${CFLAGS:Q}
                   8394: 
                   8395: CONFIGURE_ARGS:=        ${CONFIGURE_ARGS}
                   8396: 
                   8397: CFLAGS+=                -Wall
                   8398: 
                   8399: This code shows how the use of the := operator can quickly lead to unexpected
                   8400: results. The first paragraph is fairly common code. The second paragraph
                   8401: evaluates the CONFIGURE_ARGS variable, which results in CFLAGS=-O. In the third
                   8402: paragraph, the -Wall is appended to the CFLAGS, but this addition will not
                   8403: appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
                   8404: typically occur in completely unrelated files.
                   8405: 
1.184     rillig   8406: 25.3.2. At runtime
1.1       dsieger  8407: 
                   8408: After all the files have been loaded, the values of the variables cannot be
                   8409: changed anymore. Variables that are used in the shell commands are expanded at
                   8410: this point.
                   8411: 
1.184     rillig   8412: 25.4. How can variables be specified?
1.1       dsieger  8413: 
                   8414: There are many ways in which the definition and use of a variable can be
                   8415: restricted in order to detect bugs and violations of the (mostly unwritten)
1.108     rillig   8416: policies. A package can be checked with pkglint -Wall to see whether it meets
                   8417: these rules.
1.1       dsieger  8418: 
1.184     rillig   8419: 25.5. Designing interfaces for Makefile fragments
1.1       dsieger  8420: 
                   8421: Most of the .mk files fall into one of the following classes. Cases where a
                   8422: file falls into more than one class should be avoided as it often leads to
                   8423: subtle bugs.
                   8424: 
1.184     rillig   8425: 25.5.1. Procedures with parameters
1.1       dsieger  8426: 
                   8427: In a traditional imperative programming language some of the .mk files could be
1.23      jakllsch 8428: described as procedures. They take some input parameters and?after
                   8429: inclusion?provide a result in output parameters. Since all variables in
                   8430: Makefiles have global scope care must be taken not to use parameter names that
                   8431: have already another meaning. For example, PKGNAME is a bad choice for a
                   8432: parameter name.
1.1       dsieger  8433: 
                   8434: Procedures are completely evaluated at preprocessing time. That is, when
                   8435: calling a procedure all input parameters must be completely resolvable. For
                   8436: example, CONFIGURE_ARGS should never be an input parameter since it is very
                   8437: likely that further text will be added after calling the procedure, which would
                   8438: effectively apply the procedure to only a part of the variable. Also,
1.108     rillig   8439: references to other variables will be modified after calling the procedure.
1.1       dsieger  8440: 
                   8441: A procedure can declare its output parameters either as suitable for use in
                   8442: preprocessing directives or as only available at runtime. The latter
                   8443: alternative is for variables that contain references to other runtime
                   8444: variables.
                   8445: 
                   8446: Procedures shall be written such that it is possible to call the procedure more
                   8447: than once. That is, the file must not contain multiple-inclusion guards.
                   8448: 
                   8449: Examples for procedures are mk/bsd.options.mk and mk/buildlink3/bsd.builtin.mk.
                   8450: To express that the parameters are evaluated at load time, they should be
                   8451: assigned using the := operator, which should be used only for this purpose.
                   8452: 
1.184     rillig   8453: 25.5.2. Actions taken on behalf of parameters
1.1       dsieger  8454: 
                   8455: Action files take some input parameters and may define runtime variables. They
                   8456: shall not define loadtime variables. There are action files that are included
                   8457: implicitly by the pkgsrc infrastructure, while other must be included
                   8458: explicitly.
                   8459: 
                   8460: An example for action files is mk/subst.mk.
                   8461: 
1.184     rillig   8462: 25.6. The order in which files are loaded
1.1       dsieger  8463: 
                   8464: Package Makefiles usually consist of a set of variable definitions, and include
                   8465: the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
                   8466: include various other *.mk files if they need to query the availability of
                   8467: certain features like the type of compiler or the X11 implementation. Due to
                   8468: the heavy use of preprocessor directives like .if and .for, the order in which
                   8469: the files are loaded matters.
                   8470: 
                   8471: This section describes at which point the various files are loaded and gives
                   8472: reasons for that order.
                   8473: 
1.184     rillig   8474: 25.6.1. The order in bsd.prefs.mk
1.1       dsieger  8475: 
                   8476: The very first action in bsd.prefs.mk is to define some essential variables
                   8477: like OPSYS, OS_VERSION and MACHINE_ARCH.
                   8478: 
1.4       rillig   8479: Then, the user settings are loaded from the file specified in MAKECONF, which
                   8480: is usually mk.conf. After that, those variables that have not been overridden
                   8481: by the user are loaded from mk/defaults/mk.conf.
1.1       dsieger  8482: 
                   8483: After the user settings, the system settings and platform settings are loaded,
                   8484: which may override the user settings.
                   8485: 
                   8486: Then, the tool definitions are loaded. The tool wrappers are not yet in effect.
                   8487: This only happens when building a package, so the proper variables must be used
                   8488: instead of the direct tool names.
                   8489: 
                   8490: As the last steps, some essential variables from the wrapper and the package
                   8491: system flavor are loaded, as well as the variables that have been cached in
                   8492: earlier phases of a package build.
                   8493: 
1.184     rillig   8494: 25.6.2. The order in bsd.pkg.mk
1.1       dsieger  8495: 
                   8496: First, bsd.prefs.mk is loaded.
                   8497: 
                   8498: Then, the various *-vars.mk files are loaded, which fill default values for
                   8499: those variables that have not been defined by the package. These variables may
                   8500: later be used even in unrelated files.
                   8501: 
                   8502: Then, the file bsd.pkg.error.mk provides the target error-check that is added
                   8503: as a special dependency to all other targets that use DELAYED_ERROR_MSG or
                   8504: DELAYED_WARNING_MSG.
                   8505: 
                   8506: Then, the package-specific hacks from hacks.mk are included.
                   8507: 
                   8508: Then, various other files follow. Most of them don't have any dependencies on
                   8509: what they need to have included before or after them, though some do.
                   8510: 
                   8511: The code to check PKG_FAIL_REASON and PKG_SKIP_REASON is then executed, which
                   8512: restricts the use of these variables to all the files that have been included
                   8513: before. Appearances in later files will be silently ignored.
                   8514: 
                   8515: Then, the files for the main targets are included, in the order of later
                   8516: execution, though the actual order should not matter.
                   8517: 
                   8518: At last, some more files are included that don't set any interesting variables
                   8519: but rather just define make targets to be executed.
                   8520: 
1.184     rillig   8521: Chapter 26. Regression tests
1.1       dsieger  8522: 
                   8523: Table of Contents
                   8524: 
1.184     rillig   8525: 26.1. Running the regression tests
                   8526: 26.2. Adding a new regression test
1.1       dsieger  8527: 
1.184     rillig   8528:     26.2.1. Overridable functions
                   8529:     26.2.2. Helper functions
1.1       dsieger  8530: 
                   8531: The pkgsrc infrastructure consists of a large codebase, and there are many
                   8532: corners where every little bit of a file is well thought out, making pkgsrc
                   8533: likely to fail as soon as anything is changed near those parts. To prevent most
                   8534: changes from breaking anything, a suite of regression tests should go along
                   8535: with every important part of the pkgsrc infrastructure. This chapter describes
                   8536: how regression tests work in pkgsrc and how you can add new tests.
                   8537: 
1.184     rillig   8538: 26.1. Running the regression tests
1.1       dsieger  8539: 
1.25      wiz      8540: You first need to install the pkgtools/pkg_regress package, which provides the 
1.1       dsieger  8541: pkg_regress command. Then you can simply run that command, which will run all
1.168     rillig   8542: tests in the regress/ directory.
1.1       dsieger  8543: 
1.184     rillig   8544: 26.2. Adding a new regression test
1.1       dsieger  8545: 
1.168     rillig   8546: Every directory in the regress/ directory that contains a file called spec is
1.1       dsieger  8547: considered a regression test. This file is a shell program that is included by
                   8548: the pkg_regress command. The following functions can be overridden to suit your
                   8549: needs.
                   8550: 
1.184     rillig   8551: 26.2.1. Overridable functions
1.1       dsieger  8552: 
1.108     rillig   8553: These functions do not take any parameters. Although they are called in "set -e
1.168     rillig   8554: " mode, they don't stop at the first failing command. See this Stack Overflow
1.108     rillig   8555: question for details.
1.1       dsieger  8556: 
1.108     rillig   8557: do_setup
1.1       dsieger  8558: 
                   8559:     This function prepares the environment for the test. By default it does
                   8560:     nothing.
                   8561: 
1.108     rillig   8562: do_test
1.1       dsieger  8563: 
                   8564:     This function runs the actual test. By default, it calls TEST_MAKE with the
                   8565:     arguments MAKEARGS_TEST and writes its output including error messages into
                   8566:     the file TEST_OUTFILE.
                   8567: 
1.108     rillig   8568:     When defining this function, make sure that all output that needs to be
                   8569:     checked is written to the correct output file. Example:
                   8570: 
                   8571:     do_test() {
                   8572:             echo "Example output"
                   8573:     } 1>$TEST_OUTFILE 2>&1
                   8574: 
                   8575: check_result
1.1       dsieger  8576: 
                   8577:     This function is run after the test and is typically used to compare the
                   8578:     actual output from the one that is expected. It can make use of the various
1.108     rillig   8579:     helper functions from the next section. Example:
                   8580: 
                   8581:     check_result() {
                   8582:             exit_status 0
                   8583:             output_require "Example"
                   8584:             output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
                   8585:             output_prohibit "no such file or directory"
1.169     rillig   8586:             regress_fail "expected $expected but got $actual for input $input"
1.108     rillig   8587:     }
1.1       dsieger  8588: 
1.108     rillig   8589: do_cleanup
1.1       dsieger  8590: 
                   8591:     This function cleans everything up after the test has been run. By default
                   8592:     it does nothing.
                   8593: 
1.184     rillig   8594: 26.2.2. Helper functions
1.1       dsieger  8595: 
1.168     rillig   8596: regress_fail message...
                   8597: 
                   8598:     This function makes the test fail with the given error message.
                   8599: 
1.108     rillig   8600: exit_status expected
1.1       dsieger  8601: 
1.108     rillig   8602:     This function compares the exitcode of the do_test function with its first
                   8603:     parameter. If they differ, the test will fail.
1.1       dsieger  8604: 
1.108     rillig   8605: output_require regex...
1.1       dsieger  8606: 
                   8607:     This function checks for each of its parameters if the output from do_test
1.108     rillig   8608:     matches the extended regular expression. If it does not, the test will
                   8609:     fail. Example:
                   8610: 
                   8611:     output_require "looks fine"
                   8612:     output_require "^[[:alpha:]+[[:space:]][[:alpha:]]{6}$"
1.1       dsieger  8613: 
1.177     leot     8614: output_prohibit regex...
1.1       dsieger  8615: 
                   8616:     This function checks for each of its parameters if the output from do_test
                   8617:     () does not match the extended regular expression. If any of the regular
                   8618:     expressions matches, the test will fail.
                   8619: 
1.184     rillig   8620: Chapter 27. Porting pkgsrc
1.1       dsieger  8621: 
                   8622: Table of Contents
                   8623: 
1.184     rillig   8624: 27.1. Porting pkgsrc to a new operating system
1.1       dsieger  8625: 
                   8626: The pkgsrc system has already been ported to many operating systems, hardware
                   8627: architectures and compilers. This chapter explains the necessary steps to make
                   8628: pkgsrc even more portable.
                   8629: 
1.184     rillig   8630: 27.1. Porting pkgsrc to a new operating system
1.1       dsieger  8631: 
                   8632: To port pkgsrc to a new operating system (called MyOS in this example), you
                   8633: need to touch the following files:
                   8634: 
                   8635: pkgtools/bootstrap-mk-files/files/mods/MyOS.sys.mk
                   8636: 
                   8637:     This file contains some basic definitions, for example the name of the C
                   8638:     compiler.
                   8639: 
                   8640: mk/bsd.prefs.mk
                   8641: 
                   8642:     Insert code that defines the variables OPSYS, OS_VERSION, LOWER_OS_VERSION,
                   8643:     LOWER_VENDOR, MACHINE_ARCH, OBJECT_FMT, APPEND_ELF, and the other variables
                   8644:     that appear in this file.
                   8645: 
                   8646: mk/platform/MyOS.mk
                   8647: 
                   8648:     This file contains the platform-specific definitions that are used by
                   8649:     pkgsrc. Start by copying one of the other files and edit it to your needs.
                   8650: 
                   8651: mk/tools/tools.MyOS.mk
                   8652: 
                   8653:     This file defines the paths to all the tools that are needed by one or the
                   8654:     other package in pkgsrc, as well as by pkgsrc itself. Find out where these
                   8655:     tools are on your platform and add them.
                   8656: 
                   8657: Now, you should be able to build some basic packages, like lang/perl5, shells/
                   8658: bash.
                   8659: 
                   8660: Appendix A. A simple example package: bison
                   8661: 
                   8662: Table of Contents
                   8663: 
                   8664: A.1. files
                   8665: 
                   8666:     A.1.1. Makefile
                   8667:     A.1.2. DESCR
                   8668:     A.1.3. PLIST
                   8669:     A.1.4. Checking a package with pkglint
                   8670: 
                   8671: A.2. Steps for building, installing, packaging
                   8672: 
                   8673: We checked to find a piece of software that wasn't in the packages collection,
1.25      wiz      8674: and picked GNU bison. Quite why someone would want to have bison when Berkeley 
1.1       dsieger  8675: yacc is already present in the tree is beyond us, but it's useful for the
                   8676: purposes of this exercise.
                   8677: 
                   8678: A.1. files
                   8679: 
                   8680: A.1.1. Makefile
                   8681: 
1.2       rillig   8682: # $NetBSD$
1.1       dsieger  8683: #
                   8684: 
                   8685: DISTNAME=       bison-1.25
                   8686: CATEGORIES=     devel
1.171     rillig   8687: MASTER_SITES=   ${MASTER_SITE_GNU:=bison/}
1.1       dsieger  8688: 
1.30      dholland 8689: MAINTAINER=     pkgsrc-users@NetBSD.org
1.174     leot     8690: HOMEPAGE=       https://www.gnu.org/software/bison/bison.html
1.1       dsieger  8691: COMMENT=        GNU yacc clone
                   8692: 
                   8693: GNU_CONFIGURE=  yes
1.47      wiz      8694: INFO_FILES=     yes
1.1       dsieger  8695: 
                   8696: .include "../../mk/bsd.pkg.mk"
                   8697: 
                   8698: A.1.2. DESCR
                   8699: 
                   8700: GNU version of yacc.  Can make re-entrant parsers, and numerous other
                   8701: improvements.  Why you would want this when Berkeley yacc(1) is part
                   8702: of the NetBSD source tree is beyond me.
                   8703: 
                   8704: A.1.3. PLIST
                   8705: 
1.2       rillig   8706: @comment $NetBSD$
1.1       dsieger  8707: bin/bison
                   8708: man/man1/bison.1.gz
                   8709: share/bison.simple
                   8710: share/bison.hairy
                   8711: 
                   8712: A.1.4. Checking a package with pkglint
                   8713: 
                   8714: The NetBSD package system comes with pkgtools/pkglint which helps to check the
                   8715: contents of these files. After installation it is quite easy to use, just
1.171     rillig   8716: change to the directory of the package you wish to examine and run pkglint:
1.1       dsieger  8717: 
                   8718: $ pkglint
1.171     rillig   8719: ERROR: Makefile: Each package must define its LICENSE.
                   8720: WARN: Makefile:9: HOMEPAGE should migrate from http to https.
                   8721: NOTE: PLIST:3: The .gz extension is unnecessary for manual pages.
                   8722: WARN: PLIST:5: "share/bison.hairy" should be sorted before "share/bison.simple".
                   8723: 1 error, 2 warnings and 1 note found.
                   8724: (Run "pkglint -e" to show explanations.)
                   8725: (Run "pkglint -fs" to show what can be fixed automatically.)
1.172     rillig   8726: (Run "pkglint -F" to automatically fix some issues.)
1.1       dsieger  8727: 
                   8728: Depending on the supplied command line arguments (see pkglint(1)), more checks
1.170     rillig   8729: will be performed. Use e.g. pkglint -Wall for a very thorough check.
1.1       dsieger  8730: 
                   8731: A.2. Steps for building, installing, packaging
                   8732: 
                   8733: Create the directory where the package lives, plus any auxiliary directories:
                   8734: 
                   8735: # cd /usr/pkgsrc/lang
                   8736: # mkdir bison
                   8737: # cd bison
                   8738: # mkdir patches
                   8739: 
1.184     rillig   8740: Create Makefile, DESCR and PLIST (see Chapter 12, Package components - files,
1.1       dsieger  8741: directories and contents) then continue with fetching the distfile:
                   8742: 
                   8743: # make fetch
                   8744: >> bison-1.25.tar.gz doesn't seem to exist on this system.
                   8745: >> Attempting to fetch from ftp://prep.ai.mit.edu/pub/gnu//.
                   8746: Requesting ftp://prep.ai.mit.edu/pub/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8747: ftp: Error retrieving file: 500 Internal error
                   8748: 
                   8749: >> Attempting to fetch from ftp://wuarchive.wustl.edu/systems/gnu//.
                   8750: Requesting ftp://wuarchive.wustl.edu/systems/gnu//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8751: ftp: Error retrieving file: 500 Internal error
                   8752: 
                   8753: >> Attempting to fetch from ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//.
                   8754: Requesting ftp://ftp.freebsd.org/pub/FreeBSD/distfiles//bison-1.25.tar.gz (via ftp://orpheus.amdahl.com:80/)
                   8755: Successfully retrieved file.
                   8756: 
                   8757: Generate the checksum of the distfile into distinfo:
                   8758: 
                   8759: # make makedistinfo
                   8760: 
                   8761: Now compile:
                   8762: 
                   8763: # make
                   8764: >> Checksum OK for bison-1.25.tar.gz.
                   8765: ===>  Extracting for bison-1.25
                   8766: ===>  Patching for bison-1.25
                   8767: ===>   Ignoring empty patch directory
                   8768: ===>  Configuring for bison-1.25
                   8769: creating cache ./config.cache
                   8770: checking for gcc... cc
                   8771: checking whether we are using GNU C... yes
                   8772: checking for a BSD compatible install... /usr/bin/install -c -o bin -g bin
                   8773: checking how to run the C preprocessor... cc -E
                   8774: checking for minix/config.h... no
                   8775: checking for POSIXized ISC... no
                   8776: checking whether cross-compiling... no
                   8777: checking for ANSI C header files... yes
                   8778: checking for string.h... yes
                   8779: checking for stdlib.h... yes
                   8780: checking for memory.h... yes
                   8781: checking for working const... yes
                   8782: checking for working alloca.h... no
                   8783: checking for alloca... yes
                   8784: checking for strerror... yes
                   8785: updating cache ./config.cache
                   8786: creating ./config.status
                   8787: creating Makefile
                   8788: ===>  Building for bison-1.25
                   8789: 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
                   8790: 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
                   8791: 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
                   8792: 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
                   8793: 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
                   8794: 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
                   8795: 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
                   8796: 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
                   8797: 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
                   8798: 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
                   8799: 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
                   8800: 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
                   8801: 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
                   8802: 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
                   8803: 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
                   8804: 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
                   8805: 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
                   8806: 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
                   8807: 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
                   8808: 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
                   8809: 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
                   8810: 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
                   8811: ./files.c:240: warning: mktemp() possibly used unsafely, consider using mkstemp()
                   8812: rm -f bison.s1
                   8813: sed -e "/^#line/ s|bison|/usr/pkg/share/bison|" < ./bison.simple > bison.s1
                   8814: 
                   8815: Everything seems OK, so install the files:
                   8816: 
                   8817: # make install
                   8818: >> Checksum OK for bison-1.25.tar.gz.
                   8819: ===>  Installing for bison-1.25
                   8820: sh ./mkinstalldirs /usr/pkg/bin /usr/pkg/share  /usr/pkg/info /usr/pkg/man/man1
                   8821: rm -f /usr/pkg/bin/bison
                   8822: cd /usr/pkg/share; rm -f bison.simple bison.hairy
                   8823: rm -f /usr/pkg/man/man1/bison.1 /usr/pkg/info/bison.info*
                   8824: install -c  -o bin -g bin -m 555 bison /usr/pkg/bin/bison
                   8825: /usr/bin/install -c -o bin -g bin -m 644 bison.s1 /usr/pkg/share/bison.simple
                   8826: /usr/bin/install -c -o bin -g bin -m 644 ./bison.hairy /usr/pkg/share/bison.hairy
                   8827: cd .; for f in bison.info*;  do /usr/bin/install -c -o bin -g bin -m 644 $f /usr/pkg/info/$f; done
                   8828: /usr/bin/install -c -o bin -g bin -m 644 ./bison.1 /usr/pkg/man/man1/bison.1
                   8829: ===>  Registering installation for bison-1.25
                   8830: 
                   8831: You can now use bison, and also - if you decide so - remove it with pkg_delete
                   8832: bison. Should you decide that you want a binary package, do this now:
                   8833: 
                   8834: # make package
                   8835: >> Checksum OK for bison-1.25.tar.gz.
                   8836: ===>  Building package for bison-1.25
                   8837: Creating package bison-1.25.tgz
                   8838: Registering depends:.
                   8839: Creating gzip'd tar ball in '/u/pkgsrc/lang/bison/bison-1.25.tgz'
                   8840: 
                   8841: Now that you don't need the source and object files any more, clean up:
                   8842: 
                   8843: # make clean
                   8844: ===>  Cleaning for bison-1.25
                   8845: 
                   8846: Appendix B. Build logs
                   8847: 
                   8848: Table of Contents
                   8849: 
                   8850: B.1. Building figlet
                   8851: B.2. Packaging figlet
                   8852: 
                   8853: B.1. Building figlet
                   8854: 
                   8855: # make
                   8856: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   8857: => figlet221.tar.gz doesn't seem to exist on this system.
                   8858: => Attempting to fetch figlet221.tar.gz from ftp://ftp.figlet.org/pub/figlet/program/unix/.
                   8859: => [172219 bytes]
                   8860: Connected to ftp.plig.net.
                   8861: 220 ftp.plig.org NcFTPd Server (licensed copy) ready.
                   8862: 331 Guest login ok, send your complete e-mail address as password.
                   8863: 230-You are user #5 of 500 simultaneous users allowed.
                   8864: 230-
                   8865: 230-  ___ _             _ _
                   8866: 230- |  _| |_ ___   ___| |_|___   ___ ___ ___
                   8867: 230- |  _|  _| . |_| . | | | . |_| . |  _| . |
                   8868: 230- |_| |_| |  _|_|  _|_|_|_  |_|___|_| |_  |
                   8869: 230-         |_|   |_|     |___|         |___|
                   8870: 230-
                   8871: 230-** Welcome to ftp.plig.org **
                   8872: 230-
                   8873: 230-Please note that all transfers from this FTP site are logged. If you
                   8874: 230-do not like this, please disconnect now.
                   8875: 230-
1.19      snj      8876: 230-This archive is available via
1.1       dsieger  8877: 230-
                   8878: 230-HTTP:  http://ftp.plig.org/
                   8879: 230-FTP:   ftp://ftp.plig.org/     (max 500 connections)
                   8880: 230-RSYNC: rsync://ftp.plig.org/   (max  30 connections)
                   8881: 230-
                   8882: 230-Please email comments, bug reports and requests for packages to be
                   8883: 230-mirrored to ftp-admin@plig.org.
                   8884: 230-
                   8885: 230-
                   8886: 230 Logged in anonymously.
                   8887: Remote system type is UNIX.
                   8888: Using binary mode to transfer files.
                   8889: 200 Type okay.
                   8890: 250 "/pub" is new cwd.
                   8891: 250-"/pub/figlet" is new cwd.
                   8892: 250-
                   8893: 250-Welcome to the figlet archive at ftp.figlet.org
                   8894: 250-
                   8895: 250-    ftp://ftp.figlet.org/pub/figlet/
                   8896: 250-
                   8897: 250-The official FIGlet web page is:
                   8898: 250-    http://www.figlet.org/
                   8899: 250-
                   8900: 250-If you have questions, please mailto:info@figlet.org. If you want to
                   8901: 250-contribute a font or something else, you can email us.
                   8902: 250
                   8903: 250 "/pub/figlet/program" is new cwd.
                   8904: 250 "/pub/figlet/program/unix" is new cwd.
                   8905: local: figlet221.tar.gz remote: figlet221.tar.gz
                   8906: 502 Unimplemented command.
                   8907: 227 Entering Passive Mode (195,40,6,41,246,104)
                   8908: 150 Data connection accepted from 84.128.86.72:65131; transfer starting for figlet221.tar.gz (172219 bytes).
                   8909: 38% |**************                       | 65800      64.16 KB/s    00:01 ETA
                   8910: 226 Transfer completed.
                   8911: 172219 bytes received in 00:02 (75.99 KB/s)
                   8912: 221 Goodbye.
                   8913: => Checksum OK for figlet221.tar.gz.
                   8914: ===> Extracting for figlet-2.2.1nb2
                   8915: ===> Required installed package ccache-[0-9]*: ccache-2.3nb1 found
                   8916: ===> Patching for figlet-2.2.1nb2
                   8917: ===> Applying pkgsrc patches for figlet-2.2.1nb2
                   8918: ===> Overriding tools for figlet-2.2.1nb2
                   8919: ===> Creating toolchain wrappers for figlet-2.2.1nb2
                   8920: ===> Configuring for figlet-2.2.1nb2
                   8921: ===> Building for figlet-2.2.1nb2
                   8922: gcc -O2 -DDEFAULTFONTDIR=\"/usr/pkg/share/figlet\"  -DDEFAULTFONTFILE=\"standard.flf\"  figlet.c zipio.c crc.c inflate.c -o figlet
                   8923: chmod a+x figlet
                   8924: gcc -O2 -o chkfont chkfont.c
                   8925: => Unwrapping files-to-be-installed.
                   8926: #
                   8927: # make install
                   8928: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   8929: ===> Installing for figlet-2.2.1nb2
                   8930: install -d -o root -g wheel -m 755 /usr/pkg/bin
                   8931: install -d -o root -g wheel -m 755 /usr/pkg/man/man6
                   8932: mkdir -p /usr/pkg/share/figlet
                   8933: cp figlet /usr/pkg/bin
                   8934: cp chkfont /usr/pkg/bin
                   8935: chmod 555 figlist showfigfonts
                   8936: cp figlist /usr/pkg/bin
                   8937: cp showfigfonts /usr/pkg/bin
                   8938: cp fonts/*.flf /usr/pkg/share/figlet
                   8939: cp fonts/*.flc /usr/pkg/share/figlet
                   8940: cp figlet.6 /usr/pkg/man/man6
                   8941: ===> Registering installation for figlet-2.2.1nb2
                   8942: #
                   8943: 
                   8944: B.2. Packaging figlet
                   8945: 
                   8946: # make package
                   8947: ===> Checking for vulnerabilities in figlet-2.2.1nb2
                   8948: ===> Packaging figlet-2.2.1nb2
                   8949: ===> Building binary package for figlet-2.2.1nb2
                   8950: Creating package /home/cvs/pkgsrc/packages/i386/All/figlet-2.2.1nb2.tgz
                   8951: Using SrcDir value of /usr/pkg
                   8952: Registering depends:.
                   8953: #
                   8954: 
                   8955: Appendix C. Directory layout of the pkgsrc FTP server
                   8956: 
                   8957: Table of Contents
                   8958: 
1.23      jakllsch 8959: C.1. distfiles: The distributed source files
                   8960: C.2. misc: Miscellaneous things
                   8961: C.3. packages: Binary packages
                   8962: C.4. reports: Bulk build reports
1.148     leot     8963: C.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  8964: 
                   8965: As in other big projects, the directory layout of pkgsrc is quite complex for
                   8966: newbies. This chapter explains where you find things on the FTP server. The
                   8967: base directory on ftp.NetBSD.org is /pub/pkgsrc/. On other servers it may be
                   8968: different, but inside this directory, everything should look the same, no
                   8969: matter on which server you are. This directory contains some subdirectories,
                   8970: which are explained below.
                   8971: 
1.23      jakllsch 8972: C.1. distfiles: The distributed source files
1.1       dsieger  8973: 
                   8974: The directory distfiles contains lots of archive files from all pkgsrc
                   8975: packages, which are mirrored here. The subdirectories are called after their
                   8976: package names and are used when the distributed files have names that don't
                   8977: explicitly contain a version number or are otherwise too generic (for example
                   8978: release.tar.gz).
                   8979: 
1.23      jakllsch 8980: C.2. misc: Miscellaneous things
1.1       dsieger  8981: 
                   8982: This directory contains things that individual pkgsrc developers find worth
                   8983: publishing.
                   8984: 
1.23      jakllsch 8985: C.3. packages: Binary packages
1.1       dsieger  8986: 
1.3       rillig   8987: This directory contains binary packages for the various platforms that are
                   8988: supported by pkgsrc. Each subdirectory is of the form OPSYS/ARCH/OSVERSION_TAG.
                   8989: The meaning of these variables is:
                   8990: 
                   8991:   * OPSYS is the name of the operating system for which the packages have been
1.9       rillig   8992:     built. The name is taken from the output of the uname command, so it may
                   8993:     differ from the one you are used to hear.
1.3       rillig   8994: 
1.8       rillig   8995:   * ARCH is the hardware architecture of the platform for which the packages
1.10      hubertf  8996:     have been built. It also includes the ABI (Application Binary Interface)
                   8997:     for platforms that have several of them.
1.3       rillig   8998: 
1.8       rillig   8999:   * OSVERSION is the version of the operating system. For version numbers that
                   9000:     change often (for example NetBSD-current), the often-changing part should
                   9001:     be replaced with an x, for example 4.99.x.
1.3       rillig   9002: 
1.23      jakllsch 9003:   * TAG is either 20xxQy for a stable branch, or head for packages built from
1.8       rillig   9004:     the HEAD branch. The latter should only be used when the packages are
                   9005:     updated on a regular basis. Otherwise the date from checking out pkgsrc
                   9006:     should be appended, for example head_20071015.
1.3       rillig   9007: 
                   9008: The rationale for exactly this scheme is that the pkgsrc users looking for
                   9009: binary packages can quickly click through the directories on the server and
                   9010: find the best binary packages for their machines. Since they usually know the
                   9011: operating system and the hardware architecture, OPSYS and ARCH are placed
                   9012: first. After these choices, they can select the best combination of OSVERSION
                   9013: and TAG together, since it is usually the case that packages stay compatible
                   9014: between different version of the operating system.
                   9015: 
                   9016: In each of these directories, there is a whole binary packages collection for a
                   9017: specific platform. It has a directory called All which contains all binary
                   9018: packages. Besides that, there are various category directories that contain
                   9019: symbolic links to the real binary packages.
1.1       dsieger  9020: 
1.23      jakllsch 9021: C.4. reports: Bulk build reports
1.8       rillig   9022: 
                   9023: Here are the reports from bulk builds, for those who want to fix packages that
                   9024: didn't build on some of the platforms. The structure of subdirectories should
1.23      jakllsch 9025: look like the one in Section C.3, "packages: Binary packages".
1.8       rillig   9026: 
1.148     leot     9027: C.5. current, stable, pkgsrc-20xxQy: source packages
1.1       dsieger  9028: 
                   9029: These directories contain the "real" pkgsrc, that is the files that define how
                   9030: to create binary packages from source archives.
                   9031: 
1.149     leot     9032: Each of the current, stable and pkgsrc-20xxQy directories share the same
                   9033: structure. They each contain a pkgsrc directory and pkgsrc.tar.{bz,gz,xz} file.
                   9034: 
1.1       dsieger  9035: The directory pkgsrc contains a snapshot of the CVS repository, which is
1.149     leot     9036: updated regularly. The file pkgsrc.tar.{bz,gz,xz} contains the same as the
                   9037: directory, ready to be downloaded as a whole.
1.1       dsieger  9038: 
1.149     leot     9039: The current directory contains files related to the HEAD branch of the CVS
                   9040: repository. In this directory there is an additional file called
                   9041: pkgsrc-readmes.tar.{bz,gz,xz} that contains all pkgsrc READMEs with information
                   9042: about categories and packages.
                   9043: 
                   9044: The stable directory is a symlink to the latest pkgsrc-20xxQy.
                   9045: 
                   9046: The pkgsrc-20xxQy. directories contain files related to the -20xxQy stable
                   9047: branch of the CVS repository. In these directories there is an additional file
                   9048: called pkgsrc-20xxQy.tar.{bz,gz,xz}, which contains the state of pkgsrc when it
                   9049: was branched.
1.148     leot     9050: 
1.154     rillig   9051: Appendix D. Help topics
                   9052: 
                   9053: The following list contains all help topics that are available when running 
                   9054: bmake help topic=:index.
                   9055: 
1.180     rillig   9056: #!                               -lintl
                   9057: 64bit                            ABI
                   9058: ACCEPTABLE_LICENSES              ACROREAD_FONTPATH
                   9059: ADDITIONAL                       AFAIK
                   9060: AIX                              ALLOW_VULNERABLE_PACKAGES
                   9061: ALL_ENV                          ALSA_PC
                   9062: ALTERNATIVES_SRC                 AMANDA_TMP
                   9063: AMANDA_USER                      AMANDA_VAR
                   9064: APACHE_GROUP                     APACHE_MODULE_NAME
                   9065: APACHE_MODULE_SRC                APACHE_MODULE_SRCDIR
                   9066: APACHE_PKG_PREFIX                APACHE_SUEXEC_CONFIGURE_ARGS
                   9067: APACHE_SUEXEC_DOCROOT            APACHE_USER
                   9068: APPEND_ABI                       APPEND_ELF
                   9069: ARLA_CACHE                       AUDIT_PACKAGES_FLAGS
                   9070: AUTOCONF_REQD                    AUTOMAKE_OVERRIDE
                   9071: AUTOMAKE_REQD                    AUTO_MKDIRS
                   9072: BDB185_DEFAULT                   BDBBASE
                   9073: BDB_ACCEPTED                     BDB_DEFAULT
                   9074: BDB_LIBS                         BDB_TYPE
                   9075: BIND_DIR                         BIND_GROUP
                   9076: BIND_USER                        BINPKG_SITES
                   9077: BIN_INSTALL_FLAGS                BISON_PKGDATADIR
                   9078: BLAS_ACCEPTED                    BLAS_LIBS
                   9079: BLAS_TYPE                        BOOTSTRAP_DEPENDS
                   9080: BOOTSTRAP_SETUPTOOLS             BROKEN
                   9081: BROKEN_EXCEPT_ON_PLATFORM        BROKEN_ON_PLATFORM
                   9082: BSDSRCDIR                        BSDXSRCDIR
                   9083: BSD_MAKE_ENV                     BUILDLINK_AUTO_DIRS
                   9084: BUILDLINK_AUTO_VARS              BUILDLINK_CFLAGS
                   9085: BUILDLINK_CONTENTS_FILTER        BUILDLINK_CPPFLAGS
                   9086: BUILDLINK_DEPMETHOD              BUILDLINK_FILES
                   9087: BUILDLINK_FILES_CMD              BUILDLINK_FNAME_TRANSFORM
                   9088: BUILDLINK_LDFLAGS                BUILDLINK_LIBS
                   9089: BUILDLINK_OPSYS_SUPPORT_PTHREAD  BUILDLINK_PKGNAME
                   9090: BUILDLINK_PREFIX                 BUILDLINK_RPATHDIRS
                   9091: BUILDLINK_TREE                   BUILD_DEFS
                   9092: BUILD_DEFS_EFFECTS               BUILD_DEPENDS
                   9093: BUILD_DIRS                       BUILD_ENV_SHELL
                   9094: BUILD_MAKE_CMD                   BUILD_MAKE_FLAGS
                   9095: BUILD_TARGET                     BUILTIN_FIND_FILES
                   9096: BUILTIN_FIND_FILES_VAR           BUILTIN_FIND_GREP
                   9097: BUILTIN_FIND_HEADERS             BUILTIN_FIND_HEADERS_VAR
                   9098: BUILTIN_PKG                      BUILTIN_TEST_CURSES_DEFINES
                   9099: BUILTIN_TEST_CURSES_FUNCS        BUILTIN_VERSION_SCRIPT
                   9100: BUILTIN_X11_TYPE                 BUILTIN_X11_VERSION
                   9101: CACTI_GROUP                      CACTI_USER
                   9102: CANNA_GROUP                      CANNA_USER
                   9103: CAT                              CCACHE_BASE
                   9104: CCACHE_DIR                       CCACHE_LOGFILE
                   9105: CC_VERSION                       CC_VERSION_STRING
                   9106: CDRECORD_CONF                    CDROM_PKG_URL_DIR
                   9107: CDROM_PKG_URL_HOST               CHECKOUT_DATE
                   9108: CHECK_COMPILER                   CHECK_FAKEHOME
                   9109: CHECK_FILES                      CHECK_FILES_SKIP
                   9110: CHECK_FILES_STRICT               CHECK_HEADERS
                   9111: CHECK_HEADERS_SKIP               CHECK_INTERPRETER
                   9112: CHECK_INTERPRETER_SKIP           CHECK_PERMS
                   9113: CHECK_PERMS_AUTOFIX              CHECK_PERMS_SKIP
                   9114: CHECK_PORTABILITY                CHECK_PORTABILITY_EXPERIMENTAL
                   9115: CHECK_PORTABILITY_SKIP           CHECK_RELRO
                   9116: CHECK_RELRO_SKIP                 CHECK_RELRO_SUPPORTED
                   9117: CHECK_SHLIBS                     CHECK_SHLIBS_BLACKLIST
                   9118: CHECK_SHLIBS_SKIP                CHECK_SHLIBS_SUPPORTED
                   9119: CHECK_SSP                        CHECK_SSP_SKIP
                   9120: CHECK_SSP_SUPPORTED              CHECK_STRIPPED
                   9121: CHECK_STRIPPED_SKIP              CHECK_WRKREF
                   9122: CHECK_WRKREF_EXTRA_DIRS          CHECK_WRKREF_SKIP
                   9123: CLAMAV_DBDIR                     CLAMAV_GROUP
                   9124: CLAMAV_USER                      CLANGBASE
                   9125: CLEANDEPENDS                     CMAKE_DEPENDENCIES_REWRITE
                   9126: CMAKE_INSTALL_PREFIX             CMAKE_MODULE_PATH_OVERRIDE
                   9127: CMAKE_PKGSRC_BUILD_FLAGS         CMAKE_PREFIX_PATH
                   9128: CMAKE_USE_GNU_INSTALL_DIRS       COMMON_LISP_DOCFILES
                   9129: COMMON_LISP_EXAMPLES             COMMON_LISP_EXTRAFILES
                   9130: COMMON_LISP_PACKAGES             COMMON_LISP_SYSTEM
                   9131: COMPILER_RPATH_FLAG              COMPILER_USE_SYMLINKS
                   9132: CONFIGURE_ARGS                   CONFIGURE_DIRS
                   9133: CONFIGURE_ENV                    CONFIGURE_ENV_SHELL
                   9134: CONFIGURE_HAS_INFODIR            CONFIGURE_HAS_MANDIR
                   9135: CONFIGURE_SCRIPT                 CONFIG_SHELL
                   9136: CONFIG_SHELL_FLAGS               CONF_FILES
                   9137: CONF_FILES_MODE                  CONF_FILES_PERMS
                   9138: CONSERVER_DEFAULTHOST            CONSERVER_DEFAULTPORT
                   9139: CP                               CPP
                   9140: CPP_PRECOMP_FLAGS                CREATE_WRKDIR_SYMLINK
                   9141: CROSSBASE                        CTFCONVERT
                   9142: CTF_FILES_SKIP                   CTF_SUPPORTED
                   9143: CTYPE                            CUPS_GROUP
                   9144: CUPS_SYSTEM_GROUPS               CUPS_USER
                   9145: CURSES_DEFAULT                   CURSES_TYPE
                   9146: CVS_EXTRACTDIR                   CVS_MODULE
                   9147: CVS_PROJECT                      CVS_REPOSITORIES
                   9148: CVS_ROOT                         CVS_ROOT_GNU
                   9149: CVS_ROOT_NONGNU                  CVS_ROOT_SOURCEFORGE
                   9150: CVS_TAG                          CXX
                   9151: CYRUS_GROUP                      CYRUS_IDLE
                   9152: CYRUS_USER                       DAEMONTOOLS_GROUP
                   9153: DAEMONTOOLS_LOG_USER             DBUS_GROUP
                   9154: DBUS_USER                        DEFANG_GROUP
                   9155: DEFANG_USER                      DEFAULT_ACCEPTABLE_LICENSES
                   9156: DEFAULT_DISTFILES                DEFAULT_IRC_SERVER
                   9157: DEFAULT_SERIAL_DEVICE            DEF_UMASK
                   9158: DEINSTALLDEPENDS                 DEINSTALL_SRC
                   9159: DEINSTALL_TEMPLATES              DELAYED_ERROR_MSG
                   9160: DELAYED_WARNING_MSG              DEPENDS
                   9161: DEPENDS_TARGET                   DEPENDS_TYPE
                   9162: DESTDIR                          DESTDIR_VARNAME
                   9163: DIALER_GROUP                     DIGEST_REQD
                   9164: DISTDIR                          DISTFILES
                   9165: DISTINFO_FILE                    DISTNAME
                   9166: DIST_PATH                        DIST_SUBDIR
                   9167: DJBDNS_AXFR_USER                 DJBDNS_CACHE_USER
                   9168: DJBDNS_DJBDNS_GROUP              DJBDNS_LOG_USER
                   9169: DJBDNS_RBL_USER                  DJBDNS_TINY_USER
                   9170: DLOPEN_REQUIRE_PTHREADS          DL_AUTO_VARS
                   9171: DL_CFLAGS                        DL_LDFLAGS
                   9172: DL_LIBS                          DNS
                   9173: DOWNLOADED_DISTFILE              DT_LAYOUT
                   9174: DYNAMIC_SITES_CMD                DYNAMIC_SITES_SCRIPT
                   9175: ECHO                             ECHO_N
                   9176: ELK_GUI                          EMACS_TYPE
                   9177: EMULDIR                          EMULSUBDIR
                   9178: EMULSUBDIRSLASH                  EMUL_ARCH
                   9179: EMUL_DISTRO                      EMUL_EXEC_FMT
                   9180: EMUL_IS_NATIVE                   EMUL_MODULES
                   9181: EMUL_OPSYS                       EMUL_PKG_FMT
                   9182: EMUL_PLATFORM                    EMUL_PLATFORMS
                   9183: EMUL_PREFER                      EMUL_REQD
                   9184: EMUL_TYPE                        ERROR_MSG
                   9185: EXIM_GROUP                       EXIM_USER
                   9186: EXPORT_SYMBOLS_LDFLAGS           EXTRACTOR
                   9187: EXTRACT_CMD                      EXTRACT_CMD_DEFAULT
                   9188: EXTRACT_DIR                      EXTRACT_ELEMENTS
                   9189: EXTRACT_ENV                      EXTRACT_ONLY
                   9190: EXTRACT_OPTS                     EXTRACT_SUFX
                   9191: EXTRACT_USING                    FAIL
                   9192: FAILOVER_FETCH                   FAIL_MSG
                   9193: FAKE_NCURSES                     FAM
                   9194: FAM_ACCEPTED                     FAM_DEFAULT
                   9195: FAM_SERVER                       FCPATH
                   9196: FEATURE_CPPFLAGS                 FEATURE_LDFLAGS
                   9197: FEATURE_LIBS                     FETCH_AFTER_ARGS
                   9198: FETCH_BEFORE_ARGS                FETCH_CMD
                   9199: FETCH_OUTPUT_ARGS                FETCH_PROXY
                   9200: FETCH_RESUME_ARGS                FETCH_USING
                   9201: FILES_SUBST                      FILES_SUBST_SED
                   9202: FIX_SYSTEM_HEADERS               FLUXBOX_USE_GNOME
                   9203: FLUXBOX_USE_KDE                  FLUXBOX_USE_XFT
                   9204: FLUXBOX_USE_XINERAMA             FONTDIR
                   9205: FONTS_DIRS                       FONTS_VERBOSE
                   9206: FOO_HACKS_MK                     FOSSIL_EXTRACTDIR
                   9207: FOSSIL_REPO                      FOSSIL_REPOSITORIES
                   9208: FOSSIL_VERSION                   FOX_USE_XUNICODE
                   9209: FREEWNN_GROUP                    FREEWNN_USER
                   9210: FTP_PKG_URL_DIR                  FTP_PKG_URL_HOST
                   9211: GAMEDATAMODE                     GAMEDATA_PERMS
                   9212: GAMEDIRMODE                      GAMEDIR_PERMS
                   9213: GAMEGRP                          GAMEMODE
                   9214: GAMEOWN                          GAMES_GROUP
                   9215: GAMES_USER                       GCC
                   9216: GCCBASE                          GCC_REQD
                   9217: GCC_VERSION_SUFFIX               GEM_BUILD
                   9218: GEM_CLEANBUILD                   GEM_CLEANBUILD_EXTENSIONS
                   9219: GEM_DOCDIR                       GEM_EXTSDIR
                   9220: GEM_HOME                         GEM_KEEPBUILD
                   9221: GEM_LIBDIR                       GEM_NAME
                   9222: GEM_PATH                         GEM_SPECFILE
                   9223: GENERATE_PLIST                   GHOSTSCRIPT_REQD
                   9224: GITHUB_PROJECT                   GITHUB_RELEASE
                   9225: GITHUB_TAG                       GITHUB_TYPE
                   9226: GITLAB_PROJECT                   GITLAB_TAG
                   9227: GITLAB_TYPE                      GIT_BRANCH
                   9228: GIT_ENV                          GIT_EXTRACTDIR
                   9229: GIT_REPO                         GIT_REPOSITORIES
                   9230: GIT_REVISION                     GIT_TAG
                   9231: GNU                              GNU_CONFIGURE
                   9232: GNU_CONFIGURE_INFODIR            GNU_CONFIGURE_MANDIR
                   9233: GNU_CONFIGURE_QUIET              GNU_CONFIGURE_STRICT
                   9234: GODEP_REDIRECTS                  GO_BUILD_PATTERN
                   9235: GO_DEPS                          GO_DIST_BASE
                   9236: GO_MODULE_FILES                  GO_SRCPATH
                   9237: GO_VERSION_DEFAULT               GROUP_SPECIFIC_PKGS
                   9238: GRUB_NETWORK_CARDS               GRUB_PRESET_COMMAND
                   9239: GRUB_SCAN_ARGS                   GZIP
                   9240: HASKELL_COMPILER                 HASKELL_ENABLE_HADDOCK_DOCUMENTATION
                   9241: HASKELL_ENABLE_LIBRARY_PROFILING HASKELL_ENABLE_SHARED_LIBRARY
                   9242: HASKELL_OPTIMIZATION_LEVEL       HAS_CONFIGURE
                   9243: HEADER_TEMPLATES                 HG_REPO
                   9244: HG_REPOSITORIES                  HG_TAG
                   9245: HOST_PKGTOOLS_ARGS               HOST_SPECIFIC_PKGS
                   9246: HOWL_GROUP                       HOWL_USER
                   9247: ICCBASE                          ICECAST_CHROOTDIR
                   9248: ICON_THEMES                      IDOBASE
                   9249: IGNORE_CCACHE                    IGNORE_INFO_DIRS
                   9250: IGNORE_INTERACTIVE_FETCH         IMAKE
                   9251: IMAKEOPTS                        IMAKE_MAKE
                   9252: IMAKE_MANINSTALL                 IMAP_UW_CCLIENT_MBOX_FMT
                   9253: IMDICTDIR                        INCOMPAT_CURSES
                   9254: INFO_DIR                         INFO_FILES
                   9255: INFO_FILES_VERBOSE               INFO_MSG
                   9256: INIT_SYSTEM                      INN_DATA_DIR
                   9257: INN_GROUP                        INN_USER
                   9258: INSTALLATION_DIRS                INSTALLATION_DIRS_FROM_PLIST
                   9259: INSTALL_ENV                      INSTALL_SH_OVERRIDE
                   9260: INSTALL_SRC                      INSTALL_TEMPLATES
                   9261: INSTALL_UNSTRIPPED               IRCD_HYBRID_IRC_GROUP
                   9262: IRCD_HYBRID_IRC_USER             IRCD_HYBRID_MAXCONN
                   9263: IRCD_HYBRID_NICLEN               IRCD_HYBRID_SYSLOG_EVENTS
                   9264: IRCD_HYBRID_SYSLOG_FACILITY      IRCD_HYBRID_TOPICLEN
                   9265: IRIX                             IRRD_USE_PGP
                   9266: JABBERD_GROUP                    JABBERD_LOGDIR
                   9267: JABBERD_PIDDIR                   JABBERD_SPOOLDIR
                   9268: JABBERD_USER                     JAKARTA_HOME
                   9269: JAVA_APP_PATH                    JAVA_APP_TARGETS
                   9270: JAVA_BINPREFIX                   JAVA_CLASSPATH
                   9271: JAVA_HOME                        JAVA_LD_LIBRARY_PATH
                   9272: JAVA_NAME                        JAVA_UNLIMIT
                   9273: JAVA_WRAPPERS                    JPEG_ACCEPTED
                   9274: JPEG_DEFAULT                     KERBEROS
                   9275: KERMIT_SUID_UUCP                 KJS_USE_PCRE
                   9276: KNEWS_DOMAIN_FILE                KNEWS_DOMAIN_NAME
                   9277: KRB5_ACCEPTED                    KRB5_DEFAULT
                   9278: LANGUAGES                        LAPACK_LIBS
                   9279: LATEX2HTML_ICONPATH              LDCONFIG_ADD_CMD
                   9280: LDCONFIG_REMOVE_CMD              LEAFNODE_DATA_DIR
                   9281: LEAFNODE_GROUP                   LEAFNODE_USER
                   9282: LIBDVDCSS_HOMEPAGE               LIBDVDCSS_MASTER_SITES
                   9283: LIBRSVG_TYPE                     LIBTOOL
                   9284: LIBTOOLIZE_PLIST                 LIBTOOL_M4_OVERRIDE
                   9285: LIBUSB_TYPE                      LICENSE
                   9286: LINKER_RPATH_FLAG                LINK_RPATH_FLAG
                   9287: LINUX_BASE_NODEPS                LINUX_BASE_PREFERRED
                   9288: LINUX_BASE_REQUIRED              LINUX_LOCALES
                   9289: LOCALBASE                        LOCALBASE_LOCKTYPE
                   9290: LOCALPATCHES                     LOVE_DATA
                   9291: LOVE_GAME                        LOVE_VERSION
                   9292: LP64PLATFORMS                    MACHINE_PLATFORM
                   9293: MAILAGENT_DOMAIN                 MAILAGENT_EMAIL
                   9294: MAILAGENT_FQDN                   MAILAGENT_ORGANIZATION
                   9295: MAJORDOMO_HOMEDIR                MAJOR_OS_VERSION
                   9296: MAKEINFO_ARGS                    MAKE_DIRS
                   9297: MAKE_DIRS_PERMS                  MAKE_ENV
                   9298: MAKE_FILE                        MAKE_FLAGS
                   9299: MAKE_JOBS                        MAKE_JOBS_SAFE
                   9300: MAKE_PROGRAM                     MANINSTALL
                   9301: MANZ                             MASTER_SITES
                   9302: MASTER_SITE_BACKUP               MASTER_SITE_LOCAL
                   9303: MASTER_SITE_MOZILLA              MASTER_SITE_OVERRIDE
                   9304: MASTER_SITE_PERL_CPAN            MASTER_SORT
                   9305: MASTER_SORT_RANDOM               MASTER_SORT_REGEX
                   9306: MECAB_CHARSET                    MEDIATOMB_GROUP
                   9307: MEDIATOMB_USER                   MIPSPROBASE
                   9308: MIREDO_GROUP                     MIREDO_USER
                   9309: MISSING_FEATURES                 MKDIR
                   9310: MLDONKEY_GROUP                   MLDONKEY_HOME
                   9311: MLDONKEY_USER                    MONOTONE_GROUP
                   9312: MONOTONE_USER                    MOTIFBASE
                   9313: MOTIF_TYPE                       MOTIF_TYPE_DEFAULT
                   9314: MPI_TYPE                         MSGFMT_STRIP_MSGCTXT
                   9315: MSGFMT_STRIP_MSGID_PLURAL        MTOOLS_ENABLE_FLOPPYD
                   9316: MUST                             MV
                   9317: MYSQL_CHARSET                    MYSQL_DATADIR
                   9318: MYSQL_EXTRA_CHARSET              MYSQL_GROUP
                   9319: MYSQL_PKGSRCDIR                  MYSQL_USER
                   9320: MYSQL_VERSIONS_ACCEPTED          MYSQL_VERSION_DEFAULT
                   9321: NAGIOSCMD_GROUP                  NAGIOSDIR
                   9322: NAGIOS_GROUP                     NAGIOS_USER
                   9323: NATIVE_APPEND_ABI                NATIVE_APPEND_ELF
                   9324: NATIVE_EXEC_FMT                  NATIVE_MACHINE_PLATFORM
                   9325: NATIVE_OBJECT_FMT                NBPAX_PROGRAM_PREFIX
                   9326: NETBSD_LOGIN_NAME                NMH_EDITOR
                   9327: NMH_MTA                          NMH_PAGER
                   9328: NOLOGIN                          NOTE
                   9329: NOT_FOR_PLATFORM                 NOT_PAX_ASLR_SAFE
                   9330: NOT_PAX_MPROTECT_SAFE            NO_BUILD
                   9331: NO_CHECKSUM                      NO_CONFIGURE
                   9332: NO_SKIP                          NS_PREFERRED
                   9333: NULLMAILER_GROUP                 NULLMAILER_USER
                   9334: OASIS                            OASIS_BUILD_ARGS
                   9335: OBJHOSTNAME                      OBJMACHINE
                   9336: OCAML_FINDLIB_DIRS               OCAML_FINDLIB_REGISTER
                   9337: OCAML_FINDLIB_REGISTER_VERBOSE   OCAML_SITELIBDIR
                   9338: OCAML_TOPKG_DOCDIR               OCAML_USE_DUNE
                   9339: OCAML_USE_FINDLIB                OCAML_USE_JBUILDER
                   9340: OCAML_USE_OASIS                  OCAML_USE_OASIS_DYNRUN
                   9341: OCAML_USE_OPAM                   OCAML_USE_OPT_COMPILER
                   9342: OCAML_USE_TOPKG                  OMF
                   9343: ONLY_FOR_COMPILER                ONLY_FOR_PLATFORM
                   9344: OPENSSH_CHROOT                   OPENSSH_GROUP
                   9345: OPENSSH_USER                     OPSYS
                   9346: OPSYS_EMULDIR                    OSS_TYPE
                   9347: OSX                              OSX_TOLERATE_SDK_SKEW
                   9348: OS_HAVE_ALSA                     OS_HAVE_RCD
                   9349: OS_VARIANT                       OS_VERSION
                   9350: OTF_FONTS_DIR                    OVERRIDE_DIRDEPTH
                   9351: OVERRIDE_GEMSPEC                 OVERRIDE_GNU_CONFIG_SCRIPTS
                   9352: OVERRIDE_ROCKSPEC                OWN_DIRS
                   9353: OWN_DIRS_PERMS                   P4GROUP
                   9354: P4PORT                           P4ROOT
                   9355: P4USER                           PACKAGES
                   9356: PALMOS_DEFAULT_SDK               PAMBASE
                   9357: PAM_DEFAULT                      PAPERSIZE
                   9358: PASSIVE_FETCH                    PATCHDIR
                   9359: PATCHFILES                       PATCH_ARGS
                   9360: PATCH_DEBUG                      PATCH_DIST_ARGS
                   9361: PATCH_DIST_CAT                   PATCH_DIST_STRIP
                   9362: PATCH_FUZZ_FACTOR                PATCH_STRIP
                   9363: PATH                             PCCBASE
                   9364: PEAR                             PEAR_CHANNEL
                   9365: PEAR_CHANNEL_ALIAS               PEAR_CHANNEL_VERSION
                   9366: PEAR_CMD                         PEAR_LIB
                   9367: PEAR_PACKAGE_XML                 PERL5
                   9368: PERL5_CONFIGURE                  PERL5_CONFIGURE_DIRS
                   9369: PERL5_LDFLAGS                    PERL5_LICENSE
                   9370: PERL5_MODULE_TYPE                PERL5_PACKLIST
                   9371: PERL5_PACKLIST_DIR               PERL5_PERLBASE
                   9372: PERL5_SITEBASE                   PERL5_USE_PACKLIST
                   9373: PERL5_VENDORBASE                 PFCTL
                   9374: PFVAR_H                          PF_VERSION
                   9375: PGGROUP                          PGHOME
                   9376: PGPKGSRCDIR                      PGSQL_TYPE
                   9377: PGSQL_VERSIONS_ACCEPTED          PGSQL_VERSION_DEFAULT
                   9378: PGUSER                           PG_LIB_EXT
                   9379: PHP                              PHPCOMMON_MK
                   9380: PHPPKGSRCDIR                     PHP_BASE_VERS
                   9381: PHP_CHECK_INSTALLED              PHP_EXTENSION_DIR
                   9382: PHP_INITIAL_TEENY                PHP_PKG_PREFIX
                   9383: PHP_VERSION                      PHP_VERSIONS_ACCEPTED
                   9384: PHP_VERSIONS_INCOMPATIBLE        PHP_VERSION_DEFAULT
                   9385: PHP_VERSION_REQD                 PILRC_USE_GTK
                   9386: PKGCONFIG_BASE                   PKGCONFIG_FILE
                   9387: PKGCONFIG_OVERRIDE               PKGCONFIG_OVERRIDE_STAGE
                   9388: PKGDIR                           PKGGNUDIR
                   9389: PKGINFODIR                       PKGLOCALEDIR
                   9390: PKGMANDIR                        PKGNAME
                   9391: PKGNAME_REQD                     PKGPATH
                   9392: PKGREVISION                      PKGSRC_BLAS_TYPES
                   9393: PKGSRC_CHANGES                   PKGSRC_COMPILER
                   9394: PKGSRC_KEEP_BIN_PKGS             PKGSRC_LOCKTYPE
                   9395: PKGSRC_MAKE_ENV                  PKGSRC_MESSAGE_RECIPIENTS
                   9396: PKGSRC_MKPIE                     PKGSRC_MKREPRO
                   9397: PKGSRC_RUN_TEST                  PKGSRC_SETENV
                   9398: PKGSRC_SLEEPSECS                 PKGSRC_TODO
                   9399: PKGSRC_USE_CTF                   PKGSRC_USE_FORTIFY
                   9400: PKGSRC_USE_RELRO                 PKGSRC_USE_SSP
                   9401: PKGSRC_USE_STACK_CHECK           PKGTASKS_DATAFILE
                   9402: PKGTOOLS_ARGS                    PKGTOOLS_ENV
                   9403: PKG_ALTERNATIVES                 PKG_APACHE
                   9404: PKG_APACHE_ACCEPTED              PKG_APACHE_DEFAULT
                   9405: PKG_BEST_EXISTS                  PKG_BUILD_OPTIONS
                   9406: PKG_COMPRESSION                  PKG_CONFIG
                   9407: PKG_CONFIG_PERMS                 PKG_CREATE_USERGROUP
                   9408: PKG_DB_TMPDIR                    PKG_DEBUG_LEVEL
                   9409: PKG_DEFAULT_OPTIONS              PKG_DESTDIR_SUPPORT
                   9410: PKG_DEVELOPER                    PKG_DISABLED_OPTIONS
                   9411: PKG_FATAL_ERRORS                 PKG_FC
                   9412: PKG_FILELIST_CMD                 PKG_GECOS
                   9413: PKG_GID                          PKG_GROUPS
                   9414: PKG_GROUPS_VARS                  PKG_HOME
                   9415: PKG_INIT_SCRIPTS                 PKG_JAVA_HOME
                   9416: PKG_JVM                          PKG_JVMS_ACCEPTED
                   9417: PKG_JVM_DEFAULT                  PKG_LEGACY_OPTIONS
                   9418: PKG_LIBTOOL                      PKG_OPTIONS
                   9419: PKG_OPTIONS_DEPRECATED_WARNINGS  PKG_OPTIONS_LEGACY_OPTS
                   9420: PKG_OPTIONS_LEGACY_VARS          PKG_OPTIONS_NONEMPTY_SETS
                   9421: PKG_OPTIONS_OPTIONAL_GROUPS      PKG_OPTIONS_REQUIRED_GROUPS
                   9422: PKG_OPTIONS_VAR                  PKG_PHP
                   9423: PKG_PHP_MAJOR_VERS               PKG_PHP_VERSION
                   9424: PKG_RCD_SCRIPTS                  PKG_REFCOUNT_DBDIR
                   9425: PKG_REGISTER_SHELLS              PKG_RESUME_TRANSFERS
                   9426: PKG_SHELL                        PKG_SUGGESTED_OPTIONS
                   9427: PKG_SUPPORTED_OPTIONS            PKG_SYSCONFBASE
                   9428: PKG_SYSCONFBASEDIR               PKG_SYSCONFDIR
                   9429: PKG_SYSCONFDIR_PERMS             PKG_SYSCONFSUBDIR
                   9430: PKG_SYSCONFVAR                   PKG_TOOLS_BIN
                   9431: PKG_UID                          PKG_UPDATE_FONTS_DB
                   9432: PKG_USERS                        PKG_USERS_VARS
                   9433: PKG_VERBOSE                      PLIST
                   9434: PLIST_AWK                        PLIST_AWK_ENV
                   9435: PLIST_SRC                        PLIST_SUBST
                   9436: PLIST_TYPE                       PLIST_VARS
                   9437: POPTOP_USE_MPPE                  POSSIBLE_GFORTRAN_VERSION
                   9438: POST_FETCH_HOOK                  PREFER
                   9439: PREFER_NATIVE                    PREFER_NATIVE_PTHREADS
                   9440: PREFER_PKGSRC                    PREFIX
                   9441: PREPEND_PATH                     PRE_ROOT_CMD
                   9442: PRIVILEGED_STAGES                PS
                   9443: PTHREAD_AUTO_VARS                PTHREAD_CFLAGS
                   9444: PTHREAD_LDFLAGS                  PTHREAD_LIBS
                   9445: PTHREAD_OPTS                     PTHREAD_TYPE
                   9446: PVM_SSH                          PYPKGPREFIX
                   9447: PYTHON_FOR_BUILD_ONLY            PYTHON_SELF_CONFLICT
                   9448: PYTHON_VERSIONED_DEPENDENCIES    PYTHON_VERSIONS_ACCEPTED
                   9449: PYTHON_VERSIONS_INCOMPATIBLE     PYTHON_VERSION_DEFAULT
                   9450: PYTHON_VERSION_REQD              PYVERSSUFFIX
                   9451: PY_NO_EGG                        QMAILDIR
                   9452: QMAIL_ALIAS_USER                 QMAIL_DAEMON_USER
                   9453: QMAIL_LOG_USER                   QMAIL_NOFILES_GROUP
                   9454: QMAIL_PASSWD_USER                QMAIL_QMAIL_GROUP
                   9455: QMAIL_QUEUE_DIR                  QMAIL_QUEUE_EXTRA
                   9456: QMAIL_QUEUE_USER                 QMAIL_REMOTE_USER
                   9457: QMAIL_ROOT_USER                  QMAIL_SEND_USER
                   9458: QPOPPER_FAC                      QPOPPER_SPOOL_DIR
                   9459: QPOPPER_USER                     RAKE_NAME
                   9460: RASMOL_DEPTH                     RCD_DIR
                   9461: RCD_ORDER                        RCD_SCRIPTS
                   9462: RCD_SCRIPTS_DIR                  RCD_SCRIPTS_EXAMPLEDIR
                   9463: RCD_SCRIPTS_MODE                 RCD_SCRIPTS_SHELL
                   9464: RCD_SCRIPT_SRC                   RCD_SUBR
                   9465: RDOC                             READLINE_DEFAULT
                   9466: READLINE_TYPE                    REAL_ROOT_GROUP
                   9467: REAL_ROOT_USER                   RECURSIVE_MAKE
                   9468: RELAY_CTRL_DIR                   REPLACE_AWK
                   9469: REPLACE_BASH                     REPLACE_CSH
                   9470: REPLACE_KSH                      REPLACE_PERL
                   9471: REPLACE_PERL6                    REPLACE_PHP
                   9472: REPLACE_PYTHON                   REPLACE_RUBY
                   9473: REPLACE_RUBY_DIRS                REPLACE_RUBY_PAT
                   9474: REPLACE_SH                       REPLACE_TEXLUA
                   9475: REQD_DIRS                        REQD_DIRS_PERMS
                   9476: REQD_FILES                       REQD_FILES_MODE
                   9477: REQD_FILES_PERMS                 RESOLV_AUTO_VARS
                   9478: RESOLV_LDFLAGS                   RESOLV_LIBS
                   9479: RM                               ROCKSPEC_NAME
                   9480: ROCKSPEC_SPECFILE                ROOT_CMD
                   9481: ROOT_GROUP                       ROOT_USER
                   9482: RPCGEN                           RPM
                   9483: RPM2PKG_PLIST                    RPM2PKG_PREFIX
                   9484: RPM2PKG_STAGE                    RPM2PKG_STRIP
                   9485: RPM2PKG_SUBPREFIX                RPMFILES
                   9486: RPMIGNOREPATH                    RPM_DB_PREFIX
                   9487: RSSH_CVS_PATH                    RSSH_RDIST_PATH
                   9488: RSSH_RSYNC_PATH                  RSSH_SCP_PATH
                   9489: RSSH_SFTP_SERVER_PATH            RUBY
                   9490: RUBYGEM                          RUBYGEM_NAME
                   9491: RUBYGEM_OPTIONS                  RUBY_ABI_VERSION
                   9492: RUBY_ARCH                        RUBY_ARCHINC
                   9493: RUBY_ARCHLIB                     RUBY_BASE
                   9494: RUBY_BASERIDIR                   RUBY_BUILD_DOCUMENT
                   9495: RUBY_DLEXT                       RUBY_DOC
                   9496: RUBY_DYNAMIC_DIRS                RUBY_EG
                   9497: RUBY_ENCODING_ARG                RUBY_EXTCONF
                   9498: RUBY_EXTCONF_CHECK               RUBY_EXTCONF_DEBUG
                   9499: RUBY_EXTCONF_MAKEFILE            RUBY_GEM_BASE
                   9500: RUBY_INC                         RUBY_LIB
                   9501: RUBY_LIB_BASE                    RUBY_NAME
                   9502: RUBY_NOVERSION                   RUBY_PKGPREFIX
                   9503: RUBY_RAILS                       RUBY_RAILS51_VERSION
                   9504: RUBY_RAILS52_VERSION             RUBY_RAILS60_VERSION
                   9505: RUBY_RAILS_ACCEPTED              RUBY_RAILS_DEFAULT
                   9506: RUBY_RAILS_REQD                  RUBY_RAILS_STRICT_DEP
                   9507: RUBY_RIDIR                       RUBY_SETUP
                   9508: RUBY_SHLIB                       RUBY_SHLIBALIAS
                   9509: RUBY_SHLIBVER                    RUBY_SIMPLE_INSTALL
                   9510: RUBY_SITEARCHLIB                 RUBY_SITELIB
                   9511: RUBY_SITELIB_BASE                RUBY_SITERIDIR
                   9512: RUBY_SLEXT                       RUBY_SRCDIR
                   9513: RUBY_STATICLIB                   RUBY_SUFFIX
                   9514: RUBY_SYSRIDIR                    RUBY_USE_PTHREAD
                   9515: RUBY_VENDORARCHLIB               RUBY_VENDORLIB
                   9516: RUBY_VENDORLIB_BASE              RUBY_VER
                   9517: RUBY_VERSION                     RUBY_VERSIONS_ACCEPTED
                   9518: RUBY_VERSIONS_INCOMPATIBLE       RUBY_VERSION_DEFAULT
                   9519: RUBY_VERSION_REQD                RUBY_VER_DIR
                   9520: RUN                              RUN_LDCONFIG
                   9521: SAWFISH_THEMES                   SCO
                   9522: SCREWS_GROUP                     SCREWS_USER
                   9523: SCRIPTS_ENV                      SCROLLKEEPER_DATADIR
                   9524: SCROLLKEEPER_REBUILDDB           SCROLLKEEPER_UPDATEDB
                   9525: SDIST_PAWD                       SERIAL_DEVICES
                   9526: SETGIDGAME                       SETGID_GAMES_PERMS
                   9527: SETUID_ROOT_PERMS                SH
                   9528: SHLIB                            SHORTNAME
                   9529: SIGN_PACKAGES                    SILC_CLIENT_WITH_PERL
                   9530: SITE_SPECIFIC_PKGS               SKIP_DEPENDS
                   9531: SMF_INSTANCES                    SMF_MANIFEST
                   9532: SMF_METHODS                      SMF_METHOD_SHELL
                   9533: SMF_METHOD_SRC                   SMF_NAME
                   9534: SMF_PREFIX                       SMF_SRCDIR
                   9535: SNIPROXY_GROUP                   SNIPROXY_USER
                   9536: SOURCE_BUFFSIZE                  SPECIAL_PERMS
                   9537: SPECIFIC_PKGS                    SSH_SUID
                   9538: SSP_SUPPORTED                    SSYNC_PAWD
                   9539: STEP_MSG                         STRIP
                   9540: STRIP_DBG                        STRIP_DEBUG
                   9541: STRIP_DEBUG_SUPPORTED            STRIP_FILES_SKIP
                   9542: SU                               SUBDIR
                   9543: SUBST                            SUBST_CLASSES
                   9544: SUBST_FILES                      SUBST_FILTER_CMD
                   9545: SUBST_MESSAGE                    SUBST_NOOP_OK
                   9546: SUBST_SED                        SUBST_SHOW_DIFF
                   9547: SUBST_SKIP_TEXT_CHECK            SUBST_STAGE
                   9548: SUBST_VARS                       SUNWSPROBASE
                   9549: SUSE_PREFER                      SU_CMD
                   9550: SVN_EXTRACTDIR                   SVN_REPO
                   9551: SVN_REPOSITORIES                 SVN_REVISION
                   9552: TERMCAP_TYPE                     TERMINFO_DEFAULT
                   9553: TERMINFO_TYPE                    TEST
                   9554: TEST_DEPENDS                     TEST_DIRS
                   9555: TEST_ENV                         TEST_ENV_SHELL
                   9556: TEST_MAKE_CMD                    TEST_MAKE_FLAGS
                   9557: TEST_TARGET                      TEXLIVE_IGNORE_PATTERNS
                   9558: TEXLIVE_REV                      TEXLIVE_UNVERSIONED
                   9559: TEXMFSITE                        TEX_FORMATS
                   9560: TEX_HYPHEN_DAT                   TEX_HYPHEN_DEF
                   9561: TEX_TEXMF_DIRS                   THTTPD_LOG_FACILITY
                   9562: TO                               TOOLS_ALIASES
                   9563: TOOLS_ALWAYS_WRAP                TOOLS_ARGS
                   9564: TOOLS_BROKEN                     TOOLS_CMD
                   9565: TOOLS_CREATE                     TOOLS_DIR
                   9566: TOOLS_FAIL                       TOOLS_GNU_MISSING
                   9567: TOOLS_LDCONFIG                   TOOLS_NOOP
                   9568: TOOLS_PATH                       TOOLS_SCRIPT
                   9569: TOOL_DEPENDS                     TTF_FONTDIR
                   9570: TTF_FONTS_DIR                    TYPE
                   9571: UAC_REQD_EXECS                   UCSPI_SSL_GROUP
                   9572: UCSPI_SSL_USER                   UNLIMIT_RESOURCES
                   9573: UNPRIVILEGED                     UNPRIVILEGED_GROUP
                   9574: UNPRIVILEGED_GROUPS              UNPRIVILEGED_USER
                   9575: UNWRAP_FILES                     UNWRAP_PATTERNS
                   9576: UPDATE_GEMSPEC                   UPDATE_TARGET
                   9577: URI                              USERGROUP_PHASE
                   9578: USERPPP_GROUP                    USER_SPECIFIC_PKGS
                   9579: USE_ABI_DEPENDS                  USE_APR
                   9580: USE_BSD_MAKEFILE                 USE_BUILTIN
                   9581: USE_CROSS_COMPILE                USE_CURSES
                   9582: USE_CWRAPPERS                    USE_DB185
                   9583: USE_FEATURES                     USE_GAMESGROUP
                   9584: USE_GCC_RUNTIME                  USE_IMAKE
                   9585: USE_JAVA                         USE_JAVA2
                   9586: USE_LANGUAGES                    USE_LIBTOOL
                   9587: USE_NATIVE_GCC                   USE_NETBSD_REPO
                   9588: USE_PKGSRC_GCC                   USE_PKGSRC_GCC_RUNTIME
                   9589: USE_PKGTASKS                     USE_PKG_ADMIN_DIGEST
                   9590: USE_RUBY_EXTCONF                 USE_RUBY_INSTALL
                   9591: USE_RUBY_SETUP                   USE_RUBY_SETUP_PKG
                   9592: USE_TOOLS                        UUCP_GROUP
                   9593: UUCP_USER                        VARBASE
                   9594: VARNAME                          VIM_EXTRA_OPTS
                   9595: WARNING_MSG                      WCALC_CGIDIR
                   9596: WCALC_CGIPATH                    WCALC_HTMLDIR
                   9597: WCALC_HTMLPATH                   WDM_MANAGERS
                   9598: WRAPPER_REORDER_CMDS             WRKDIR
                   9599: WRKDIR_BASENAME                  WRKDIR_LOCKTYPE
                   9600: WRKLOG                           WRKOBJDIR
                   9601: WRKSRC                           X10_PORT
                   9602: X11                              X11BASE
                   9603: X11_PKGSRCDIR                    X11_TYPE
                   9604: X509_CERTIFICATE                 X509_KEY
                   9605: XAW_TYPE                         XLOCK_DEFAULT_MODE
                   9606: XMKMF_FLAGS                      XXX
                   9607: XXXX                             YES
                   9608: ZSH_STATIC                       __stdc__
                   9609: _vargroups                       accept
                   9610: acquire-localbase-lock           acquire-lock
                   9611: add                              administrator
                   9612: alloca                           alternatives
                   9613: aslr                             asprintf
                   9614: atlas                            autoconf
                   9615: automake                         autoreconf
                   9616: awk                              bash
                   9617: big-endian                       bin-install
                   9618: bind                             binpkg-list
                   9619: blas                             bootstrap-depends
                   9620: broken                           broken_on_platform
                   9621: bsd                              bsd.prog.mk
                   9622: build                            build-env
                   9623: buildlink-directories            buildlink-oss-soundcard-h
                   9624: c                                c++
                   9625: ccache                           cce
                   9626: cdefs                            ceil
                   9627: changes                          changes-entry
                   9628: changes-entry-noupdate           check
                   9629: check-clean                      check-files
                   9630: check-files-clean                check-vulnerable
                   9631: checksum                         checksum-phase
                   9632: clean                            clean-depends
                   9633: cleandir                         commit
                   9634: commit-changes-entry             compact
                   9635: compiler                         conf
                   9636: config.guess                     config.sub
                   9637: configuration                    configure
                   9638: configure-env                    configure-help
                   9639: configure_args                   connect
                   9640: cos                              cputime
                   9641: create-usergroup                 csh
                   9642: ctf                              cvs
                   9643: debug                            declaration
                   9644: declare                          defined
                   9645: depend                           dependencies
                   9646: depends                          depends-checksum
                   9647: depends-fetch                    deps
                   9648: describe                         destdir
                   9649: disable                          distclean
                   9650: distinfo                         dl
                   9651: dlopen                           do-build
                   9652: do-buildlink                     do-clean
                   9653: do-configure                     do-configure-post-hook
                   9654: do-extract                       do-fetch
                   9655: do-install                       emul
                   9656: emul-distinfo                    emul-fetch
                   9657: emulation                        emulator
                   9658: enable                           endian
                   9659: endif                            enomem
                   9660: err                              errx
                   9661: etc                              exp
                   9662: extract-rpm                      fabs
                   9663: feature                          features
                   9664: fetch                            fetch-list
                   9665: follows                          forbids
                   9666: form                             format
                   9667: fortify                          fortify_source
                   9668: fossil                           friend
                   9669: fts                              fts_close
                   9670: fts_open                         fts_read
                   9671: fts_set                          gcc
                   9672: gethostbyaddr                    gethostbyname
                   9673: gethostbyname2                   getopt_long
                   9674: getprogname                      getservbyname
                   9675: getservbyport                    getservent
                   9676: gettext                          git
                   9677: github                           gitlab
                   9678: glob                             gnu
                   9679: gnu_configure_strict             go
                   9680: go-deps                          golang
                   9681: guess-license                    hashbang
                   9682: heimdal                          help
                   9683: hg                               imake
                   9684: increment                        inet_aton
                   9685: interp                           interpreter
                   9686: intl                             iso
                   9687: kerberos                         krb
                   9688: krb5                             ksh
                   9689: lapack                           latex
                   9690: libintl_bindtextdomain           libintl_gettext
                   9691: libintl_textdomain               libnbcompat
                   9692: libs                             libtool
                   9693: licence                          license
                   9694: lintl                            little-endian
                   9695: lock                             locking
                   9696: lvalue                           make
                   9697: makesum                          memory
                   9698: mercurial                        meta
                   9699: meta-package                     meta_package
                   9700: mit-krb5                         mk.conf
                   9701: mkl                              mount
                   9702: mprotect                         mremap
                   9703: nb                               nbcompat
                   9704: obstack                          obstack_ptr_grow
                   9705: occurs                           only
                   9706: openblas                         options
                   9707: options.mk                       order
                   9708: override                         override-intltool
                   9709: override-message-intltool        package
                   9710: parallel                         path
                   9711: pax                              paxctl
                   9712: pbulk-index                      pc
                   9713: perl                             perl5
                   9714: perms                            php
                   9715: pkg-build-options                pkg-config
                   9716: pkg_build_options                platform
                   9717: plist                            post-extract
                   9718: post-fetch                       post-wrapper
                   9719: pre-build-checks-hook            pre-configure
                   9720: pre-configure-checks-hook        pre-extract
                   9721: pre-fetch                        print-go-deps
                   9722: print-plist                      print-summary-data
                   9723: privileged-install-hook          pypi
                   9724: python                           readme-all
                   9725: recv                             recvfrom
                   9726: regcomp                          release-localbase-lock
                   9727: release-lock                     relro
                   9728: rename                           reorder
                   9729: replace                          replace_interpreter
                   9730: reproducible                     resolv
                   9731: root                             ruby
                   9732: send                             sendfile
                   9733: sendto                           setenv
                   9734: setgid                           setprogname
                   9735: setuid                           sh
1.181     rillig   9736: shebang                          show
                   9737: show-all                         show-build-defs
                   9738: show-depends                     show-deps
                   9739: show-distfiles                   show-downlevel
                   9740: show-subdir-var                  show-tools
                   9741: show-var                         show-vars
                   9742: snprintf                         socket
                   9743: ssp                              st_mode
                   9744: stage-install                    strcasestr
                   9745: strict                           strip
                   9746: strndup                          strnlen
                   9747: strsep                           subst
                   9748: substitutions                    subversion
                   9749: sun                              sunpro
                   9750: sunwspro                         svn
                   9751: symlink                          test
                   9752: test-env                         tex
                   9753: texlive                          tmp
                   9754: tool                             tools
                   9755: tools-libtool-m4-override        type
                   9756: ulimit                           undefined
                   9757: undo-replace                     unlimit
                   9758: unprivileged                     unprivileged-install-hook
                   9759: unstripped                       update
                   9760: upload                           upload-distfiles
                   9761: use_tools                        user
                   9762: utimes                           vasprintf
                   9763: verbose                          vsnprintf
                   9764: warn                             warning
                   9765: warnings                         warnx
                   9766: wattr_off                        wattr_on
                   9767: work                             wrapper
                   9768: wrkdir                            
1.154     rillig   9769: 
                   9770: Appendix E. Editing guidelines for the pkgsrc guide
1.1       dsieger  9771: 
                   9772: Table of Contents
                   9773: 
1.154     rillig   9774: E.1. Make targets
                   9775: E.2. Procedure
1.1       dsieger  9776: 
                   9777: This section contains information on editing the pkgsrc guide itself.
                   9778: 
1.154     rillig   9779: E.1. Make targets
1.1       dsieger  9780: 
                   9781: The pkgsrc guide's source code is stored in pkgsrc/doc/guide/files, and several
                   9782: files are created from it:
                   9783: 
                   9784:   * pkgsrc/doc/pkgsrc.txt
                   9785: 
                   9786:   * pkgsrc/doc/pkgsrc.html
                   9787: 
1.174     leot     9788:   * https://www.NetBSD.org/docs/pkgsrc/
1.1       dsieger  9789: 
1.174     leot     9790:   * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.pdf: The PDF version of the
                   9791:     pkgsrc guide.
1.1       dsieger  9792: 
1.174     leot     9793:   * https://www.NetBSD.org/docs/pkgsrc/pkgsrc.ps: PostScript version of the
1.2       rillig   9794:     pkgsrc guide.
1.1       dsieger  9795: 
1.154     rillig   9796: E.2. Procedure
1.1       dsieger  9797: 
                   9798: The procedure to edit the pkgsrc guide is:
                   9799: 
                   9800:  1. Make sure you have the packages needed to regenerate the pkgsrc guide (and
1.46      obache   9801:     other XML-based NetBSD documentation) installed. These are automatically
                   9802:     installed when you install the meta-pkgs/pkgsrc-guide-tools package.
1.1       dsieger  9803: 
                   9804:  2. Run cd doc/guide to get to the right directory. All further steps will take
                   9805:     place here.
                   9806: 
                   9807:  3. Edit the XML file(s) in files/.
                   9808: 
                   9809:  4. Run bmake to check the pkgsrc guide for valid XML and to build the final
                   9810:     output files. If you get any errors at this stage, you can just edit the
                   9811:     files, as there are only symbolic links in the working directory, pointing
                   9812:     to the files in files/.
                   9813: 
                   9814:  5. (cd files && cvs commit)
                   9815: 
                   9816:  6. Run bmake clean && bmake to regenerate the output files with the proper RCS
                   9817:     Ids.
                   9818: 
                   9819:  7. Run bmake regen to install and commit the files in both pkgsrc/doc and
                   9820:     htdocs.
                   9821: 
                   9822:     Note
                   9823: 
                   9824:     If you have added, removed or renamed some chapters, you need to
                   9825:     synchronize them using cvs add or cvs delete in the htdocs directory.
                   9826: 

CVSweb <webmaster@jp.NetBSD.org>