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

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

CVSweb <webmaster@jp.NetBSD.org>