Received: by mail.netbsd.org (Postfix, from userid 605) id 8388C84E7C; Sat, 20 Jun 2020 05:32:32 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mail.netbsd.org (Postfix) with ESMTP id E7CB484DB1 for ; Sat, 20 Jun 2020 05:32:31 +0000 (UTC) X-Virus-Scanned: amavisd-new at netbsd.org Received: from mail.netbsd.org ([127.0.0.1]) by localhost (mail.netbsd.org [127.0.0.1]) (amavisd-new, port 10025) with ESMTP id t0SUHT-FA4Id for ; Sat, 20 Jun 2020 05:32:12 +0000 (UTC) Received: from cvs.NetBSD.org (ivanova.netbsd.org [199.233.217.197]) by mail.netbsd.org (Postfix) with ESMTP id 194D384DAD for ; Sat, 20 Jun 2020 05:32:12 +0000 (UTC) Received: by cvs.NetBSD.org (Postfix, from userid 500) id 138ECFB28; Sat, 20 Jun 2020 05:32:12 +0000 (UTC) Content-Transfer-Encoding: 7bit Content-Type: multipart/mixed; boundary="_----------=_15926311323080" MIME-Version: 1.0 Date: Sat, 20 Jun 2020 05:32:12 +0000 From: "Roland Illig" Subject: CVS commit: pkgsrc/doc To: pkgsrc-changes@NetBSD.org Reply-To: rillig@netbsd.org X-Mailer: log_accum Message-Id: <20200620053212.138ECFB28@cvs.NetBSD.org> Sender: pkgsrc-changes-owner@NetBSD.org List-Id: pkgsrc-changes.NetBSD.org Precedence: bulk List-Unsubscribe: This is a multi-part message in MIME format. --_----------=_15926311323080 Content-Disposition: inline Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" Module Name: pkgsrc Committed By: rillig Date: Sat Jun 20 05:32:11 UTC 2020 Modified Files: pkgsrc/doc: pkgsrc.html pkgsrc.txt Log Message: doc/pkgsrc.*: regen To generate a diff of this commit: cvs rdiff -u -r1.298 -r1.299 pkgsrc/doc/pkgsrc.html cvs rdiff -u -r1.296 -r1.297 pkgsrc/doc/pkgsrc.txt Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files. --_----------=_15926311323080 Content-Disposition: inline Content-Length: 859895 Content-Transfer-Encoding: binary Content-Type: text/x-diff; charset=utf-8 Modified files: Index: pkgsrc/doc/pkgsrc.html diff -u pkgsrc/doc/pkgsrc.html:1.298 pkgsrc/doc/pkgsrc.html:1.299 --- pkgsrc/doc/pkgsrc.html:1.298 Thu Jun 18 20:31:14 2020 +++ pkgsrc/doc/pkgsrc.html Sat Jun 20 05:32:11 2020 @@ -31,7 +31,7 @@
-

$NetBSD: pkgsrc.xml,v 1.36 2020/01/03 15:55:24 leot Exp $

+

$NetBSD: pkgsrc.xml,v 1.38 2020/06/20 05:31:10 rillig Exp $

Abstract

pkgsrc is a centralized package management system for @@ -170,141 +170,141 @@ builds)

II. The pkgsrc developer's guide
11. Getting help
-
12. Creating a new pkgsrc package from scratch
+
12. Package components - files, directories and contents
-
12.1. Common types of packages
+
12.1. Makefile
+
12.2. distinfo
+
12.3. patches/*
-
12.1.1. Perl modules
-
12.1.2. Python modules and programs
-
12.1.3. R packages
-
12.1.4. TeXlive packages
+
12.3.1. Structure of a single patch file
+
12.3.2. Creating patch files
+
12.3.3. Sources where the patch files come from
+
12.3.4. Patching guidelines
+
12.3.5. Feedback to the author
-
12.2. Examples
-
12.2.1. How the www/nvu package came into pkgsrc
+
12.4. Other mandatory files
+
12.5. Optional files
+
+
12.5.1. Files affecting the binary package
+
12.5.2. Files affecting the build process
+
12.5.3. Files affecting nothing at all
+
+
12.6. work*
+
12.7. files/*
-
13. Package components - files, directories and contents
+
13. The build process
-
13.1. Makefile
-
13.2. distinfo
-
13.3. patches/*
+
13.1. Introduction
+
13.2. Program location
+
13.3. Directories used during the build process
+
13.4. Running a phase
+
13.5. The fetch phase
-
13.3.1. Structure of a single patch file
-
13.3.2. Creating patch files
-
13.3.3. Sources where the patch files come from
-
13.3.4. Patching guidelines
-
13.3.5. Feedback to the author
+
13.5.1. What to fetch and where to get it from
+
13.5.2. How are the files fetched?
-
13.4. Other mandatory files
-
13.5. Optional files
+
13.6. The checksum phase
+
13.7. The extract phase
+
13.8. The patch phase
+
13.9. The tools phase
+
13.10. The wrapper phase
+
13.11. The configure phase
+
13.12. The build phase
+
13.13. The test phase
+
13.14. The install phase
+
13.15. The package phase
+
13.16. Cleaning up
+
13.17. Other helpful targets
+
+
14. Creating a new pkgsrc package from scratch
+
+
14.1. Common types of packages
-
13.5.1. Files affecting the binary package
-
13.5.2. Files affecting the build process
-
13.5.3. Files affecting nothing at all
+
14.1.1. Perl modules
+
14.1.2. Python modules and programs
+
14.1.3. R packages
+
14.1.4. TeXlive packages
-
13.6. work*
-
13.7. files/*
+
14.2. Examples
+
14.2.1. How the www/nvu package came into pkgsrc
-
14. Programming in Makefiles
+
15. Programming in Makefiles
-
14.1. Caveats
-
14.2. Makefile variables
-
14.2.1. Naming conventions
-
14.3. Code snippets
+
15.1. Caveats
+
15.2. Makefile variables
+
15.2.1. Naming conventions
+
15.3. Code snippets
-
14.3.1. Adding things to a list
-
14.3.2. Echoing a string exactly as-is
-
14.3.3. Passing CFLAGS to GNU configure scripts
-
14.3.4. Handling possibly empty variables
+
15.3.1. Adding things to a list
+
15.3.2. Echoing a string exactly as-is
+
15.3.3. Passing CFLAGS to GNU configure scripts
+
15.3.4. Handling possibly empty variables
-
15. PLIST issues
+
16. Options handling
-
15.1. RCS ID
-
15.2. Semi-automatic PLIST generation
-
15.3. Tweaking output of make print-PLIST
-
15.4. Variable substitution in PLIST
-
15.5. Man page compression
-
15.6. Changing PLIST source with PLIST_SRC
-
15.7. Platform-specific and differing PLISTs
-
15.8. Build-specific PLISTs
-
15.9. Sharing directories between packages
+
16.1. Global default options
+
16.2. Converting packages to use bsd.options.mk
+
16.3. Option Names
+
16.4. Determining the options of dependencies
-
16. Buildlink methodology
+
17. Tools needed for building or running
-
16.1. Converting packages to use buildlink3
-
16.2. Writing buildlink3.mk files
+
17.1. Tools for pkgsrc builds
+
17.2. Tools needed by packages
+
17.3. Tools provided by platforms
+
+
18. Buildlink methodology
+
+
18.1. Converting packages to use buildlink3
+
18.2. Writing buildlink3.mk files
-
16.2.1. Anatomy of a buildlink3.mk file
-
16.2.2. Updating +
18.2.1. Anatomy of a buildlink3.mk file
+
18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
-
16.3. Writing builtin.mk files
+
18.3. Writing builtin.mk files
+
+
18.3.1. Anatomy of a builtin.mk file
+
18.3.2. Global preferences for native or pkgsrc software
+
+
+
19. PLIST issues
-
16.3.1. Anatomy of a builtin.mk file
-
16.3.2. Global preferences for native or pkgsrc software
+
19.1. RCS ID
+
19.2. Semi-automatic PLIST generation
+
19.3. Tweaking output of make print-PLIST
+
19.4. Variable substitution in PLIST
+
19.5. Man page compression
+
19.6. Changing PLIST source with PLIST_SRC
+
19.7. Platform-specific and differing PLISTs
+
19.8. Build-specific PLISTs
+
19.9. Sharing directories between packages
+
20. The pkginstall framework
+
+
20.1. Files and directories outside the installation prefix
+
+
20.1.1. Directory manipulation
+
20.1.2. File manipulation
-
17. The pkginstall framework
+
20.2. Configuration files
-
17.1. Files and directories outside the installation prefix
-
-
17.1.1. Directory manipulation
-
17.1.2. File manipulation
-
-
17.2. Configuration files
-
-
17.2.1. How PKG_SYSCONFDIR is set
-
17.2.2. Telling the software where configuration files are
-
17.2.3. Patching installations
-
17.2.4. Disabling handling of configuration files
-
-
17.3. System startup scripts
-
17.3.1. Disabling handling of system startup scripts
-
17.4. System users and groups
-
17.5. System shells
-
17.5.1. Disabling shell registration
-
17.6. Fonts
-
17.6.1. Disabling automatic update of the fonts databases
-
-
18. Options handling
-
-
18.1. Global default options
-
18.2. Converting packages to use bsd.options.mk
-
18.3. Option Names
-
18.4. Determining the options of dependencies
-
-
19. The build process
-
-
19.1. Introduction
-
19.2. Program location
-
19.3. Directories used during the build process
-
19.4. Running a phase
-
19.5. The fetch phase
-
-
19.5.1. What to fetch and where to get it from
-
19.5.2. How are the files fetched?
-
-
19.6. The checksum phase
-
19.7. The extract phase
-
19.8. The patch phase
-
19.9. The tools phase
-
19.10. The wrapper phase
-
19.11. The configure phase
-
19.12. The build phase
-
19.13. The test phase
-
19.14. The install phase
-
19.15. The package phase
-
19.16. Cleaning up
-
19.17. Other helpful targets
-
-
20. Tools needed for building or running
-
-
20.1. Tools for pkgsrc builds
-
20.2. Tools needed by packages
-
20.3. Tools provided by platforms
+
20.2.1. How PKG_SYSCONFDIR is set
+
20.2.2. Telling the software where configuration files are
+
20.2.3. Patching installations
+
20.2.4. Disabling handling of configuration files
+
+
20.3. System startup scripts
+
20.3.1. Disabling handling of system startup scripts
+
20.4. System users and groups
+
20.5. System shells
+
20.5.1. Disabling shell registration
+
20.6. Fonts
+
20.6.1. Disabling automatic update of the fonts databases
21. Making your package work
@@ -376,7 +376,13 @@ builds)
21.7. Marking packages as having problems
-
22. Debugging
+
22. GNOME packaging and porting
+
+
22.1. Meta packages
+
22.2. Packaging a GNOME application
+
22.3. Updating GNOME to a newer version
+
22.4. Patching guidelines
+
23. Submitting and Committing
23.1. Submitting binary packages
@@ -389,48 +395,41 @@ builds)
23.8. Moving a package in pkgsrc
24. Frequently Asked Questions
-
25. GNOME packaging and porting
-
-
25.1. Meta packages
-
25.2. Packaging a GNOME application
-
25.3. Updating GNOME to a newer version
-
25.4. Patching guidelines
-
III. The pkgsrc infrastructure internals
-
26. Design of the pkgsrc infrastructure
+
25. Design of the pkgsrc infrastructure
-
26.1. The meaning of variable definitions
-
26.2. Avoiding problems before they arise
-
26.3. Variable evaluation
+
25.1. The meaning of variable definitions
+
25.2. Avoiding problems before they arise
+
25.3. Variable evaluation
-
26.3.1. At load time
-
26.3.2. At runtime
+
25.3.1. At load time
+
25.3.2. At runtime
-
26.4. How can variables be specified?
-
26.5. Designing interfaces for Makefile fragments
+
25.4. How can variables be specified?
+
25.5. Designing interfaces for Makefile fragments
-
26.5.1. Procedures with parameters
-
26.5.2. Actions taken on behalf of parameters
+
25.5.1. Procedures with parameters
+
25.5.2. Actions taken on behalf of parameters
-
26.6. The order in which files are loaded
+
25.6. The order in which files are loaded
-
26.6.1. The order in bsd.prefs.mk
-
26.6.2. The order in bsd.pkg.mk
+
25.6.1. The order in bsd.prefs.mk
+
25.6.2. The order in bsd.pkg.mk
-
27. Regression tests
+
26. Regression tests
-
27.1. Running the regression tests
-
27.2. Adding a new regression test
+
26.1. Running the regression tests
+
26.2. Adding a new regression test
-
27.2.1. Overridable functions
-
27.2.2. Helper functions
+
26.2.1. Overridable functions
+
26.2.2. Helper functions
-
28. Porting pkgsrc
-
28.1. Porting pkgsrc to a new operating system
+
27. Porting pkgsrc
+
27.1. Porting pkgsrc to a new operating system
A. A simple example package: bison
@@ -472,9 +471,9 @@ source packages
1.1. Platforms supported by pkgsrc
-
13.1. Patching examples +
12.1. Patching examples
-
25.1. PLIST handling for GNOME packages +
22.1. PLIST handling for GNOME packages
@@ -1753,7 +1752,7 @@ spelling mistakes) takes place.

pkgsrc tree instances.)

  • LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. - See Section 13.3, “patches/* for more + See Section 12.3, “patches/* for more information.

  • PKGMAKECONF: Location of the mk.conf file used by a package's @@ -2077,7 +2076,7 @@ PKG_OPTIONS.apache= suexec

    7.2. Settings for creation of binary packages

    -

    See Section 19.17, “Other helpful targets”.

    +

    See Section 13.17, “Other helpful targets”.

  • @@ -3059,7 +3058,7 @@ most cases, the flags from the original with [*]) are passed unmodified to the actual compiler (the lines starting with <.>). If the flag is missing from the actual compiler command, it must have been removed by -the pkgsrc compiler wrappers.

    +the pkgsrc compiler wrappers.

    @@ -3112,141 +3111,141 @@ anymore, you can remove that file and ru

    Table of Contents

    11. Getting help
    -
    12. Creating a new pkgsrc package from scratch
    +
    12. Package components - files, directories and contents
    -
    12.1. Common types of packages
    +
    12.1. Makefile
    +
    12.2. distinfo
    +
    12.3. patches/*
    -
    12.1.1. Perl modules
    -
    12.1.2. Python modules and programs
    -
    12.1.3. R packages
    -
    12.1.4. TeXlive packages
    +
    12.3.1. Structure of a single patch file
    +
    12.3.2. Creating patch files
    +
    12.3.3. Sources where the patch files come from
    +
    12.3.4. Patching guidelines
    +
    12.3.5. Feedback to the author
    -
    12.2. Examples
    -
    12.2.1. How the www/nvu package came into pkgsrc
    +
    12.4. Other mandatory files
    +
    12.5. Optional files
    +
    +
    12.5.1. Files affecting the binary package
    +
    12.5.2. Files affecting the build process
    +
    12.5.3. Files affecting nothing at all
    +
    +
    12.6. work*
    +
    12.7. files/*
    -
    13. Package components - files, directories and contents
    +
    13. The build process
    -
    13.1. Makefile
    -
    13.2. distinfo
    -
    13.3. patches/*
    +
    13.1. Introduction
    +
    13.2. Program location
    +
    13.3. Directories used during the build process
    +
    13.4. Running a phase
    +
    13.5. The fetch phase
    -
    13.3.1. Structure of a single patch file
    -
    13.3.2. Creating patch files
    -
    13.3.3. Sources where the patch files come from
    -
    13.3.4. Patching guidelines
    -
    13.3.5. Feedback to the author
    +
    13.5.1. What to fetch and where to get it from
    +
    13.5.2. How are the files fetched?
    -
    13.4. Other mandatory files
    -
    13.5. Optional files
    +
    13.6. The checksum phase
    +
    13.7. The extract phase
    +
    13.8. The patch phase
    +
    13.9. The tools phase
    +
    13.10. The wrapper phase
    +
    13.11. The configure phase
    +
    13.12. The build phase
    +
    13.13. The test phase
    +
    13.14. The install phase
    +
    13.15. The package phase
    +
    13.16. Cleaning up
    +
    13.17. Other helpful targets
    +
    +
    14. Creating a new pkgsrc package from scratch
    +
    +
    14.1. Common types of packages
    -
    13.5.1. Files affecting the binary package
    -
    13.5.2. Files affecting the build process
    -
    13.5.3. Files affecting nothing at all
    +
    14.1.1. Perl modules
    +
    14.1.2. Python modules and programs
    +
    14.1.3. R packages
    +
    14.1.4. TeXlive packages
    -
    13.6. work*
    -
    13.7. files/*
    +
    14.2. Examples
    +
    14.2.1. How the www/nvu package came into pkgsrc
    -
    14. Programming in Makefiles
    +
    15. Programming in Makefiles
    -
    14.1. Caveats
    -
    14.2. Makefile variables
    -
    14.2.1. Naming conventions
    -
    14.3. Code snippets
    +
    15.1. Caveats
    +
    15.2. Makefile variables
    +
    15.2.1. Naming conventions
    +
    15.3. Code snippets
    -
    14.3.1. Adding things to a list
    -
    14.3.2. Echoing a string exactly as-is
    -
    14.3.3. Passing CFLAGS to GNU configure scripts
    -
    14.3.4. Handling possibly empty variables
    +
    15.3.1. Adding things to a list
    +
    15.3.2. Echoing a string exactly as-is
    +
    15.3.3. Passing CFLAGS to GNU configure scripts
    +
    15.3.4. Handling possibly empty variables
    -
    15. PLIST issues
    +
    16. Options handling
    -
    15.1. RCS ID
    -
    15.2. Semi-automatic PLIST generation
    -
    15.3. Tweaking output of make print-PLIST
    -
    15.4. Variable substitution in PLIST
    -
    15.5. Man page compression
    -
    15.6. Changing PLIST source with PLIST_SRC
    -
    15.7. Platform-specific and differing PLISTs
    -
    15.8. Build-specific PLISTs
    -
    15.9. Sharing directories between packages
    +
    16.1. Global default options
    +
    16.2. Converting packages to use bsd.options.mk
    +
    16.3. Option Names
    +
    16.4. Determining the options of dependencies
    -
    16. Buildlink methodology
    +
    17. Tools needed for building or running
    -
    16.1. Converting packages to use buildlink3
    -
    16.2. Writing buildlink3.mk files
    +
    17.1. Tools for pkgsrc builds
    +
    17.2. Tools needed by packages
    +
    17.3. Tools provided by platforms
    +
    +
    18. Buildlink methodology
    +
    +
    18.1. Converting packages to use buildlink3
    +
    18.2. Writing buildlink3.mk files
    -
    16.2.1. Anatomy of a buildlink3.mk file
    -
    16.2.2. Updating +
    18.2.1. Anatomy of a buildlink3.mk file
    +
    18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
    -
    16.3. Writing builtin.mk files
    +
    18.3. Writing builtin.mk files
    +
    +
    18.3.1. Anatomy of a builtin.mk file
    +
    18.3.2. Global preferences for native or pkgsrc software
    +
    +
    +
    19. PLIST issues
    -
    16.3.1. Anatomy of a builtin.mk file
    -
    16.3.2. Global preferences for native or pkgsrc software
    +
    19.1. RCS ID
    +
    19.2. Semi-automatic PLIST generation
    +
    19.3. Tweaking output of make print-PLIST
    +
    19.4. Variable substitution in PLIST
    +
    19.5. Man page compression
    +
    19.6. Changing PLIST source with PLIST_SRC
    +
    19.7. Platform-specific and differing PLISTs
    +
    19.8. Build-specific PLISTs
    +
    19.9. Sharing directories between packages
    +
    20. The pkginstall framework
    +
    +
    20.1. Files and directories outside the installation prefix
    +
    +
    20.1.1. Directory manipulation
    +
    20.1.2. File manipulation
    -
    17. The pkginstall framework
    +
    20.2. Configuration files
    -
    17.1. Files and directories outside the installation prefix
    -
    -
    17.1.1. Directory manipulation
    -
    17.1.2. File manipulation
    -
    -
    17.2. Configuration files
    -
    -
    17.2.1. How PKG_SYSCONFDIR is set
    -
    17.2.2. Telling the software where configuration files are
    -
    17.2.3. Patching installations
    -
    17.2.4. Disabling handling of configuration files
    -
    -
    17.3. System startup scripts
    -
    17.3.1. Disabling handling of system startup scripts
    -
    17.4. System users and groups
    -
    17.5. System shells
    -
    17.5.1. Disabling shell registration
    -
    17.6. Fonts
    -
    17.6.1. Disabling automatic update of the fonts databases
    -
    -
    18. Options handling
    -
    -
    18.1. Global default options
    -
    18.2. Converting packages to use bsd.options.mk
    -
    18.3. Option Names
    -
    18.4. Determining the options of dependencies
    -
    -
    19. The build process
    -
    -
    19.1. Introduction
    -
    19.2. Program location
    -
    19.3. Directories used during the build process
    -
    19.4. Running a phase
    -
    19.5. The fetch phase
    -
    -
    19.5.1. What to fetch and where to get it from
    -
    19.5.2. How are the files fetched?
    -
    -
    19.6. The checksum phase
    -
    19.7. The extract phase
    -
    19.8. The patch phase
    -
    19.9. The tools phase
    -
    19.10. The wrapper phase
    -
    19.11. The configure phase
    -
    19.12. The build phase
    -
    19.13. The test phase
    -
    19.14. The install phase
    -
    19.15. The package phase
    -
    19.16. Cleaning up
    -
    19.17. Other helpful targets
    -
    -
    20. Tools needed for building or running
    -
    -
    20.1. Tools for pkgsrc builds
    -
    20.2. Tools needed by packages
    -
    20.3. Tools provided by platforms
    +
    20.2.1. How PKG_SYSCONFDIR is set
    +
    20.2.2. Telling the software where configuration files are
    +
    20.2.3. Patching installations
    +
    20.2.4. Disabling handling of configuration files
    +
    +
    20.3. System startup scripts
    +
    20.3.1. Disabling handling of system startup scripts
    +
    20.4. System users and groups
    +
    20.5. System shells
    +
    20.5.1. Disabling shell registration
    +
    20.6. Fonts
    +
    20.6.1. Disabling automatic update of the fonts databases
    21. Making your package work
    @@ -3318,7 +3317,13 @@ anymore, you can remove that file and ru
    21.7. Marking packages as having problems
    -
    22. Debugging
    +
    22. GNOME packaging and porting
    +
    +
    22.1. Meta packages
    +
    22.2. Packaging a GNOME application
    +
    22.3. Updating GNOME to a newer version
    +
    22.4. Patching guidelines
    +
    23. Submitting and Committing
    23.1. Submitting binary packages
    @@ -3331,13 +3336,6 @@ anymore, you can remove that file and ru
    23.8. Moving a package in pkgsrc
    24. Frequently Asked Questions
    -
    25. GNOME packaging and porting
    -
    -
    25.1. Meta packages
    -
    25.2. Packaging a GNOME application
    -
    25.3. Updating GNOME to a newer version
    -
    25.4. Patching guidelines
    -

    @@ -3386,922 +3384,462 @@ anymore, you can remove that file and ru

    -Chapter 12. Creating a new pkgsrc package from scratch

    +Chapter 12. Package components - files, directories and contents
    -

    When you find a package that is not yet in pkgsrc, you -most likely have a URL from where you can download the source -code. Starting with this URL, creating a package involves only a -few steps.

    -
      -
    1. First, install the packages pkgtools/url2pkg and pkgtools/pkglint.

    2. -
    3. Then, choose one of the top-level directories as the -category in which you want to place your package. You can also create a -directory of your own (maybe called local). In that -category directory, create another directory for your package and change -into it.

    4. -
    5. Run the program url2pkg, which will ask -you for a URL. Enter the URL of the distribution file (in most cases a -.tar.gz file) and watch how the basic ingredients -of your package are created automatically. The distribution file is -extracted automatically to fill in some details in the -Makefile that would otherwise have to be done -manually.

    6. -
    7. -

      Examine the extracted files to determine the dependencies of -your package. Ideally, this is mentioned in some -README file, but things may differ. For each of -these dependencies, look where it exists in pkgsrc, and if there is a -file called buildlink3.mk in that directory, add a -line to your package Makefile which includes that -file just before the last line. If the -buildlink3.mk file does not exist, it must be -created first. The buildlink3.mk file makes sure -that the package's include files and libraries are provided.

      -

      If you just need binaries from a package, add a -DEPENDS line to the Makefile, which specifies the -version of the dependency and where it can be found in pkgsrc. This line -should be placed in the third paragraph. If the dependency is only -needed for building the package, but not when using it, use -TOOL_DEPENDS or BUILD_DEPENDS -instead of DEPENDS. -The difference between TOOL_DEPENDS and -BUILD_DEPENDS occurs when cross-compiling: -TOOL_DEPENDS are native -packages, i.e. packages for the architecture where the package -is built; -BUILD_DEPENDS are target -packages, i.e. packages for the architecture for which the package -is built. There is also TEST_DEPENDS, which is used -to specify a dependency used only for testing the resulting package -built, using the upstream project's included test suite. -Your package may then look like this:

      +

      Whenever you're preparing a package, there are a number of +files involved which are described in the following +sections.

      +
      +

      +12.1. Makefile +

      +

      Building, installation and creation of a binary package are all + controlled by the package's Makefile. + The Makefile describes various things about + a package, for example from where to get it, how to configure, + build, and install it.

      +

      A package Makefile contains several + sections that describe the package.

      +

      In the first section there are the following variables, which + should appear exactly in the order given here. The order and + grouping of the variables is mostly historical and has no further + meaning.

      +
        +
      • DISTNAME is the basename of the + distribution file to be downloaded from the package's + website.

      • +
      • PKGNAME is the name of the + package, as used by pkgsrc. You need to provide it if + DISTNAME (which is the default) is not a good + name for the package in pkgsrc or DISTNAME is not + provided (no distribution file is required). Usually it is the pkgsrc + directory name together with the version number. It must match the + regular expression + ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that is, it + starts with a letter or digit, and contains only letters, digits, + dashes, underscores, dots and plus signs.

      • +
      • +

        CATEGORIES is a list of categories + which the package fits in. You can choose any of the top-level + directories of pkgsrc for it.

        +

        Currently the following values are available for + CATEGORIES. If more than + one is used, they need to be separated by spaces:

        -[...]
        -
        -TOOL_DEPENDS+=  libxslt-[0-9]*:../../textproc/libxslt
        -DEPENDS+=       screen-[0-9]*:../../misc/screen
        -DEPENDS+=       screen>=4.0:../../misc/screen
        -
        -[...]
        -
        -.include "../../category/package/buildlink3.mk"
        -.include "../../devel/glib2/buildlink3.mk"
        -.include "../../mk/bsd.pkg.mk"
        +archivers     cross         geography     meta-pkgs     security
        +audio         databases     graphics      misc          shells
        +benchmarks    devel         ham           multimedia    sysutils
        +biology       editors       inputmethod   net           textproc
        +cad           emulators     lang          news          time
        +chat          finance       mail          parallel      wm
        +comms         fonts         math          pkgtools      www
        +converters    games         mbone         print         x11
         
      • -
      • Run pkglint to see what things still need -to be done to make your package a good one. If you don't -know what pkglint's warnings want to tell you, try pkglint ---explain or pkglint --e, which outputs additional -explanations.

      • -
      • In many cases the package is not yet ready to build. You can -find instructions for the most common cases in the next section, Section 12.1, “Common types of packages”. After you have followed the instructions -over there, you can hopefully continue here.

      • -
      • Run bmake clean to clean the working -directory from the extracted files. Besides these files, a lot of cache -files and other system information has been saved in the working -directory, which may become wrong after you edited the -Makefile.

      • -
      • Now, run bmake to build the package. For -the various things that can go wrong in this phase, consult Chapter 21, Making your package work.

      • -
      • When the package builds fine, the next step is to install -the package. Run bmake install and hope that -everything works.

      • -
      • Up to now, the file PLIST, which -contains a list of the files that are installed by the package, is -nearly empty. Run bmake print-PLIST ->PLIST to generate a probably correct list. Check -the file using your preferred text editor to see if the list of -files looks plausible.

      • -
      • Run pkglint again to see if the generated -PLIST contains garbage or not.

      • -
      • When you ran bmake install, the package -has been registered in the database of installed files, but with an -empty list of files. To fix this, run bmake deinstall -and bmake install again. Now the package is -registered with the list of files from -PLIST.

      • -
      • Run bmake package to create a binary -package from the set of installed files.

      • -
    +
  • MASTER_SITES, + DYNAMIC_MASTER_SITES, + DIST_SUBDIR, EXTRACT_SUFX + and DISTFILES are discussed in detail in + Section 13.5, “The fetch phase”.

  • + +

    The second section contains information about separately + downloaded patches, if any. +

    +
      +
    • PATCHFILES: + Name(s) of additional files that contain distribution patches. + There is no default. pkgsrc will look for them at + PATCH_SITES. + They will automatically be uncompressed before patching if + the names end with .gz or + .Z.

    • +
    • PATCH_SITES: + Primary location(s) for distribution patch files (see + PATCHFILES above) if not found locally.

    • +
    • PATCH_DIST_STRIP: + an argument to patch(1) that sets the pathname strip count to + help find the correct files to patch. It defaults to + -p0.

    • +
    +

    The third section contains the following variables. +

    +
      +
    • MAINTAINER is the email + address of the person who feels responsible for this package, + and who is most likely to look at problems or questions regarding + this package which have been reported with send-pr(1). + Other developers may contact the MAINTAINER + before making changes to the package, but are not required to + do so. When packaging a new program, set MAINTAINER + to yourself. If you really can't maintain the package for future + updates, set it to + .

    • +
    • OWNER should be used instead + of MAINTAINER when you do not want other + developers to update or change the package without contacting + you first. A package Makefile should contain one of + MAINTAINER or OWNER, but + not both.

    • +
    • HOMEPAGE is a URL where users can + find more information about the package.

    • +
    • COMMENT is a one-line + description of the package (should not include the package + name).

    • +
    • LICENSE indicates the license(s) + applicable for the package. See Section 21.1.3, “Handling licenses” for further details.

    • +
    +

    Other variables that affect the build: +

    +
    • +

      WRKSRC: The directory where the + interesting distribution files of the package are found. The + default is ${WRKDIR}/${DISTNAME}, which + works for most packages.

      +

      If a package doesn't create a subdirectory for itself + (most GNU software does, for instance), but extracts itself in + the current directory, you should set + WRKSRC=${WRKDIR}.

      +

      If a package doesn't create a subdirectory with the + name of DISTNAME but some different name, + set WRKSRC to point to the proper name in + ${WRKDIR}, for example + WRKSRC=${WRKDIR}/${DISTNAME}/unix. See + lang/tcl and x11/tk for other examples.

      +

      The name of the working directory created by pkgsrc is + taken from the WRKDIR_BASENAME + variable. By default, its value is + work. If you want to use the same + pkgsrc tree for building different kinds of binary packages, + you can change the variable according to your needs. Two + other variables handle common cases of setting + WRKDIR_BASENAME individually. If + OBJHOSTNAME is defined in + mk.conf, the first component of + the host's name is attached to the directory name. If + OBJMACHINE is defined, the platform name + is attached, which might look like + work.i386 or + work.sparc.

      +
    +

    Please pay attention to the following gotchas:

    +
      +
    • Add MANCOMPRESSED if man pages are + installed in compressed form by the package. For packages using + BSD-style makefiles which honor MANZ, there is + MANCOMPRESSED_IF_MANZ.

    • +
    • Replace /usr/local with + ${PREFIX} in all files (see patches, + below).

    • +
    • If the package installs any info files, see Section 21.6.7, “Packages installing info files”.

    • +
    +

    -12.1. Common types of packages

    -
    -

    -12.1.1. Perl modules

    -

    Simple Perl modules are handled automatically by -url2pkg, including dependencies.

    +12.2. distinfo +
    +

    The distinfo file contains the message + digest, or checksum, of each distfile needed for the package. This + ensures that the distfiles retrieved from the Internet have not been + corrupted during transfer or altered by a malign force to introduce + a security hole. To provide maximum security, all distfiles are + protected using three different message digest algorithms (SHA1, + RMD160, SHA512), as well as the file size.

    +

    The distinfo file also contains the + checksums for all the patches found in the + patches directory (see Section 12.3, “patches/*). These checksums ensure that patches + are only applied intentionally and that they don't accidentally change, + e.g. when merging different changes together. They also make sure that + new patches are actually added to CVS and old ones are removed. + Too see whether the patches and the distinfo file + match, run pkglint after changing the patches.

    +

    To regenerate the distinfo file, use the + make distinfo command.

    +

    Some packages have different sets of distfiles depending on + the platform, for example lang/openjdk8. These are kept in the same + distinfo file and care should be taken when + upgrading such a package to ensure distfile information is not + lost.

    +
    +

    +12.3. patches/* +

    +

    Some packages don't work out-of-the box on the various + platforms that are supported by pkgsrc. These packages need + to be patched to make them work. The patch files can be + found in the patches/ directory.

    +

    In the patch phase, these patches are + applied to the files in WRKSRC directory after + extracting them, in alphabetic order.

    -12.1.2. Python modules and programs

    -

    Python modules and programs packages are easily created using a -set of predefined variables.

    -

    -If some Python versions are not supported by the software, set the -PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions -that are not supported, e.g. -

    -
    -PYTHON_VERSIONS_INCOMPATIBLE=       27
    -
    -

    -If the packaged software is a Python module, include one of -../../lang/python/egg.mk, -../../lang/python/distutils.mk, or -../../lang/python/extension.mk.

    -

    Most Python packages use either distutils or -easy-setup/setuptools (eggs). -If the packaged software is using setuptools, you only need -to include ../../lang/python/egg.mk. -Otherwise, if the software uses distutils, include -../../lang/python/distutils.mk, -so pkgsrc will use this framework. -distutils uses a script called setup.py; -if the distutils driver is not called -setup.py, set the PYSETUP variable -to the name of the script.

    -

    Either way, the package directory should be called -py-software and PKGNAME should be set to -${PYPKGPREFIX}-${DISTNAME}, e.g. -

    -
    -DISTNAME=   foopymodule-1.2.10
    -PKGNAME=    ${PYPKGPREFIX}-${DISTNAME}
    -
    -

    If it is an application, include -../../lang/python/application.mk. -In order to correctly set the path to the Python interpreter, use the -REPLACE_PYTHON variable and set it to the list of files -(paths relative to WRKSRC) that must be corrected. -For example: -

    -
    -REPLACE_PYTHON=   *.py
    -
    -

    Some Python modules have separate distributions for Python-2.x -and Python-3.x support. In pkgsrc this is handled by the -versioned_dependencies.mk file. Set -PYTHON_VERSIONED_DEPENDENCIES to the list of -packages that should be depended upon and include -../../lang/python/versioned_dependencies.mk, -then the pkgsrc infrastructure will depend on the appropriate package -version. For example: -

    -
    -PYTHON_VERSIONED_DEPENDENCIES=dialog
    -
    -

    -Look inside versioned_dependencies.mk for a list -of supported packages.

    +12.3.1. Structure of a single patch file
    +

    The patch-* files should be in + diff -bu format, and apply without a fuzz to avoid + problems. (To force patches to apply with fuzz you can set + PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch + should contain only changes for a single file, and no file should be + patched by more than one patch file. This helps to keep future + modifications simple.

    +

    Each patch file is structured as follows: In the first line, + there is the RCS Id of the patch itself. The second line should be + empty for aesthetic reasons. After that, there should be a comment for + each change that the patch does. There are a number of standard + cases:

    +
      +
    • Patches for commonly known vulnerabilities should + mention the vulnerability ID (CAN, CVE).

    • +
    • Patches that change source code should mention the + platform and other environment (for example, the compiler) that the + patch is needed for.

    • +
    +

    The patch should be commented so that any + developer who knows the code of the application can make some use of + the patch. Special care should be taken for the upstream developers, + since we generally want that they accept our patches, so we have less + work in the future.

    -12.1.3. R packages

    -

    Simple R packages from CRAN -are handled automatically by R2pkg, which is -available in pkgtools/R2pkg. -Individual packages (and optionally their dependencies) may be created -and updated. R packages generally follow the same form, and most of -the relevant information needed is contained in a -DESCRIPTION file as part of each R package on -CRAN. -Consequently, R2pkg downloads that information and -creates or updates a package in the canonical form. The resulting -package should be reviewed for correctness.

    +12.3.2. Creating patch files
    +

    One important thing to mention is to pay attention that no RCS + IDs get stored in the patch files, as these will cause problems when + later checked into the NetBSD CVS tree. Use the + pkgdiff command from the pkgtools/pkgdiff package to avoid these + problems.

    +

    For even more automation, we recommend using + mkpatches from the same package to make a + whole set of patches. You just have to backup files before you + edit them to filename.orig, e.g. with + cp -p filename filename.orig or, easier, by + using pkgvi again from the same package. If + you upgrade a package this way, you can easily compare the new + set of patches with the previously existing one with + patchdiff. The files in patches + are replaced by new files, so carefully check if you want to take all + the changes.

    +

    When you have finished a package, remember to generate + the checksums for the patch files by using the make + makepatchsum command, see Section 12.2, “distinfo.

    +

    When adding a patch that corrects a problem in the + distfile (rather than e.g. enforcing pkgsrc's view of where + man pages should go), send the patch as a bug report to the + maintainer. This benefits non-pkgsrc users of the package, + and usually makes it possible to remove the patch in future + version.

    +

    The file names of the patch files are usually of the form + patch-path_to_file__with__underscores.c. + Many packages still use the previous convention + patch-[a-z][a-z], + but new patches should be of the form containing the filename. + mkpatches included in pkgtools/pkgdiff takes care of the name + automatically.

    -12.1.4. TeXlive packages

    -

    TeXlive packages from CTAN are handled automatically by -texlive2pkg, which is available in pkgtools/texlive2pkg.

    -

    If the TeXlive package name is not known, it may be useful to -search CTAN. A -Contained in field on the package page typically -identifies the basename of the package file in the TeXlive -archive.

    -

    If the TeXlive package name is known, download the files from -the TeXlive -archive. For package foo, you will need -to download foo.tar.xz. Most TeXlive packages -also have associated documentation packages, so download -foo.doc.tar.xz at the same time. These files -should be placed in the appropriate category directory, which is often -but not always print. Then run the following -command in the category directory.

    -
    -texlive2pkg foo.tar.xz foo.doc.tar.xz
    -
    -

    This will create two packages, tex-foo and -tex-foo-doc. Be sure to check that both packages -are correct.

    -

    Finally, CTAN -currently does not include version information in package filenames -and changes their contents periodically when updates occur. -Consequently, pkgsrc avoids downloading distfiles directly from CTAN and instead relies on the -pkgsrc archives. For each new or updated TeXlive package, e.g., the -main one and the corresponding documentation, upload the distfiles -with the following command in each package directory.

    +12.3.3. Sources where the patch files come from
    +

    If you want to share patches between multiple packages + in pkgsrc, e.g. because they use the same distfiles, set + PATCHDIR to the path where the patch files + can be found, e.g.:

    -make upload-distfiles
    +PATCHDIR=       ../../editors/xemacs/patches
     
    +

    Patch files that are distributed by the author or other + maintainers can be listed in + PATCHFILES.

    +

    If it is desired to store any patches that should not be + committed into pkgsrc, they can be kept outside the pkgsrc + tree in the $LOCALPATCHES directory. The + directory tree there is expected to have the same + category/package structure as pkgsrc, and + patches are expected to be stored inside these dirs (also + known as $LOCALPATCHES/$PKGPATH). For + example, if you want to keep a private patch for + pkgsrc/graphics/png, keep it in + $LOCALPATCHES/graphics/png/mypatch. All + files in the named directory are expected to be patch files, + and they are applied after pkgsrc patches are + applied.

    - -
    -

    -12.2. Examples

    -12.2.1. How the www/nvu package came into pkgsrc

    -
    -

    -12.2.1.1. The initial package

    -

    Looking at the file pkgsrc/doc/TODO, I saw -that the nvu package has not yet been imported into -pkgsrc. As the description says it has to do with the web, the obvious -choice for the category is www.

    -
    -$ mkdir www/nvu
    -$ cd www/nvu
    -
    -

    The web site says that the sources are available as a tar file, so -I fed that URL to the url2pkg program:

    -
    -$ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
    -
    -

    My editor popped up, and I added a PKGNAME line -below the DISTNAME line, as the package name should -not have the word sources in it. I also filled in the -MAINTAINER, HOMEPAGE and -COMMENT fields. Then the package -Makefile looked like that:

    -
    -# $NetBSD $
    -#
    -
    -DISTNAME=       nvu-1.0-sources
    -PKGNAME=        nvu-1.0
    -CATEGORIES=     www
    -MASTER_SITES=   http://cvs.nvu.com/download/
    -EXTRACT_SUFX=   .tar.bz2
    -
    -MAINTAINER=     rillig@NetBSD.org
    -HOMEPAGE=       http://cvs.nvu.com/
    -COMMENT=        Web Authoring System
    -
    -# url2pkg-marker (please do not remove this line.)
    -.include "../../mk/bsd.pkg.mk"
    -
    -

    On the first line of output above, an artificial space has been added between NetBSD and $, -this is a workaround to prevent CVS expanding to the filename of the -guide.

    -

    Then, I quit the editor and watched pkgsrc downloading a large -source archive:

    -
    -url2pkg> Running "make makesum" ...
    -=> Required installed package digest>=20010302: digest-20060826 found
    -=> Fetching nvu-1.0-sources.tar.bz2
    -Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
    -100% |*************************************| 28992 KB  150.77 KB/s00:00 ETA
    -29687976 bytes retrieved in 03:12 (150.77 KB/s)
    -url2pkg> Running "make extract" ...
    -=> Required installed package digest>=20010302: digest-20060826 found
    -=> Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
    -=> Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
    -work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
    -===> Installing dependencies for nvu-1.0
    -===> Overriding tools for nvu-1.0
    -===> Extracting for nvu-1.0
    -url2pkg> Adjusting the Makefile.
    -
    -Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
    -
    -Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
    -
    -
    -
    -

    -12.2.1.2. Fixing all kinds of problems to make the package work

    -

    Now that the package has been extracted, let's see what's inside -it. The package has a README.txt, but that only -says something about mozilla, so it's probably useless for seeing what -dependencies this package has. But since there is a GNU configure script -in the package, let's hope that it will complain about everything it -needs.

    -
    -$ bmake
    -=> Required installed package digest>=20010302: digest-20060826 found
    -=> Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
    -=> Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
    -===> Patching for nvu-1.0
    -===> Creating toolchain wrappers for nvu-1.0
    -===> Configuring for nvu-1.0
    -[...]
    -configure: error: Perl 5.004 or higher is required.
    -[...]
    -WARNING: Please add USE_TOOLS+=perl to the package Makefile.
    -[...]
    -
    -

    That worked quite well. So I opened the package Makefile in my -editor, and since it already has a USE_TOOLS line, I -just appended perl to it. Since the dependencies of the -package have changed now, and since a perl wrapper is automatically -installed in the tools phase, I need to build the package -from scratch.

    -
    -$ bmake clean
    -===> Cleaning for nvu-1.0
    -$ bmake
    -[...]
    -*** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
    -GNU Make.  You will not be able to build Mozilla without GNU Make.
    -[...]
    -
    -

    So I added gmake to the -USE_TOOLS line and tried again (from scratch).

    -
    -[...]
    -checking for GTK - version >= 1.2.0... no
    -*** Could not run GTK test program, checking why...
    -[...]
    -
    -

    Now to the other dependencies. The first question is: Where is the -GTK package hidden in pkgsrc?

    -
    -$ echo ../../*/gtk*
    -[many packages ...]
    -$ echo ../../*/gtk
    -../../x11/gtk
    -$ echo ../../*/gtk2
    -../../x11/gtk2
    -$ echo ../../*/gtk2/bui*
    -../../x11/gtk2/buildlink3.mk
    -
    -

    The first try was definitely too broad. The second one had exactly -one result, which is very good. But there is one pitfall with GNOME -packages. Before GNOME 2 had been released, there were already many -GNOME 1 packages in pkgsrc. To be able to continue to use these -packages, the GNOME 2 packages were imported as separate packages, and -their names usually have a 2 appended. So I checked -whether this was the case here, and indeed it was.

    -

    Since the GTK2 package has a buildlink3.mk -file, adding the dependency is very easy. I just inserted an -.include line before the last line of the package -Makefile, so that it now looks like this:

    +12.3.4. Patching guidelines
    +

    When fixing a portability issue in the code do not use + preprocessor magic to check for the current operating system nor + platform. Doing so hurts portability to other platforms because + the OS-specific details are not abstracted appropriately.

    +

    The general rule to follow is: instead of checking for the + operating system the application is being built on, check for the + specific features you need. For example, + instead of assuming that kqueue is available under NetBSD and + using the __NetBSD__ macro to conditionalize + kqueue support, add a check that detects kqueue itself — + yes, this generally involves patching the + configure script. There is absolutely nothing + that prevents some OSes from adopting interfaces from other OSes + (e.g. Linux implementing kqueue), something that the above checks + cannot take into account.

    +

    Of course, checking for features generally involves more + work on the developer's side, but the resulting changes are + cleaner and there are chances they will work on many other + platforms. Not to mention that there are higher chances of being + later integrated into the mainstream sources. Remember: + It doesn't work unless it is right!

    +

    Some typical examples:

    +
    +

    Table 12.1. Patching examples

    +
    +++++ + + + + + + + + + + + + + + + + + + + + + + +
    WhereIncorrectCorrect
    configure script
    -[...]
    -.include "../../x11/gtk2/buildlink3.mk"
    -.include "../../mk/bsd.pkg.mk
    +case ${target_os} in
    +netbsd*) have_kvm=yes ;;
    +*)       have_kvm=no  ;;
    +esac
     
    -

    After another bmake clean && bmake, the answer -was:

    +
    -[...]
    -checking for gtk-config... /home/roland/pkg/bin/gtk-config
    -checking for GTK - version >= 1.2.0... no
    -*** Could not run GTK test program, checking why...
    -*** The test program failed to compile or link. See the file config.log for the
    -*** exact error that occured. This usually means GTK was incorrectly installed
    -*** or that you have moved GTK since it was installed. In the latter case, you
    -*** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
    -configure: error: Test for GTK failed.
    -[...]
    +AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)
     
    -

    In this particular case, the assumption that every package -prefers GNOME 2 had been wrong. The first of the lines above -told me that this package really wanted to have the GNOME 1 version of -GTK. If the package had looked for GTK2, it would have looked for -pkg-config instead of gtk-config. -So I changed the x11/gtk2 to -x11/gtk in the package Makefile, -and tried again.

    +
    C source file
    -[...]
    -cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\"  [...]
    -In file included from xpidl.c:42:
    -xpidl.h:53:24: libIDL/IDL.h: No such file or directory
    -In file included from xpidl.c:42:
    -xpidl.h:132: error: parse error before "IDL_ns"
    -[...]
    +#if defined(__NetBSD__)
    +#  include <sys/event.h>
    +#endif
     
    -

    The package still does not find all of its dependencies. Now the -question is: Which package provides the -libIDL/IDL.h header file?

    +
    -$ echo ../../*/*idl*
    -../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
    -$ echo ../../*/*IDL*
    -../../net/libIDL
    +#if defined(HAVE_SYS_EVENT_H)
    +#  include <sys/event.h>
    +#endif
     
    -

    Let's take the one from the second try. So I included the -../../net/libIDL/buildlink3.mk file and tried -again. But the error didn't change. After digging through some of the -code, I concluded that the build process of the package was broken and -couldn't have ever worked, but since the Mozilla source tree is quite -large, I didn't want to fix it. So I added the following to the package -Makefile and tried again:

    +
    C source file
    -CPPFLAGS+=              -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
    -BUILDLINK_TRANSFORM+=   l:IDL:IDL-2
    +int
    +monitor_file(...)
    +{
    +#if defined(__NetBSD__)
    +        int fd = kqueue();
    +        ...
    +#else
    +        ...
    +#endif
    +}
     
    -

    The latter line is needed because the package expects the library -libIDL.so, but only -libIDL-2.so is available. So I told the compiler -wrapper to rewrite that on the fly.

    -

    The next problem was related to a recent change of the FreeType -interface. I looked up in www/seamonkey -which patch files were relevant for this issue and copied them to the -patches directory. Then I retried, fixed the -patches so that they applied cleanly and retried again. This time, -everything worked.

    - -
    -

    -12.2.1.3. Installing the package

    +
    -$ bmake CHECK_FILES=no install
    -[...]
    -$ bmake print-PLIST >PLIST
    -$ bmake deinstall
    -$ bmake install
    +int
    +monitor_file(...)
    +{
    +#if defined(HAVE_KQUEUE)
    +        int fd = kqueue();
    +        ...
    +#else
    +        ...
    +#endif
    +}
     
    +
    +
    + +
    +

    +12.3.5. Feedback to the author

    +

    Always, always, always + feed back any portability fixes or + improvements you do to a package to the mainstream developers. + This is the only way to get their attention on portability issues + and to ensure that future versions can be built out-of-the box on + NetBSD. Furthermore, any user that gets newer distfiles will get + the fixes straight from the packaged code.

    +

    This generally involves cleaning up the patches + (because sometimes the patches that are + added to pkgsrc are quick hacks), filing bug reports in the + appropriate trackers for the projects and working with the + mainstream authors to accept your changes. It is + extremely important that you do it so that + the packages in pkgsrc are kept simple and thus further changes + can be done without much hassle.

    +

    When you have done this, please add a URL to the upstream + bug report to the patch comment.

    +

    Support the idea of free software!

    - -
    -

    -Chapter 13. Package components - files, directories and contents

    - -

    Whenever you're preparing a package, there are a number of -files involved which are described in the following -sections.

    -
    -

    -13.1. Makefile -

    -

    Building, installation and creation of a binary package are all - controlled by the package's Makefile. - The Makefile describes various things about - a package, for example from where to get it, how to configure, - build, and install it.

    -

    A package Makefile contains several - sections that describe the package.

    -

    In the first section there are the following variables, which - should appear exactly in the order given here. The order and - grouping of the variables is mostly historical and has no further - meaning.

    -
      -
    • DISTNAME is the basename of the - distribution file to be downloaded from the package's - website.

    • -
    • PKGNAME is the name of the - package, as used by pkgsrc. You need to provide it if - DISTNAME (which is the default) is not a good - name for the package in pkgsrc or DISTNAME is not - provided (no distribution file is required). Usually it is the pkgsrc - directory name together with the version number. It must match the - regular expression - ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that is, it - starts with a letter or digit, and contains only letters, digits, - dashes, underscores, dots and plus signs.

    • -
    • -

      CATEGORIES is a list of categories - which the package fits in. You can choose any of the top-level - directories of pkgsrc for it.

      -

      Currently the following values are available for - CATEGORIES. If more than - one is used, they need to be separated by spaces:

      -
      -archivers     cross         geography     meta-pkgs     security
      -audio         databases     graphics      misc          shells
      -benchmarks    devel         ham           multimedia    sysutils
      -biology       editors       inputmethod   net           textproc
      -cad           emulators     lang          news          time
      -chat          finance       mail          parallel      wm
      -comms         fonts         math          pkgtools      www
      -converters    games         mbone         print         x11
      -
      -
    • -
    • MASTER_SITES, - DYNAMIC_MASTER_SITES, - DIST_SUBDIR, EXTRACT_SUFX - and DISTFILES are discussed in detail in - Section 19.5, “The fetch phase”.

    • -
    -

    The second section contains information about separately - downloaded patches, if any. -

    -
      -
    • PATCHFILES: - Name(s) of additional files that contain distribution patches. - There is no default. pkgsrc will look for them at - PATCH_SITES. - They will automatically be uncompressed before patching if - the names end with .gz or - .Z.

    • -
    • PATCH_SITES: - Primary location(s) for distribution patch files (see - PATCHFILES above) if not found locally.

    • -
    • PATCH_DIST_STRIP: - an argument to patch(1) that sets the pathname strip count to - help find the correct files to patch. It defaults to - -p0.

    • -
    -

    The third section contains the following variables. -

    -
      -
    • MAINTAINER is the email - address of the person who feels responsible for this package, - and who is most likely to look at problems or questions regarding - this package which have been reported with send-pr(1). - Other developers may contact the MAINTAINER - before making changes to the package, but are not required to - do so. When packaging a new program, set MAINTAINER - to yourself. If you really can't maintain the package for future - updates, set it to - .

    • -
    • OWNER should be used instead - of MAINTAINER when you do not want other - developers to update or change the package without contacting - you first. A package Makefile should contain one of - MAINTAINER or OWNER, but - not both.

    • -
    • HOMEPAGE is a URL where users can - find more information about the package.

    • -
    • COMMENT is a one-line - description of the package (should not include the package - name).

    • -
    • LICENSE indicates the license(s) - applicable for the package. See Section 21.1.3, “Handling licenses” for further details.

    • -
    -

    Other variables that affect the build: -

    -
    • -

      WRKSRC: The directory where the - interesting distribution files of the package are found. The - default is ${WRKDIR}/${DISTNAME}, which - works for most packages.

      -

      If a package doesn't create a subdirectory for itself - (most GNU software does, for instance), but extracts itself in - the current directory, you should set - WRKSRC=${WRKDIR}.

      -

      If a package doesn't create a subdirectory with the - name of DISTNAME but some different name, - set WRKSRC to point to the proper name in - ${WRKDIR}, for example - WRKSRC=${WRKDIR}/${DISTNAME}/unix. See - lang/tcl and x11/tk for other examples.

      -

      The name of the working directory created by pkgsrc is - taken from the WRKDIR_BASENAME - variable. By default, its value is - work. If you want to use the same - pkgsrc tree for building different kinds of binary packages, - you can change the variable according to your needs. Two - other variables handle common cases of setting - WRKDIR_BASENAME individually. If - OBJHOSTNAME is defined in - mk.conf, the first component of - the host's name is attached to the directory name. If - OBJMACHINE is defined, the platform name - is attached, which might look like - work.i386 or - work.sparc.

      -
    -

    Please pay attention to the following gotchas:

    -
      -
    • Add MANCOMPRESSED if man pages are - installed in compressed form by the package. For packages using - BSD-style makefiles which honor MANZ, there is - MANCOMPRESSED_IF_MANZ.

    • -
    • Replace /usr/local with - ${PREFIX} in all files (see patches, - below).

    • -
    • If the package installs any info files, see Section 21.6.7, “Packages installing info files”.

    • -
    -

    -13.2. distinfo -

    -

    The distinfo file contains the message - digest, or checksum, of each distfile needed for the package. This - ensures that the distfiles retrieved from the Internet have not been - corrupted during transfer or altered by a malign force to introduce - a security hole. To provide maximum security, all distfiles are - protected using three different message digest algorithms (SHA1, - RMD160, SHA512), as well as the file size.

    -

    The distinfo file also contains the - checksums for all the patches found in the - patches directory (see Section 13.3, “patches/*). These checksums ensure that patches - are only applied intentionally and that they don't accidentally change, - e.g. when merging different changes together. They also make sure that - new patches are actually added to CVS and old ones are removed. - Too see whether the patches and the distinfo file - match, run pkglint after changing the patches.

    -

    To regenerate the distinfo file, use the - make distinfo command.

    -

    Some packages have different sets of distfiles depending on - the platform, for example lang/openjdk8. These are kept in the same - distinfo file and care should be taken when - upgrading such a package to ensure distfile information is not - lost.

    +12.4. Other mandatory files
    +
    +
    DESCR
    +

    A multi-line description of the piece of software. This should include + any credits where they are due. Please bear in mind that others do not + share your sense of humour (or spelling idiosyncrasies), and that others + will read everything that you write here.

    +
    PLIST
    +

    This file governs the files that are installed on your + system: all the binaries, manual pages, etc. There are other + directives which may be entered in this file, to control the + creation and deletion of directories, and the location of + inserted files. See Chapter 19, PLIST issues for more + information.

    +

    -13.3. patches/* -

    -

    Some packages don't work out-of-the box on the various - platforms that are supported by pkgsrc. These packages need - to be patched to make them work. The patch files can be - found in the patches/ directory.

    -

    In the patch phase, these patches are - applied to the files in WRKSRC directory after - extracting them, in alphabetic order.

    -
    -

    -13.3.1. Structure of a single patch file

    -

    The patch-* files should be in - diff -bu format, and apply without a fuzz to avoid - problems. (To force patches to apply with fuzz you can set - PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch - should contain only changes for a single file, and no file should be - patched by more than one patch file. This helps to keep future - modifications simple.

    -

    Each patch file is structured as follows: In the first line, - there is the RCS Id of the patch itself. The second line should be - empty for aesthetic reasons. After that, there should be a comment for - each change that the patch does. There are a number of standard - cases:

    -
      -
    • Patches for commonly known vulnerabilities should - mention the vulnerability ID (CAN, CVE).

    • -
    • Patches that change source code should mention the - platform and other environment (for example, the compiler) that the - patch is needed for.

    • -
    -

    The patch should be commented so that any - developer who knows the code of the application can make some use of - the patch. Special care should be taken for the upstream developers, - since we generally want that they accept our patches, so we have less - work in the future.

    -
    +12.5. Optional files

    -13.3.2. Creating patch files

    -

    One important thing to mention is to pay attention that no RCS - IDs get stored in the patch files, as these will cause problems when - later checked into the NetBSD CVS tree. Use the - pkgdiff command from the pkgtools/pkgdiff package to avoid these - problems.

    -

    For even more automation, we recommend using - mkpatches from the same package to make a - whole set of patches. You just have to backup files before you - edit them to filename.orig, e.g. with - cp -p filename filename.orig or, easier, by - using pkgvi again from the same package. If - you upgrade a package this way, you can easily compare the new - set of patches with the previously existing one with - patchdiff. The files in patches - are replaced by new files, so carefully check if you want to take all - the changes.

    -

    When you have finished a package, remember to generate - the checksums for the patch files by using the make - makepatchsum command, see Section 13.2, “distinfo.

    -

    When adding a patch that corrects a problem in the - distfile (rather than e.g. enforcing pkgsrc's view of where - man pages should go), send the patch as a bug report to the - maintainer. This benefits non-pkgsrc users of the package, - and usually makes it possible to remove the patch in future - version.

    -

    The file names of the patch files are usually of the form - patch-path_to_file__with__underscores.c. - Many packages still use the previous convention - patch-[a-z][a-z], - but new patches should be of the form containing the filename. - mkpatches included in pkgtools/pkgdiff takes care of the name - automatically.

    -
    -
    -

    -13.3.3. Sources where the patch files come from

    -

    If you want to share patches between multiple packages - in pkgsrc, e.g. because they use the same distfiles, set - PATCHDIR to the path where the patch files - can be found, e.g.:

    -
    -PATCHDIR=       ../../editors/xemacs/patches
    -
    -

    Patch files that are distributed by the author or other - maintainers can be listed in - PATCHFILES.

    -

    If it is desired to store any patches that should not be - committed into pkgsrc, they can be kept outside the pkgsrc - tree in the $LOCALPATCHES directory. The - directory tree there is expected to have the same - category/package structure as pkgsrc, and - patches are expected to be stored inside these dirs (also - known as $LOCALPATCHES/$PKGPATH). For - example, if you want to keep a private patch for - pkgsrc/graphics/png, keep it in - $LOCALPATCHES/graphics/png/mypatch. All - files in the named directory are expected to be patch files, - and they are applied after pkgsrc patches are - applied.

    -
    -
    -

    -13.3.4. Patching guidelines

    -

    When fixing a portability issue in the code do not use - preprocessor magic to check for the current operating system nor - platform. Doing so hurts portability to other platforms because - the OS-specific details are not abstracted appropriately.

    -

    The general rule to follow is: instead of checking for the - operating system the application is being built on, check for the - specific features you need. For example, - instead of assuming that kqueue is available under NetBSD and - using the __NetBSD__ macro to conditionalize - kqueue support, add a check that detects kqueue itself — - yes, this generally involves patching the - configure script. There is absolutely nothing - that prevents some OSes from adopting interfaces from other OSes - (e.g. Linux implementing kqueue), something that the above checks - cannot take into account.

    -

    Of course, checking for features generally involves more - work on the developer's side, but the resulting changes are - cleaner and there are chances they will work on many other - platforms. Not to mention that there are higher chances of being - later integrated into the mainstream sources. Remember: - It doesn't work unless it is right!

    -

    Some typical examples:

    -
    -

    Table 13.1. Patching examples

    -
    ----- - - - - - - - - - - - - - - - - - - - - - - -
    WhereIncorrectCorrect
    configure script -
    -case ${target_os} in
    -netbsd*) have_kvm=yes ;;
    -*)       have_kvm=no  ;;
    -esac
    -
    -
    -
    -AC_CHECK_LIB(kvm, kvm_open, have_kvm=yes, have_kvm=no)
    -
    -
    C source file -
    -#if defined(__NetBSD__)
    -#  include <sys/event.h>
    -#endif
    -
    -
    -
    -#if defined(HAVE_SYS_EVENT_H)
    -#  include <sys/event.h>
    -#endif
    -
    -
    C source file -
    -int
    -monitor_file(...)
    -{
    -#if defined(__NetBSD__)
    -        int fd = kqueue();
    -        ...
    -#else
    -        ...
    -#endif
    -}
    -
    -
    -
    -int
    -monitor_file(...)
    -{
    -#if defined(HAVE_KQUEUE)
    -        int fd = kqueue();
    -        ...
    -#else
    -        ...
    -#endif
    -}
    -
    -
    -
    -
    -
    -
    -

    -13.3.5. Feedback to the author

    -

    Always, always, always - feed back any portability fixes or - improvements you do to a package to the mainstream developers. - This is the only way to get their attention on portability issues - and to ensure that future versions can be built out-of-the box on - NetBSD. Furthermore, any user that gets newer distfiles will get - the fixes straight from the packaged code.

    -

    This generally involves cleaning up the patches - (because sometimes the patches that are - added to pkgsrc are quick hacks), filing bug reports in the - appropriate trackers for the projects and working with the - mainstream authors to accept your changes. It is - extremely important that you do it so that - the packages in pkgsrc are kept simple and thus further changes - can be done without much hassle.

    -

    When you have done this, please add a URL to the upstream - bug report to the patch comment.

    -

    Support the idea of free software!

    -
    - -
    -

    -13.4. Other mandatory files

    -
    -
    DESCR
    -

    A multi-line description of the piece of software. This should include - any credits where they are due. Please bear in mind that others do not - share your sense of humour (or spelling idiosyncrasies), and that others - will read everything that you write here.

    -
    PLIST
    -

    This file governs the files that are installed on your - system: all the binaries, manual pages, etc. There are other - directives which may be entered in this file, to control the - creation and deletion of directories, and the location of - inserted files. See Chapter 15, PLIST issues for more - information.

    -
    -
    -
    -

    -13.5. Optional files

    -
    -

    -13.5.1. Files affecting the binary package

    +12.5.1. Files affecting the binary package
    INSTALL
    @@ -4311,7 +3849,7 @@ monitor_file(...) are moved in place. This can be used to do any custom procedures not possible with @exec commands in PLIST. See pkg_add(1) and - pkg_create(1) for more information. See also Section 17.1, “Files and directories outside the installation prefix”. + pkg_create(1) for more information. See also Section 20.1, “Files and directories outside the installation prefix”. Please note that you can modify variables in it easily by using FILES_SUBST in the package's Makefile:

    @@ -4375,7 +3913,7 @@ MESSAGE_SUBST+= SOMEVAR="somevalue"

    -13.5.2. Files affecting the build process

    +12.5.2. Files affecting the build process
    Makefile.common

    This file contains arbitrary things that could @@ -4387,7 +3925,7 @@ MESSAGE_SUBST+= SOMEVAR="somevalue" describes what it does.

    buildlink3.mk

    This file contains the dependency information - for the buildlink3 framework (see Chapter 16, Buildlink methodology).

    + for the buildlink3 framework (see Chapter 18, Buildlink methodology).

    hacks.mk

    This file contains workarounds for compiler bugs and similar things. It is included automatically by the pkgsrc @@ -4396,7 +3934,7 @@ MESSAGE_SUBST+= SOMEVAR="somevalue" it.

    options.mk

    This file contains the code for the - package-specific options (see Chapter 18, Options handling) that can be + package-specific options (see Chapter 16, Options handling) that can be selected by the user. If a package has only one or two options, it is equally acceptable to put the code directly into the Makefile.

    @@ -4404,7 +3942,7 @@ MESSAGE_SUBST+= SOMEVAR="somevalue"

    -13.5.3. Files affecting nothing at all

    +12.5.3. Files affecting nothing at all
    README*

    These files do not take place in the creation of @@ -4419,7 +3957,7 @@ MESSAGE_SUBST+= SOMEVAR="somevalue"

    -13.6. work* +12.6. work*

    When you type make, the distribution files are unpacked into the directory denoted by @@ -4433,7 +3971,7 @@ MESSAGE_SUBST+= SOMEVAR="somevalue"

    -13.7. files/* +12.7. files/*

    If you have any files that you wish to be placed in the package prior to configuration or building, you can place these files here @@ -4450,2703 +3988,3185 @@ FILESDIR= ../../editors/xemacs/fil

    -Chapter 14. Programming in Makefiles

    +Chapter 13. The build process
    -

    Pkgsrc consists of many Makefile fragments, - each of which forms a well-defined part of the pkgsrc system. Using - the make(1) system as a programming language for a big system - like pkgsrc requires some discipline to keep the code correct and - understandable.

    -

    The basic ingredients for Makefile - programming are variables and shell - commands. Among these shell commands may even be more complex ones - like awk(1) programs. To make sure that every shell command runs - as intended it is necessary to quote all variables correctly when they - are used.

    -

    This chapter describes some patterns that appear quite often in - Makefiles, including the pitfalls that come along - with them.

    -14.1. Caveats

    -
    • -

      When you are creating a file as a - target of a rule, always write the data to a temporary file first - and finally rename that file. Otherwise there might occur an error - in the middle of generating the file, and when the user runs - make(1) for the second time, the file exists and will not be - regenerated properly. Example:

      -
      -wrong:
      -        @echo "line 1" > ${.TARGET}
      -        @echo "line 2" >> ${.TARGET}
      -        @false
      -
      -correct:
      -        @echo "line 1" > ${.TARGET}.tmp
      -        @echo "line 2" >> ${.TARGET}.tmp
      -        @false
      -        @mv ${.TARGET}.tmp ${.TARGET}
      -
      -

      When you run make wrong twice, the file - wrong will exist, although there was an error - message in the first run. On the other hand, running make - correct gives an error message twice, as expected.

      -

      You might remember that make(1) sometimes removes - ${.TARGET} in case of error, but this only - happens when it is interrupted, for example by pressing - Ctrl+C. This does not happen - when one of the commands fails (like false(1) above).

      -
    +13.1. Introduction
    +

    This chapter gives a detailed description on how a package is + built. Building a package is separated into different + phases (for example fetch, + build, install), all of which are + described in the following sections. Each phase is split into + so-called stages, which take the name of the + containing phase, prefixed by one of pre-, + do- or post-. (Examples are + pre-configure, post-build.) Most + of the actual work is done in the do-* stages.

    +

    Never override the regular targets (like + fetch), if you have to, override the + do-* ones instead.

    +

    The basic steps for building a program are always the same. First + the program's source (distfile) must be brought to + the local system and then extracted. After any pkgsrc-specific patches + to compile properly are applied, the software can be configured, then + built (usually by compiling), and finally the generated binaries, etc. + can be put into place on the system.

    +

    To get more details about what is happening at each step, + you can set the PKG_VERBOSE variable, or the + PATCH_DEBUG variable if you are just interested + in more details about the patch step.

    -14.2. Makefile variables

    -

    Makefile variables contain strings that - can be processed using the five operators =, - +=, ?=, := and - !=, which are described in the make(1) man - page.

    -

    When a variable's value is parsed from a - Makefile, the hash character # and - the backslash character \ are handled specially. If a - backslash is the last character in a line, that backslash is removed - from the line and the line continues with the next line of the file.

    -

    The # character starts a comment that reaches - until the end of the line. To get an actual # character, - such as in a URL, write \# instead.

    -

    The evaluation of variables either happens immediately or lazy. - It happens immediately when the variable occurs on the right-hand - side of the := or the != operator, in a - .if condition or a .for loop. - In the other cases, it is evaluated lazily.

    -

    Some of the modifiers split the string into words and then - operate on the words, others operate on the string as a whole. When a - string is split into words, double quotes and single quotes are - interpreted as delimiters, just like in sh(1).

    -
    -

    -14.2.1. Naming conventions

    +13.2. Program location
    +

    Before outlining the process performed by the NetBSD package system in + the next section, here's a brief discussion on where programs are + installed, and which variables influence this.

    +

    The automatic variable PREFIX indicates + where all files of the final program shall be installed. It is + usually set to LOCALBASE + (/usr/pkg), or CROSSBASE + for pkgs in the cross category. The value of + PREFIX needs to be put + into the various places in the program's source where paths to + these files are encoded. See Section 12.3, “patches/* and Section 21.3.1, “Shared libraries - libtool” for more details.

    +

    When choosing which of these variables to use, + follow the following rules:

      -
    • All variable names starting with an underscore - are reserved for use by the pkgsrc infrastructure. They shall - not be used by packages.

    • -
    • In .for loops you should use - lowercase variable names for the iteration - variables.

    • -
    • All list variables should have a plural name, - such as PKG_OPTIONS or - DISTFILES.

    • +
    • PREFIX always points to the location + where the current pkg will be installed. When referring to a + pkg's own installation path, use + ${PREFIX}.

    • +
    • LOCALBASE is where all non-X11 pkgs + are installed. If you need to construct a -I or -L argument + to the compiler to find includes and libraries installed by + another non-X11 pkg, use ${LOCALBASE}. The name + LOCALBASE stems from FreeBSD, which + installed all packages in /usr/local. As + pkgsrc leaves /usr/local for the system + administrator, this variable is a misnomer.

    • +
    • X11BASE is where the actual X11 + distribution (from xsrc, etc.) is installed. When looking for + standard X11 includes (not those + installed by a package), use ${X11BASE}.

    • +
    • X11-based packages using imake must set + USE_IMAKE to be installed correctly under + LOCALBASE.

    • +
    • Within ${PREFIX}, packages should + install files according to hier(7), with the exception that + manual pages go into ${PREFIX}/man, not + ${PREFIX}/share/man.

    +
    +

    +13.3. Directories used during the build process

    +

    When building a package, various directories are used to store + source files, temporary files, pkgsrc-internal files, and so on. These + directories are explained here.

    +

    Some of the directory variables contain relative pathnames. There + are two common base directories for these relative directories: + PKGSRCDIR/PKGPATH is used for directories that are + pkgsrc-specific. WRKSRC is used for directories + inside the package itself.

    +
    +
    PKGSRCDIR
    +

    This is an absolute pathname that points to the pkgsrc + root directory. Generally, you don't need + it.

    +
    PKGDIR
    +

    This is an absolute pathname that points to the + current package.

    +
    PKGPATH
    +

    This is a pathname relative to + PKGSRCDIR that points to the current + package.

    +
    WRKDIR
    +

    This is an absolute pathname pointing to the directory + where all work takes place. The distfiles are extracted to this + directory. It also contains temporary directories and log files used by + the various pkgsrc frameworks, like buildlink or + the wrappers.

    +
    WRKSRC
    +

    This is an absolute pathname pointing to the directory + where the distfiles are extracted. It is usually a direct subdirectory + of WRKDIR, and often it's the only directory entry + that isn't hidden. This variable may be changed by a package + Makefile.

    +
    +

    The CREATE_WRKDIR_SYMLINK definition takes either + the value yes or no and defaults + to no. It indicates whether a symbolic link to the + WRKDIR is to be created in the pkgsrc entry's directory. + If users would like to have their pkgsrc trees behave in a + read-only manner, then the value of + CREATE_WRKDIR_SYMLINK should be set to + no.

    -14.3. Code snippets

    -
    -

    -14.3.1. Adding things to a list

    -

    When adding a string that possibly contains whitespace or quotes to -a list (example 1), it must be quoted using the :Q -modifier.

    -

    When adding another list to a list (example 2), it must not be -quoted, since its elements are already quoted.

    -
    -STRING=         foo * bar `date`
    -LIST=           # empty
    -ANOTHER_LIST=   a=b c=d
    -
    -LIST+=          ${STRING:Q}       # 1
    -LIST+=          ${ANOTHER_LIST}   # 2
    -
    +13.4. Running a phase
    +

    You can run a particular phase by typing make + phase, where phase is the name of the + phase. This will automatically run all phases that are required for this + phase. The default phase is build, that is, when you + run make without parameters in a package directory, + the package will be built, but not installed.

    +
    +

    +13.5. The fetch phase

    +

    The first step in building a package is to fetch the + distribution files (distfiles) from the sites that are providing + them. This is the task of the fetch + phase.

    -14.3.2. Echoing a string exactly as-is

    -

    Echoing a string containing special characters needs special -work.

    +13.5.1. What to fetch and where to get it from
    +

    In simple cases, MASTER_SITES + defines all URLs from where the distfile, whose name is + derived from the DISTNAME variable, is + fetched. The more complicated cases are described + below.

    +

    The variable DISTFILES specifies + the list of distfiles that have to be fetched. Its value + defaults to ${DEFAULT_DISTFILES} and + its value is ${DISTNAME}${EXTRACT_SUFX}, + so that most packages don't need to define it at all. + EXTRACT_SUFX is + .tar.gz by default, but can be changed + freely. Note that if your package requires additional + distfiles to the default one, you cannot just append the + additional filenames using the += + operator, but you have write for example:

    -STRING=         foo bar <    > * `date` $$HOME ' "
    -EXAMPLE_ENV=    string=${STRING:Q} x=multiple\ quoted\ words
    -
    -all:
    -        echo ${STRING}                  # 1
    -        echo ${STRING:Q}                # 2
    -        printf '%s\n' ${STRING:Q}''     # 3
    -        env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"'   # 4
    +DISTFILES=      ${DEFAULT_DISTFILES} additional-files.tar.gz
     
    -

    Example 1 leads to a syntax error in the shell, as the characters -are just copied.

    -

    Example 2 quotes the string so that the shell interprets it -correctly. But the echo command may additionally interpret strings with a -leading dash or those containing backslashes.

    -

    Example 3 can handle arbitrary strings, since printf(1) only -interprets the format string, but not the next argument. The trailing -single quotes handle the case when the string is empty. In that case, the -:Q modifier would result in an empty string too, which would then be -skipped by the shell. For printf(1) this doesn't make a difference, -but other programs may care.

    -

    In example 4, the EXAMPLE_ENV does not -need to be quoted because the quoting has already been done -when adding elements to the list.

    - -
    -

    -14.3.3. Passing CFLAGS to GNU configure scripts

    -

    When passing CFLAGS or similar variables to a -GNU-style configure script (especially those that call other configure -scripts), it must not have leading or trailing whitespace, since -otherwise the configure script gets confused. To trim leading and -trailing whitespace, use the :M modifier, as in the -following example:

    +

    Each distfile is fetched from a list of sites, usually + MASTER_SITES. If the package has multiple + DISTFILES or multiple + PATCHFILES from different sites, you can + set + SITES.distfile + to the list of URLs where the file + distfile + (including the suffix) can be found.

    -CPPFLAGS=               # empty
    -CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX}\"
    -CPPFLAGS+=              ${MY_CPPFLAGS}
    -
    -CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
    -
    -all:
    -        echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
    -        echo x${CONFIGURE_ARGS:Q}x      # properly trimmed
    +DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
    +DISTFILES+=     foo-file.tar.gz
    +SITES.foo-file.tar.gz= \
    +https://www.somewhere.com/somehow/ \
    +https://www.somewhereelse.com/mirror/somehow/
     
    -

    In this example, CPPFLAGS has both leading and -trailing whitespace because the += operator always adds a -space.

    -
    -
    -

    -14.3.4. Handling possibly empty variables

    -

    When a possibly empty variable is used in a shell program, it may -lead to a syntax error.

    +

    When actually fetching the distfiles, each item from + MASTER_SITES or + SITES.* gets the name of each distfile + appended to it, without an intermediate slash. Therefore, + all site values have to end with a slash or other separator + character. This allows for example to set + MASTER_SITES to a URL of a CGI script + that gets the name of the distfile as a parameter. In this + case, the definition would look like:

    -EGFILES=        # empty
    -
    -install-examples:   # produces a syntax error in the shell
    -        for egfile in ${EGFILES}; do            \
    -                echo "Installing $$egfile";     \
    -        done
    +MASTER_SITES=   https://www.example.com/download.cgi?file=
     
    -

    The shell only sees the text for egfile in ; do, since -${EGFILES} is replaced with an empty string by make(1). -To fix this syntax error, use one of the snippets below.

    +

    The exception to this rule are URLs starting with a dash. + In that case the URL is taken as is, fetched and the result + stored under the name of the distfile. You can use this style + for the case when the download URL style does not match the + above common case. For example, if permanent download URL is a + redirector to the real download URL, or the download file name + is offered by an HTTP Content-Disposition header. In the + following example, foo-1.0.0.tar.gz will be + created instead of the default + v1.0.0.tar.gz.

    -EMPTY=          # empty
    -
    -install-examples:
    -        for egfile in ${EGFILES} ""; do         \
    -                [ -n "$$egfile" ] || continue;  \
    -                echo "Installing $$egfile";     \
    -        done
    +DISTNAME=       foo-1.0.0
    +MASTER_SITES=   -https://www.example.com/archive/v1.0.0.tar.gz
     
    -

    In this case, an empty string is appended to the iteration list (to -prevent the syntax error) and filtered out later.

    -
    -EGFILES=        # empty
    -
    -install-examples:
    -.for egfile in ${EGFILES}
    -        echo "Installing ${egfile}"
    -.endfor
    +

    There are some predefined values for + MASTER_SITES, which can be used in + packages. The names of the variables should speak for + themselves.

    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    MASTER_SITE_APACHEMASTER_SITE_BACKUP
    MASTER_SITE_CRATESIOMASTER_SITE_CYGWIN
    MASTER_SITE_DEBIANMASTER_SITE_FREEBSD
    MASTER_SITE_FREEBSD_LOCALMASTER_SITE_GENTOO
    MASTER_SITE_GITHUBMASTER_SITE_GNOME
    MASTER_SITE_GNUMASTER_SITE_GNUSTEP
    MASTER_SITE_HASKELL_HACKAGEMASTER_SITE_IFARCHIVE
    MASTER_SITE_KDEMASTER_SITE_MOZILLA
    MASTER_SITE_MOZILLA_ALLMASTER_SITE_MYSQL
    MASTER_SITE_NETLIBMASTER_SITE_OPENBSD
    MASTER_SITE_OPENOFFICEMASTER_SITE_OSDN
    MASTER_SITE_PERL_CPANMASTER_SITE_PGSQL
    MASTER_SITE_PYPIMASTER_SITE_RUBYGEMS
    MASTER_SITE_R_CRANMASTER_SITE_SOURCEFORGE
    MASTER_SITE_SUNSITEMASTER_SITE_SUSE
    MASTER_SITE_TEX_CTANMASTER_SITE_XCONTRIB
    MASTER_SITE_XEMACSMASTER_SITE_XORG
    +

    Some explanations for the less self-explaining ones: + MASTER_SITE_BACKUP contains backup sites + for packages that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local + package source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/LOCAL_PORTS/.

    +

    If you choose one of these predefined sites, you may + want to specify a subdirectory of that site. Since these + macros may expand to more than one actual site, you + must use the following construct to + specify a subdirectory:

    +
    +MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
    +MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
     
    -

    If one of the filenames contains special characters, it should be -enclosed in single or double quotes.

    -

    To have a shell command test whether a make variable is empty, use -the following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".

    +

    Note the trailing slash after the subdirectory + name.

    +
    +

    +13.5.2. How are the files fetched?

    +

    The fetch phase makes sure that + all the distfiles exist in a local directory + (DISTDIR, which can be set by the pkgsrc + user). If the files do not exist, they are fetched using + commands of the form

    +
    +${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
    +
    +

    where ${site} varies through + several possibilities in turn: first, + MASTER_SITE_OVERRIDE is tried, then the + sites specified in either SITES.file if + defined, else MASTER_SITES or + PATCH_SITES, as applies, then finally the + value of MASTER_SITE_BACKUP. The order of + all except the first and the last can be optionally sorted + by the user, via setting either + MASTER_SORT_RANDOM, and + MASTER_SORT_AWK or + MASTER_SORT_REGEX.

    +

    The specific command and arguments used depend on the + FETCH_USING parameter. The example above is + for FETCH_USING=custom.

    +

    The distfiles mirror run by the NetBSD Foundation uses the + mirror-distfiles target to mirror the + distfiles, if they are freely distributable. Packages setting + NO_SRC_ON_FTP (usually to + ${RESTRICTED}) will not have their distfiles + mirrored.

    -
    -

    -Chapter 15. PLIST issues

    -
    -

    Table of Contents

    -
    -
    15.1. RCS ID
    -
    15.2. Semi-automatic PLIST generation
    -
    15.3. Tweaking output of make print-PLIST
    -
    15.4. Variable substitution in PLIST
    -
    15.5. Man page compression
    -
    15.6. Changing PLIST source with PLIST_SRC
    -
    15.7. Platform-specific and differing PLISTs
    -
    15.8. Build-specific PLISTs
    -
    15.9. Sharing directories between packages
    -
    +
    +

    +13.6. The checksum phase

    +

    After the distfile(s) are fetched, their checksum is + generated and compared with the checksums stored in the + distinfo file. If the checksums don't match, the build is + aborted. This is to ensure the same distfile is used for + building, and that the distfile wasn't changed, e.g. by some + malign force, deliberately changed distfiles on the master + distribution site or network lossage.

    -

    The PLIST file contains a package's - packing list, i.e. a list of files that belong to - the package (relative to the ${PREFIX} - directory it's been installed in) plus some additional statements - - see the pkg_create(1) man page for a full list. - This chapter addresses some issues that need attention when - dealing with the PLIST file (or files, see - below!).

    -15.1. RCS ID

    -

    Be sure to add a RCS ID line as the first thing in any - PLIST file you write:

    -
    -@comment $NetBSD $
    -
    -

    An artificial space has been added between NetBSD and $, this is a -workaround here to prevent CVS expanding to the filename of the guide. When -adding the RCS ID the space should be omitted.

    +13.7. The extract phase
    +

    When the distfiles are present on the local system, they + need to be extracted, as they usually come in the form of some + compressed archive format.

    +

    By default, all DISTFILES are + extracted. If you only need some of them, you can set the + EXTRACT_ONLY variable to the list of those + files.

    +

    Extracting the files is usually done by a little + program, mk/extract/extract, which + already knows how to extract various archive formats, so most + likely you will not need to change anything here. But if you + need, the following variables may help you:

    +
    +
    EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
    +

    Use these variables to override the default + options for an extract command, which are defined in + mk/extract/extract.

    +
    EXTRACT_USING
    +

    This variable can be set to + bsdtar, gtar, nbtar + (which is the default value), pax, or an + absolute pathname pointing to the command with which tar + archives should be extracted. It is preferred to choose bsdtar over gtar + if NetBSD's pax-as-tar is not good enough.

    +
    +

    If the extract program doesn't + serve your needs, you can also override the + EXTRACT_CMD variable, which holds the + command used for extracting the files. This command is + executed in the ${WRKSRC} + directory. During execution of this command, the shell + variable extract_file holds the absolute + pathname of the file that is going to be extracted.

    +

    And if that still does not suffice, you can override the + do-extract target in the package + Makefile.

    -15.2. Semi-automatic PLIST generation

    -

    You can use the make print-PLIST command - to output a PLIST that matches any new files since the package - was extracted. See Section 19.17, “Other helpful targets” for - more information on this target.

    +13.8. The patch phase
    +

    After extraction, all the patches named by the + PATCHFILES, those present in the patches + subdirectory of the package as well as in + $LOCALPATCHES/$PKGPATH (e.g. + /usr/local/patches/graphics/png) are + applied. Patchfiles ending in .Z or + .gz are uncompressed before they are + applied, files ending in .orig or + .rej are ignored. Any special options to + patch(1) can be handed in + PATCH_DIST_ARGS. See Section 12.3, “patches/* for more details.

    +

    By default patch(1) is given special arguments to make it + fail if the expected text from the patch context is not found in the + patched file. If that happens, fix the patch file by comparing it + with the actual text in the file to be patched.

    -15.3. Tweaking output of make print-PLIST -

    -

    The PRINT_PLIST_AWK variable takes a set - of AWK patterns and actions that are used to filter the output of - print-PLIST. You can append any chunk of AWK - scripting you like to it, but be careful with quoting.

    -

    For example, to get all files inside the - libdata/foo directory removed from the - resulting PLIST:

    -
    -PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
    -
    -

    The PRINT_PLIST_AWK transformations are - evaluated after the file list and directory list are sorted. - EARLY_PRINT_PLIST_AWK is like - PRINT_PLIST_AWK except it operates before the file - list and directory list are sorted.

    +13.9. The tools phase
    +

    This is covered in Chapter 17, Tools needed for building or running. +

    -15.4. Variable substitution in PLIST

    -

    A number of variables are substituted automatically in - PLISTs when a package is installed on a system. This includes the - following variables:

    +13.10. The wrapper phase
    +

    This phase creates wrapper programs for the compilers and + linkers. The following variables can be used to tweak the + wrappers.

    -
    ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
    -
    -

    Some packages like emacs and perl embed information - about which architecture they were built on into the - pathnames where they install their files. To handle this - case, PLIST will be preprocessed before actually used, and - the symbol - ${MACHINE_ARCH} will be - replaced by what uname -p gives. The - same is done if the string - ${MACHINE_GNU_ARCH} is embedded in - PLIST somewhere - use this on packages that have GNU - autoconf-created configure scripts.

    -
    -

    Legacy note

    -

    There used to be a symbol - $ARCH that - was replaced by the output of uname - -m, but that's no longer supported and has - been removed.

    -
    -
    -
    ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
    -
    -

    Some packages want to embed the OS name and version - into some paths. To do this, use these variables in the - PLIST: -

    -
      -
    • ${OPSYS} - output of uname -s

    • -
    • ${LOWER_OPSYS} - lowercase common name (eg. solaris)

    • -
    • ${OS_VERSION} - uname -r

    • -
    -
    +
    ECHO_WRAPPER_MSG
    +

    The command used to print progress + messages. Does nothing by default. Set to + ${ECHO} to see the progress + messages.

    +
    WRAPPER_DEBUG
    +

    This variable can be set to + yes (default) or no, + depending on whether you want additional information in the + wrapper log file.

    +
    WRAPPER_UPDATE_CACHE
    +

    This variable can be set to + yes or no, depending + on whether the wrapper should use its cache, which will + improve the speed. The default value is + yes, but is forced to + no if the platform does not support + it.

    +
    WRAPPER_REORDER_CMDS
    +

    A list of reordering commands. A reordering + command has the form + reorder:l:lib1:lib2. + It ensures that that + -llib1 occurs + before -llib2. +

    -

    For a list of values which are replaced by - default, the output of make help topic=PLIST_SUBST as -well as searching the pkgsrc/mk directory with grep for -PLIST_SUBST should help.

    -

    If you want to change other variables not listed above, you - can add variables and their expansions to this variable in the - following way, similar to MESSAGE_SUBST (see Section 13.5, “Optional files”):

    -
    -PLIST_SUBST+=   SOMEVAR="somevalue"
    -
    -

    This replaces all occurrences of ${SOMEVAR} - in the PLIST with - somevalue.

    -

    The PLIST_VARS variable can be used to simplify - the common case of conditionally including some - PLIST entries. It can be done by adding - PLIST_VARS+=foo and - setting the corresponding PLIST.foo variable - to yes if the entry should be included. - This will substitute ${PLIST.foo} - in the PLIST with either - "" or - "@comment ". - For example, in Makefile:

    -
    -PLIST_VARS+=    foo
    -.if condition
    -PLIST.foo=      yes
    -.else
    -
    -

    And then in PLIST:

    -
    -@comment $NetBSD $
    -bin/bar
    -man/man1/bar.1
    -${PLIST.foo}bin/foo
    -${PLIST.foo}man/man1/foo.1
    -${PLIST.foo}share/bar/foo.data
    -
    -

    An artificial space has been added between NetBSD and $, this is a -workaround here to prevent CVS expanding to the filename of the guide. When -adding the RCS ID the space should be ommited.

    - -
    -

    -15.5. Man page compression

    -

    Man pages should be installed in compressed form if - MANZ is set (in bsd.own.mk), - and uncompressed otherwise. To handle this in the - PLIST file, the suffix .gz is - appended/removed automatically for man pages according to - MANZ and MANCOMPRESSED being set - or not, see above for details. This modification of the - PLIST file is done on a copy of it, not - PLIST itself.

    -15.6. Changing PLIST source with PLIST_SRC -

    -

    To use one or more files as source for the PLIST used - in generating the binary package, set the variable - PLIST_SRC to the names of that file(s). - The files are later concatenated using cat(1), and the order of things is - important. The default for PLIST_SRC is - ${PKGDIR}/PLIST.

    +13.11. The configure phase
    +

    Most pieces of software need information on the header + files, system calls, and library routines which are available + on the platform they run on. The process of determining this + information is known as configuration, and is usually + automated. In most cases, a script is supplied with the + distfiles, and its invocation results in generation of header + files, Makefiles, etc.

    +

    If the package contains a configure script, this can be + invoked by setting HAS_CONFIGURE to + yes. If the configure script is a GNU autoconf + script, you should set GNU_CONFIGURE to + yes instead. What happens in the + configure phase is roughly:

    +
    +.for d in ${CONFIGURE_DIRS}
    +        cd ${WRKSRC} \
    +        && cd ${d} \
    +        && env ${CONFIGURE_ENV} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
    +.endfor
    +
    +

    CONFIGURE_DIRS (default: + .) is a list of pathnames relative to + WRKSRC. In each of these directories, the + configure script is run with the environment + CONFIGURE_ENV and arguments + CONFIGURE_ARGS. The variables + CONFIGURE_ENV, + CONFIGURE_SCRIPT (default: + ./configure) and + CONFIGURE_ARGS may all be changed by the + package.

    +

    If the program uses the Perl way of configuration (mainly Perl + modules, but not only), i.e. a file called + Makefile.PL, it should include + ../../lang/perl5/module.mk. To set any parameter for + Makefile.PL use the MAKE_PARAMS + variable (e.g., MAKE_PARAMS+=foo=bar

    +

    If the program uses an Imakefile + for configuration, the appropriate steps can be invoked by + setting USE_IMAKE to + yes. If you only need xmkmf, add it to USE_TOOLS. + You can add variables to xmkmf's environment by adding them to the + SCRIPTS_ENV variable.

    +

    If the program uses cmake + for configuration, the appropriate steps can be invoked by + setting USE_CMAKE to yes. + You can add variables to cmake's environment by adding them to the + CONFIGURE_ENV variable and arguments to cmake + by adding them to the CMAKE_ARGS variable. + The top directory argument is given by the + CMAKE_ARG_PATH variable, that defaults to + . (relative to CONFIGURE_DIRS)

    +

    If there is no configure step at all, set + NO_CONFIGURE to yes.

    -15.7. Platform-specific and differing PLISTs

    -

    Some packages decide to install a different set of files based on - the operating system being used. These differences can be - automatically handled by using the following files:

    -
      -
    • PLIST.common

    • -
    • PLIST.${OPSYS}

    • -
    • PLIST.${MACHINE_ARCH}

    • -
    • PLIST.${OPSYS}-${MACHINE_ARCH}

    • -
    • PLIST.common_end

    • -
    +13.12. The build phase
    +

    For building a package, a rough equivalent of the + following code is executed.

    +
    +.for d in ${BUILD_DIRS}
    +        cd ${WRKSRC} \
    +        && cd ${d} \
    +        && env ${MAKE_ENV} \
    +            ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
    +                -f ${MAKE_FILE} \
    +                ${BUILD_TARGET}
    +.endfor
    +
    +

    BUILD_DIRS (default: + .) is a list of pathnames relative to + WRKSRC. In each of these directories, + MAKE_PROGRAM is run with the environment + MAKE_ENV and arguments + BUILD_MAKE_FLAGS. The variables + MAKE_ENV, + BUILD_MAKE_FLAGS, + MAKE_FILE and + BUILD_TARGET may all be changed by the + package.

    +

    The default value of MAKE_PROGRAM is + gmake if USE_TOOLS contains + gmake, make otherwise. The + default value of MAKE_FILE is + Makefile, and BUILD_TARGET + defaults to all.

    +

    If there is no build step at all, set + NO_BUILD to yes.

    -15.8. Build-specific PLISTs

    -

    Some packages decide to generate hard-to-guess file names - during installation that are hard to wire down.

    -

    In such cases, you can set the - GENERATE_PLIST variable to shell code - terminated (with a semicolon) that will output PLIST entries which - will be appended to the PLIST

    -

    You can find one example in editors/xemacs:

    -
    -GENERATE_PLIST+=        ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
    -
    -

    which will append something like - bin/xemacs-21.4.23-54e8ea71.dmp to the - PLIST. -

    +13.13. The test phase
    +

    [TODO]

    -15.9. Sharing directories between packages

    -

    A shared directory is a directory where - multiple (and unrelated) packages install files. These - directories were problematic because you had to add special - tricks in the PLIST to conditionally remove them, or have some - centralized package handle them.

    -

    In pkgsrc, it is now easy: Each package should create - directories and install files as needed; pkg_delete - will remove any directories left empty after uninstalling a - package.

    -

    If a package needs an empty directory to work, create - the directory during installation as usual, and also add an - entry to the PLIST: - -

    +13.14. The install phase
    +

    Once the build stage has completed, the final step is to + install the software in public directories, so users can + access the programs and files.

    +

    In the install phase, a rough + equivalent of the following code is executed. Additionally, + before and after this code, much magic is performed to do + consistency checks, registering the package, and so on.

    -@pkgdir path/to/empty/directory
    +.for d in ${INSTALL_DIRS}
    +        cd ${WRKSRC} \
    +        && cd ${d} \
    +        && env ${MAKE_ENV} \
    +            ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
    +                -f ${MAKE_FILE} \
    +                ${INSTALL_TARGET}
    +.endfor
     
    -

    - - or take a look at MAKE_DIRS and - OWN_DIRS. -

    - - -
    -

    -Chapter 16. Buildlink methodology

    - -

    Buildlink is a framework in pkgsrc that controls what headers and libraries - are seen by a package's configure and build processes. This is implemented - in a two step process:

    -
      -
    1. Symlink headers and libraries for dependencies into - BUILDLINK_DIR, which by default is a subdirectory - of WRKDIR.

    2. -
    3. Create wrapper scripts that are used in place of the normal compiler - tools that translate -I${LOCALBASE}/include and - -L${LOCALBASE}/lib into references to - BUILDLINK_DIR. The wrapper scripts also make - native compiler on some operating systems look like GCC, so that - packages that expect GCC won't require modifications to build with - those native compilers.

    4. -
    -

    This normalizes the environment in which a package is built so that the - package may be built consistently despite what other software may be - installed. Please note that the normal system header and library paths, - e.g. /usr/include, - /usr/lib, etc., are always searched -- buildlink3 is - designed to insulate the package build from non-system-supplied - software.

    +

    The variable's meanings are analogous to the ones in the + build phase. + INSTALL_DIRS defaults to + BUILD_DIRS. INSTALL_TARGET + is install by default, plus + install.man if USE_IMAKE is + defined and NO_INSTALL_MANPAGES is not + defined.

    +

    In the install phase, the following + variables are useful. They are all variations of the + install(1) command that have the owner, group and + permissions preset. INSTALL is the plain + install command. The specialized variants, together with their + intended use, are:

    +
    +
    INSTALL_PROGRAM_DIR
    +

    directories that contain + binaries

    +
    INSTALL_SCRIPT_DIR
    +

    directories that contain + scripts

    +
    INSTALL_LIB_DIR
    +

    directories that contain shared and static + libraries

    +
    INSTALL_DATA_DIR
    +

    directories that contain data + files

    +
    INSTALL_MAN_DIR
    +

    directories that contain man + pages

    +
    INSTALL_GAME_DIR
    +

    directories that contain data files for games +

    +
    INSTALL_PROGRAM
    +

    binaries that can be stripped from debugging + symbols

    +
    INSTALL_SCRIPT
    +

    binaries that cannot be + stripped

    +
    INSTALL_GAME
    +

    game + binaries

    +
    INSTALL_LIB
    +

    shared and static + libraries

    +
    INSTALL_DATA
    +

    data files

    +
    INSTALL_GAME_DATA
    +

    data files for + games

    +
    INSTALL_MAN
    +

    man pages

    +
    +

    Some other variables are:

    +
    +
    INSTALL_UNSTRIPPED
    +

    If set to yes, do not run strip(1) + when installing binaries. Any debugging sections and symbols present in + binaries will be preserved. +

    +
    INSTALLATION_DIRS
    +

    A list of directories relative to + PREFIX that are created by pkgsrc at the + beginning of the install phase. + The package is supposed to create all needed directories itself + before installing files to it and list all other directories here. +

    +
    +

    In the rare cases that a package shouldn't install anything, + set NO_INSTALL to yes. This is + mostly relevant for packages in the regress + category.

    +

    -16.1. Converting packages to use buildlink3

    -

    The process of converting packages to use the buildlink3 - framework (bl3ifying) is fairly straightforward. - The things to keep in mind are:

    -
      -
    1. Ensure that the build always calls the wrapper scripts - instead of the actual toolchain. Some packages are tricky, - and the only way to know for sure is the check - ${WRKDIR}/.work.log to see if the - wrappers are being invoked.

    2. -
    3. Don't override PREFIX from within - the package Makefile, e.g. Java VMs, standalone shells, - etc., because the code to symlink files into - ${BUILDLINK_DIR} looks for files - relative to pkg_info -qp pkgname. -

    4. -
    5. Remember that only the - buildlink3.mk files that you list in a - package's Makefile are added as dependencies for that package. -

    6. -
    -

    If a dependency on a particular package is required for its libraries and - headers, then we replace:

    -
    -DEPENDS+=       foo>=1.1.0:../../category/foo
    -
    -

    with

    -
    -.include "../../category/foo/buildlink3.mk"
    -
    -

    The buildlink3.mk files usually define the required dependencies. - If you need a newer version of the dependency when using buildlink3.mk - files, then you can define it in your Makefile; for example:

    -
    -BUILDLINK_API_DEPENDS.foo+=   foo>=1.1.0
    -.include "../../category/foo/buildlink3.mk"
    -
    -

    There are several buildlink3.mk - files in pkgsrc/mk - that handle special package issues:

    -
      -
    • bdb.buildlink3.mk chooses either - the native or a pkgsrc Berkeley DB implementation based on - the values of BDB_ACCEPTED and - BDB_DEFAULT.

    • -
    • curses.buildlink3.mk: If the system - comes with neither Curses nor NCurses, this will take care - to install the devel/ncurses package.

    • -
    • krb5.buildlink3.mk uses the value - of KRB5_ACCEPTED to choose between - adding a dependency on Heimdal or MIT-krb5 for packages that - require a Kerberos 5 implementation.

    • -
    • motif.buildlink3.mk checks for a - system-provided Motif installation or adds a dependency on - x11/lesstif or x11/motif. The user can set - MOTIF_TYPE to dt, - lesstif or motif - to choose which Motif version will be used.

    • -
    • readline.buildlink3.mk checks for a - system-provided GNU readline or editline (libedit) installation, - or adds a dependency on devel/readline, - devel/editline. The user can set - READLINE_DEFAULT to choose readline implementation. - If your package really needs GNU readline library, its Makefile - should include devel/readline/buildlink3.mk - instead of readline.buildlink3.mk.

    • -
    • oss.buildlink3.mk defines several - variables that may be used by packages that use the - Open Sound System (OSS) API.

    • -
    • pgsql.buildlink3.mk will accept - any of the Postgres versions in the variable - PGSQL_VERSIONS_ACCEPTED and default to - the version PGSQL_VERSION_DEFAULT. See - the file for more information.

    • -
    • pthread.buildlink3.mk uses the value of - PTHREAD_OPTS and checks for native pthreads or adds - a dependency on devel/pth as needed.

    • -
    • xaw.buildlink3.mk uses the value of - XAW_TYPE to choose a particular Athena widgets - library.

    • -
    -

    The comments in those buildlink3.mk - files provide a more complete - description of how to use them properly.

    +13.15. The package phase
    +

    Once the install stage has completed, a binary package of + the installed files can be built. These binary packages can be + used for quick installation without previous compilation, e.g. by + the make bin-install or by using + pkg_add.

    +

    By default, the binary packages are created in + ${PACKAGES}/All and symlinks are created in + ${PACKAGES}/category, + one for each category in the CATEGORIES + variable. PACKAGES defaults to + pkgsrc/packages.

    -16.2. Writing buildlink3.mk files

    -

    A package's buildlink3.mk file is - included by Makefiles to indicate the need to compile and link - against header files and libraries provided by the package. A - buildlink3.mk file should always provide - enough information to add the correct type of dependency - relationship and include any other - buildlink3.mk files that it needs to find - headers and libraries that it needs in turn.

    -

    To generate an initial buildlink3.mk - file for further editing, Rene Hexel's pkgtools/createbuildlink - package is highly recommended. For most packages, the following - command will generate a good starting point for - buildlink3.mk files:

    -
    -% cd pkgsrc/category/pkgdir
    -% createbuildlink >buildlink3.mk
    -    
    -
    -

    -16.2.1. Anatomy of a buildlink3.mk file

    -

    The following real-life example - buildlink3.mk is taken - from pkgsrc/graphics/tiff:

    -
    -# $NetBSD: buildlink3.mk,v 1.16 2009/03/20 19:24:45 joerg Exp $
    -
    -BUILDLINK_TREE+=        tiff
    -
    -.if !defined(TIFF_BUILDLINK3_MK)
    -TIFF_BUILDLINK3_MK:=
    -
    -BUILDLINK_API_DEPENDS.tiff+=    tiff>=3.6.1
    -BUILDLINK_ABI_DEPENDS.tiff+=    tiff>=3.7.2nb1
    -BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
    -
    -.include "../../devel/zlib/buildlink3.mk"
    -.include "../../graphics/jpeg/buildlink3.mk"
    -.endif # TIFF_BUILDLINK3_MK
    -
    -BUILDLINK_TREE+=        -tiff
    -
    -

    The header and footer manipulate - BUILDLINK_TREE, which is common across all - buildlink3.mk files and is used to track - the dependency tree.

    -

    The main section is protected from multiple inclusion - and controls how the dependency on pkg is - added. Several important variables are set in the section:

    -
      -
    • BUILDLINK_API_DEPENDS.pkg - is the dependency version recorded in the installed - package; this should always be set using - += to ensure that - we're appending to any pre-existing list of values. This - variable should be set to the last version of the - package that had an backwards-incompatible API change. -

    • -
    • BUILDLINK_PKGSRCDIR.pkg - is the location of the pkg - pkgsrc directory.

    • -
    • BUILDLINK_DEPMETHOD.pkg - (not shown above) controls whether we use - BUILD_DEPENDS or - DEPENDS to add the dependency on - pkg. The build dependency is - selected by setting - BUILDLINK_DEPMETHOD.pkg - to build. By default, the full dependency is - used.

    • -
    • BUILDLINK_INCDIRS.pkg - and - BUILDLINK_LIBDIRS.pkg - (not shown above) are lists of subdirectories of - ${BUILDLINK_PREFIX.pkg} - to add to the header and library search paths. These - default to include and lib - respectively.

    • -
    • BUILDLINK_CPPFLAGS.pkg - (not shown above) is the list of preprocessor flags to add - to CPPFLAGS, which are passed on to the - configure and build phases. The -I option - should be avoided and instead be handled using - BUILDLINK_INCDIRS.pkg as - above.

    • -
    -

    The following variables are all optionally defined within - this second section (protected against multiple inclusion) and - control which package files are symlinked into - ${BUILDLINK_DIR} and how their names are - transformed during the symlinking:

    -
      -
    • BUILDLINK_FILES.pkg - (not shown above) is a shell glob pattern relative to - ${BUILDLINK_PREFIX.pkg} - to be symlinked into - ${BUILDLINK_DIR}, - e.g. include/*.h.

    • -
    • BUILDLINK_FILES_CMD.pkg - (not shown above) is a shell pipeline that - outputs to stdout a list of files relative to - ${BUILDLINK_PREFIX.pkg}. - The resulting files are to be symlinked - into ${BUILDLINK_DIR}. By default, - this takes the +CONTENTS of a - pkg and filters it through - ${BUILDLINK_CONTENTS_FILTER.pkg}.

    • -
    • BUILDLINK_CONTENTS_FILTER.pkg - (not shown above) is a filter command that filters - +CONTENTS input into a list of files - relative to - ${BUILDLINK_PREFIX.pkg} - on stdout. By default, - BUILDLINK_CONTENTS_FILTER.pkg - outputs the contents of the include - and lib directories in the package - +CONTENTS.

    • -
    • BUILDLINK_FNAME_TRANSFORM.pkg - (not shown above) is a list of sed arguments used to - transform the name of the source filename into a - destination filename, e.g. -e - "s|/curses.h|/ncurses.h|g".

    • -
    -

    This section can additionally include any - buildlink3.mk needed for - pkg's library dependencies. - Including these buildlink3.mk files - means that the headers and libraries for these - dependencies are also symlinked into - ${BUILDLINK_DIR} - whenever the pkg - buildlink3.mk - file is included. Dependencies are only added for directly - include buildlink3.mk files.

    -

    When providing a buildlink3.mk and - including other buildlink3.mk files in it, - please only add necessary ones, i.e., those whose libraries or - header files are automatically exposed when the package is - use.

    -

    In particular, if only an executable - (bin/foo) is linked against a library, that - library does not need to be propagated in the - buildlink3.mk file.

    -

    The following steps should help you decide if a - buildlink3.mk file needs to be included: -

    -
      -
    • Look at the installed header files: What - headers do they include? The packages providing these files - must be buildlinked.

    • -
    • Run ldd on all installed - libraries and look against what other libraries they link. - Some of the packages providing these probably need to be - buildlinked; however, it's not automatic, since e.g. GTK on - some systems pulls in the X libraries, so they will show up in - the ldd output, while on others (like OS - X) it won't. ldd output can thus only be - used as a hint.

    • -
    -

    -

    -
    -
    -

    -16.2.2. Updating - BUILDLINK_API_DEPENDS.pkg - and - BUILDLINK_ABI_DEPENDS.pkg - in buildlink3.mk files

    -

    Both variables set lower bounds for a version of this package. - The two variables differ in that one describes source - compatibility (API) and the other binary compatibility (ABI). - The difference is that a change in the API breaks compilation of - programs while changes in the ABI stop compiled programs from - running.

    -

    The - BUILDLINK_API_DEPENDS.pkg - variable in a buildlink3.mk should be - changed very rarely. (One possible scenario: If all packages - using this package need a higher version than defined in the - buildlink3.mk, - BUILDLINK_API_DEPENDS.pkg - could be updated to that higher version.)

    -

    On the other hand, changes to - BUILDLINK_ABI_DEPENDS.pkg - are more common. The variable will need to be updated every - time the major version of one of its shared libraries is changed, - or any other change where a binary built against the previous - version of the package will not run against the new version any - longer.

    -

    In such a case, the package's - BUILDLINK_ABI_DEPENDS.pkg - must be increased to require the new package version. Then the - PKGREVISION of all packages that depend on - this package need to be increased, and if they have - buildlink3.mk files, their - BUILDLINK_ABI_DEPENDS.pkg - must be increased to the new version as well. This is required - so that a package will pull in the versions of the packages that - use the new ABI and that the packages' - PKGREVISIONs uniquely identify the packages - built against the new ABI. The pkgtools/revbump package can help with - these updates.

    -

    See Section 21.1.5, “Handling dependencies” for more information - about dependencies on other packages, including the - BUILDLINK_API_DEPENDS definitions.

    -

    Please take careful consideration before adjusting - BUILDLINK_API_DEPENDS.pkg - or - BUILDLINK_ABI_DEPENDS.pkg - in a buildlink3.mk file as we don't want to - cause unneeded package deletions and rebuilds. In many cases, - new versions of packages work just fine with older - dependencies.

    -

    Also it is not needed to set - BUILDLINK_ABI_DEPENDS.pkg - when it is identical to - BUILDLINK_API_DEPENDS.pkg.

    -
    +13.16. Cleaning up
    +

    Once you're finished with a package, you can clean the work + directory by running make clean. If you want + to clean the work directories of all dependencies too, use + make clean-depends.

    -16.3. Writing builtin.mk files

    -

    Some packages in pkgsrc install headers and libraries that - coincide with headers and libraries present in the base system. - Aside from a buildlink3.mk file, these - packages should also include a builtin.mk - file that includes the necessary checks to decide whether using - the built-in software or the pkgsrc software is - appropriate.

    -

    The only requirements of a builtin.mk file for - pkg are:

    -
      -
    1. It should set - USE_BUILTIN.pkg - to either yes or no - after it is included.

    2. -
    3. It should not override any - USE_BUILTIN.pkg - which is already set before the - builtin.mk file is included.

    4. -
    5. It should be written to allow multiple inclusion. This - is very important and takes careful - attention to Makefile coding.

    6. -
    -
    -

    -16.3.1. Anatomy of a builtin.mk file

    -

    The following is the recommended template for builtin.mk - files:

    -
    -.if !defined(IS_BUILTIN.foo)
    -#
    -# IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
    -# genuinely exists in the system or not.
    -#
    -IS_BUILTIN.foo?=        no
    -
    -# BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
    -# version can be determined.
    -#
    -.  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
    -BUILTIN_PKG.foo?=       foo-1.0
    -.  endif
    -.endif  # IS_BUILTIN.foo
    -
    -.if !defined(USE_BUILTIN.foo)
    -USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
    -.  if defined(BUILTIN_PKG.foo)
    -.    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
    -.      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
    -USE_BUILTIN.foo!=                                                       \
    -        ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}            \
    -        && ${ECHO} "yes" || ${ECHO} "no"
    -.      endif
    -.    endfor
    -.  endif
    -.endif  # USE_BUILTIN.foo
    -
    -CHECK_BUILTIN.foo?=     no
    -.if !empty(CHECK_BUILTIN.foo:M[nN][oO])
    -#
    -# Here we place code that depends on whether USE_BUILTIN.foo is set to
    -# "yes" or "no".
    -#
    -.endif  # CHECK_BUILTIN.foo
    -
    -

    The first section sets - IS_BUILTIN.pkg - depending on if pkg really exists - in the base system. This should not be a base system software - with similar functionality to pkg; - it should only be yes if the actual package is - included as part of the base system. This variable is only - used internally within the builtin.mk - file.

    -

    The second section sets - BUILTIN_PKG.pkg - to the version of pkg in the base - system if it exists (if - IS_BUILTIN.pkg - is yes). This variable is only used internally - within the builtin.mk file.

    -

    The third section sets - USE_BUILTIN.pkg - and is required in all - builtin.mk files. The code in this - section must make the determination whether the built-in - software is adequate to satisfy the dependencies listed in - BUILDLINK_API_DEPENDS.pkg. - This is typically done by comparing - BUILTIN_PKG.pkg - against each of the dependencies in - BUILDLINK_API_DEPENDS.pkg. - USE_BUILTIN.pkg - must be set to the correct value by the - end of the builtin.mk file. Note that - USE_BUILTIN.pkg - may be yes even if - IS_BUILTIN.pkg - is no because we may make the determination - that the built-in version of the software is similar enough to - be used as a replacement.

    -

    The last section is guarded by - CHECK_BUILTIN.pkg, - and includes code that uses the value of - USE_BUILTIN.pkg - set in the previous section. This typically includes, e.g., - adding additional dependency restrictions and listing additional - files to symlink into ${BUILDLINK_DIR} (via - BUILDLINK_FILES.pkg).

    -
    -
    -

    -16.3.2. Global preferences for native or pkgsrc software

    -

    When building packages, it's possible to choose whether to set - a global preference for using either the built-in (native) - version or the pkgsrc version of software to satisfy a - dependency. This is controlled by setting - PREFER_PKGSRC and - PREFER_NATIVE. These variables take values - of either yes, no, or a list of - packages. PREFER_PKGSRC tells pkgsrc to - use the pkgsrc versions of software, while - PREFER_NATIVE tells pkgsrc to use the - built-in versions. Preferences are determined by the most - specific instance of the package in either - PREFER_PKGSRC or - PREFER_NATIVE. If a package is specified - in neither or in both variables, then - PREFER_PKGSRC has precedence over - PREFER_NATIVE. For example, to require - using pkgsrc versions of software for all but the most basic - bits on a NetBSD system, you can set:

    -
    -PREFER_PKGSRC=  yes
    -PREFER_NATIVE=  getopt skey tcp_wrappers
    -
    -

    A package must have a - builtin.mk - file to be listed in PREFER_NATIVE, - otherwise it is simply ignored in that list.

    -

    Setting PREFER_NATIVE should be performed - straight after bootstrap and PREFER_PKGSRC during - bootstrap. - Switching between settings globally at a later date can introduce - complications with dependency resolution. This is caused by packages - built with the opposite preference being installed alongside each other.

    +13.17. Other helpful targets
    +
    +
    pre/post-*
    +
    +

    For any of the main targets described in the previous + section (configure, build, install, etc.), two auxiliary + targets exist with + pre- and post- used as a + prefix for the main target's name. These targets are + invoked before and after the main target is called, + allowing extra configuration or installation steps be + performed from a package's Makefile, for example, which + a program's configure script or install target + omitted.

    +

    About 5% of the pkgsrc packages define their custom + post-extract target, another 5% define pre-configure, and 10% + define post-install. The other pre/post-* targets are defined + even less often.

    +
    +
    do-*
    +
    +

    Should one of the main targets do the wrong thing, + and should there be no variable to fix this, you can + redefine it with the do-* target. (Note that redefining + the target itself instead of the do-* target is a bad + idea, as the pre-* and post-* targets won't be called + anymore, etc.)

    +

    About 15% of the pkgsrc packages override the default + do-install, the other do-* targets are overridden even less + often.

    +
    +
    reinstall
    +
    +

    If you did a make install and + you noticed some file was not installed properly, you + can repeat the installation with this target, which will + ignore the already installed flag.

    +

    This is the default value of + DEPENDS_TARGET except in the case of + make update and make + package, where the defaults are + package and update, + respectively.

    +
    +
    deinstall
    +
    +

    This target does a pkg_delete(1) in the + current directory, effectively de-installing the + package. The following variables can be used to tune the + behaviour:

    +
    +
    PKG_VERBOSE
    +

    Add a "-v" to the pkg_delete(1) command.

    +
    DEINSTALLDEPENDS
    +

    Remove all packages that require (depend on) + the given package. This can be used to remove any + packages that may have been pulled in by a given + package, e.g. if make deinstall + DEINSTALLDEPENDS=1 is done in + pkgsrc/x11/kde, this is + likely to remove whole KDE. Works by adding + -R to the pkg_delete(1) + command line.

    +
    +
    +
    bin-install
    +

    Install a binary package from local disk and via FTP + from a list of sites (see the + BINPKG_SITES variable), and do a + make package if no binary package is + available anywhere. The arguments given to + pkg_add can be set via + BIN_INSTALL_FLAGS e.g., to do verbose + operation, etc.

    +
    install-clean
    +

    This target removes the state files for the "install" and later + phases so that the "install" target may be re-invoked. This can be + used after editing the PLIST to install the package without + rebuilding it.

    +
    build-clean
    +

    This target removes the state files for the "build" and later + phases so that the "build" target may be re-invoked.

    +
    update
    +
    +

    This target causes the current package to be + updated to the latest version. The package and all + depending packages first get de-installed, then current + versions of the corresponding packages get compiled and + installed. This is similar to manually noting which + packages are currently installed, then performing a + series of make deinstall and + make install (or whatever + UPDATE_TARGET is set to) for these + packages.

    +

    You can use the update target to + resume package updating in case a previous make + update was interrupted for some reason. + However, in this case, make sure you don't call + make clean or otherwise remove the + list of dependent packages in WRKDIR. + Otherwise, you lose the ability to automatically update + the current package along with the dependent packages + you have installed.

    +

    Resuming an interrupted make + update will only work as long as the package + tree remains unchanged. If the source code for one of + the packages to be updated has been changed, resuming + make update will most certainly + fail!

    +

    The following variables can be used either on the + command line or in mk.conf to + alter the behaviour of make + update:

    +
    +
    UPDATE_TARGET
    +

    Install target to recursively use for the + updated package and the dependent packages. + Defaults to DEPENDS_TARGET if + set, install otherwise for + make update. Other good + targets are package or + bin-install. Do not set this to + update or you will get stuck in an + endless loop!

    +
    NOCLEAN
    +

    Don't clean up after updating. Useful if + you want to leave the work sources of the updated + packages around for inspection or other purposes. + Be sure you eventually clean up the source tree + (see the clean-update target below) + or you may run into troubles with old source code + still lying around on your next + make or make + update.

    +
    REINSTALL
    +

    Deinstall each package before installing + (making DEPENDS_TARGET). This + may be necessary if the + clean-update target (see below) was + called after interrupting a running make + update.

    +
    DEPENDS_TARGET
    +

    Allows you to disable recursion and hardcode + the target for packages. The default is + update for the update target, + facilitating a recursive update of prerequisite + packages. Only set + DEPENDS_TARGET if you want to + disable recursive updates. Use + UPDATE_TARGET instead to just + set a specific target for each package to be + installed during make update + (see above).

    +
    +
    +
    clean-update
    +
    +

    Clean the source tree for all packages that would + get updated if make update was called + from the current directory. This target should not be + used if the current package (or any of its depending + packages) have already been de-installed (e.g., after + calling make update) or you may lose + some packages you intended to update. As a rule of + thumb: only use this target before + the first time you run make update + and only if you have a dirty package tree (e.g., if you + used NOCLEAN).

    +

    If you are unsure about whether your tree is + clean, you can either perform a make + clean at the top of the tree, or use the + following sequence of commands from the directory of the + package you want to update (before + running make update for the first + time, otherwise you lose all the packages you wanted to + update!):

    -# ./bootstrap --prefer-pkgsrc yes
    -
    -
    +# make clean-update +# make clean CLEANDEPENDS=YES +# make update + +

    The following variables can be used either on the + command line or in mk.conf to alter the behaviour of + make clean-update:

    +
    +
    CLEAR_DIRLIST
    +

    After make clean, do not + reconstruct the list of directories to update for + this package. Only use this if make + update successfully installed all + packages you wanted to update. Normally, this is + done automatically on make + update, but may have been suppressed by + the NOCLEAN variable (see + above).

    +
    + +
    replace
    +
    +

    Update the installation of the current package. This + differs from update in that it does not replace dependent + packages. You will need to install pkgtools/pkg_tarup for this + target to work.

    +

    Be careful when using this + target! There are no guarantees that dependent + packages will still work, in particular they will most + certainly break if you make replace a + library package whose shared library major version changed + between your installed version and the new one. For this + reason, this target is not officially supported and only + recommended for advanced users.

    +
    +
    info
    +

    This target invokes pkg_info(1) for the current + package. You can use this to check which version of a + package is installed.

    +
    index
    +
    +

    This is a top-level command, i.e. it should be used in + the pkgsrc directory. It creates a + database of all packages in the local pkgsrc tree, including + dependencies, comment, maintainer, and some other useful + information. Individual entries are created by running + make describe in the packages' + directories. This index file is saved as + pkgsrc/INDEX. It can be displayed in + verbose format by running make + print-index. You can search in it with + make search + key=something. You can + extract a list of all packages that depend on a particular + one by running make show-deps + PKG=somepackage.

    +

    Running this command takes a very long time, some + hours even on fast machines!

    +
    +
    readme
    +
    +

    This target generates a + README.html file, which can be + viewed using a browser such as www/firefox or www/links. The generated files + contain references to any packages which are in the + PACKAGES directory on the local + host. The generated files can be made to refer to URLs + based on FTP_PKG_URL_HOST and + FTP_PKG_URL_DIR. For example, if I + wanted to generate README.html + files which pointed to binary packages on the local + machine, in the directory + /usr/packages, set + FTP_PKG_URL_HOST=file://localhost and + FTP_PKG_URL_DIR=/usr/packages. The + ${PACKAGES} directory and its + subdirectories will be searched for all the binary + packages.

    +

    The target can be run at the toplevel or in category + directories, in which case it descends recursively.

    +
    +
    readme-all
    +

    This is a top-level command, run it in + pkgsrc. Use this target to create a + file README-all.html which contains a + list of all packages currently available in the NetBSD + Packages Collection, together with the category they belong + to and a short description. This file is compiled from the + pkgsrc/*/README.html files, so be sure + to run this after a make + readme.

    +
    cdrom-readme
    +

    This is very much the same as the + readme target (see above), but is to be + used when generating a pkgsrc tree to be written to a + CD-ROM. This target also produces + README.html files, and can be made + to refer to URLs based on + CDROM_PKG_URL_HOST and + CDROM_PKG_URL_DIR.

    +
    show-distfiles
    +

    This target shows which distfiles and patchfiles + are needed to build the package + (ALLFILES, which contains all + DISTFILES and + PATCHFILES, but not + patches/*).

    +
    show-downlevel
    +

    This target shows nothing if the package is not + installed. If a version of this package is installed, + but is not the version provided in this version of + pkgsrc, then a warning message is displayed. This target + can be used to show which of your installed packages are + downlevel, and so the old versions can be deleted, and + the current ones added.

    +
    show-pkgsrc-dir
    +

    This target shows the directory in the pkgsrc + hierarchy from which the package can be built and + installed. This may not be the same directory as the one + from which the package was installed. This target is + intended to be used by people who may wish to upgrade + many packages on a single host, and can be invoked from + the top-level pkgsrc Makefile by using the + show-host-specific-pkgs target.

    +
    show-installed-depends
    +

    This target shows which installed packages match + the current package's DEPENDS. Useful + if out of date dependencies are causing build + problems.

    +
    print-build-depends-list
    +

    This target shows the list of packages that the current package + depends on for building.

    +
    print-run-depends-list
    +

    This target shows the list of packages that the current package + depends on for running.

    +
    check-shlibs
    +

    After a package is installed, check all its + binaries and (on ELF platforms) shared libraries to see + if they find the shared libs they need. Run by default + if PKG_DEVELOPER is set in mk.conf.

    +
    print-PLIST
    +
    +

    After a make install from a new or + upgraded pkg, this prints out an attempt to generate a + new PLIST from a find + -newer work/.extract_done. An attempt is made + to care for shared libs etc., but it is + strongly recommended to review the + result before putting it into + PLIST. On upgrades, it's useful to + diff the output of this command against an already + existing PLIST file.

    +

    If the package installs files via tar(1) or + other methods that don't update file access times, be + sure to add these files manually to your + PLIST, as the find + -newer command used by this target won't catch + them!

    +

    See Section 19.3, “Tweaking output of make print-PLIST for more + information on this target.

    +
    +

    -Chapter 17. The pkginstall framework

    +Chapter 14. Creating a new pkgsrc package from scratch
    -

    This chapter describes the framework known as -pkginstall, whose key features are:

    -
      -
    • Generic installation and manipulation of directories and files - outside the pkgsrc-handled tree, LOCALBASE.

    • -
    • Automatic handling of configuration files during installation, - provided that packages are correctly designed.

    • -
    • Generation and installation of system startup scripts.

    • -
    • Registration of system users and groups.

    • -
    • Registration of system shells.

    • -
    • Automatic updating of fonts databases.

    • -
    -

    The following sections inspect each of the above points in detail.

    -

    You may be thinking that many of the things described here could be -easily done with simple code in the package's post-installation target -(post-install). This is incorrect, -as the code in them is only executed when building from source. Machines -using binary packages could not benefit from it at all (as the code itself -could be unavailable). Therefore, the only way to achieve any of the items -described above is by means of the installation scripts, which are -automatically generated by pkginstall.

    -
    -

    -17.1. Files and directories outside the installation prefix

    -

    As you already know, the PLIST file holds a list -of files and directories that belong to a package. The names used in it -are relative to the installation prefix (${PREFIX}), -which means that it cannot register files outside this directory (absolute -path names are not allowed). Despite this restriction, some packages need -to install files outside this location; e.g., under -${VARBASE} or -${PKG_SYSCONFDIR}. The only way to achieve this -is to create such files during installation time by using -installation scripts.

    -

    The generic installation scripts are shell scripts that can -contain arbitrary code. The list of scripts to execute is taken from -the INSTALL_FILE variable, which defaults to -INSTALL. A similar variable exists for package -removal (DEINSTALL_FILE, whose default is -DEINSTALL). These scripts can run arbitrary -commands, so they have the potential to create and manage files -anywhere in the file system.

    -

    Using these general installation files is not recommended, but -may be needed in some special cases. One reason for avoiding them is -that the user has to trust the packager that there is no unwanted or -simply erroneous code included in the installation script. Also, -previously there were many similar scripts for the same functionality, -and fixing a common error involved finding and changing all of -them.

    -

    The pkginstall framework offers another, standardized way. It -provides generic scripts to abstract the manipulation of such files -and directories based on variables set in the package's -Makefile. The rest of this section describes -these variables.

    -
    -

    -17.1.1. Directory manipulation

    -

    The following variables can be set to request the creation of -directories anywhere in the file system:

    -
      -
    • -

      MAKE_DIRS and OWN_DIRS - contain a list of directories that should be created and should attempt - to be destroyed by the installation scripts. The difference between - the two is that the latter prompts the administrator to remove any - directories that may be left after deinstallation (because they were - not empty), while the former does not. Example:

      -
      -MAKE_DIRS+=             ${VARBASE}/foo/private
      -
      +

      When you find a package that is not yet in pkgsrc, you +most likely have a URL from where you can download the source +code. Starting with this URL, creating a package involves only a +few steps.

      +
        +
      1. In your mk.conf, set PKG_DEVELOPER=yes to +enable the basic quality checks.

      2. +
      3. +

        Install the package meta-pkgs/pkg_developer, which among others will +install the utilities url2pkg, +pkglint, pkgvi and +mkpatches:

        +
        $ cd /usr/pkgsrc
        +$ (cd meta-pkgs/pkg_developer && bmake update)
      4. -
      5. -

        MAKE_DIRS_PERMS and - OWN_DIRS_PERMS contain a list of tuples describing - which directories should be created and should attempt to be destroyed - by the installation scripts. Each tuple holds the following values, - separated by spaces: the directory name, its owner, its group and its - numerical mode. For example:

        -
        -MAKE_DIRS_PERMS+=       ${VARBASE}/foo/private \
        -                        ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
        -
        -

        The difference between the two is exactly the same as their - non-PERMS counterparts.

        +
      6. +

        Choose one of the top-level directories as the category in +which you want to place your package. You can also create a directory of +your own (maybe called local). In that category +directory, create another directory for your package and change into +it:

        +
        $ mkdir category/package
        +$ cd category/package
      7. -
    -
    -
    -

    -17.1.2. File manipulation

    -

    Creating non-empty files outside the installation prefix is tricky -because the PLIST forces all files to be inside it. -To overcome this problem, the only solution is to extract the file in the -known place (i.e., inside the installation prefix) and copy it to the -appropriate location during installation (done by the installation scripts -generated by pkginstall). We will call the former the master -file in the following paragraphs, which describe the variables -that can be used to automatically and consistently handle files outside the -installation prefix:

    -
      -
    • -

      CONF_FILES and - REQD_FILES are pairs of master and target files. - During installation time, the master file is copied to the target one - if and only if the latter does not exist. Upon deinstallation, the - target file is removed provided that it was not modified by the - installation.

      -

      The difference between the two is that the latter prompts the - administrator to remove any files that may be left after - deinstallation (because they were not empty), while the former does - not.

      +
    • +

      Run the program url2pkg, which will ask +you for a URL. Enter the URL of the distribution file (in most cases a +.tar.gz file) and watch how the basic ingredients +of your package are created automatically. The distribution file is +extracted automatically to fill in some details in the +Makefile that would otherwise have to be done +manually:

      +
      $ url2pkg https://www.example.org/packages/package-1.0.tar.gz
    • -
    • -

      CONF_FILES_PERMS and - REQD_FILES_PERMS contain tuples describing master - files as well as their target locations. For each of them, it also - specifies their owner, their group and their numeric permissions, in - this order. For example:

      +
    • +

      Examine the extracted files to determine the dependencies of +your package. Ideally, this is mentioned in some +README file, but things may differ. For each of +these dependencies, look where it exists in pkgsrc, and if there is a +file called buildlink3.mk in that directory, add a +line to your package Makefile which includes that +file just before the last line. If the +buildlink3.mk file does not exist, it must be +created first. The buildlink3.mk file makes sure +that the package's include files and libraries are provided.

      +

      If you just need binaries from a package, add a +DEPENDS line to the Makefile, which specifies the +version of the dependency and where it can be found in pkgsrc. This line +should be placed in the third paragraph. If the dependency is only +needed for building the package, but not when using it, use +TOOL_DEPENDS or BUILD_DEPENDS +instead of DEPENDS. +The difference between TOOL_DEPENDS and +BUILD_DEPENDS occurs when cross-compiling: +TOOL_DEPENDS are native +packages, i.e. packages for the architecture where the package +is built; +BUILD_DEPENDS are target +packages, i.e. packages for the architecture for which the package +is built. There is also TEST_DEPENDS, which is used +to specify a dependency used only for testing the resulting package +built, using the upstream project's included test suite. +Your package may then look like this:

      -REQD_FILES_PERMS+=      ${PREFIX}/share/somefile ${VARBASE}/somefile \
      -                        ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
      -
      -

      The difference between the two is exactly the same as their - non-PERMS counterparts.

      -
    • -
    -
    -
    -
    -

    -17.2. Configuration files

    -

    Configuration files are special in the sense that they are installed -in their own specific directory, PKG_SYSCONFDIR, and -need special treatment during installation (most of which is automated by -pkginstall). The main concept you must bear in mind is that files marked -as configuration files are automatically copied to the right place (somewhere -inside PKG_SYSCONFDIR) during installation if -and only if they didn't exist before. Similarly, they will not -be removed if they have local modifications. This ensures that -administrators never lose any custom changes they may have made.

    -
    -

    -17.2.1. How PKG_SYSCONFDIR is set

    -

    As said before, the PKG_SYSCONFDIR variable -specifies where configuration files shall be installed. Its contents are -set based upon the following variables:

    -
      -
    • PKG_SYSCONFBASE: The configuration's root - directory. Defaults to ${PREFIX}/etc although it may - be overridden by the user to point to his preferred location (e.g., - /etc, /etc/pkg, etc.). - Packages must not use it directly.

    • -
    • -

      PKG_SYSCONFSUBDIR: A subdirectory of - PKG_SYSCONFBASE under which the configuration files - for the package being built shall be installed. The definition of this - variable only makes sense in the package's - Makefile (i.e., it is not user-customizable).

      -

      As an example, consider the Apache package, - www/apache24, which places its - configuration files under the - httpd/ subdirectory of - PKG_SYSCONFBASE. This should be set in the package - Makefile.

      -
    • -
    • PKG_SYSCONFVAR: Specifies the name of the - variable that holds this package's configuration directory (if - different from PKG_SYSCONFBASE). It defaults to - PKGBASE's value, and is always prefixed with - PKG_SYSCONFDIR.

    • -
    • PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the - directory where the configuration files for the package identified by - PKG_SYSCONFVAR's shall be placed.

    • -
    -

    Based on the above variables, pkginstall determines the value of -PKG_SYSCONFDIR, which is the only -variable that can be used within a package to refer to its configuration -directory. The algorithm used to set its value is basically the -following:

    -
      -
    1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, - its value is used.

    2. -
    3. If the previous variable is not defined but - PKG_SYSCONFSUBDIR is set in the package's - Makefile, the resulting value is - ${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}.

    4. -
    5. Otherwise, it is set to - ${PKG_SYSCONFBASE}.

    6. +[...] + +TOOL_DEPENDS+= libxslt-[0-9]*:../../textproc/libxslt +DEPENDS+= screen-[0-9]*:../../misc/screen +DEPENDS+= screen>=4.0:../../misc/screen + +[...] + +.include "../../category/package/buildlink3.mk" +.include "../../devel/glib2/buildlink3.mk" +.include "../../mk/bsd.pkg.mk" + + +
    7. Run pkglint to see what things still need +to be done to make your package a good one. If you don't +know what pkglint's warnings want to tell you, try pkglint +--explain or pkglint -e, which outputs +additional explanations.

    8. +
    9. In many cases the package is not yet ready to build. You can +find instructions for the most common cases in the next section, Section 14.1, “Common types of packages”. After you have followed the instructions +over there, you can hopefully continue here.

    10. +
    11. Run bmake clean to clean the working +directory from the extracted files. Besides these files, a lot of cache +files and other system information has been saved in the working +directory, which may become wrong after you edited the +Makefile.

    12. +
    13. +

      Now, run bmake to build the package. For +the various things that can go wrong in this phase, consult Chapter 21, Making your package work.

      +

      If the extracted files from the package need to be fixed, run multiple rounds of these commands:

      +
      $ make
      +$ pkgvi ${WRKSRC}/some/file/that/does/not/compile
      +$ mkpatches
      +$ make mps
      +$ make clean
      +
    14. +
    15. When the package builds fine, the next step is to install +the package. Run bmake install and hope that +everything works.

    16. +
    17. Up to now, the file PLIST, which +contains a list of the files that are installed by the package, is +nearly empty. Run bmake print-PLIST +>PLIST to generate a probably correct list. Check +the file using your preferred text editor to see if the list of +files looks plausible.

    18. +
    19. Run pkglint again to see if the generated +PLIST contains garbage or not.

    20. +
    21. When you ran bmake install, the package +had been registered in the database of installed files, but with an +empty list of files. To fix this, run bmake deinstall +and bmake install again. Now the package is +registered with the list of files from +PLIST.

    22. +
    23. Run bmake package to create a binary +package from the set of installed files.

    24. +
    25. Run bmake clean update to run everything +from above again in a single step, making sure that the PLIST is correct +and the whole package is created as intended.

    26. +
    27. Run pkglint to see if there's anything left to do.

    28. +
    29. Commit the package to pkgsrc-wip or main pkgsrc; see Chapter 23, Submitting and Committing.

    -

    It is worth mentioning that ${PKG_SYSCONFDIR} is -automatically added to OWN_DIRS. See Section 17.1.1, “Directory manipulation” what this means. This does not apply to -subdirectories of ${PKG_SYSCONFDIR}, they still have to -be created with OWN_DIRS or MAKE_DIRS.

    -
    +
    +

    +14.1. Common types of packages

    -17.2.2. Telling the software where configuration files are

    -

    Given that pkgsrc (and users!) expect configuration files to be in a -known place, you need to teach each package where it shall install its -files. In some cases you will have to patch the package Makefiles to -achieve it. If you are lucky, though, it may be as easy as passing an -extra flag to the configuration script; this is the case of GNU Autoconf- -generated files:

    -
    -CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
    -
    -

    Note that this specifies where the package has to look -for its configuration files, not where they will be originally -installed (although the difference is never explicit, -unfortunately).

    +14.1.1. Perl modules
    +

    Simple Perl modules are handled automatically by +url2pkg, including dependencies.

    -17.2.3. Patching installations

    -

    As said before, pkginstall automatically handles configuration files. -This means that the packages themselves must not -touch the contents of ${PKG_SYSCONFDIR} -directly. Bad news is that many software installation scripts -will, out of the box, mess with the contents of that directory. So what is -the correct procedure to fix this issue?

    -

    You must teach the package (usually by manually patching it) to -install any configuration files under the examples hierarchy, -share/examples/${PKGBASE}/. This way, the -PLIST registers them and the administrator always -has the original copies available.

    -

    Once the required configuration files are in place (i.e., under the -examples hierarchy), the pkginstall framework can use them as master copies -during the package installation to update what is in -${PKG_SYSCONFDIR}. To achieve this, the variables -CONF_FILES and CONF_FILES_PERMS are -used. Check out Section 17.1.2, “File manipulation” for information -about their syntax and their purpose. Here is an example, taken from the -mail/mutt package:

    +14.1.2. Python modules and programs
    +

    Python modules and programs packages are easily created using a +set of predefined variables.

    +

    +If some Python versions are not supported by the software, set the +PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions +that are not supported, e.g. +

    -EGDIR=        ${PREFIX}/share/doc/mutt/samples
    -CONF_FILES=   ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
    +PYTHON_VERSIONS_INCOMPATIBLE=       27
     
    -

    Note that the EGDIR variable is specific to that -package and has no meaning outside it.

    - -
    -

    -17.2.4. Disabling handling of configuration files

    -

    The automatic copying of config files can be toggled by setting the -environment variable PKG_CONFIG prior to package -installation.

    -
    - -
    -

    -17.3. System startup scripts

    -

    System startup scripts are special files because they must be -installed in a place known by the underlying OS, usually outside the -installation prefix. Therefore, the same rules described in Section 17.1, “Files and directories outside the installation prefix” apply, and the same solutions -can be used. However, pkginstall provides a special mechanism to handle -these files.

    -

    In order to provide system startup scripts, the package has -to:

    -
      -
    1. Store the script inside ${FILESDIR}, with - the .sh suffix appended. Considering the - print/cups package as an example, it has a - cupsd.sh in its files directory.

    2. -
    3. -

      Tell pkginstall to handle it, appending the name of the script, - without its extension, to the RCD_SCRIPTS variable. - Continuing the previous example:

      +

      +If the packaged software is a Python module, include one of +../../lang/python/egg.mk, +../../lang/python/distutils.mk, or +../../lang/python/extension.mk.

      +

      Most Python packages use either distutils or +easy-setup/setuptools (eggs). +If the packaged software is using setuptools, you only need +to include ../../lang/python/egg.mk. +Otherwise, if the software uses distutils, include +../../lang/python/distutils.mk, +so pkgsrc will use this framework. +distutils uses a script called setup.py; +if the distutils driver is not called +setup.py, set the PYSETUP variable +to the name of the script.

      +

      Either way, the package directory should be called +py-software and PKGNAME should be set to +${PYPKGPREFIX}-${DISTNAME}, e.g. +

      -RCD_SCRIPTS+=   cupsd
      +DISTNAME=   foopymodule-1.2.10
      +PKGNAME=    ${PYPKGPREFIX}-${DISTNAME}
       
      -
    4. -
    -

    Once this is done, pkginstall will do the following steps for each -script in an automated fashion:

    -
      -
    1. Process the file found in the files directory applying all the - substitutions described in the FILES_SUBST - variable.

    2. -
    3. Copy the script from the files directory to the examples - hierarchy, ${PREFIX}/share/examples/rc.d/. Note - that this master file must be explicitly registered in the - PLIST.

    4. -
    5. Add code to the installation scripts to copy the startup script - from the examples hierarchy into the system-wide startup scripts - directory.

    6. -
    -
    -

    -17.3.1. Disabling handling of system startup scripts

    -

    The automatic copying of config files can be toggled by setting the -environment variable PKG_RCD_SCRIPTS prior to package -installation. Note that the scripts will be always copied inside the -examples hierarchy, ${PREFIX}/share/examples/rc.d/, no -matter what the value of this variable is.

    -
    -
    -
    -

    -17.4. System users and groups

    -

    If a package needs to create special users and/or groups during -installation, it can do so by using the pkginstall framework.

    -

    Users can be created by adding entries to the -PKG_USERS variable. Each entry has the following -syntax:

    +

    If it is an application, include +../../lang/python/application.mk. +In order to correctly set the path to the Python interpreter, use the +REPLACE_PYTHON variable and set it to the list of files +(paths relative to WRKSRC) that must be corrected. +For example: +

    -user:group
    +REPLACE_PYTHON=   *.py
     
    -

    Further specification of user details may be done by setting -per-user variables. -PKG_UID.user is the -numeric UID for the user. -PKG_GECOS.user is the -user's description or comment. -PKG_HOME.user is the -user's home directory, and defaults to -/nonexistent if not specified. -PKG_SHELL.user is the -user's shell, and defaults to /sbin/nologin if -not specified.

    -

    Similarly, groups can be created by adding entries to the -PKG_GROUPS variable, whose syntax is:

    +

    Some Python modules have separate distributions for Python-2.x +and Python-3.x support. In pkgsrc this is handled by the +versioned_dependencies.mk file. Set +PYTHON_VERSIONED_DEPENDENCIES to the list of +packages that should be depended upon and include +../../lang/python/versioned_dependencies.mk, +then the pkgsrc infrastructure will depend on the appropriate package +version. For example: +

    -group
    +PYTHON_VERSIONED_DEPENDENCIES=dialog
     
    -

    The numeric GID of the group may be set by defining -PKG_GID.group.

    -

    If a package needs to create the users and groups at an earlier -stage, then it can set USERGROUP_PHASE to either -configure,build, or -pre-install to indicate the phase before which the -users and groups are created. In this case, the numeric UIDs and GIDs -of the created users and groups are automatically hardcoded into the -final installation scripts.

    +

    +Look inside versioned_dependencies.mk for a list +of supported packages.

    -
    -

    -17.5. System shells

    -

    Packages that install system shells should register them in the shell -database, /etc/shells, to make things easier to the -administrator. This must be done from the installation scripts to keep -binary packages working on any system. pkginstall provides an easy way to -accomplish this task.

    -

    When a package provides a shell interpreter, it has to set the -PKG_SHELL variable to its absolute file name. This will -add some hooks to the installation scripts to handle it. Consider the -following example, taken from shells/zsh:

    +
    +

    +14.1.3. R packages

    +

    Simple R packages from CRAN +are handled automatically by R2pkg, which is +available in pkgtools/R2pkg. +Individual packages (and optionally their dependencies) may be created +and updated. R packages generally follow the same form, and most of +the relevant information needed is contained in a +DESCRIPTION file as part of each R package on +CRAN. +Consequently, R2pkg downloads that information and +creates or updates a package in the canonical form. The resulting +package should be reviewed for correctness.

    +
    +
    +

    +14.1.4. TeXlive packages

    +

    TeXlive packages from CTAN are handled automatically by +texlive2pkg, which is available in pkgtools/texlive2pkg.

    +

    If the TeXlive package name is not known, it may be useful to +search CTAN. A +Contained in field on the package page typically +identifies the basename of the package file in the TeXlive +archive.

    +

    If the TeXlive package name is known, download the files from +the TeXlive +archive. For package foo, you will need +to download foo.tar.xz. Most TeXlive packages +also have associated documentation packages, so download +foo.doc.tar.xz at the same time. These files +should be placed in the appropriate category directory, which is often +but not always print. Then run the following +command in the category directory.

    +
    +texlive2pkg foo.tar.xz foo.doc.tar.xz
    +
    +

    This will create two packages, tex-foo and +tex-foo-doc. Be sure to check that both packages +are correct.

    +

    Finally, CTAN +currently does not include version information in package filenames +and changes their contents periodically when updates occur. +Consequently, pkgsrc avoids downloading distfiles directly from CTAN and instead relies on the +pkgsrc archives. For each new or updated TeXlive package, e.g., the +main one and the corresponding documentation, upload the distfiles +with the following command in each package directory.

    -PKG_SHELL=      ${PREFIX}/bin/zsh
    +make upload-distfiles
     
    -
    -

    -17.5.1. Disabling shell registration

    -

    The automatic registration of shell interpreters can be disabled by -the administrator by setting the PKG_REGISTER_SHELLS -environment variable to NO.

    -17.6. Fonts

    -

    Packages that install X11 fonts should update the database files -that index the fonts within each fonts directory. This can easily be -accomplished within the pkginstall framework.

    -

    When a package installs X11 fonts, it must list the directories in -which fonts are installed in the -FONTS_DIRS.type variables, -where type can be one of ttf, -type1 or x11. This will add hooks to the -installation scripts to run the appropriate commands to update the fonts -database files within each of those directories. For convenience, if the -directory path is relative, it is taken to be relative to the package's -installation prefix. Consider the following example, taken from fonts/dbz-ttf:

    -
    -FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
    -
    +14.2. Examples

    -17.6.1. Disabling automatic update of the fonts databases

    -

    The automatic update of fonts databases can be disabled by -the administrator by setting the PKG_UPDATE_FONTS_DB -environment variable to NO.

    -
    - - -
    -

    -Chapter 18. Options handling

    - -

    Many packages have the ability to be built to support different -sets of features. bsd.options.mk is a framework -in pkgsrc that provides generic handling of those options that -determine different ways in which the packages can be built. It's -possible for the user to specify exactly which sets of options will be -built into a package or to allow a set of global default options -apply.

    -

    There are two broad classes of behaviors that one might want to -control via options. One is whether some particular feature is -enabled in a program that will be built anyway, often by including or -not including a dependency on some other package. The other is -whether or not an additional program will be built as part of the -package. Generally, it is better to make a split package for such -additional programs instead of using options, because it enables -binary packages to be built which can then be added separately. For -example, the foo package might have minimal dependencies (those -packages without which foo doesn't make sense), and then the foo-gfoo -package might include the GTK frontend program gfoo. This is better -than including a gtk option to foo that adds gfoo, because either that -option is default, in which case binary users can't get foo without -gfoo, or not default, in which case they can't get gfoo. With split -packages, they can install foo without having GTK, and later decide to -install gfoo (pulling in GTK at that time). This is an advantage to -source users too, avoiding the need for rebuilds.

    -

    Plugins with widely varying dependencies should usually be split -instead of options.

    -

    It is often more work to maintain split packages, especially if -the upstream package does not support this. The decision of split -vs. option should be made based on the likelihood that users will want -or object to the various pieces, the size of the dependencies that are -included, and the amount of work.

    -

    A further consideration is licensing. Non-free parts, or parts -that depend on non-free dependencies (especially plugins) should -almost always be split if feasible.

    -
    -

    -18.1. Global default options

    -

    Global default options are listed in -PKG_DEFAULT_OPTIONS, which is a list of the options -that should be built into every package if that option is supported. -This variable should be set in mk.conf.

    -
    -
    -

    -18.2. Converting packages to use bsd.options.mk -

    -

    The following example shows how -bsd.options.mk should be used -by the hypothetical ``wibble'' package, either in the package -Makefile, or in a file, -e.g. options.mk, that is included by the -main package Makefile.

    +14.2.1. How the www/nvu package came into pkgsrc
    +
    +

    +14.2.1.1. The initial package

    +

    Looking at the file pkgsrc/doc/TODO, I saw +that the nvu package has not yet been imported into +pkgsrc. As the description says it has to do with the web, the obvious +choice for the category is www.

    -PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
    -PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
    -PKG_OPTIONS_OPTIONAL_GROUPS=    database
    -PKG_OPTIONS_GROUP.database=     mysql pgsql
    -PKG_SUGGESTED_OPTIONS=          wibble-foo
    -PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
    -PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
    -
    -.include "../../mk/bsd.prefs.mk"
    -
    -# this package was previously named wibble2
    -.if defined(PKG_OPTIONS.wibble2)
    -PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
    -PKG_OPTIONS_DEPRECATED_WARNINGS+= \
    -        "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
    -.endif
    +$ mkdir www/nvu
    +$ cd www/nvu
    +
    +

    The web site says that the sources are available as a tar file, so +I fed that URL to the url2pkg program:

    +
    +$ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
    +
    +

    My editor popped up, and I added a PKGNAME line +below the DISTNAME line, as the package name should +not have the word sources in it. I also filled in the +MAINTAINER, HOMEPAGE and +COMMENT fields. Then the package +Makefile looked like that:

    +
    +# $NetBSD $
    +#
     
    -.include "../../mk/bsd.options.mk"
    +DISTNAME=       nvu-1.0-sources
    +PKGNAME=        nvu-1.0
    +CATEGORIES=     www
    +MASTER_SITES=   http://cvs.nvu.com/download/
    +EXTRACT_SUFX=   .tar.bz2
     
    -# Package-specific option-handling
    +MAINTAINER=     rillig@NetBSD.org
    +HOMEPAGE=       http://cvs.nvu.com/
    +COMMENT=        Web Authoring System
     
    -###
    -### FOO support
    -###
    -.if !empty(PKG_OPTIONS:Mwibble-foo)
    -CONFIGURE_ARGS+=    --enable-foo
    -.endif
    +# url2pkg-marker (please do not remove this line.)
    +.include "../../mk/bsd.pkg.mk"
    +
    +

    On the first line of output above, an artificial space has been added between NetBSD and $, +this is a workaround to prevent CVS expanding to the filename of the +guide.

    +

    Then, I quit the editor and watched pkgsrc downloading a large +source archive:

    +
    +url2pkg> Running "make makesum" ...
    +=> Required installed package digest>=20010302: digest-20060826 found
    +=> Fetching nvu-1.0-sources.tar.bz2
    +Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
    +100% |*************************************| 28992 KB  150.77 KB/s00:00 ETA
    +29687976 bytes retrieved in 03:12 (150.77 KB/s)
    +url2pkg> Running "make extract" ...
    +=> Required installed package digest>=20010302: digest-20060826 found
    +=> Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
    +=> Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
    +work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
    +===> Installing dependencies for nvu-1.0
    +===> Overriding tools for nvu-1.0
    +===> Extracting for nvu-1.0
    +url2pkg> Adjusting the Makefile.
     
    -###
    -### LDAP support
    -###
    -.if !empty(PKG_OPTIONS:Mldap)
    -.  include "../../databases/openldap-client/buildlink3.mk"
    -CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
    -.endif
    +Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
     
    -###
    -### database support
    -###
    -.if !empty(PKG_OPTIONS:Mmysql)
    -.  include "../../mk/mysql.buildlink3.mk"
    -.endif
    -.if !empty(PKG_OPTIONS:Mpgsql)
    -.  include "../../mk/pgsql.buildlink3.mk"
    -.endif
    +Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
    +
    +
    +
    +

    +14.2.1.2. Fixing all kinds of problems to make the package work

    +

    Now that the package has been extracted, let's see what's inside +it. The package has a README.txt, but that only +says something about mozilla, so it's probably useless for seeing what +dependencies this package has. But since there is a GNU configure script +in the package, let's hope that it will complain about everything it +needs.

    +
    +$ bmake
    +=> Required installed package digest>=20010302: digest-20060826 found
    +=> Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
    +=> Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
    +===> Patching for nvu-1.0
    +===> Creating toolchain wrappers for nvu-1.0
    +===> Configuring for nvu-1.0
    +[...]
    +configure: error: Perl 5.004 or higher is required.
    +[...]
    +WARNING: Please add USE_TOOLS+=perl to the package Makefile.
    +[...]
    +
    +

    That worked quite well. So I opened the package Makefile in my +editor, and since it already has a USE_TOOLS line, I +just appended perl to it. Since the dependencies of the +package have changed now, and since a perl wrapper is automatically +installed in the tools phase, I need to build the package +from scratch.

    +
    +$ bmake clean
    +===> Cleaning for nvu-1.0
    +$ bmake
    +[...]
    +*** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
    +GNU Make.  You will not be able to build Mozilla without GNU Make.
    +[...]
    +
    +

    So I added gmake to the +USE_TOOLS line and tried again (from scratch).

    +
    +[...]
    +checking for GTK - version >= 1.2.0... no
    +*** Could not run GTK test program, checking why...
    +[...]
    +
    +

    Now to the other dependencies. The first question is: Where is the +GTK package hidden in pkgsrc?

    +
    +$ echo ../../*/gtk*
    +[many packages ...]
    +$ echo ../../*/gtk
    +../../x11/gtk
    +$ echo ../../*/gtk2
    +../../x11/gtk2
    +$ echo ../../*/gtk2/bui*
    +../../x11/gtk2/buildlink3.mk
    +
    +

    The first try was definitely too broad. The second one had exactly +one result, which is very good. But there is one pitfall with GNOME +packages. Before GNOME 2 had been released, there were already many +GNOME 1 packages in pkgsrc. To be able to continue to use these +packages, the GNOME 2 packages were imported as separate packages, and +their names usually have a 2 appended. So I checked +whether this was the case here, and indeed it was.

    +

    Since the GTK2 package has a buildlink3.mk +file, adding the dependency is very easy. I just inserted an +.include line before the last line of the package +Makefile, so that it now looks like this:

    +
    +[...]
    +.include "../../x11/gtk2/buildlink3.mk"
    +.include "../../mk/bsd.pkg.mk
     
    -

    The first section contains the information about which build -options are supported by the package, and any default options settings -if needed.

    -
      -
    1. PKG_OPTIONS_VAR is the name of the -make(1) variable that the user can set to override the default -options. It should be set to -PKG_OPTIONS.pkgbase. Do not set it to -PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined -at the point where the options are processed.

    2. -
    3. PKG_SUPPORTED_OPTIONS is a list of -build options supported by the package.

    4. -
    5. PKG_OPTIONS_OPTIONAL_GROUPS is a -list of names of groups of mutually exclusive options. The options in -each group are listed in -PKG_OPTIONS_GROUP.groupname. -The most specific setting of any option from the group takes -precedence over all other options in the group. Options from the -groups will be automatically added to -PKG_SUPPORTED_OPTIONS.

    6. -
    7. PKG_OPTIONS_REQUIRED_GROUPS is like -PKG_OPTIONS_OPTIONAL_GROUPS, but building the -packages will fail if no option from the group is -selected.

    8. -
    9. PKG_OPTIONS_NONEMPTY_SETS is a list -of names of sets of options. At least one option from each set must -be selected. The options in each set are listed in -PKG_OPTIONS_SET.setname. -Options from the sets will be automatically added to -PKG_SUPPORTED_OPTIONS. Building the package will -fail if no option from the set is selected.

    10. -
    11. PKG_SUGGESTED_OPTIONS is a list of -build options which are enabled by default.

    12. -
    13. PKG_OPTIONS_LEGACY_VARS is a list -of -USE_VARIABLE:option -pairs that map legacy mk.conf variables to -their option counterparts. Pairs should be added with -+= to keep the listing of global legacy variables. A -warning will be issued if the user uses a legacy -variable.

    14. -
    15. PKG_OPTIONS_LEGACY_OPTS is a list -of -old-option:new-option -pairs that map options that have been renamed to their new -counterparts. Pairs should be added with += to keep -the listing of global legacy options. A warning will be issued if -the user uses a legacy option.

    16. -
    17. PKG_LEGACY_OPTIONS is a list of -options implied by deprecated variables used. This can be used for -cases that neither PKG_OPTIONS_LEGACY_VARS nor -PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when -PKG_OPTIONS_VAR is renamed.

    18. -
    19. PKG_OPTIONS_DEPRECATED_WARNINGS is -a list of warnings about deprecated variables or options used, and -what to use instead.

    20. -
    -

    A package should never modify -PKG_DEFAULT_OPTIONS or the variable named in -PKG_OPTIONS_VAR. These are strictly user-settable. -To suggest a default set of options, use -PKG_SUGGESTED_OPTIONS.

    -

    PKG_OPTIONS_VAR must be defined before -including bsd.options.mk. If none of -PKG_SUPPORTED_OPTIONS, -PKG_OPTIONS_OPTIONAL_GROUPS, and -PKG_OPTIONS_REQUIRED_GROUPS are defined (as can -happen with platform-specific options if none of them is supported on -the current platform), PKG_OPTIONS is set to the -empty list and the package is otherwise treated as not using the -options framework.

    -

    After the inclusion of bsd.options.mk, the -variable PKG_OPTIONS contains the list of selected -build options, properly filtered to remove unsupported and duplicate -options.

    -

    The remaining sections contain the logic that is specific to -each option. The correct way to check for an option is to check -whether it is listed in PKG_OPTIONS:

    +

    After another bmake clean && bmake, the answer +was:

    -.if !empty(PKG_OPTIONS:Moption)
    +[...]
    +checking for gtk-config... /home/roland/pkg/bin/gtk-config
    +checking for GTK - version >= 1.2.0... no
    +*** Could not run GTK test program, checking why...
    +*** The test program failed to compile or link. See the file config.log for the
    +*** exact error that occured. This usually means GTK was incorrectly installed
    +*** or that you have moved GTK since it was installed. In the latter case, you
    +*** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
    +configure: error: Test for GTK failed.
    +[...]
     
    -
    -
    -

    -18.3. Option Names

    -

    Options that enable similar features in different packages (like -optional support for a library) should use a common name in all -packages that support it (like the name of the library). If another -package already has an option with the same meaning, use the same -name.

    -

    Options that enable features specific to one package, where it's -unlikely that another (unrelated) package has the same (or a similar) -optional feature, should use a name prefixed with -pkgname-.

    -

    If a group of related packages share an optional feature -specific to that group, prefix it with the name of the -main package -(e. g. djbware-errno-hack).

    -

    For new options, add a line to -mk/defaults/options.description. Lines have two -fields, separated by tab. The first field is the option name, the -second its description. The description should be a whole sentence -(starting with an uppercase letter and ending with a period) that -describes what enabling the option does. E. g. Enable ispell -support. The file is sorted by option names.

    -
    -
    -

    -18.4. Determining the options of dependencies

    -

    When writing buildlink3.mk files, it is often necessary to list -different dependencies based on the options with which the package was -built. For querying these options, the file -pkgsrc/mk/pkg-build-options.mk should be used. A -typical example looks like this:

    +

    In this particular case, the assumption that every package +prefers GNOME 2 had been wrong. The first of the lines above +told me that this package really wanted to have the GNOME 1 version of +GTK. If the package had looked for GTK2, it would have looked for +pkg-config instead of gtk-config. +So I changed the x11/gtk2 to +x11/gtk in the package Makefile, +and tried again.

    -pkgbase := libpurple
    -.include "../../mk/pkg-build-options.mk"
    -
    -.if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
    -...
    -.endif
    +[...]
    +cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\"  [...]
    +In file included from xpidl.c:42:
    +xpidl.h:53:24: libIDL/IDL.h: No such file or directory
    +In file included from xpidl.c:42:
    +xpidl.h:132: error: parse error before "IDL_ns"
    +[...]
     
    -

    Including pkg-build-options.mk here will set -the variable PKG_BUILD_OPTIONS.libpurple to the build -options of the libpurple package, which can then be queried like -PKG_OPTIONS in the options.mk -file. See the file pkg-build-options.mk for more -details.

    -
    - -
    -

    -Chapter 19. The build process

    - -
    -

    -19.1. Introduction

    -

    This chapter gives a detailed description on how a package is - built. Building a package is separated into different - phases (for example fetch, - build, install), all of which are - described in the following sections. Each phase is split into - so-called stages, which take the name of the - containing phase, prefixed by one of pre-, - do- or post-. (Examples are - pre-configure, post-build.) Most - of the actual work is done in the do-* stages.

    -

    Never override the regular targets (like - fetch), if you have to, override the - do-* ones instead.

    -

    The basic steps for building a program are always the same. First - the program's source (distfile) must be brought to - the local system and then extracted. After any pkgsrc-specific patches - to compile properly are applied, the software can be configured, then - built (usually by compiling), and finally the generated binaries, etc. - can be put into place on the system.

    -

    To get more details about what is happening at each step, - you can set the PKG_VERBOSE variable, or the - PATCH_DEBUG variable if you are just interested - in more details about the patch step.

    -
    -
    -

    -19.2. Program location

    -

    Before outlining the process performed by the NetBSD package system in - the next section, here's a brief discussion on where programs are - installed, and which variables influence this.

    -

    The automatic variable PREFIX indicates - where all files of the final program shall be installed. It is - usually set to LOCALBASE - (/usr/pkg), or CROSSBASE - for pkgs in the cross category. The value of - PREFIX needs to be put - into the various places in the program's source where paths to - these files are encoded. See Section 13.3, “patches/* and Section 21.3.1, “Shared libraries - libtool” for more details.

    -

    When choosing which of these variables to use, - follow the following rules:

    -
      -
    • PREFIX always points to the location - where the current pkg will be installed. When referring to a - pkg's own installation path, use - ${PREFIX}.

    • -
    • LOCALBASE is where all non-X11 pkgs - are installed. If you need to construct a -I or -L argument - to the compiler to find includes and libraries installed by - another non-X11 pkg, use ${LOCALBASE}. The name - LOCALBASE stems from FreeBSD, which - installed all packages in /usr/local. As - pkgsrc leaves /usr/local for the system - administrator, this variable is a misnomer.

    • -
    • X11BASE is where the actual X11 - distribution (from xsrc, etc.) is installed. When looking for - standard X11 includes (not those - installed by a package), use ${X11BASE}.

    • -
    • X11-based packages using imake must set - USE_IMAKE to be installed correctly under - LOCALBASE.

    • -
    • Within ${PREFIX}, packages should - install files according to hier(7), with the exception that - manual pages go into ${PREFIX}/man, not - ${PREFIX}/share/man.

    • -
    +

    The package still does not find all of its dependencies. Now the +question is: Which package provides the +libIDL/IDL.h header file?

    +
    +$ echo ../../*/*idl*
    +../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
    +$ echo ../../*/*IDL*
    +../../net/libIDL
    +
    +

    Let's take the one from the second try. So I included the +../../net/libIDL/buildlink3.mk file and tried +again. But the error didn't change. After digging through some of the +code, I concluded that the build process of the package was broken and +couldn't have ever worked, but since the Mozilla source tree is quite +large, I didn't want to fix it. So I added the following to the package +Makefile and tried again:

    +
    +CPPFLAGS+=              -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
    +BUILDLINK_TRANSFORM+=   l:IDL:IDL-2
    +
    +

    The latter line is needed because the package expects the library +libIDL.so, but only +libIDL-2.so is available. So I told the compiler +wrapper to rewrite that on the fly.

    +

    The next problem was related to a recent change of the FreeType +interface. I looked up in www/seamonkey +which patch files were relevant for this issue and copied them to the +patches directory. Then I retried, fixed the +patches so that they applied cleanly and retried again. This time, +everything worked.

    +
    +
    +

    +14.2.1.3. Installing the package

    +
    +$ bmake CHECK_FILES=no install
    +[...]
    +$ bmake print-PLIST >PLIST
    +$ bmake deinstall
    +$ bmake install
    +
    +
    +
    + + +
    +

    +Chapter 15. Programming in Makefiles

    + +

    Pkgsrc consists of many Makefile fragments, + each of which forms a well-defined part of the pkgsrc system. Using + the make(1) system as a programming language for a big system + like pkgsrc requires some discipline to keep the code correct and + understandable.

    +

    The basic ingredients for Makefile + programming are variables and shell + commands. Among these shell commands may even be more complex ones + like awk(1) programs. To make sure that every shell command runs + as intended it is necessary to quote all variables correctly when they + are used.

    +

    This chapter describes some patterns that appear quite often in + Makefiles, including the pitfalls that come along + with them.

    -19.3. Directories used during the build process

    -

    When building a package, various directories are used to store - source files, temporary files, pkgsrc-internal files, and so on. These - directories are explained here.

    -

    Some of the directory variables contain relative pathnames. There - are two common base directories for these relative directories: - PKGSRCDIR/PKGPATH is used for directories that are - pkgsrc-specific. WRKSRC is used for directories - inside the package itself.

    -
    -
    PKGSRCDIR
    -

    This is an absolute pathname that points to the pkgsrc - root directory. Generally, you don't need - it.

    -
    PKGDIR
    -

    This is an absolute pathname that points to the - current package.

    -
    PKGPATH
    -

    This is a pathname relative to - PKGSRCDIR that points to the current - package.

    -
    WRKDIR
    -

    This is an absolute pathname pointing to the directory - where all work takes place. The distfiles are extracted to this - directory. It also contains temporary directories and log files used by - the various pkgsrc frameworks, like buildlink or - the wrappers.

    -
    WRKSRC
    -

    This is an absolute pathname pointing to the directory - where the distfiles are extracted. It is usually a direct subdirectory - of WRKDIR, and often it's the only directory entry - that isn't hidden. This variable may be changed by a package - Makefile.

    -
    -

    The CREATE_WRKDIR_SYMLINK definition takes either - the value yes or no and defaults - to no. It indicates whether a symbolic link to the - WRKDIR is to be created in the pkgsrc entry's directory. - If users would like to have their pkgsrc trees behave in a - read-only manner, then the value of - CREATE_WRKDIR_SYMLINK should be set to - no.

    +15.1. Caveats
    +
    • +

      When you are creating a file as a + target of a rule, always write the data to a temporary file first + and finally rename that file. Otherwise there might occur an error + in the middle of generating the file, and when the user runs + make(1) for the second time, the file exists and will not be + regenerated properly. Example:

      +
      +wrong:
      +        @echo "line 1" > ${.TARGET}
      +        @echo "line 2" >> ${.TARGET}
      +        @false
      +
      +correct:
      +        @echo "line 1" > ${.TARGET}.tmp
      +        @echo "line 2" >> ${.TARGET}.tmp
      +        @false
      +        @mv ${.TARGET}.tmp ${.TARGET}
      +
      +

      When you run make wrong twice, the file + wrong will exist, although there was an error + message in the first run. On the other hand, running make + correct gives an error message twice, as expected.

      +

      You might remember that make(1) sometimes removes + ${.TARGET} in case of error, but this only + happens when it is interrupted, for example by pressing + Ctrl+C. This does not happen + when one of the commands fails (like false(1) above).

      +

    -19.4. Running a phase

    -

    You can run a particular phase by typing make - phase, where phase is the name of the - phase. This will automatically run all phases that are required for this - phase. The default phase is build, that is, when you - run make without parameters in a package directory, - the package will be built, but not installed.

    +15.2. Makefile variables
    +

    Makefile variables contain strings that + can be processed using the five operators =, + +=, ?=, := and + !=, which are described in the make(1) man + page.

    +

    When a variable's value is parsed from a + Makefile, the hash character # and + the backslash character \ are handled specially. If a + backslash is the last character in a line, that backslash is removed + from the line and the line continues with the next line of the file.

    +

    The # character starts a comment that reaches + until the end of the line. To get an actual # character, + such as in a URL, write \# instead.

    +

    The evaluation of variables either happens immediately or lazy. + It happens immediately when the variable occurs on the right-hand + side of the := or the != operator, in a + .if condition or a .for loop. + In the other cases, it is evaluated lazily.

    +

    Some of the modifiers split the string into words and then + operate on the words, others operate on the string as a whole. When a + string is split into words, double quotes and single quotes are + interpreted as delimiters, just like in sh(1).

    +
    +

    +15.2.1. Naming conventions

    +
      +
    • All variable names starting with an underscore + are reserved for use by the pkgsrc infrastructure. They shall + not be used by packages.

    • +
    • In .for loops you should use + lowercase variable names for the iteration + variables.

    • +
    • All list variables should have a plural name, + such as PKG_OPTIONS or + DISTFILES.

    • +
    +

    -19.5. The fetch phase

    -

    The first step in building a package is to fetch the - distribution files (distfiles) from the sites that are providing - them. This is the task of the fetch - phase.

    +15.3. Code snippets

    -19.5.1. What to fetch and where to get it from

    -

    In simple cases, MASTER_SITES - defines all URLs from where the distfile, whose name is - derived from the DISTNAME variable, is - fetched. The more complicated cases are described - below.

    -

    The variable DISTFILES specifies - the list of distfiles that have to be fetched. Its value - defaults to ${DEFAULT_DISTFILES} and - its value is ${DISTNAME}${EXTRACT_SUFX}, - so that most packages don't need to define it at all. - EXTRACT_SUFX is - .tar.gz by default, but can be changed - freely. Note that if your package requires additional - distfiles to the default one, you cannot just append the - additional filenames using the += - operator, but you have write for example:

    +15.3.1. Adding things to a list
    +

    When adding a string that possibly contains whitespace or quotes to +a list (example 1), it must be quoted using the :Q +modifier.

    +

    When adding another list to a list (example 2), it must not be +quoted, since its elements are already quoted.

    -DISTFILES=      ${DEFAULT_DISTFILES} additional-files.tar.gz
    +STRING=         foo * bar `date`
    +LIST=           # empty
    +ANOTHER_LIST=   a=b c=d
    +
    +LIST+=          ${STRING:Q}       # 1
    +LIST+=          ${ANOTHER_LIST}   # 2
     
    -

    Each distfile is fetched from a list of sites, usually - MASTER_SITES. If the package has multiple - DISTFILES or multiple - PATCHFILES from different sites, you can - set - SITES.distfile - to the list of URLs where the file - distfile - (including the suffix) can be found.

    + +
    +

    +15.3.2. Echoing a string exactly as-is

    +

    Echoing a string containing special characters needs special +work.

    -DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
    -DISTFILES+=     foo-file.tar.gz
    -SITES.foo-file.tar.gz= \
    -https://www.somewhere.com/somehow/ \
    -https://www.somewhereelse.com/mirror/somehow/
    +STRING=         foo bar <    > * `date` $$HOME ' "
    +EXAMPLE_ENV=    string=${STRING:Q} x=multiple\ quoted\ words
    +
    +all:
    +        echo ${STRING}                  # 1
    +        echo ${STRING:Q}                # 2
    +        printf '%s\n' ${STRING:Q}''     # 3
    +        env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"'   # 4
     
    -

    When actually fetching the distfiles, each item from - MASTER_SITES or - SITES.* gets the name of each distfile - appended to it, without an intermediate slash. Therefore, - all site values have to end with a slash or other separator - character. This allows for example to set - MASTER_SITES to a URL of a CGI script - that gets the name of the distfile as a parameter. In this - case, the definition would look like:

    +

    Example 1 leads to a syntax error in the shell, as the characters +are just copied.

    +

    Example 2 quotes the string so that the shell interprets it +correctly. But the echo command may additionally interpret strings with a +leading dash or those containing backslashes.

    +

    Example 3 can handle arbitrary strings, since printf(1) only +interprets the format string, but not the next argument. The trailing +single quotes handle the case when the string is empty. In that case, the +:Q modifier would result in an empty string too, which would then be +skipped by the shell. For printf(1) this doesn't make a difference, +but other programs may care.

    +

    In example 4, the EXAMPLE_ENV does not +need to be quoted because the quoting has already been done +when adding elements to the list.

    +
    +
    +

    +15.3.3. Passing CFLAGS to GNU configure scripts

    +

    When passing CFLAGS or similar variables to a +GNU-style configure script (especially those that call other configure +scripts), it must not have leading or trailing whitespace, since +otherwise the configure script gets confused. To trim leading and +trailing whitespace, use the :M modifier, as in the +following example:

    +
    +CPPFLAGS=               # empty
    +CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX}\"
    +CPPFLAGS+=              ${MY_CPPFLAGS}
    +
    +CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
    +
    +all:
    +        echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
    +        echo x${CONFIGURE_ARGS:Q}x      # properly trimmed
    +
    +

    In this example, CPPFLAGS has both leading and +trailing whitespace because the += operator always adds a +space.

    +
    +
    +

    +15.3.4. Handling possibly empty variables

    +

    When a possibly empty variable is used in a shell program, it may +lead to a syntax error.

    -MASTER_SITES=   https://www.example.com/download.cgi?file=
    +EGFILES=        # empty
    +
    +install-examples:   # produces a syntax error in the shell
    +        for egfile in ${EGFILES}; do            \
    +                echo "Installing $$egfile";     \
    +        done
     
    -

    The exception to this rule are URLs starting with a dash. - In that case the URL is taken as is, fetched and the result - stored under the name of the distfile. You can use this style - for the case when the download URL style does not match the - above common case. For example, if permanent download URL is a - redirector to the real download URL, or the download file name - is offered by an HTTP Content-Disposition header. In the - following example, foo-1.0.0.tar.gz will be - created instead of the default - v1.0.0.tar.gz.

    +

    The shell only sees the text for egfile in ; do, since +${EGFILES} is replaced with an empty string by make(1). +To fix this syntax error, use one of the snippets below.

    -DISTNAME=       foo-1.0.0
    -MASTER_SITES=   -https://www.example.com/archive/v1.0.0.tar.gz
    +EMPTY=          # empty
    +
    +install-examples:
    +        for egfile in ${EGFILES} ""; do         \
    +                [ -n "$$egfile" ] || continue;  \
    +                echo "Installing $$egfile";     \
    +        done
     
    -

    There are some predefined values for - MASTER_SITES, which can be used in - packages. The names of the variables should speak for - themselves.

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    MASTER_SITE_APACHEMASTER_SITE_BACKUP
    MASTER_SITE_CRATESIOMASTER_SITE_CYGWIN
    MASTER_SITE_DEBIANMASTER_SITE_FREEBSD
    MASTER_SITE_FREEBSD_LOCALMASTER_SITE_GENTOO
    MASTER_SITE_GITHUBMASTER_SITE_GNOME
    MASTER_SITE_GNUMASTER_SITE_GNUSTEP
    MASTER_SITE_HASKELL_HACKAGEMASTER_SITE_IFARCHIVE
    MASTER_SITE_KDEMASTER_SITE_MOZILLA
    MASTER_SITE_MOZILLA_ALLMASTER_SITE_MYSQL
    MASTER_SITE_NETLIBMASTER_SITE_OPENBSD
    MASTER_SITE_OPENOFFICEMASTER_SITE_OSDN
    MASTER_SITE_PERL_CPANMASTER_SITE_PGSQL
    MASTER_SITE_PYPIMASTER_SITE_RUBYGEMS
    MASTER_SITE_R_CRANMASTER_SITE_SOURCEFORGE
    MASTER_SITE_SUNSITEMASTER_SITE_SUSE
    MASTER_SITE_TEX_CTANMASTER_SITE_XCONTRIB
    MASTER_SITE_XEMACSMASTER_SITE_XORG
    -

    Some explanations for the less self-explaining ones: - MASTER_SITE_BACKUP contains backup sites - for packages that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local - package source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/distfiles/LOCAL_PORTS/.

    -

    If you choose one of these predefined sites, you may - want to specify a subdirectory of that site. Since these - macros may expand to more than one actual site, you - must use the following construct to - specify a subdirectory:

    +

    In this case, an empty string is appended to the iteration list (to +prevent the syntax error) and filtered out later.

    -MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
    -MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
    +EGFILES=        # empty
    +
    +install-examples:
    +.for egfile in ${EGFILES}
    +        echo "Installing ${egfile}"
    +.endfor
     
    -

    Note the trailing slash after the subdirectory - name.

    +

    If one of the filenames contains special characters, it should be +enclosed in single or double quotes.

    +

    To have a shell command test whether a make variable is empty, use +the following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".

    -
    -

    -19.5.2. How are the files fetched?

    -

    The fetch phase makes sure that - all the distfiles exist in a local directory - (DISTDIR, which can be set by the pkgsrc - user). If the files do not exist, they are fetched using - commands of the form

    +
    + +
    +

    +Chapter 16. Options handling

    + +

    Many packages have the ability to be built to support different +sets of features. bsd.options.mk is a framework +in pkgsrc that provides generic handling of those options that +determine different ways in which the packages can be built. It's +possible for the user to specify exactly which sets of options will be +built into a package or to allow a set of global default options +apply.

    +

    There are two broad classes of behaviors that one might want to +control via options. One is whether some particular feature is +enabled in a program that will be built anyway, often by including or +not including a dependency on some other package. The other is +whether or not an additional program will be built as part of the +package. Generally, it is better to make a split package for such +additional programs instead of using options, because it enables +binary packages to be built which can then be added separately. For +example, the foo package might have minimal dependencies (those +packages without which foo doesn't make sense), and then the foo-gfoo +package might include the GTK frontend program gfoo. This is better +than including a gtk option to foo that adds gfoo, because either that +option is default, in which case binary users can't get foo without +gfoo, or not default, in which case they can't get gfoo. With split +packages, they can install foo without having GTK, and later decide to +install gfoo (pulling in GTK at that time). This is an advantage to +source users too, avoiding the need for rebuilds.

    +

    Plugins with widely varying dependencies should usually be split +instead of options.

    +

    It is often more work to maintain split packages, especially if +the upstream package does not support this. The decision of split +vs. option should be made based on the likelihood that users will want +or object to the various pieces, the size of the dependencies that are +included, and the amount of work.

    +

    A further consideration is licensing. Non-free parts, or parts +that depend on non-free dependencies (especially plugins) should +almost always be split if feasible.

    +
    +

    +16.1. Global default options

    +

    Global default options are listed in +PKG_DEFAULT_OPTIONS, which is a list of the options +that should be built into every package if that option is supported. +This variable should be set in mk.conf.

    +
    +
    +

    +16.2. Converting packages to use bsd.options.mk +

    +

    The following example shows how +bsd.options.mk should be used +by the hypothetical ``wibble'' package, either in the package +Makefile, or in a file, +e.g. options.mk, that is included by the +main package Makefile.

    +
    +PKG_OPTIONS_VAR=                PKG_OPTIONS.wibble
    +PKG_SUPPORTED_OPTIONS=          wibble-foo ldap
    +PKG_OPTIONS_OPTIONAL_GROUPS=    database
    +PKG_OPTIONS_GROUP.database=     mysql pgsql
    +PKG_SUGGESTED_OPTIONS=          wibble-foo
    +PKG_OPTIONS_LEGACY_VARS+=       WIBBLE_USE_OPENLDAP:ldap
    +PKG_OPTIONS_LEGACY_OPTS+=       foo:wibble-foo
    +
    +.include "../../mk/bsd.prefs.mk"
    +
    +# this package was previously named wibble2
    +.if defined(PKG_OPTIONS.wibble2)
    +PKG_LEGACY_OPTIONS+=            ${PKG_OPTIONS.wibble2}
    +PKG_OPTIONS_DEPRECATED_WARNINGS+= \
    +        "Deprecated variable PKG_OPTIONS.wibble2 used, use ${PKG_OPTIONS_VAR} instead."
    +.endif
    +
    +.include "../../mk/bsd.options.mk"
    +
    +# Package-specific option-handling
    +
    +###
    +### FOO support
    +###
    +.if !empty(PKG_OPTIONS:Mwibble-foo)
    +CONFIGURE_ARGS+=    --enable-foo
    +.endif
    +
    +###
    +### LDAP support
    +###
    +.if !empty(PKG_OPTIONS:Mldap)
    +.  include "../../databases/openldap-client/buildlink3.mk"
    +CONFIGURE_ARGS+=    --enable-ldap=${BUILDLINK_PREFIX.openldap-client}
    +.endif
    +
    +###
    +### database support
    +###
    +.if !empty(PKG_OPTIONS:Mmysql)
    +.  include "../../mk/mysql.buildlink3.mk"
    +.endif
    +.if !empty(PKG_OPTIONS:Mpgsql)
    +.  include "../../mk/pgsql.buildlink3.mk"
    +.endif
    +
    +

    The first section contains the information about which build +options are supported by the package, and any default options settings +if needed.

    +
      +
    1. PKG_OPTIONS_VAR is the name of the +make(1) variable that the user can set to override the default +options. It should be set to +PKG_OPTIONS.pkgbase. Do not set it to +PKG_OPTIONS.${PKGBASE}, since PKGBASE is not defined +at the point where the options are processed.

    2. +
    3. PKG_SUPPORTED_OPTIONS is a list of +build options supported by the package.

    4. +
    5. PKG_OPTIONS_OPTIONAL_GROUPS is a +list of names of groups of mutually exclusive options. The options in +each group are listed in +PKG_OPTIONS_GROUP.groupname. +The most specific setting of any option from the group takes +precedence over all other options in the group. Options from the +groups will be automatically added to +PKG_SUPPORTED_OPTIONS.

    6. +
    7. PKG_OPTIONS_REQUIRED_GROUPS is like +PKG_OPTIONS_OPTIONAL_GROUPS, but building the +packages will fail if no option from the group is +selected.

    8. +
    9. PKG_OPTIONS_NONEMPTY_SETS is a list +of names of sets of options. At least one option from each set must +be selected. The options in each set are listed in +PKG_OPTIONS_SET.setname. +Options from the sets will be automatically added to +PKG_SUPPORTED_OPTIONS. Building the package will +fail if no option from the set is selected.

    10. +
    11. PKG_SUGGESTED_OPTIONS is a list of +build options which are enabled by default.

    12. +
    13. PKG_OPTIONS_LEGACY_VARS is a list +of +USE_VARIABLE:option +pairs that map legacy mk.conf variables to +their option counterparts. Pairs should be added with ++= to keep the listing of global legacy variables. A +warning will be issued if the user uses a legacy +variable.

    14. +
    15. PKG_OPTIONS_LEGACY_OPTS is a list +of +old-option:new-option +pairs that map options that have been renamed to their new +counterparts. Pairs should be added with += to keep +the listing of global legacy options. A warning will be issued if +the user uses a legacy option.

    16. +
    17. PKG_LEGACY_OPTIONS is a list of +options implied by deprecated variables used. This can be used for +cases that neither PKG_OPTIONS_LEGACY_VARS nor +PKG_OPTIONS_LEGACY_OPTS can handle, e. g. when +PKG_OPTIONS_VAR is renamed.

    18. +
    19. PKG_OPTIONS_DEPRECATED_WARNINGS is +a list of warnings about deprecated variables or options used, and +what to use instead.

    20. +
    +

    A package should never modify +PKG_DEFAULT_OPTIONS or the variable named in +PKG_OPTIONS_VAR. These are strictly user-settable. +To suggest a default set of options, use +PKG_SUGGESTED_OPTIONS.

    +

    PKG_OPTIONS_VAR must be defined before +including bsd.options.mk. If none of +PKG_SUPPORTED_OPTIONS, +PKG_OPTIONS_OPTIONAL_GROUPS, and +PKG_OPTIONS_REQUIRED_GROUPS are defined (as can +happen with platform-specific options if none of them is supported on +the current platform), PKG_OPTIONS is set to the +empty list and the package is otherwise treated as not using the +options framework.

    +

    After the inclusion of bsd.options.mk, the +variable PKG_OPTIONS contains the list of selected +build options, properly filtered to remove unsupported and duplicate +options.

    +

    The remaining sections contain the logic that is specific to +each option. The correct way to check for an option is to check +whether it is listed in PKG_OPTIONS:

    -${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
    +.if !empty(PKG_OPTIONS:Moption)
     
    -

    where ${site} varies through - several possibilities in turn: first, - MASTER_SITE_OVERRIDE is tried, then the - sites specified in either SITES.file if - defined, else MASTER_SITES or - PATCH_SITES, as applies, then finally the - value of MASTER_SITE_BACKUP. The order of - all except the first and the last can be optionally sorted - by the user, via setting either - MASTER_SORT_RANDOM, and - MASTER_SORT_AWK or - MASTER_SORT_REGEX.

    -

    The specific command and arguments used depend on the - FETCH_USING parameter. The example above is - for FETCH_USING=custom.

    -

    The distfiles mirror run by the NetBSD Foundation uses the - mirror-distfiles target to mirror the - distfiles, if they are freely distributable. Packages setting - NO_SRC_ON_FTP (usually to - ${RESTRICTED}) will not have their distfiles - mirrored.

    -

    -19.6. The checksum phase

    -

    After the distfile(s) are fetched, their checksum is - generated and compared with the checksums stored in the - distinfo file. If the checksums don't match, the build is - aborted. This is to ensure the same distfile is used for - building, and that the distfile wasn't changed, e.g. by some - malign force, deliberately changed distfiles on the master - distribution site or network lossage.

    +16.3. Option Names
    +

    Options that enable similar features in different packages (like +optional support for a library) should use a common name in all +packages that support it (like the name of the library). If another +package already has an option with the same meaning, use the same +name.

    +

    Options that enable features specific to one package, where it's +unlikely that another (unrelated) package has the same (or a similar) +optional feature, should use a name prefixed with +pkgname-.

    +

    If a group of related packages share an optional feature +specific to that group, prefix it with the name of the +main package +(e. g. djbware-errno-hack).

    +

    For new options, add a line to +mk/defaults/options.description. Lines have two +fields, separated by tab. The first field is the option name, the +second its description. The description should be a whole sentence +(starting with an uppercase letter and ending with a period) that +describes what enabling the option does. E. g. Enable ispell +support. The file is sorted by option names.

    -19.7. The extract phase

    -

    When the distfiles are present on the local system, they - need to be extracted, as they usually come in the form of some - compressed archive format.

    -

    By default, all DISTFILES are - extracted. If you only need some of them, you can set the - EXTRACT_ONLY variable to the list of those - files.

    -

    Extracting the files is usually done by a little - program, mk/extract/extract, which - already knows how to extract various archive formats, so most - likely you will not need to change anything here. But if you - need, the following variables may help you:

    -
    -
    EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
    -

    Use these variables to override the default - options for an extract command, which are defined in - mk/extract/extract.

    -
    EXTRACT_USING
    -

    This variable can be set to - bsdtar, gtar, nbtar - (which is the default value), pax, or an - absolute pathname pointing to the command with which tar - archives should be extracted. It is preferred to choose bsdtar over gtar - if NetBSD's pax-as-tar is not good enough.

    -
    -

    If the extract program doesn't - serve your needs, you can also override the - EXTRACT_CMD variable, which holds the - command used for extracting the files. This command is - executed in the ${WRKSRC} - directory. During execution of this command, the shell - variable extract_file holds the absolute - pathname of the file that is going to be extracted.

    -

    And if that still does not suffice, you can override the - do-extract target in the package - Makefile.

    +16.4. Determining the options of dependencies
    +

    When writing buildlink3.mk files, it is often necessary to list +different dependencies based on the options with which the package was +built. For querying these options, the file +pkgsrc/mk/pkg-build-options.mk should be used. A +typical example looks like this:

    +
    +pkgbase := libpurple
    +.include "../../mk/pkg-build-options.mk"
    +
    +.if !empty(PKG_BUILD_OPTIONS.libpurple:Mdbus)
    +...
    +.endif
    +
    +

    Including pkg-build-options.mk here will set +the variable PKG_BUILD_OPTIONS.libpurple to the build +options of the libpurple package, which can then be queried like +PKG_OPTIONS in the options.mk +file. See the file pkg-build-options.mk for more +details.

    -
    -

    -19.8. The patch phase

    -

    After extraction, all the patches named by the - PATCHFILES, those present in the patches - subdirectory of the package as well as in - $LOCALPATCHES/$PKGPATH (e.g. - /usr/local/patches/graphics/png) are - applied. Patchfiles ending in .Z or - .gz are uncompressed before they are - applied, files ending in .orig or - .rej are ignored. Any special options to - patch(1) can be handed in - PATCH_DIST_ARGS. See Section 13.3, “patches/* for more details.

    -

    By default patch(1) is given special arguments to make it - fail if the expected text from the patch context is not found in the - patched file. If that happens, fix the patch file by comparing it - with the actual text in the file to be patched.

    -
    -

    -19.9. The tools phase

    -

    This is covered in Chapter 20, Tools needed for building or running. -

    +
    +

    +Chapter 17. Tools needed for building or running

    + -
    -

    -19.10. The wrapper phase

    -

    This phase creates wrapper programs for the compilers and - linkers. The following variables can be used to tweak the - wrappers.

    -
    -
    ECHO_WRAPPER_MSG
    -

    The command used to print progress - messages. Does nothing by default. Set to - ${ECHO} to see the progress - messages.

    -
    WRAPPER_DEBUG
    -

    This variable can be set to - yes (default) or no, - depending on whether you want additional information in the - wrapper log file.

    -
    WRAPPER_UPDATE_CACHE
    -

    This variable can be set to - yes or no, depending - on whether the wrapper should use its cache, which will - improve the speed. The default value is - yes, but is forced to - no if the platform does not support - it.

    -
    WRAPPER_REORDER_CMDS
    -

    A list of reordering commands. A reordering - command has the form - reorder:l:lib1:lib2. - It ensures that that - -llib1 occurs - before -llib2. -

    -
    +

    The USE_TOOLS definition is used both internally +by pkgsrc and also for individual packages to define what commands +are needed for building a package (like TOOL_DEPENDS) +or for later run-time of an installed packaged (such as +DEPENDS). +If the native system provides an adequate tool, then in many cases, a pkgsrc +package will not be used.

    +

    When building a package, the replacement tools are +made available in a directory (as symlinks or wrapper scripts) +that is early in the executable search path. Just like the buildlink +system, this helps with consistent builds.

    +

    A tool may be needed to help build a specific package. For example, +perl, GNU make (gmake) or yacc may be needed.

    +

    Also a tool may be needed, for example, because the native system's supplied +tool may be inefficient for building a package with pkgsrc. +For example, a package may need GNU awk, bison (instead of +yacc) or a better sed.

    +

    The tools used by a package can be listed by running +make show-tools.

    +
    +

    +17.1. Tools for pkgsrc builds

    +

    The default set of tools used by pkgsrc is defined in +bsd.pkg.mk. This includes standard Unix tools, +such as: cat, awk, +chmod, test, and so on. +These can be seen by running: +make show-var VARNAME=USE_TOOLS.

    +

    If a package needs a specific program to build +then the USE_TOOLS variable can be used +to define the tools needed.

    -19.11. The configure phase

    -

    Most pieces of software need information on the header - files, system calls, and library routines which are available - on the platform they run on. The process of determining this - information is known as configuration, and is usually - automated. In most cases, a script is supplied with the - distfiles, and its invocation results in generation of header - files, Makefiles, etc.

    -

    If the package contains a configure script, this can be - invoked by setting HAS_CONFIGURE to - yes. If the configure script is a GNU autoconf - script, you should set GNU_CONFIGURE to - yes instead. What happens in the - configure phase is roughly:

    +17.2. Tools needed by packages
    +

    In the following examples, the :run means that it is needed at +run-time (and becomes a DEPENDS). +The default is a build dependency which can be set with +:build. (So in this example, it is the same as gmake:build +and pkg-config:build.)

    -.for d in ${CONFIGURE_DIRS}
    -        cd ${WRKSRC} \
    -        && cd ${d} \
    -        && env ${CONFIGURE_ENV} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
    -.endfor
    +USE_TOOLS+=     gmake perl:run pkg-config
     
    -

    CONFIGURE_DIRS (default: - .) is a list of pathnames relative to - WRKSRC. In each of these directories, the - configure script is run with the environment - CONFIGURE_ENV and arguments - CONFIGURE_ARGS. The variables - CONFIGURE_ENV, - CONFIGURE_SCRIPT (default: - ./configure) and - CONFIGURE_ARGS may all be changed by the - package.

    -

    If the program uses the Perl way of configuration (mainly Perl - modules, but not only), i.e. a file called - Makefile.PL, it should include - ../../lang/perl5/module.mk. To set any parameter for - Makefile.PL use the MAKE_PARAMS - variable (e.g., MAKE_PARAMS+=foo=bar

    -

    If the program uses an Imakefile - for configuration, the appropriate steps can be invoked by - setting USE_IMAKE to - yes. If you only need xmkmf, add it to USE_TOOLS. - You can add variables to xmkmf's environment by adding them to the - SCRIPTS_ENV variable.

    -

    If the program uses cmake - for configuration, the appropriate steps can be invoked by - setting USE_CMAKE to yes. - You can add variables to cmake's environment by adding them to the - CONFIGURE_ENV variable and arguments to cmake - by adding them to the CMAKE_ARGS variable. - The top directory argument is given by the - CMAKE_ARG_PATH variable, that defaults to - . (relative to CONFIGURE_DIRS)

    -

    If there is no configure step at all, set - NO_CONFIGURE to yes.

    +

    When using the tools framework, a +TOOLS_PATH.foo variable is defined +which contains the full path to the appropriate tool. For example, +TOOLS_PATH.bash could be /bin/bash +on Linux systems.

    +

    If you always need a pkgsrc version of the +tool at run-time, then just use DEPENDS instead. +

    -19.12. The build phase

    -

    For building a package, a rough equivalent of the - following code is executed.

    +17.3. Tools provided by platforms
    +

    When improving or porting pkgsrc to a new platform, have a look +at (or create) the corresponding platform specific make file fragment under +pkgsrc/mk/tools/tools.${OPSYS}.mk which defines +the name of the common tools. For example:

    -.for d in ${BUILD_DIRS}
    -        cd ${WRKSRC} \
    -        && cd ${d} \
    -        && env ${MAKE_ENV} \
    -            ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
    -                -f ${MAKE_FILE} \
    -                ${BUILD_TARGET}
    -.endfor
    +.if exists(/usr/bin/bzcat)
    +TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
    +.elif exists(/usr/bin/bzip2)
    +TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
    +.endif
    +
    +TOOLS_PLATFORM.true?=           true                    # shell builtin
     
    -

    BUILD_DIRS (default: - .) is a list of pathnames relative to - WRKSRC. In each of these directories, - MAKE_PROGRAM is run with the environment - MAKE_ENV and arguments - BUILD_MAKE_FLAGS. The variables - MAKE_ENV, - BUILD_MAKE_FLAGS, - MAKE_FILE and - BUILD_TARGET may all be changed by the - package.

    -

    The default value of MAKE_PROGRAM is - gmake if USE_TOOLS contains - gmake, make otherwise. The - default value of MAKE_FILE is - Makefile, and BUILD_TARGET - defaults to all.

    -

    If there is no build step at all, set - NO_BUILD to yes.

    -
    -

    -19.13. The test phase

    -

    [TODO]

    +
    +

    +Chapter 18. Buildlink methodology

    + +

    Buildlink is a framework in pkgsrc that controls what headers and libraries + are seen by a package's configure and build processes. This is implemented + in a two step process:

    +
      +
    1. Symlink headers and libraries for dependencies into + BUILDLINK_DIR, which by default is a subdirectory + of WRKDIR.

    2. +
    3. Create wrapper scripts that are used in place of the normal compiler + tools that translate -I${LOCALBASE}/include and + -L${LOCALBASE}/lib into references to + BUILDLINK_DIR. The wrapper scripts also make + native compiler on some operating systems look like GCC, so that + packages that expect GCC won't require modifications to build with + those native compilers.

    4. +
    +

    This normalizes the environment in which a package is built so that the + package may be built consistently despite what other software may be + installed. Please note that the normal system header and library paths, + e.g. /usr/include, + /usr/lib, etc., are always searched -- buildlink3 is + designed to insulate the package build from non-system-supplied + software.

    -19.14. The install phase

    -

    Once the build stage has completed, the final step is to - install the software in public directories, so users can - access the programs and files.

    -

    In the install phase, a rough - equivalent of the following code is executed. Additionally, - before and after this code, much magic is performed to do - consistency checks, registering the package, and so on.

    -
    -.for d in ${INSTALL_DIRS}
    -        cd ${WRKSRC} \
    -        && cd ${d} \
    -        && env ${MAKE_ENV} \
    -            ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
    -                -f ${MAKE_FILE} \
    -                ${INSTALL_TARGET}
    -.endfor
    -
    -

    The variable's meanings are analogous to the ones in the - build phase. - INSTALL_DIRS defaults to - BUILD_DIRS. INSTALL_TARGET - is install by default, plus - install.man if USE_IMAKE is - defined and NO_INSTALL_MANPAGES is not - defined.

    -

    In the install phase, the following - variables are useful. They are all variations of the - install(1) command that have the owner, group and - permissions preset. INSTALL is the plain - install command. The specialized variants, together with their - intended use, are:

    -
    -
    INSTALL_PROGRAM_DIR
    -

    directories that contain - binaries

    -
    INSTALL_SCRIPT_DIR
    -

    directories that contain - scripts

    -
    INSTALL_LIB_DIR
    -

    directories that contain shared and static - libraries

    -
    INSTALL_DATA_DIR
    -

    directories that contain data - files

    -
    INSTALL_MAN_DIR
    -

    directories that contain man - pages

    -
    INSTALL_GAME_DIR
    -

    directories that contain data files for games -

    -
    INSTALL_PROGRAM
    -

    binaries that can be stripped from debugging - symbols

    -
    INSTALL_SCRIPT
    -

    binaries that cannot be - stripped

    -
    INSTALL_GAME
    -

    game - binaries

    -
    INSTALL_LIB
    -

    shared and static - libraries

    -
    INSTALL_DATA
    -

    data files

    -
    INSTALL_GAME_DATA
    -

    data files for - games

    -
    INSTALL_MAN
    -

    man pages

    -
    -

    Some other variables are:

    -
    -
    INSTALL_UNSTRIPPED
    -

    If set to yes, do not run strip(1) - when installing binaries. Any debugging sections and symbols present in - binaries will be preserved. -

    -
    INSTALLATION_DIRS
    -

    A list of directories relative to - PREFIX that are created by pkgsrc at the - beginning of the install phase. - The package is supposed to create all needed directories itself - before installing files to it and list all other directories here. -

    -
    -

    In the rare cases that a package shouldn't install anything, - set NO_INSTALL to yes. This is - mostly relevant for packages in the regress - category.

    +18.1. Converting packages to use buildlink3
    +

    The process of converting packages to use the buildlink3 + framework (bl3ifying) is fairly straightforward. + The things to keep in mind are:

    +
      +
    1. Ensure that the build always calls the wrapper scripts + instead of the actual toolchain. Some packages are tricky, + and the only way to know for sure is the check + ${WRKDIR}/.work.log to see if the + wrappers are being invoked.

    2. +
    3. Don't override PREFIX from within + the package Makefile, e.g. Java VMs, standalone shells, + etc., because the code to symlink files into + ${BUILDLINK_DIR} looks for files + relative to pkg_info -qp pkgname. +

    4. +
    5. Remember that only the + buildlink3.mk files that you list in a + package's Makefile are added as dependencies for that package. +

    6. +
    +

    If a dependency on a particular package is required for its libraries and + headers, then we replace:

    +
    +DEPENDS+=       foo>=1.1.0:../../category/foo
    +
    +

    with

    +
    +.include "../../category/foo/buildlink3.mk"
    +
    +

    The buildlink3.mk files usually define the required dependencies. + If you need a newer version of the dependency when using buildlink3.mk + files, then you can define it in your Makefile; for example:

    +
    +BUILDLINK_API_DEPENDS.foo+=   foo>=1.1.0
    +.include "../../category/foo/buildlink3.mk"
    +
    +

    There are several buildlink3.mk + files in pkgsrc/mk + that handle special package issues:

    +
      +
    • bdb.buildlink3.mk chooses either + the native or a pkgsrc Berkeley DB implementation based on + the values of BDB_ACCEPTED and + BDB_DEFAULT.

    • +
    • curses.buildlink3.mk: If the system + comes with neither Curses nor NCurses, this will take care + to install the devel/ncurses package.

    • +
    • krb5.buildlink3.mk uses the value + of KRB5_ACCEPTED to choose between + adding a dependency on Heimdal or MIT-krb5 for packages that + require a Kerberos 5 implementation.

    • +
    • motif.buildlink3.mk checks for a + system-provided Motif installation or adds a dependency on + x11/lesstif or x11/motif. The user can set + MOTIF_TYPE to dt, + lesstif or motif + to choose which Motif version will be used.

    • +
    • readline.buildlink3.mk checks for a + system-provided GNU readline or editline (libedit) installation, + or adds a dependency on devel/readline, + devel/editline. The user can set + READLINE_DEFAULT to choose readline implementation. + If your package really needs GNU readline library, its Makefile + should include devel/readline/buildlink3.mk + instead of readline.buildlink3.mk.

    • +
    • oss.buildlink3.mk defines several + variables that may be used by packages that use the + Open Sound System (OSS) API.

    • +
    • pgsql.buildlink3.mk will accept + any of the Postgres versions in the variable + PGSQL_VERSIONS_ACCEPTED and default to + the version PGSQL_VERSION_DEFAULT. See + the file for more information.

    • +
    • pthread.buildlink3.mk uses the value of + PTHREAD_OPTS and checks for native pthreads or adds + a dependency on devel/pth as needed.

    • +
    • xaw.buildlink3.mk uses the value of + XAW_TYPE to choose a particular Athena widgets + library.

    • +
    +

    The comments in those buildlink3.mk + files provide a more complete + description of how to use them properly.

    -19.15. The package phase

    -

    Once the install stage has completed, a binary package of - the installed files can be built. These binary packages can be - used for quick installation without previous compilation, e.g. by - the make bin-install or by using - pkg_add.

    -

    By default, the binary packages are created in - ${PACKAGES}/All and symlinks are created in - ${PACKAGES}/category, - one for each category in the CATEGORIES - variable. PACKAGES defaults to - pkgsrc/packages.

    +18.2. Writing buildlink3.mk files
    +

    A package's buildlink3.mk file is + included by Makefiles to indicate the need to compile and link + against header files and libraries provided by the package. A + buildlink3.mk file should always provide + enough information to add the correct type of dependency + relationship and include any other + buildlink3.mk files that it needs to find + headers and libraries that it needs in turn.

    +

    To generate an initial buildlink3.mk + file for further editing, Rene Hexel's pkgtools/createbuildlink + package is highly recommended. For most packages, the following + command will generate a good starting point for + buildlink3.mk files:

    +
    +% cd pkgsrc/category/pkgdir
    +% createbuildlink >buildlink3.mk
    +    
    +
    +

    +18.2.1. Anatomy of a buildlink3.mk file

    +

    The following real-life example + buildlink3.mk is taken + from pkgsrc/graphics/tiff:

    +
    +# $NetBSD: buildlink3.mk,v 1.16 2009/03/20 19:24:45 joerg Exp $
    +
    +BUILDLINK_TREE+=        tiff
    +
    +.if !defined(TIFF_BUILDLINK3_MK)
    +TIFF_BUILDLINK3_MK:=
    +
    +BUILDLINK_API_DEPENDS.tiff+=    tiff>=3.6.1
    +BUILDLINK_ABI_DEPENDS.tiff+=    tiff>=3.7.2nb1
    +BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
    +
    +.include "../../devel/zlib/buildlink3.mk"
    +.include "../../graphics/jpeg/buildlink3.mk"
    +.endif # TIFF_BUILDLINK3_MK
    +
    +BUILDLINK_TREE+=        -tiff
    +
    +

    The header and footer manipulate + BUILDLINK_TREE, which is common across all + buildlink3.mk files and is used to track + the dependency tree.

    +

    The main section is protected from multiple inclusion + and controls how the dependency on pkg is + added. Several important variables are set in the section:

    +
      +
    • BUILDLINK_API_DEPENDS.pkg + is the actual dependency recorded in the installed + package; this should always be set using + += to ensure that + we're appending to any pre-existing list of values. This + variable should be set to the first version of the + package that had an backwards-incompatible API change. +

    • +
    • BUILDLINK_PKGSRCDIR.pkg + is the location of the pkg + pkgsrc directory.

    • +
    • BUILDLINK_DEPMETHOD.pkg + (not shown above) controls whether we use + BUILD_DEPENDS or + DEPENDS to add the dependency on + pkg. The build dependency is + selected by setting + BUILDLINK_DEPMETHOD.pkg + to build. By default, the full dependency is + used.

    • +
    • BUILDLINK_INCDIRS.pkg + and + BUILDLINK_LIBDIRS.pkg + (not shown above) are lists of subdirectories of + ${BUILDLINK_PREFIX.pkg} + to add to the header and library search paths. These + default to include and lib + respectively.

    • +
    • BUILDLINK_CPPFLAGS.pkg + (not shown above) is the list of preprocessor flags to add + to CPPFLAGS, which are passed on to the + configure and build phases. The -I option + should be avoided and instead be handled using + BUILDLINK_INCDIRS.pkg as + above.

    • +
    +

    The following variables are all optionally defined within + this second section (protected against multiple inclusion) and + control which package files are symlinked into + ${BUILDLINK_DIR} and how their names are + transformed during the symlinking:

    +
      +
    • BUILDLINK_FILES.pkg + (not shown above) is a shell glob pattern relative to + ${BUILDLINK_PREFIX.pkg} + to be symlinked into + ${BUILDLINK_DIR}, + e.g. include/*.h.

    • +
    • BUILDLINK_FILES_CMD.pkg + (not shown above) is a shell pipeline that + outputs to stdout a list of files relative to + ${BUILDLINK_PREFIX.pkg}. + The resulting files are to be symlinked + into ${BUILDLINK_DIR}. By default, + this takes the +CONTENTS of a + pkg and filters it through + ${BUILDLINK_CONTENTS_FILTER.pkg}.

    • +
    • BUILDLINK_CONTENTS_FILTER.pkg + (not shown above) is a filter command that filters + +CONTENTS input into a list of files + relative to + ${BUILDLINK_PREFIX.pkg} + on stdout. By default, + BUILDLINK_CONTENTS_FILTER.pkg + outputs the contents of the include + and lib directories in the package + +CONTENTS.

    • +
    • BUILDLINK_FNAME_TRANSFORM.pkg + (not shown above) is a list of sed arguments used to + transform the name of the source filename into a + destination filename, e.g. -e + "s|/curses.h|/ncurses.h|g".

    • +
    +

    This section can additionally include any + buildlink3.mk needed for + pkg's library dependencies. + Including these buildlink3.mk files + means that the headers and libraries for these + dependencies are also symlinked into + ${BUILDLINK_DIR} + whenever the pkg + buildlink3.mk + file is included. Dependencies are only added for directly + include buildlink3.mk files.

    +

    When providing a buildlink3.mk and + including other buildlink3.mk files in it, + please only add necessary ones, i.e., those whose libraries or + header files are automatically exposed when the package is + use.

    +

    In particular, if only an executable + (bin/foo) is linked against a library, that + library does not need to be propagated in the + buildlink3.mk file.

    +

    The following steps should help you decide if a + buildlink3.mk file needs to be included: +

    +
      +
    • Look at the installed header files: What + headers do they include? The packages providing these files + must be buildlinked.

    • +
    • Run ldd on all installed + libraries and look against what other libraries they link. + Some of the packages providing these probably need to be + buildlinked; however, it's not automatic, since e.g. GTK on + some systems pulls in the X libraries, so they will show up in + the ldd output, while on others (like OS + X) it won't. ldd output can thus only be + used as a hint.

    • +
    +

    +

    +
    +
    +

    +18.2.2. Updating + BUILDLINK_API_DEPENDS.pkg + and + BUILDLINK_ABI_DEPENDS.pkg + in buildlink3.mk files

    +

    These two variables differ in that one describes source + compatibility (API) and the other binary compatibility (ABI). + The difference is that a change in the API breaks compilation of + programs while changes in the ABI stop compiled programs from + running.

    +

    Changes to the + BUILDLINK_API_DEPENDS.pkg + variable in a buildlink3.mk file happen + very rarely. One possible reason is that all packages depending + on this already need a newer version. In case it is bumped see + the description below.

    +

    The most common example of an ABI change is that the major + version of a shared library is increased. In this case, + BUILDLINK_ABI_DEPENDS.pkg + should be adjusted to require at least the new package version. + Then the packages that depend on this package need their + PKGREVISIONs increased and, if they have + buildlink3.mk files, their + BUILDLINK_ABI_DEPENDS.pkg + adjusted, too. This is needed so pkgsrc will require the correct + package dependency and not settle for an older one when building + the source.

    +

    See Section 21.1.5, “Handling dependencies” for + more information about dependencies on other packages, + including the BUILDLINK_ABI_DEPENDS and + ABI_DEPENDS definitions.

    +

    Please take careful consideration before adjusting + BUILDLINK_API_DEPENDS.pkg + or + BUILDLINK_ABI_DEPENDS.pkg + as we don't want to cause unneeded package deletions and + rebuilds. In many cases, new versions of packages work just + fine with older dependencies.

    +

    Also it is not needed to set + BUILDLINK_ABI_DEPENDS.pkg + when it is identical to + BUILDLINK_API_DEPENDS.pkg.

    -
    -

    -19.16. Cleaning up

    -

    Once you're finished with a package, you can clean the work - directory by running make clean. If you want - to clean the work directories of all dependencies too, use - make clean-depends.

    -19.17. Other helpful targets

    -
    -
    pre/post-*
    -

    For any of the main targets described in the - previous section, two auxiliary targets exist with - pre- and post- used as a - prefix for the main target's name. These targets are - invoked before and after the main target is called, - allowing extra configuration or installation steps be - performed from a package's Makefile, for example, which - a program's configure script or install target - omitted.

    -
    do-*
    -

    Should one of the main targets do the wrong thing, - and should there be no variable to fix this, you can - redefine it with the do-* target. (Note that redefining - the target itself instead of the do-* target is a bad - idea, as the pre-* and post-* targets won't be called - anymore, etc.) You will not usually need to do - this.

    -
    reinstall
    -
    -

    If you did a make install and - you noticed some file was not installed properly, you - can repeat the installation with this target, which will - ignore the already installed flag.

    -

    This is the default value of - DEPENDS_TARGET except in the case of - make update and make - package, where the defaults are - package and update, - respectively.

    -
    -
    deinstall
    -
    -

    This target does a pkg_delete(1) in the - current directory, effectively de-installing the - package. The following variables can be used to tune the - behaviour:

    -
    -
    PKG_VERBOSE
    -

    Add a "-v" to the pkg_delete(1) command.

    -
    DEINSTALLDEPENDS
    -

    Remove all packages that require (depend on) - the given package. This can be used to remove any - packages that may have been pulled in by a given - package, e.g. if make deinstall - DEINSTALLDEPENDS=1 is done in - pkgsrc/x11/kde, this is - likely to remove whole KDE. Works by adding - -R to the pkg_delete(1) - command line.

    -
    -
    -
    bin-install
    -

    Install a binary package from local disk and via FTP - from a list of sites (see the - BINPKG_SITES variable), and do a - make package if no binary package is - available anywhere. The arguments given to - pkg_add can be set via - BIN_INSTALL_FLAGS e.g., to do verbose - operation, etc.

    -
    install-clean
    -

    This target removes the state files for the "install" and later - phases so that the "install" target may be re-invoked. This can be - used after editing the PLIST to install the package without - rebuilding it.

    -
    build-clean
    -

    This target removes the state files for the "build" and later - phases so that the "build" target may be re-invoked.

    -
    update
    -
    -

    This target causes the current package to be - updated to the latest version. The package and all - depending packages first get de-installed, then current - versions of the corresponding packages get compiled and - installed. This is similar to manually noting which - packages are currently installed, then performing a - series of make deinstall and - make install (or whatever - UPDATE_TARGET is set to) for these - packages.

    -

    You can use the update target to - resume package updating in case a previous make - update was interrupted for some reason. - However, in this case, make sure you don't call - make clean or otherwise remove the - list of dependent packages in WRKDIR. - Otherwise, you lose the ability to automatically update - the current package along with the dependent packages - you have installed.

    -

    Resuming an interrupted make - update will only work as long as the package - tree remains unchanged. If the source code for one of - the packages to be updated has been changed, resuming - make update will most certainly - fail!

    -

    The following variables can be used either on the - command line or in mk.conf to - alter the behaviour of make - update:

    -
    -
    UPDATE_TARGET
    -

    Install target to recursively use for the - updated package and the dependent packages. - Defaults to DEPENDS_TARGET if - set, install otherwise for - make update. Other good - targets are package or - bin-install. Do not set this to - update or you will get stuck in an - endless loop!

    -
    NOCLEAN
    -

    Don't clean up after updating. Useful if - you want to leave the work sources of the updated - packages around for inspection or other purposes. - Be sure you eventually clean up the source tree - (see the clean-update target below) - or you may run into troubles with old source code - still lying around on your next - make or make - update.

    -
    REINSTALL
    -

    Deinstall each package before installing - (making DEPENDS_TARGET). This - may be necessary if the - clean-update target (see below) was - called after interrupting a running make - update.

    -
    DEPENDS_TARGET
    -

    Allows you to disable recursion and hardcode - the target for packages. The default is - update for the update target, - facilitating a recursive update of prerequisite - packages. Only set - DEPENDS_TARGET if you want to - disable recursive updates. Use - UPDATE_TARGET instead to just - set a specific target for each package to be - installed during make update - (see above).

    -
    -
    -
    clean-update
    -
    -

    Clean the source tree for all packages that would - get updated if make update was called - from the current directory. This target should not be - used if the current package (or any of its depending - packages) have already been de-installed (e.g., after - calling make update) or you may lose - some packages you intended to update. As a rule of - thumb: only use this target before - the first time you run make update - and only if you have a dirty package tree (e.g., if you - used NOCLEAN).

    -

    If you are unsure about whether your tree is - clean, you can either perform a make - clean at the top of the tree, or use the - following sequence of commands from the directory of the - package you want to update (before - running make update for the first - time, otherwise you lose all the packages you wanted to - update!):

    +18.3. Writing builtin.mk files
    +

    Some packages in pkgsrc install headers and libraries that + coincide with headers and libraries present in the base system. + Aside from a buildlink3.mk file, these + packages should also include a builtin.mk + file that includes the necessary checks to decide whether using + the built-in software or the pkgsrc software is + appropriate.

    +

    The only requirements of a builtin.mk file for + pkg are:

    +
      +
    1. It should set + USE_BUILTIN.pkg + to either yes or no + after it is included.

    2. +
    3. It should not override any + USE_BUILTIN.pkg + which is already set before the + builtin.mk file is included.

    4. +
    5. It should be written to allow multiple inclusion. This + is very important and takes careful + attention to Makefile coding.

    6. +
    +
    +

    +18.3.1. Anatomy of a builtin.mk file

    +

    The following is the recommended template for builtin.mk + files:

    +
    +.if !defined(IS_BUILTIN.foo)
    +#
    +# IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
    +# genuinely exists in the system or not.
    +#
    +IS_BUILTIN.foo?=        no
    +
    +# BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
    +# version can be determined.
    +#
    +.  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
    +BUILTIN_PKG.foo?=       foo-1.0
    +.  endif
    +.endif  # IS_BUILTIN.foo
    +
    +.if !defined(USE_BUILTIN.foo)
    +USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
    +.  if defined(BUILTIN_PKG.foo)
    +.    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
    +.      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
    +USE_BUILTIN.foo!=                                                       \
    +        ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}            \
    +        && ${ECHO} "yes" || ${ECHO} "no"
    +.      endif
    +.    endfor
    +.  endif
    +.endif  # USE_BUILTIN.foo
    +
    +CHECK_BUILTIN.foo?=     no
    +.if !empty(CHECK_BUILTIN.foo:M[nN][oO])
    +#
    +# Here we place code that depends on whether USE_BUILTIN.foo is set to
    +# "yes" or "no".
    +#
    +.endif  # CHECK_BUILTIN.foo
    +
    +

    The first section sets + IS_BUILTIN.pkg + depending on if pkg really exists + in the base system. This should not be a base system software + with similar functionality to pkg; + it should only be yes if the actual package is + included as part of the base system. This variable is only + used internally within the builtin.mk + file.

    +

    The second section sets + BUILTIN_PKG.pkg + to the version of pkg in the base + system if it exists (if + IS_BUILTIN.pkg + is yes). This variable is only used internally + within the builtin.mk file.

    +

    The third section sets + USE_BUILTIN.pkg + and is required in all + builtin.mk files. The code in this + section must make the determination whether the built-in + software is adequate to satisfy the dependencies listed in + BUILDLINK_API_DEPENDS.pkg. + This is typically done by comparing + BUILTIN_PKG.pkg + against each of the dependencies in + BUILDLINK_API_DEPENDS.pkg. + USE_BUILTIN.pkg + must be set to the correct value by the + end of the builtin.mk file. Note that + USE_BUILTIN.pkg + may be yes even if + IS_BUILTIN.pkg + is no because we may make the determination + that the built-in version of the software is similar enough to + be used as a replacement.

    +

    The last section is guarded by + CHECK_BUILTIN.pkg, + and includes code that uses the value of + USE_BUILTIN.pkg + set in the previous section. This typically includes, e.g., + adding additional dependency restrictions and listing additional + files to symlink into ${BUILDLINK_DIR} (via + BUILDLINK_FILES.pkg).

    +
    +
    +

    +18.3.2. Global preferences for native or pkgsrc software

    +

    When building packages, it's possible to choose whether to set + a global preference for using either the built-in (native) + version or the pkgsrc version of software to satisfy a + dependency. This is controlled by setting + PREFER_PKGSRC and + PREFER_NATIVE. These variables take values + of either yes, no, or a list of + packages. PREFER_PKGSRC tells pkgsrc to + use the pkgsrc versions of software, while + PREFER_NATIVE tells pkgsrc to use the + built-in versions. Preferences are determined by the most + specific instance of the package in either + PREFER_PKGSRC or + PREFER_NATIVE. If a package is specified + in neither or in both variables, then + PREFER_PKGSRC has precedence over + PREFER_NATIVE. For example, to require + using pkgsrc versions of software for all but the most basic + bits on a NetBSD system, you can set:

    +
    +PREFER_PKGSRC=  yes
    +PREFER_NATIVE=  getopt skey tcp_wrappers
    +
    +

    A package must have a + builtin.mk + file to be listed in PREFER_NATIVE, + otherwise it is simply ignored in that list.

    +

    Setting PREFER_NATIVE should be performed + straight after bootstrap and PREFER_PKGSRC during + bootstrap. + Switching between settings globally at a later date can introduce + complications with dependency resolution. This is caused by packages + built with the opposite preference being installed alongside each other.

    -# make clean-update
    -# make clean CLEANDEPENDS=YES
    -# make update
    -	  
    -

    The following variables can be used either on the - command line or in mk.conf to alter the behaviour of - make clean-update:

    -
    -
    CLEAR_DIRLIST
    -

    After make clean, do not - reconstruct the list of directories to update for - this package. Only use this if make - update successfully installed all - packages you wanted to update. Normally, this is - done automatically on make - update, but may have been suppressed by - the NOCLEAN variable (see - above).

    -
    - -
    replace
    -
    -

    Update the installation of the current package. This - differs from update in that it does not replace dependent - packages. You will need to install pkgtools/pkg_tarup for this - target to work.

    -

    Be careful when using this - target! There are no guarantees that dependent - packages will still work, in particular they will most - certainly break if you make replace a - library package whose shared library major version changed - between your installed version and the new one. For this - reason, this target is not officially supported and only - recommended for advanced users.

    -
    -
    info
    -

    This target invokes pkg_info(1) for the current - package. You can use this to check which version of a - package is installed.

    -
    index
    -
    -

    This is a top-level command, i.e. it should be used in - the pkgsrc directory. It creates a - database of all packages in the local pkgsrc tree, including - dependencies, comment, maintainer, and some other useful - information. Individual entries are created by running - make describe in the packages' - directories. This index file is saved as - pkgsrc/INDEX. It can be displayed in - verbose format by running make - print-index. You can search in it with - make search - key=something. You can - extract a list of all packages that depend on a particular - one by running make show-deps - PKG=somepackage.

    -

    Running this command takes a very long time, some - hours even on fast machines!

    -
    -
    readme
    -
    -

    This target generates a - README.html file, which can be - viewed using a browser such as www/firefox or www/links. The generated files - contain references to any packages which are in the - PACKAGES directory on the local - host. The generated files can be made to refer to URLs - based on FTP_PKG_URL_HOST and - FTP_PKG_URL_DIR. For example, if I - wanted to generate README.html - files which pointed to binary packages on the local - machine, in the directory - /usr/packages, set - FTP_PKG_URL_HOST=file://localhost and - FTP_PKG_URL_DIR=/usr/packages. The - ${PACKAGES} directory and its - subdirectories will be searched for all the binary - packages.

    -

    The target can be run at the toplevel or in category - directories, in which case it descends recursively.

    -
    -
    readme-all
    -

    This is a top-level command, run it in - pkgsrc. Use this target to create a - file README-all.html which contains a - list of all packages currently available in the NetBSD - Packages Collection, together with the category they belong - to and a short description. This file is compiled from the - pkgsrc/*/README.html files, so be sure - to run this after a make - readme.

    -
    cdrom-readme
    -

    This is very much the same as the - readme target (see above), but is to be - used when generating a pkgsrc tree to be written to a - CD-ROM. This target also produces - README.html files, and can be made - to refer to URLs based on - CDROM_PKG_URL_HOST and - CDROM_PKG_URL_DIR.

    -
    show-distfiles
    -

    This target shows which distfiles and patchfiles - are needed to build the package - (ALLFILES, which contains all - DISTFILES and - PATCHFILES, but not - patches/*).

    -
    show-downlevel
    -

    This target shows nothing if the package is not - installed. If a version of this package is installed, - but is not the version provided in this version of - pkgsrc, then a warning message is displayed. This target - can be used to show which of your installed packages are - downlevel, and so the old versions can be deleted, and - the current ones added.

    -
    show-pkgsrc-dir
    -

    This target shows the directory in the pkgsrc - hierarchy from which the package can be built and - installed. This may not be the same directory as the one - from which the package was installed. This target is - intended to be used by people who may wish to upgrade - many packages on a single host, and can be invoked from - the top-level pkgsrc Makefile by using the - show-host-specific-pkgs target.

    -
    show-installed-depends
    -

    This target shows which installed packages match - the current package's DEPENDS. Useful - if out of date dependencies are causing build - problems.

    -
    print-build-depends-list
    -

    This target shows the list of packages that the current package - depends on for building.

    -
    print-run-depends-list
    -

    This target shows the list of packages that the current package - depends on for running.

    -
    check-shlibs
    -

    After a package is installed, check all its - binaries and (on ELF platforms) shared libraries to see - if they find the shared libs they need. Run by default - if PKG_DEVELOPER is set in mk.conf.

    -
    print-PLIST
    +# ./bootstrap --prefer-pkgsrc yes + +
    + + +
    +

    +Chapter 19. PLIST issues

    + +

    The PLIST file contains a package's + packing list, i.e. a list of files that belong to + the package (relative to the ${PREFIX} + directory it's been installed in) plus some additional statements + - see the pkg_create(1) man page for a full list. + This chapter addresses some issues that need attention when + dealing with the PLIST file (or files, see + below!).

    +
    +

    +19.1. RCS ID

    +

    Be sure to add a RCS ID line as the first thing in any + PLIST file you write:

    +
    +@comment $NetBSD $
    +
    +

    An artificial space has been added between NetBSD and $, this is a +workaround here to prevent CVS expanding to the filename of the guide. When +adding the RCS ID the space should be omitted.

    +
    +
    +

    +19.2. Semi-automatic PLIST generation

    +

    You can use the make print-PLIST command + to output a PLIST that matches any new files since the package + was extracted. See Section 13.17, “Other helpful targets” for + more information on this target.

    +
    +
    +

    +19.3. Tweaking output of make print-PLIST +

    +

    The PRINT_PLIST_AWK variable takes a set + of AWK patterns and actions that are used to filter the output of + print-PLIST. You can append any chunk of AWK + scripting you like to it, but be careful with quoting.

    +

    For example, to get all files inside the + libdata/foo directory removed from the + resulting PLIST:

    +
    +PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
    +
    +
    +
    +

    +19.4. Variable substitution in PLIST

    +

    A number of variables are substituted automatically in + PLISTs when a package is installed on a system. This includes the + following variables:

    +
    +
    ${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
    -

    After a make install from a new or - upgraded pkg, this prints out an attempt to generate a - new PLIST from a find - -newer work/.extract_done. An attempt is made - to care for shared libs etc., but it is - strongly recommended to review the - result before putting it into - PLIST. On upgrades, it's useful to - diff the output of this command against an already - existing PLIST file.

    -

    If the package installs files via tar(1) or - other methods that don't update file access times, be - sure to add these files manually to your - PLIST, as the find - -newer command used by this target won't catch - them!

    -

    See Section 15.3, “Tweaking output of make print-PLIST for more - information on this target.

    +

    Some packages like emacs and perl embed information + about which architecture they were built on into the + pathnames where they install their files. To handle this + case, PLIST will be preprocessed before actually used, and + the symbol + ${MACHINE_ARCH} will be + replaced by what uname -p gives. The + same is done if the string + ${MACHINE_GNU_ARCH} is embedded in + PLIST somewhere - use this on packages that have GNU + autoconf-created configure scripts.

    +
    +

    Legacy note

    +

    There used to be a symbol + $ARCH that + was replaced by the output of uname + -m, but that's no longer supported and has + been removed.

    +
    +
    +
    ${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
    +
    +

    Some packages want to embed the OS name and version + into some paths. To do this, use these variables in the + PLIST: +

    +
      +
    • ${OPSYS} - output of uname -s

    • +
    • ${LOWER_OPSYS} - lowercase common name (eg. solaris)

    • +
    • ${OS_VERSION} - uname -r

    • +
    +

    For a list of values which are replaced by + default, the output of make help topic=PLIST_SUBST as +well as searching the pkgsrc/mk directory with grep for +PLIST_SUBST should help.

    +

    If you want to change other variables not listed above, you + can add variables and their expansions to this variable in the + following way, similar to MESSAGE_SUBST (see Section 12.5, “Optional files”):

    +
    +PLIST_SUBST+=   SOMEVAR="somevalue"
    +
    +

    This replaces all occurrences of ${SOMEVAR} + in the PLIST with + somevalue.

    +

    The PLIST_VARS variable can be used to simplify + the common case of conditionally including some + PLIST entries. It can be done by adding + PLIST_VARS+=foo and + setting the corresponding PLIST.foo variable + to yes if the entry should be included. + This will substitute ${PLIST.foo} + in the PLIST with either + "" or + "@comment ". + For example, in Makefile:

    +
    +PLIST_VARS+=    foo
    +.if condition
    +PLIST.foo=      yes
    +.else
    +
    +

    And then in PLIST:

    +
    +@comment $NetBSD $
    +bin/bar
    +man/man1/bar.1
    +${PLIST.foo}bin/foo
    +${PLIST.foo}man/man1/foo.1
    +${PLIST.foo}share/bar/foo.data
    +
    +

    An artificial space has been added between NetBSD and $, this is a +workaround here to prevent CVS expanding to the filename of the guide. When +adding the RCS ID the space should be ommited.

    +
    +
    +

    +19.5. Man page compression

    +

    Man pages should be installed in compressed form if + MANZ is set (in bsd.own.mk), + and uncompressed otherwise. To handle this in the + PLIST file, the suffix .gz is + appended/removed automatically for man pages according to + MANZ and MANCOMPRESSED being set + or not, see above for details. This modification of the + PLIST file is done on a copy of it, not + PLIST itself.

    +
    +
    +

    +19.6. Changing PLIST source with PLIST_SRC +

    +

    To use one or more files as source for the PLIST used + in generating the binary package, set the variable + PLIST_SRC to the names of that file(s). + The files are later concatenated using cat(1), and the order of things is + important. The default for PLIST_SRC is + ${PKGDIR}/PLIST.

    +
    +
    +

    +19.7. Platform-specific and differing PLISTs

    +

    Some packages decide to install a different set of files based on + the operating system being used. These differences can be + automatically handled by using the following files:

    +
      +
    • PLIST.common

    • +
    • PLIST.${OPSYS}

    • +
    • PLIST.${MACHINE_ARCH}

    • +
    • PLIST.${OPSYS}-${MACHINE_ARCH}

    • +
    • PLIST.common_end

    • +
    +
    +
    +

    +19.8. Build-specific PLISTs

    +

    Some packages decide to generate hard-to-guess file names + during installation that are hard to wire down.

    +

    In such cases, you can set the + GENERATE_PLIST variable to shell code + terminated (with a semicolon) that will output PLIST entries which + will be appended to the PLIST

    +

    You can find one example in editors/xemacs:

    +
    +GENERATE_PLIST+=        ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
    +
    +

    which will append something like + bin/xemacs-21.4.23-54e8ea71.dmp to the + PLIST. +

    +
    +
    +

    +19.9. Sharing directories between packages

    +

    A shared directory is a directory where + multiple (and unrelated) packages install files. These + directories were problematic because you had to add special + tricks in the PLIST to conditionally remove them, or have some + centralized package handle them.

    +

    In pkgsrc, it is now easy: Each package should create + directories and install files as needed; pkg_delete + will remove any directories left empty after uninstalling a + package.

    +

    If a package needs an empty directory to work, create + the directory during installation as usual, and also add an + entry to the PLIST: + +

    +
    +@pkgdir path/to/empty/directory
    +
    +

    + + or take a look at MAKE_DIRS and + OWN_DIRS. +

    +
    +
    +
    +

    +Chapter 20. The pkginstall framework

    + +

    This chapter describes the framework known as +pkginstall, whose key features are:

    +
      +
    • Generic installation and manipulation of directories and files + outside the pkgsrc-handled tree, LOCALBASE.

    • +
    • Automatic handling of configuration files during installation, + provided that packages are correctly designed.

    • +
    • Generation and installation of system startup scripts.

    • +
    • Registration of system users and groups.

    • +
    • Registration of system shells.

    • +
    • Automatic updating of fonts databases.

    • +
    +

    The following sections inspect each of the above points in detail.

    +

    You may be thinking that many of the things described here could be +easily done with simple code in the package's post-installation target +(post-install). This is incorrect, +as the code in them is only executed when building from source. Machines +using binary packages could not benefit from it at all (as the code itself +could be unavailable). Therefore, the only way to achieve any of the items +described above is by means of the installation scripts, which are +automatically generated by pkginstall.

    +
    +

    +20.1. Files and directories outside the installation prefix

    +

    As you already know, the PLIST file holds a list +of files and directories that belong to a package. The names used in it +are relative to the installation prefix (${PREFIX}), +which means that it cannot register files outside this directory (absolute +path names are not allowed). Despite this restriction, some packages need +to install files outside this location; e.g., under +${VARBASE} or +${PKG_SYSCONFDIR}. The only way to achieve this +is to create such files during installation time by using +installation scripts.

    +

    The generic installation scripts are shell scripts that can +contain arbitrary code. The list of scripts to execute is taken from +the INSTALL_FILE variable, which defaults to +INSTALL. A similar variable exists for package +removal (DEINSTALL_FILE, whose default is +DEINSTALL). These scripts can run arbitrary +commands, so they have the potential to create and manage files +anywhere in the file system.

    +

    Using these general installation files is not recommended, but +may be needed in some special cases. One reason for avoiding them is +that the user has to trust the packager that there is no unwanted or +simply erroneous code included in the installation script. Also, +previously there were many similar scripts for the same functionality, +and fixing a common error involved finding and changing all of +them.

    +

    The pkginstall framework offers another, standardized way. It +provides generic scripts to abstract the manipulation of such files +and directories based on variables set in the package's +Makefile. The rest of this section describes +these variables.

    +
    +

    +20.1.1. Directory manipulation

    +

    The following variables can be set to request the creation of +directories anywhere in the file system:

    +
      +
    • +

      MAKE_DIRS and OWN_DIRS + contain a list of directories that should be created and should attempt + to be destroyed by the installation scripts. The difference between + the two is that the latter prompts the administrator to remove any + directories that may be left after deinstallation (because they were + not empty), while the former does not. Example:

      +
      +MAKE_DIRS+=             ${VARBASE}/foo/private
      +
      +
    • +
    • +

      MAKE_DIRS_PERMS and + OWN_DIRS_PERMS contain a list of tuples describing + which directories should be created and should attempt to be destroyed + by the installation scripts. Each tuple holds the following values, + separated by spaces: the directory name, its owner, its group and its + numerical mode. For example:

      +
      +MAKE_DIRS_PERMS+=       ${VARBASE}/foo/private \
      +                        ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
      +
      +

      The difference between the two is exactly the same as their + non-PERMS counterparts.

      +
    • +
    +
    +

    +20.1.2. File manipulation

    +

    Creating non-empty files outside the installation prefix is tricky +because the PLIST forces all files to be inside it. +To overcome this problem, the only solution is to extract the file in the +known place (i.e., inside the installation prefix) and copy it to the +appropriate location during installation (done by the installation scripts +generated by pkginstall). We will call the former the master +file in the following paragraphs, which describe the variables +that can be used to automatically and consistently handle files outside the +installation prefix:

    +
      +
    • +

      CONF_FILES and + REQD_FILES are pairs of master and target files. + During installation time, the master file is copied to the target one + if and only if the latter does not exist. Upon deinstallation, the + target file is removed provided that it was not modified by the + installation.

      +

      The difference between the two is that the latter prompts the + administrator to remove any files that may be left after + deinstallation (because they were not empty), while the former does + not.

      +
    • +
    • +

      CONF_FILES_PERMS and + REQD_FILES_PERMS contain tuples describing master + files as well as their target locations. For each of them, it also + specifies their owner, their group and their numeric permissions, in + this order. For example:

      +
      +REQD_FILES_PERMS+=      ${PREFIX}/share/somefile ${VARBASE}/somefile \
      +                        ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
      +
      +

      The difference between the two is exactly the same as their + non-PERMS counterparts.

      +
    • +
    -
    -

    -Chapter 20. Tools needed for building or running

    - -

    The USE_TOOLS definition is used both internally -by pkgsrc and also for individual packages to define what commands -are needed for building a package (like TOOL_DEPENDS) -or for later run-time of an installed packaged (such as -DEPENDS). -If the native system provides an adequate tool, then in many cases, a pkgsrc -package will not be used.

    -

    When building a package, the replacement tools are -made available in a directory (as symlinks or wrapper scripts) -that is early in the executable search path. Just like the buildlink -system, this helps with consistent builds.

    -

    A tool may be needed to help build a specific package. For example, -perl, GNU make (gmake) or yacc may be needed.

    -

    Also a tool may be needed, for example, because the native system's supplied -tool may be inefficient for building a package with pkgsrc. -For example, a package may need GNU awk, bison (instead of -yacc) or a better sed.

    -

    The tools used by a package can be listed by running -make show-tools.

    -20.1. Tools for pkgsrc builds

    -

    The default set of tools used by pkgsrc is defined in -bsd.pkg.mk. This includes standard Unix tools, -such as: cat, awk, -chmod, test, and so on. -These can be seen by running: -make show-var VARNAME=USE_TOOLS.

    -

    If a package needs a specific program to build -then the USE_TOOLS variable can be used -to define the tools needed.

    +20.2. Configuration files
    +

    Configuration files are special in the sense that they are installed +in their own specific directory, PKG_SYSCONFDIR, and +need special treatment during installation (most of which is automated by +pkginstall). The main concept you must bear in mind is that files marked +as configuration files are automatically copied to the right place (somewhere +inside PKG_SYSCONFDIR) during installation if +and only if they didn't exist before. Similarly, they will not +be removed if they have local modifications. This ensures that +administrators never lose any custom changes they may have made.

    +
    +

    +20.2.1. How PKG_SYSCONFDIR is set

    +

    As said before, the PKG_SYSCONFDIR variable +specifies where configuration files shall be installed. Its contents are +set based upon the following variables:

    +
      +
    • PKG_SYSCONFBASE: The configuration's root + directory. Defaults to ${PREFIX}/etc although it may + be overridden by the user to point to his preferred location (e.g., + /etc, /etc/pkg, etc.). + Packages must not use it directly.

    • +
    • +

      PKG_SYSCONFSUBDIR: A subdirectory of + PKG_SYSCONFBASE under which the configuration files + for the package being built shall be installed. The definition of this + variable only makes sense in the package's + Makefile (i.e., it is not user-customizable).

      +

      As an example, consider the Apache package, + www/apache24, which places its + configuration files under the + httpd/ subdirectory of + PKG_SYSCONFBASE. This should be set in the package + Makefile.

      +
    • +
    • PKG_SYSCONFVAR: Specifies the name of the + variable that holds this package's configuration directory (if + different from PKG_SYSCONFBASE). It defaults to + PKGBASE's value, and is always prefixed with + PKG_SYSCONFDIR.

    • +
    • PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the + directory where the configuration files for the package identified by + PKG_SYSCONFVAR's shall be placed.

    • +
    +

    Based on the above variables, pkginstall determines the value of +PKG_SYSCONFDIR, which is the only +variable that can be used within a package to refer to its configuration +directory. The algorithm used to set its value is basically the +following:

    +
      +
    1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, + its value is used.

    2. +
    3. If the previous variable is not defined but + PKG_SYSCONFSUBDIR is set in the package's + Makefile, the resulting value is + ${PKG_SYSCONFBASE}/${PKG_SYSCONFSUBDIR}.

    4. +
    5. Otherwise, it is set to + ${PKG_SYSCONFBASE}.

    6. +
    +

    It is worth mentioning that ${PKG_SYSCONFDIR} is +automatically added to OWN_DIRS. See Section 20.1.1, “Directory manipulation” what this means. This does not apply to +subdirectories of ${PKG_SYSCONFDIR}, they still have to +be created with OWN_DIRS or MAKE_DIRS.

    +
    +
    +

    +20.2.2. Telling the software where configuration files are

    +

    Given that pkgsrc (and users!) expect configuration files to be in a +known place, you need to teach each package where it shall install its +files. In some cases you will have to patch the package Makefiles to +achieve it. If you are lucky, though, it may be as easy as passing an +extra flag to the configuration script; this is the case of GNU Autoconf- +generated files:

    +
    +CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
    +
    +

    Note that this specifies where the package has to look +for its configuration files, not where they will be originally +installed (although the difference is never explicit, +unfortunately).

    +
    +
    +

    +20.2.3. Patching installations

    +

    As said before, pkginstall automatically handles configuration files. +This means that the packages themselves must not +touch the contents of ${PKG_SYSCONFDIR} +directly. Bad news is that many software installation scripts +will, out of the box, mess with the contents of that directory. So what is +the correct procedure to fix this issue?

    +

    You must teach the package (usually by manually patching it) to +install any configuration files under the examples hierarchy, +share/examples/${PKGBASE}/. This way, the +PLIST registers them and the administrator always +has the original copies available.

    +

    Once the required configuration files are in place (i.e., under the +examples hierarchy), the pkginstall framework can use them as master copies +during the package installation to update what is in +${PKG_SYSCONFDIR}. To achieve this, the variables +CONF_FILES and CONF_FILES_PERMS are +used. Check out Section 20.1.2, “File manipulation” for information +about their syntax and their purpose. Here is an example, taken from the +mail/mutt package:

    +
    +EGDIR=        ${PREFIX}/share/doc/mutt/samples
    +CONF_FILES=   ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
    +
    +

    Note that the EGDIR variable is specific to that +package and has no meaning outside it.

    +
    +
    +

    +20.2.4. Disabling handling of configuration files

    +

    The automatic copying of config files can be toggled by setting the +environment variable PKG_CONFIG prior to package +installation.

    +
    +
    +
    +

    +20.3. System startup scripts

    +

    System startup scripts are special files because they must be +installed in a place known by the underlying OS, usually outside the +installation prefix. Therefore, the same rules described in Section 20.1, “Files and directories outside the installation prefix” apply, and the same solutions +can be used. However, pkginstall provides a special mechanism to handle +these files.

    +

    In order to provide system startup scripts, the package has +to:

    +
      +
    1. Store the script inside ${FILESDIR}, with + the .sh suffix appended. Considering the + print/cups package as an example, it has a + cupsd.sh in its files directory.

    2. +
    3. +

      Tell pkginstall to handle it, appending the name of the script, + without its extension, to the RCD_SCRIPTS variable. + Continuing the previous example:

      +
      +RCD_SCRIPTS+=   cupsd
      +
      +
    4. +
    +

    Once this is done, pkginstall will do the following steps for each +script in an automated fashion:

    +
      +
    1. Process the file found in the files directory applying all the + substitutions described in the FILES_SUBST + variable.

    2. +
    3. Copy the script from the files directory to the examples + hierarchy, ${PREFIX}/share/examples/rc.d/. Note + that this master file must be explicitly registered in the + PLIST.

    4. +
    5. Add code to the installation scripts to copy the startup script + from the examples hierarchy into the system-wide startup scripts + directory.

    6. +
    +
    +

    +20.3.1. Disabling handling of system startup scripts

    +

    The automatic copying of config files can be toggled by setting the +environment variable PKG_RCD_SCRIPTS prior to package +installation. Note that the scripts will be always copied inside the +examples hierarchy, ${PREFIX}/share/examples/rc.d/, no +matter what the value of this variable is.

    +
    +
    +
    +

    +20.4. System users and groups

    +

    If a package needs to create special users and/or groups during +installation, it can do so by using the pkginstall framework.

    +

    Users can be created by adding entries to the +PKG_USERS variable. Each entry has the following +syntax:

    +
    +user:group
    +
    +

    Further specification of user details may be done by setting +per-user variables. +PKG_UID.user is the +numeric UID for the user. +PKG_GECOS.user is the +user's description or comment. +PKG_HOME.user is the +user's home directory, and defaults to +/nonexistent if not specified. +PKG_SHELL.user is the +user's shell, and defaults to /sbin/nologin if +not specified.

    +

    Similarly, groups can be created by adding entries to the +PKG_GROUPS variable, whose syntax is:

    +
    +group
    +
    +

    The numeric GID of the group may be set by defining +PKG_GID.group.

    +

    If a package needs to create the users and groups at an earlier +stage, then it can set USERGROUP_PHASE to either +configure,build, or +pre-install to indicate the phase before which the +users and groups are created. In this case, the numeric UIDs and GIDs +of the created users and groups are automatically hardcoded into the +final installation scripts.

    -20.2. Tools needed by packages

    -

    In the following examples, the :run means that it is needed at -run-time (and becomes a DEPENDS). -The default is a build dependency which can be set with -:build. (So in this example, it is the same as gmake:build -and pkg-config:build.)

    +20.5. System shells
    +

    Packages that install system shells should register them in the shell +database, /etc/shells, to make things easier to the +administrator. This must be done from the installation scripts to keep +binary packages working on any system. pkginstall provides an easy way to +accomplish this task.

    +

    When a package provides a shell interpreter, it has to set the +PKG_SHELL variable to its absolute file name. This will +add some hooks to the installation scripts to handle it. Consider the +following example, taken from shells/zsh:

    -USE_TOOLS+=     gmake perl:run pkg-config
    +PKG_SHELL=      ${PREFIX}/bin/zsh
     
    -

    When using the tools framework, a -TOOLS_PATH.foo variable is defined -which contains the full path to the appropriate tool. For example, -TOOLS_PATH.bash could be /bin/bash -on Linux systems.

    -

    If you always need a pkgsrc version of the -tool at run-time, then just use DEPENDS instead. -

    +
    +

    +20.5.1. Disabling shell registration

    +

    The automatic registration of shell interpreters can be disabled by +the administrator by setting the PKG_REGISTER_SHELLS +environment variable to NO.

    +

    -20.3. Tools provided by platforms

    -

    When improving or porting pkgsrc to a new platform, have a look -at (or create) the corresponding platform specific make file fragment under -pkgsrc/mk/tools/tools.${OPSYS}.mk which defines -the name of the common tools. For example:

    +20.6. Fonts
    +

    Packages that install X11 fonts should update the database files +that index the fonts within each fonts directory. This can easily be +accomplished within the pkginstall framework.

    +

    When a package installs X11 fonts, it must list the directories in +which fonts are installed in the +FONTS_DIRS.type variables, +where type can be one of ttf, +type1 or x11. This will add hooks to the +installation scripts to run the appropriate commands to update the fonts +database files within each of those directories. For convenience, if the +directory path is relative, it is taken to be relative to the package's +installation prefix. Consider the following example, taken from fonts/dbz-ttf:

    -.if exists(/usr/bin/bzcat)
    -TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
    -.elif exists(/usr/bin/bzip2)
    -TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
    -.endif
    -
    -TOOLS_PLATFORM.true?=           true                    # shell builtin
    +FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
     
    +
    +

    +20.6.1. Disabling automatic update of the fonts databases

    +

    The automatic update of fonts databases can be disabled by +the administrator by setting the PKG_UPDATE_FONTS_DB +environment variable to NO.

    +
    @@ -7469,14 +7489,14 @@ ACCEPTABLE_LICENSES+=xv-license USE_TOOLS definition, as well as dependencies via buildlink3.mk, which is the preferred way to handle dependencies, and which uses the variables named above. - See Chapter 16, Buildlink methodology for more information.

    + See Chapter 18, Buildlink methodology for more information.

    The basic difference is that the DEPENDS definition registers that pre-requisite in the binary package so it will be pulled in when the binary package is later installed, whilst the BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS definitions do not, marking a dependency that is only needed for building or testing the resulting - package. See also Chapter 12, Creating a new pkgsrc package from scratch for more information.

    + package. See also Chapter 14, Creating a new pkgsrc package from scratch for more information.

    This means that if you only need a package present whilst you are building or testing, it should be noted as a TOOL_DEPENDS, @@ -8305,7 +8325,7 @@ pre-configure:

    Compilers for the C, C++, and Fortran languages comes with the NetBSD base system. By default, pkgsrc assumes that a package is written in C and will hide all other compilers (via the wrapper - framework, see Chapter 16, Buildlink methodology).

    + framework, see Chapter 18, Buildlink methodology).

    To declare which language's compiler a package needs, set the USE_LANGUAGES variable. Allowed values currently are c, c++, and @@ -8982,7 +9002,7 @@ PERL5_PACKLIST= auto/Pg/.packlist Or if the ./configure script uses a non-standard use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.

    -

    See Section 15.5, “Man page compression” for +

    See Section 19.5, “Man page compression” for information on installation of compressed manual pages.

    @@ -9264,99 +9284,317 @@ PERL5_PACKLIST= auto/Pg/.packlist

    -21.7. Marking packages as having problems

    -

    In some cases one does not have the time to solve a problem - immediately. In this case, one can plainly mark a package as broken. For - this, one just sets the variable BROKEN to the - reason why the package is broken (similar to the - PKG_FAIL_REASON variable). A user trying to build - the package will immediately be shown this message, and the build - will not be even tried.

    -

    BROKEN packages are removed from pkgsrc in irregular - intervals.

    -
    - -
    -

    -Chapter 22. Debugging

    -

    To check out all the gotchas when building a package, here are - the steps that I do in order to get a package working. Please note - this is basically the same as what was explained in the previous - sections, only with some debugging aids.

    -
      -
    • Be sure to set PKG_DEVELOPER=yes in mk.conf.

    • -
    • -

      Install pkgtools/url2pkg, - create a directory for a new package, change into it, then run - url2pkg:

      -
      % mkdir /usr/pkgsrc/category/examplepkg
      -% cd /usr/pkgsrc/category/examplepkg
      -% url2pkg https://www.example.com/path/to/distfile.tar.gz
      -
    • -
    • Edit the Makefile as requested.

    • -
    • Fill in the DESCR file

    • -
    • Run make configure

    • -
    • Add any dependencies glimpsed from documentation and the - configure step to the package's - Makefile.

    • -
    • -

      Make the package compile, doing multiple rounds of

      -
      % make
      -% pkgvi ${WRKSRC}/some/file/that/does/not/compile
      -% mkpatches
      -% patchdiff
      -% mv ${WRKDIR}/.newpatches/* patches
      -% make mps
      -% make clean
      -

      Doing this step as non-root user will ensure that no files - are modified that shouldn't be, especially during the build - phase. mkpatches, - patchdiff and pkgvi are - from the pkgtools/pkgdiff - package.

      -
    • -
    • Look at the Makefile, fix if - necessary; see Section 13.1, “Makefile.

    • -
    • -

      Generate a PLIST:

      -
      # make install
      -# make print-PLIST >PLIST
      -# make deinstall
      -# make install
      -# make deinstall
      -

      You usually need to be root to do - this. Look if there are any files left:

      -
      # make print-PLIST
      -

      If this reveals any files that are missing in - PLIST, add them.

      -
    • -
    • -

      Now that the PLIST is OK, install the - package again and make a binary package:

      -
      # make reinstall
      -# make package
      -
    • -
    • -

      Delete the installed package:

      -
      # pkg_delete examplepkg
      -
    • +21.7. Marking packages as having problems
    +

    In some cases one does not have the time to solve a problem + immediately. In this case, one can plainly mark a package as broken. For + this, one just sets the variable BROKEN to the + reason why the package is broken (similar to the + PKG_FAIL_REASON variable). A user trying to build + the package will immediately be shown this message, and the build + will not be even tried.

    +

    BROKEN packages are removed from pkgsrc in irregular + intervals.

    + + +
    +

    +Chapter 22. GNOME packaging and porting

    + +

    Quoting GNOME's web +site:

    +

    The GNOME project provides two things: The GNOME desktop + environment, an intuitive and attractive desktop for users, and the + GNOME development platform, an extensive framework for building + applications that integrate into the rest of the desktop.

    +

    pkgsrc provides a seamless way to automatically build and install +a complete GNOME environment under many different +platforms. We can say with confidence that pkgsrc is one of +the most advanced build and packaging systems for GNOME due to its +included technologies buildlink3, the wrappers and tools framework and +automatic configuration file management. Lots of efforts are put into +achieving a completely clean deinstallation of installed software +components.

    +

    Given that pkgsrc is NetBSD's official packaging system, +the above also means that great efforts are put into making GNOME work +under this operating system. Recently, DragonFly BSD also adopted +pkgsrc as its preferred packaging system, contributing lots of +portability fixes to make GNOME build and install under it.

    +

    This chapter is aimed at pkgsrc developers and other people +interested in helping our GNOME porting and packaging efforts. It +provides instructions on how to manage the existing packages and some +important information regarding their internals.

    +
    +

    We need your help!

    +

    Should you have some spare cycles to devote to NetBSD, pkgsrc + and GNOME and are willing to learn new exciting stuff, please jump + straight to the pending + work list! There is still a long way to go to get a + fully-functional GNOME desktop under NetBSD and we need your help to + achieve it!

    +
    +
    +

    +22.1. Meta packages

    +

    pkgsrc includes three GNOME-related meta packages:

    +
      +
    • meta-pkgs/gnome-base: Provides + the core GNOME desktop environment. It only includes the necessary + bits to get it to boot correctly, although it may lack important + functionality for daily operation. The idea behind this package is + to let end users build their own configurations on top of this one, + first installing this meta package to achieve a functional setup and + then adding individual applications.

    • +
    • meta-pkgs/gnome: Provides a + complete installation of the GNOME platform and desktop as defined + by the GNOME project; this is based on the components distributed in + the platform/x.y/x.y.z/sources and + desktop/x.y/x.y.z/sources directories of the + official FTP server. Developer-only tools found in those + directories are not installed unless required by some other + component to work properly. Similarly, packages from the bindings + set (bindings/x.y/x.y.z/sources) are not pulled + in unless required as a dependency for an end-user component. This + package "extends" meta-pkgs/gnome-base.

    • +
    • meta-pkgs/gnome-devel: + Installs all the tools required to build a GNOME component when + fetched from the CVS repository. These are required to let the + autogen.sh scripts work appropriately.

    • +
    +

    In all these packages, the DEPENDS lines are +sorted in a way that eases updates: a package may depend on other +packages listed before it but not on any listed after it. It is very +important to keep this order to ease updates so... do not +change it to alphabetical sorting!

    +
    +
    +

    +22.2. Packaging a GNOME application

    +

    Almost all GNOME applications are written in C and use a common +set of tools as their build system. Things get different with the new +bindings to other languages (such as Python), but the following will +give you a general idea on the minimum required tools:

    +
      +
    • +

      Almost all GNOME applications use the GNU Autotools as their + build system. As a general rule you will need to tell this to your + package:

      +
      +GNU_CONFIGURE=yes
      +USE_LIBTOOL=yes
      +USE_TOOLS+=gmake
      +
      +
    • +
    • +

      If the package uses pkg-config to detect dependencies, add this + tool to the list of required utilities:

      +
      +USE_TOOLS+=pkg-config
      +
      +

      Also use pkgtools/verifypc at + the end of the build process to ensure that you did not miss to + specify any dependency in your package and that the version + requirements are all correct.

      +
    • +
    • If the package uses intltool, be sure to add + intltool to the USE_TOOLS + to handle dependencies and to force the package to use the latest + available version.

    • +
    • +

      If the package uses gtk-doc (a documentation generation + utility), do not add a dependency on it. The + tool is rather big and the distfile should come with pregenerated + documentation anyway; if it does not, it is a bug that you ought to + report. For such packages you should disable gtk-doc (unless it is + the default):

      +
      +CONFIGURE_ARGS+=--disable-gtk-doc
      +
      +

      The default location of installed HTML files + (share/gtk-doc/<package-name>) is correct + and should not be changed unless the package insists on installing + them somewhere else. Otherwise programs as + devhelp will not be able to open them. You can + do that with an entry similar to:

      +
      +CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...
      +
      +
    • +
    +

    GNOME uses multiple shared directories and +files under the installation prefix to maintain databases. In this +context, shared means that those exact same directories and files are +used among several different packages, leading to conflicts in the +PLIST. pkgsrc currently includes functionality to +handle the most common cases, so you have to forget about using +@unexec ${RMDIR} lines in your file lists and +omitting shared files from them. If you find yourself doing those, +your package is most likely incorrect.

    +

    The following table lists the common situations that result in +using shared directories or files. For each of them, the appropriate +solution is given. After applying the solution be sure to +regenerate the package's file list with +make print-PLIST and ensure it is correct.

    +
    +

    Table 22.1. PLIST handling for GNOME packages

    +
    ++++ + + + + + + + + + + + + + + + + + + + + + + +
    If the package...Then...
    Installs OMF files under share/omf.See Section 21.6.10, “Packages installing scrollkeeper/rarian data files”.
    Installs icons under the + share/icons/hicolor hierarchy or updates + share/icons/hicolor/icon-theme.cache.See Section 21.6.19, “Packages installing hicolor theme icons”.
    Installs files under + share/mime/packages.See Section 21.6.14, “Packages installing extensions to the MIME database”.
    Installs .desktop files under + share/applications and these include MIME + information.See Section 21.6.20, “Packages installing desktop files”.
    +
    +
    +
    +
    +

    +22.3. Updating GNOME to a newer version

    +

    When seeing GNOME as a whole, there are two kinds of +updates:

    +
    +
    Major update
    +
    +

    Given that there is still a very long way for GNOME 3 (if it + ever appears), we consider a major update one that goes from a + 2.X version to a 2.Y one, + where Y is even and greater than + X. These are hard to achieve because they + introduce lots of changes in the components' code and almost all + GNOME distfiles are updated to newer versions. Some of them can + even break API and ABI compatibility with the previous major + version series. As a result, the update needs to be done all at + once to minimize breakage.

    +

    A major update typically consists of around 80 package + updates and the addition of some new ones.

    +
    +
    Minor update
    +
    +

    We consider a minor update one that goes from a + 2.A.X version to a 2.A.Y + one where Y is greater than + X. These are easy to achieve because they do + not update all GNOME components, can be done in an incremental way + and do not break API nor ABI compatibility.

    +

    A minor update typically consists of around 50 package + updates, although the numbers here may vary a lot.

    +
    +
    +

    In order to update the GNOME components in pkgsrc to a new stable +release (either major or minor), the following steps should be +followed:

    +
    1. -

      Repeat the above make print-PLIST - command, which shouldn't find anything now:

      -
      # make print-PLIST
      +

      Get a list of all the tarballs that form the new release by + using the following commands. These will leave the full list of the + components' distfiles into the list.txt + file:

      +
      % echo ls "*.tar.bz2" | \
      +    ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
      +    awk '{ print $9 }' >list.txt
      +% echo ls "*.tar.bz2" | \
      +    ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
      +    awk '{ print $9 }' >>list.txt
    2. +
    3. Open each meta package's Makefile and + bump their version to the release you are updating them to. The + three meta packages should be always consistent with versioning. + Obviously remove any PKGREVISIONs that might be + in them.

    4. -

      Reinstall the binary package:

      -
      # pkg_add .../examplepkg.tgz
      +

      For each meta package, update all its + DEPENDS lines to match the latest versions as + shown by the above commands. Do not list any + newer version (even if found in the FTP) because the meta packages + are supposed to list the exact versions that form a specific GNOME + release. Exceptions are permitted here if a newer version solves a + serious issue in the overall desktop experience; these typically + come in the form of a revision bump in pkgsrc, not in newer versions + from the developers.

      +

      Packages not listed in the list.txt file + should be updated to the latest version available (if found in + pkgsrc). This is the case, for example, of the dependencies on the + GNU Autotools in the meta-pkgs/gnome-devel meta package.

    5. -
    6. Play with it. Make sure everything works.

    7. -

      Run pkglint from pkgtools/pkglint, and fix the problems it - reports:

      -
      # pkglint
      +

      Generate a patch from the modified meta packages and extract the + list of "new" lines. This will provide you an outline on what + packages need to be updated in pkgsrc and in what order:

      +
      % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
    8. -
    9. Submit (or commit, if you have cvs access); see Chapter 23, Submitting and Committing.

    10. -
    +
  • For major desktop updates it is recommended to zap all your + installed packages and start over from scratch at this point.

  • +
  • Now comes the longest step by far: iterate over the contents + of todo.txt and update the packages listed in + it in order. For major desktop updates none of these should be + committed until the entire set is completed because there are chances + of breaking not-yet-updated packages.

  • +
  • Once the packages are up to date and working, commit them to + the tree one by one with appropriate log messages. At the end, + commit the three meta package updates and all the corresponding + changes to the doc/CHANGES-<YEAR> and + pkgsrc/doc/TODO files.

  • +
    +
    +
    +

    +22.4. Patching guidelines

    +

    GNOME is a very big component in pkgsrc which approaches 100 +packages. Please, it is very important that you always, always, +always feed back any portability +fixes you do to a GNOME package to the mainstream developers (see Section 12.3.5, “Feedback to the author”). This is the only way to get +their attention on portability issues and to ensure that future versions +can be built out-of-the box on NetBSD. The less custom patches in +pkgsrc, the easier further updates are. Those developers in charge of +issuing major GNOME updates will be grateful if you do that.

    +

    The most common places to report bugs are the GNOME's Bugzilla and the freedesktop.org's +Bugzilla. Not all components use these to track bugs, but most +of them do. Do not be short on your reports: always provide detailed +explanations of the current failure, how it can be improved to achieve +maximum portability and, if at all possible, provide a patch against CVS +head. The more verbose you are, the higher chances of your patch being +accepted.

    +

    Also, please avoid using preprocessor magic to fix portability +issues. While the FreeBSD GNOME people are doing a great job in porting +GNOME to their operating system, the official GNOME sources are now +plagued by conditionals that check for __FreeBSD__ +and similar macros. This hurts portability. Please see our patching +guidelines (Section 12.3.4, “Patching guidelines”) for more +details.

    +

    @@ -9390,7 +9628,7 @@ builds).

    23.2. Submitting source packages (for non-NetBSD-developers)

    First, check that your package is complete, compiles and - runs well; see Chapter 22, Debugging and the rest of this + runs well; see Chapter 14, Creating a new pkgsrc package from scratch and the rest of this document. Next, generate an uuencoded gzipped tar(1) archive that contains all files that make up the package. Finally, send this package to the pkgsrc bug tracking system, @@ -9689,500 +9927,200 @@ What shall I do?

    MAKEFLAGS are the flags passed to the pkgsrc-internal invocations of make(1), while MAKE_FLAGS are the flags that are passed to - the MAKE_PROGRAM when building the - package. [FIXME: What is .MAKEFLAGS for?]

    - - - -

    24.2.

    - -

    What is the difference between - MAKE, GMAKE and - MAKE_PROGRAM?

    - - - -

    MAKE is the path to the - make(1) program that is used in the pkgsrc - infrastructure. GMAKE is the path to GNU - Make, but you need to say USE_TOOLS+=gmake to - use that. MAKE_PROGRAM is the path to the - Make program that is used for building the - package.

    - - - -

    24.3.

    - -

    What is the difference between - CC, PKG_CC and - PKGSRC_COMPILER?

    - - - -

    CC is the path to the real C - compiler, which can be configured by the pkgsrc user. - PKG_CC is the path to the compiler wrapper. - PKGSRC_COMPILER is not a - path to a compiler, but the type of compiler that should be - used. See mk/compiler.mk for more - information about the latter variable.

    - - - -

    24.4.

    - -

    What is the difference between - BUILDLINK_LDFLAGS, - BUILDLINK_LDADD and - BUILDLINK_LIBS?

    - - - -

    [FIXME]

    - - - -

    24.5.

    - -

    Why does make show-var - VARNAME=BUILDLINK_PREFIX.foo - say it's empty?

    - - - -

    For optimization reasons, some variables are only - available in the wrapper phase and later. To - simulate the wrapper phase, append - PKG_PHASE=wrapper to the above - command.

    - - - -

    24.6.

    - -

    What does - ${MASTER_SITE_SOURCEFORGE:=package/} mean? I - don't understand the := inside - it.

    - - - -

    The := is not really an - assignment operator, although it looks like it. - Instead, it is a degenerate form of - ${LIST:old_string=new_string}, - which is documented in the make(1) man page and which is - commonly used in the form ${SRCS:.c=.o}. In the - case of MASTER_SITE_*, - old_string is the empty string and - new_string is - package/. That's where the - : and the = fall - together.

    - - - -

    24.7.

    - -

    Which mailing lists are there for package - developers?

    - - - -
    -
    tech-pkg
    -

    This is a list for technical discussions related - to pkgsrc development, e.g. soliciting feedback for changes to - pkgsrc infrastructure, proposed new features, questions related - to porting pkgsrc to a new platform, advice for maintaining a - package, patches that affect many packages, help requests moved - from pkgsrc-users when an infrastructure bug is found, - etc.

    -
    pkgsrc-bugs
    -

    All bug reports in category "pkg" sent with - send-pr(1) appear here. Please do not report your bugs here - directly; use one of the other mailing - lists.

    -
    + the MAKE_PROGRAM when building the + package. [FIXME: What is .MAKEFLAGS for?]

    -

    24.8.

    +

    24.2.

    -

    Where is the pkgsrc - documentation?

    +

    What is the difference between + MAKE, GMAKE and + MAKE_PROGRAM?

    +

    MAKE is the path to the + make(1) program that is used in the pkgsrc + infrastructure. GMAKE is the path to GNU + Make, but you need to say USE_TOOLS+=gmake to + use that. MAKE_PROGRAM is the path to the + Make program that is used for building the + package.

    + + -

    There are many places where you can find - documentation about pkgsrc:

    -
      -
    • The pkgsrc guide (this document) is a collection - of chapters that explain large parts of pkgsrc, but some - chapters tend to be outdated. Which ones they are is hard to - say.

    • -
    • On the mailing list archives (see https://mail-index.NetBSD.org/), you can find discussions - about certain features, announcements of new parts of the pkgsrc - infrastructure and sometimes even announcements that a certain - feature has been marked as obsolete. The benefit here is that - each message has a date appended to it.

    • -
    • Many of the files in the - mk/ directory start with a comment that - describes the purpose of the file and how it can be used by the - pkgsrc user and package authors. An easy way to find this - documentation is to run bmake - help.

    • -
    • The CVS log messages are a rich source of - information, but they tend to be highly abbreviated, especially - for actions that occur often. Some contain a detailed - description of what has changed, but they are geared towards the - other pkgsrc developers, not towards an average pkgsrc user. - They also only document changes, so if you - don't know what has been before, these messages may not be worth - too much to you.

    • -
    • Some parts of pkgsrc are only implicitly - documented, that is the documentation exists only in the - mind of the developer who wrote the code. To get this - information, use the cvs annotate command - to see who has written it and ask on the - tech-pkg mailing list, so that others can - find your questions later (see above). To be sure that the - developer in charge reads the mail, you may CC him or - her.

    • -
    +

    24.3.

    +

    What is the difference between + CC, PKG_CC and + PKGSRC_COMPILER?

    + + + +

    CC is the path to the real C + compiler, which can be configured by the pkgsrc user. + PKG_CC is the path to the compiler wrapper. + PKGSRC_COMPILER is not a + path to a compiler, but the type of compiler that should be + used. See mk/compiler.mk for more + information about the latter variable.

    -

    24.9.

    +

    24.4.

    -

    I have a little time to kill. -What shall I do?

    +

    What is the difference between + BUILDLINK_LDFLAGS, + BUILDLINK_LDADD and + BUILDLINK_LIBS?

    +

    [FIXME]

    + + -

    This is not really an FAQ yet, but here's the answer -anyway.

    -
      -
    • Run pkg_chk -N (from the - pkgtools/pkg_chk package). It - will tell you about newer versions of installed packages that are - available, but not yet updated in pkgsrc.

    • -
    • Browse pkgsrc/doc/TODO - — it contains a list of suggested new packages and a list of - cleanups and enhancements for pkgsrc that would be nice to - have.

    • -
    • Review packages for which review was requested on - the tech-pkg - mailing list.

    • -
    +

    24.5.

    +

    Why does make show-var + VARNAME=BUILDLINK_PREFIX.foo + say it's empty?

    - - -

    -
    -
    -

    -Chapter 25. GNOME packaging and porting

    - -

    Quoting GNOME's web -site:

    -

    The GNOME project provides two things: The GNOME desktop - environment, an intuitive and attractive desktop for users, and the - GNOME development platform, an extensive framework for building - applications that integrate into the rest of the desktop.

    -

    pkgsrc provides a seamless way to automatically build and install -a complete GNOME environment under many different -platforms. We can say with confidence that pkgsrc is one of -the most advanced build and packaging systems for GNOME due to its -included technologies buildlink3, the wrappers and tools framework and -automatic configuration file management. Lots of efforts are put into -achieving a completely clean deinstallation of installed software -components.

    -

    Given that pkgsrc is NetBSD's official packaging system, -the above also means that great efforts are put into making GNOME work -under this operating system. Recently, DragonFly BSD also adopted -pkgsrc as its preferred packaging system, contributing lots of -portability fixes to make GNOME build and install under it.

    -

    This chapter is aimed at pkgsrc developers and other people -interested in helping our GNOME porting and packaging efforts. It -provides instructions on how to manage the existing packages and some -important information regarding their internals.

    -
    -

    We need your help!

    -

    Should you have some spare cycles to devote to NetBSD, pkgsrc - and GNOME and are willing to learn new exciting stuff, please jump - straight to the pending - work list! There is still a long way to go to get a - fully-functional GNOME desktop under NetBSD and we need your help to - achieve it!

    -
    -
    -

    -25.1. Meta packages

    -

    pkgsrc includes three GNOME-related meta packages:

    -
      -
    • meta-pkgs/gnome-base: Provides - the core GNOME desktop environment. It only includes the necessary - bits to get it to boot correctly, although it may lack important - functionality for daily operation. The idea behind this package is - to let end users build their own configurations on top of this one, - first installing this meta package to achieve a functional setup and - then adding individual applications.

    • -
    • meta-pkgs/gnome: Provides a - complete installation of the GNOME platform and desktop as defined - by the GNOME project; this is based on the components distributed in - the platform/x.y/x.y.z/sources and - desktop/x.y/x.y.z/sources directories of the - official FTP server. Developer-only tools found in those - directories are not installed unless required by some other - component to work properly. Similarly, packages from the bindings - set (bindings/x.y/x.y.z/sources) are not pulled - in unless required as a dependency for an end-user component. This - package "extends" meta-pkgs/gnome-base.

    • -
    • meta-pkgs/gnome-devel: - Installs all the tools required to build a GNOME component when - fetched from the CVS repository. These are required to let the - autogen.sh scripts work appropriately.

    • -
    -

    In all these packages, the DEPENDS lines are -sorted in a way that eases updates: a package may depend on other -packages listed before it but not on any listed after it. It is very -important to keep this order to ease updates so... do not -change it to alphabetical sorting!

    -
    -
    -

    -25.2. Packaging a GNOME application

    -

    Almost all GNOME applications are written in C and use a common -set of tools as their build system. Things get different with the new -bindings to other languages (such as Python), but the following will -give you a general idea on the minimum required tools:

    -
      -
    • -

      Almost all GNOME applications use the GNU Autotools as their - build system. As a general rule you will need to tell this to your - package:

      -
      -GNU_CONFIGURE=yes
      -USE_LIBTOOL=yes
      -USE_TOOLS+=gmake
      -
      -
    • -
    • -

      If the package uses pkg-config to detect dependencies, add this - tool to the list of required utilities:

      -
      -USE_TOOLS+=pkg-config
      -
      -

      Also use pkgtools/verifypc at - the end of the build process to ensure that you did not miss to - specify any dependency in your package and that the version - requirements are all correct.

      -
    • -
    • If the package uses intltool, be sure to add - intltool to the USE_TOOLS - to handle dependencies and to force the package to use the latest - available version.

    • -
    • -

      If the package uses gtk-doc (a documentation generation - utility), do not add a dependency on it. The - tool is rather big and the distfile should come with pregenerated - documentation anyway; if it does not, it is a bug that you ought to - report. For such packages you should disable gtk-doc (unless it is - the default):

      -
      -CONFIGURE_ARGS+=--disable-gtk-doc
      -
      -

      The default location of installed HTML files - (share/gtk-doc/<package-name>) is correct - and should not be changed unless the package insists on installing - them somewhere else. Otherwise programs as - devhelp will not be able to open them. You can - do that with an entry similar to:

      -
      -CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...
      -
      -
    • -
    -

    GNOME uses multiple shared directories and -files under the installation prefix to maintain databases. In this -context, shared means that those exact same directories and files are -used among several different packages, leading to conflicts in the -PLIST. pkgsrc currently includes functionality to -handle the most common cases, so you have to forget about using -@unexec ${RMDIR} lines in your file lists and -omitting shared files from them. If you find yourself doing those, -your package is most likely incorrect.

    -

    The following table lists the common situations that result in -using shared directories or files. For each of them, the appropriate -solution is given. After applying the solution be sure to -regenerate the package's file list with -make print-PLIST and ensure it is correct.

    -
    -

    Table 25.1. PLIST handling for GNOME packages

    -
    ---- - - - - - - - - + + + - - - + + + - - - + + + - - - + + + + + + + + + + + + + + + + + + + + + + + -
    If the package...Then...
    Installs OMF files under share/omf.See Section 21.6.10, “Packages installing scrollkeeper/rarian data files”.

    For optimization reasons, some variables are only + available in the wrapper phase and later. To + simulate the wrapper phase, append + PKG_PHASE=wrapper to the above + command.

    Installs icons under the - share/icons/hicolor hierarchy or updates - share/icons/hicolor/icon-theme.cache.See Section 21.6.19, “Packages installing hicolor theme icons”.
    +

    24.6.

    +

    What does + ${MASTER_SITE_SOURCEFORGE:=package/} mean? I + don't understand the := inside + it.

    Installs files under - share/mime/packages.See Section 21.6.14, “Packages installing extensions to the MIME database”.

    The := is not really an + assignment operator, although it looks like it. + Instead, it is a degenerate form of + ${LIST:old_string=new_string}, + which is documented in the make(1) man page and which is + commonly used in the form ${SRCS:.c=.o}. In the + case of MASTER_SITE_*, + old_string is the empty string and + new_string is + package/. That's where the + : and the = fall + together.

    Installs .desktop files under - share/applications and these include MIME - information.See Section 21.6.20, “Packages installing desktop files”.
    +

    24.7.

    +

    Which mailing lists are there for package + developers?

    +
    tech-pkg
    +

    This is a list for technical discussions related + to pkgsrc development, e.g. soliciting feedback for changes to + pkgsrc infrastructure, proposed new features, questions related + to porting pkgsrc to a new platform, advice for maintaining a + package, patches that affect many packages, help requests moved + from pkgsrc-users when an infrastructure bug is found, + etc.

    +
    pkgsrc-bugs
    +

    All bug reports in category "pkg" sent with + send-pr(1) appear here. Please do not report your bugs here + directly; use one of the other mailing + lists.

    +
    +

    24.8.

    +

    Where is the pkgsrc + documentation?

    +

    There are many places where you can find + documentation about pkgsrc:

    +
      +
    • The pkgsrc guide (this document) is a collection + of chapters that explain large parts of pkgsrc, but some + chapters tend to be outdated. Which ones they are is hard to + say.

    • +
    • On the mailing list archives (see https://mail-index.NetBSD.org/), you can find discussions + about certain features, announcements of new parts of the pkgsrc + infrastructure and sometimes even announcements that a certain + feature has been marked as obsolete. The benefit here is that + each message has a date appended to it.

    • +
    • Many of the files in the + mk/ directory start with a comment that + describes the purpose of the file and how it can be used by the + pkgsrc user and package authors. An easy way to find this + documentation is to run bmake + help.

    • +
    • The CVS log messages are a rich source of + information, but they tend to be highly abbreviated, especially + for actions that occur often. Some contain a detailed + description of what has changed, but they are geared towards the + other pkgsrc developers, not towards an average pkgsrc user. + They also only document changes, so if you + don't know what has been before, these messages may not be worth + too much to you.

    • +
    • Some parts of pkgsrc are only implicitly + documented, that is the documentation exists only in the + mind of the developer who wrote the code. To get this + information, use the cvs annotate command + to see who has written it and ask on the + tech-pkg mailing list, so that others can + find your questions later (see above). To be sure that the + developer in charge reads the mail, you may CC him or + her.

    • +
    +
    +

    24.9.

    +

    I have a little time to kill. +What shall I do?

    +

    This is not really an FAQ yet, but here's the answer +anyway.

    +
      +
    • Run pkg_chk -N (from the + pkgtools/pkg_chk package). It + will tell you about newer versions of installed packages that are + available, but not yet updated in pkgsrc.

    • +
    • Browse pkgsrc/doc/TODO + — it contains a list of suggested new packages and a list of + cleanups and enhancements for pkgsrc that would be nice to + have.

    • +
    • Review packages for which review was requested on + the tech-pkg + mailing list.

    • +
    +
    -
    -
    -
    -
    -

    -25.3. Updating GNOME to a newer version

    -

    When seeing GNOME as a whole, there are two kinds of -updates:

    -
    -
    Major update
    -
    -

    Given that there is still a very long way for GNOME 3 (if it - ever appears), we consider a major update one that goes from a - 2.X version to a 2.Y one, - where Y is even and greater than - X. These are hard to achieve because they - introduce lots of changes in the components' code and almost all - GNOME distfiles are updated to newer versions. Some of them can - even break API and ABI compatibility with the previous major - version series. As a result, the update needs to be done all at - once to minimize breakage.

    -

    A major update typically consists of around 80 package - updates and the addition of some new ones.

    -
    -
    Minor update
    -
    -

    We consider a minor update one that goes from a - 2.A.X version to a 2.A.Y - one where Y is greater than - X. These are easy to achieve because they do - not update all GNOME components, can be done in an incremental way - and do not break API nor ABI compatibility.

    -

    A minor update typically consists of around 50 package - updates, although the numbers here may vary a lot.

    -
    -
    -

    In order to update the GNOME components in pkgsrc to a new stable -release (either major or minor), the following steps should be -followed:

    -
      -
    1. -

      Get a list of all the tarballs that form the new release by - using the following commands. These will leave the full list of the - components' distfiles into the list.txt - file:

      -
      % echo ls "*.tar.bz2" | \
      -    ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
      -    awk '{ print $9 }' >list.txt
      -% echo ls "*.tar.bz2" | \
      -    ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
      -    awk '{ print $9 }' >>list.txt
      -
    2. -
    3. Open each meta package's Makefile and - bump their version to the release you are updating them to. The - three meta packages should be always consistent with versioning. - Obviously remove any PKGREVISIONs that might be - in them.

    4. -
    5. -

      For each meta package, update all its - DEPENDS lines to match the latest versions as - shown by the above commands. Do not list any - newer version (even if found in the FTP) because the meta packages - are supposed to list the exact versions that form a specific GNOME - release. Exceptions are permitted here if a newer version solves a - serious issue in the overall desktop experience; these typically - come in the form of a revision bump in pkgsrc, not in newer versions - from the developers.

      -

      Packages not listed in the list.txt file - should be updated to the latest version available (if found in - pkgsrc). This is the case, for example, of the dependencies on the - GNU Autotools in the meta-pkgs/gnome-devel meta package.

      -
    6. -
    7. -

      Generate a patch from the modified meta packages and extract the - list of "new" lines. This will provide you an outline on what - packages need to be updated in pkgsrc and in what order:

      -
      % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
      -
    8. -
    9. For major desktop updates it is recommended to zap all your - installed packages and start over from scratch at this point.

    10. -
    11. Now comes the longest step by far: iterate over the contents - of todo.txt and update the packages listed in - it in order. For major desktop updates none of these should be - committed until the entire set is completed because there are chances - of breaking not-yet-updated packages.

    12. -
    13. Once the packages are up to date and working, commit them to - the tree one by one with appropriate log messages. At the end, - commit the three meta package updates and all the corresponding - changes to the doc/CHANGES-<YEAR> and - pkgsrc/doc/TODO files.

    14. -
    -
    -
    -

    -25.4. Patching guidelines

    -

    GNOME is a very big component in pkgsrc which approaches 100 -packages. Please, it is very important that you always, always, -always feed back any portability -fixes you do to a GNOME package to the mainstream developers (see Section 13.3.5, “Feedback to the author”). This is the only way to get -their attention on portability issues and to ensure that future versions -can be built out-of-the box on NetBSD. The less custom patches in -pkgsrc, the easier further updates are. Those developers in charge of -issuing major GNOME updates will be grateful if you do that.

    -

    The most common places to report bugs are the GNOME's Bugzilla and the freedesktop.org's -Bugzilla. Not all components use these to track bugs, but most -of them do. Do not be short on your reports: always provide detailed -explanations of the current failure, how it can be improved to achieve -maximum portability and, if at all possible, provide a patch against CVS -head. The more verbose you are, the higher chances of your patch being -accepted.

    -

    Also, please avoid using preprocessor magic to fix portability -issues. While the FreeBSD GNOME people are doing a great job in porting -GNOME to their operating system, the official GNOME sources are now -plagued by conditionals that check for __FreeBSD__ -and similar macros. This hurts portability. Please see our patching -guidelines (Section 13.3.4, “Patching guidelines”) for more -details.

    +
    @@ -10198,64 +10136,64 @@ details.

    -Chapter 26. Design of the pkgsrc infrastructure

    +Chapter 25. Design of the pkgsrc infrastructure
    @@ -10265,7 +10203,7 @@ details.

    like.

    -26.1. The meaning of variable definitions

    +25.1. The meaning of variable definitions

    Whenever a variable is defined in the pkgsrc infrastructure, the location and the way of definition provide much information about the intended use of that variable. @@ -10296,7 +10234,7 @@ details.

    -26.2. Avoiding problems before they arise

    +25.2. Avoiding problems before they arise

    All variables that contain lists of things should default to being empty. Two examples that do not follow this rule are USE_LANGUAGES and @@ -10320,10 +10258,10 @@ DISTFILES= ${DISTNAME}${EXTRACT_SUF

    -26.3. Variable evaluation

    +25.3. Variable evaluation

    -26.3.1. At load time

    +25.3.1. At load time

    Variable evaluation takes place either at load time or at runtime, depending on the context in which they occur. The contexts where variables are evaluated at load time are:

    @@ -10365,7 +10303,7 @@ CFLAGS+= -Wall

    -26.3.2. At runtime

    +25.3.2. At runtime

    After all the files have been loaded, the values of the variables cannot be changed anymore. Variables that are used in the shell commands are expanded at this point.

    @@ -10373,7 +10311,7 @@ CFLAGS+= -Wall

    -26.4. How can variables be specified?

    +25.4. How can variables be specified?

    There are many ways in which the definition and use of a variable can be restricted in order to detect bugs and violations of the (mostly unwritten) policies. A package can be checked with @@ -10382,14 +10320,14 @@ CFLAGS+= -Wall

    -26.5. Designing interfaces for Makefile fragments

    +25.5. Designing interfaces for Makefile fragments

    Most of the .mk files fall into one of the following classes. Cases where a file falls into more than one class should be avoided as it often leads to subtle bugs.

    -26.5.1. Procedures with parameters

    +25.5.1. Procedures with parameters

    In a traditional imperative programming language some of the .mk files could be described as procedures. They take some input parameters and—after @@ -10423,7 +10361,7 @@ CFLAGS+= -Wall

    -26.5.2. Actions taken on behalf of parameters

    +25.5.2. Actions taken on behalf of parameters

    Action files take some input parameters and may define runtime variables. They shall not define loadtime variables. There are action files that are included implicitly by the @@ -10435,7 +10373,7 @@ CFLAGS+= -Wall

    -26.6. The order in which files are loaded

    +25.6. The order in which files are loaded

    Package Makefiles usually consist of a set of variable definitions, and include the file ../../mk/bsd.pkg.mk in the very last line. @@ -10450,7 +10388,7 @@ CFLAGS+= -Wall are loaded and gives reasons for that order.

    -26.6.1. The order in bsd.prefs.mk +25.6.1. The order in bsd.prefs.mk

    The very first action in bsd.prefs.mk is to define some essential variables like @@ -10475,7 +10413,7 @@ CFLAGS+= -Wall

    -26.6.2. The order in bsd.pkg.mk +25.6.2. The order in bsd.pkg.mk

    First, bsd.prefs.mk is loaded.

    Then, the various *-vars.mk files are @@ -10508,15 +10446,15 @@ CFLAGS+= -Wall

    -Chapter 27. Regression tests

    +Chapter 26. Regression tests
    @@ -10530,7 +10468,7 @@ CFLAGS+= -Wall how you can add new tests.

    -27.1. Running the regression tests

    +26.1. Running the regression tests

    You first need to install the pkgtools/pkg_regress package, which provides the pkg_regress command. Then you can simply run that command, which will run all tests in the @@ -10538,7 +10476,7 @@ CFLAGS+= -Wall

    -27.2. Adding a new regression test

    +26.2. Adding a new regression test

    Every directory in the regress/ directory that contains a file called spec is considered a regression test. This file is a shell program @@ -10547,7 +10485,7 @@ CFLAGS+= -Wall needs.

    -27.2.1. Overridable functions

    +26.2.1. Overridable functions

    These functions do not take any parameters. Although they are called in set -e mode, they don't stop at the first failing command. See this Stack Overflow @@ -10595,7 +10533,7 @@ check_result() {

    -27.2.2. Helper functions

    +26.2.2. Helper functions
    regress_fail message...

    This function makes the test fail with the given error message.

    @@ -10626,10 +10564,10 @@ output_require "^[[:alpha:]+[[:space:]][

    -Chapter 28. Porting pkgsrc

    +Chapter 27. Porting pkgsrc

    The pkgsrc system has already been ported to many operating systems, hardware architectures and compilers. This @@ -10637,7 +10575,7 @@ output_require "^[[:alpha:]+[[:space:]][ portable.

    -28.1. Porting pkgsrc to a new operating system

    +27.1. Porting pkgsrc to a new operating system

    To port pkgsrc to a new operating system (called MyOS in this example), you need to touch the following files:

    @@ -10768,7 +10706,7 @@ WARN: PLIST:5: "share/bison.hairy" shoul # cd bison # mkdir patches

    Create Makefile, DESCR and - PLIST (see Chapter 13, Package components - files, directories and contents) + PLIST (see Chapter 12, Package components - files, directories and contents) then continue with fetching the distfile:

    # make fetch
     >> bison-1.25.tar.gz doesn't seem to exist on this system.
    
    Index: pkgsrc/doc/pkgsrc.txt
    diff -u pkgsrc/doc/pkgsrc.txt:1.296 pkgsrc/doc/pkgsrc.txt:1.297
    --- pkgsrc/doc/pkgsrc.txt:1.296	Thu Jun 18 20:31:14 2020
    +++ pkgsrc/doc/pkgsrc.txt	Sat Jun 20 05:32:11 2020
    @@ -14,7 +14,7 @@ The pkgsrc Developers
     
     Copyright   1994-2020 The NetBSD Foundation, Inc
     
    -$NetBSD: pkgsrc.xml,v 1.36 2020/01/03 15:55:24 leot Exp $
    +$NetBSD: pkgsrc.xml,v 1.38 2020/06/20 05:31:10 rillig Exp $
     
     Abstract
     
    @@ -154,144 +154,144 @@ I. The pkgsrc user's guide
     II. The pkgsrc developer's guide
     
         11. Getting help
    -    12. Creating a new pkgsrc package from scratch
    +    12. Package components - files, directories and contents
     
    -        12.1. Common types of packages
    +        12.1. Makefile
    +        12.2. distinfo
    +        12.3. patches/*
     
    -            12.1.1. Perl modules
    -            12.1.2. Python modules and programs
    -            12.1.3. R packages
    -            12.1.4. TeXlive packages
    +            12.3.1. Structure of a single patch file
    +            12.3.2. Creating patch files
    +            12.3.3. Sources where the patch files come from
    +            12.3.4. Patching guidelines
    +            12.3.5. Feedback to the author
     
    -        12.2. Examples
    +        12.4. Other mandatory files
    +        12.5. Optional files
     
    -            12.2.1. How the www/nvu package came into pkgsrc
    +            12.5.1. Files affecting the binary package
    +            12.5.2. Files affecting the build process
    +            12.5.3. Files affecting nothing at all
     
    -    13. Package components - files, directories and contents
    +        12.6. work*
    +        12.7. files/*
     
    -        13.1. Makefile
    -        13.2. distinfo
    -        13.3. patches/*
    +    13. The build process
     
    -            13.3.1. Structure of a single patch file
    -            13.3.2. Creating patch files
    -            13.3.3. Sources where the patch files come from
    -            13.3.4. Patching guidelines
    -            13.3.5. Feedback to the author
    +        13.1. Introduction
    +        13.2. Program location
    +        13.3. Directories used during the build process
    +        13.4. Running a phase
    +        13.5. The fetch phase
     
    -        13.4. Other mandatory files
    -        13.5. Optional files
    +            13.5.1. What to fetch and where to get it from
    +            13.5.2. How are the files fetched?
     
    -            13.5.1. Files affecting the binary package
    -            13.5.2. Files affecting the build process
    -            13.5.3. Files affecting nothing at all
    +        13.6. The checksum phase
    +        13.7. The extract phase
    +        13.8. The patch phase
    +        13.9. The tools phase
    +        13.10. The wrapper phase
    +        13.11. The configure phase
    +        13.12. The build phase
    +        13.13. The test phase
    +        13.14. The install phase
    +        13.15. The package phase
    +        13.16. Cleaning up
    +        13.17. Other helpful targets
     
    -        13.6. work*
    -        13.7. files/*
    +    14. Creating a new pkgsrc package from scratch
     
    -    14. Programming in Makefiles
    +        14.1. Common types of packages
     
    -        14.1. Caveats
    -        14.2. Makefile variables
    +            14.1.1. Perl modules
    +            14.1.2. Python modules and programs
    +            14.1.3. R packages
    +            14.1.4. TeXlive packages
     
    -            14.2.1. Naming conventions
    +        14.2. Examples
     
    -        14.3. Code snippets
    +            14.2.1. How the www/nvu package came into pkgsrc
     
    -            14.3.1. Adding things to a list
    -            14.3.2. Echoing a string exactly as-is
    -            14.3.3. Passing CFLAGS to GNU configure scripts
    -            14.3.4. Handling possibly empty variables
    +    15. Programming in Makefiles
     
    -    15. PLIST issues
    +        15.1. Caveats
    +        15.2. Makefile variables
     
    -        15.1. RCS ID
    -        15.2. Semi-automatic PLIST generation
    -        15.3. Tweaking output of make print-PLIST
    -        15.4. Variable substitution in PLIST
    -        15.5. Man page compression
    -        15.6. Changing PLIST source with PLIST_SRC
    -        15.7. Platform-specific and differing PLISTs
    -        15.8. Build-specific PLISTs
    -        15.9. Sharing directories between packages
    +            15.2.1. Naming conventions
     
    -    16. Buildlink methodology
    +        15.3. Code snippets
     
    -        16.1. Converting packages to use buildlink3
    -        16.2. Writing buildlink3.mk files
    +            15.3.1. Adding things to a list
    +            15.3.2. Echoing a string exactly as-is
    +            15.3.3. Passing CFLAGS to GNU configure scripts
    +            15.3.4. Handling possibly empty variables
     
    -            16.2.1. Anatomy of a buildlink3.mk file
    -            16.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
    -                BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
    +    16. Options handling
     
    -        16.3. Writing builtin.mk files
    +        16.1. Global default options
    +        16.2. Converting packages to use bsd.options.mk
    +        16.3. Option Names
    +        16.4. Determining the options of dependencies
     
    -            16.3.1. Anatomy of a builtin.mk file
    -            16.3.2. Global preferences for native or pkgsrc software
    +    17. Tools needed for building or running
     
    -    17. The pkginstall framework
    +        17.1. Tools for pkgsrc builds
    +        17.2. Tools needed by packages
    +        17.3. Tools provided by platforms
     
    -        17.1. Files and directories outside the installation prefix
    +    18. Buildlink methodology
     
    -            17.1.1. Directory manipulation
    -            17.1.2. File manipulation
    +        18.1. Converting packages to use buildlink3
    +        18.2. Writing buildlink3.mk files
     
    -        17.2. Configuration files
    +            18.2.1. Anatomy of a buildlink3.mk file
    +            18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and
    +                BUILDLINK_ABI_DEPENDS.pkg in buildlink3.mk files
     
    -            17.2.1. How PKG_SYSCONFDIR is set
    -            17.2.2. Telling the software where configuration files are
    -            17.2.3. Patching installations
    -            17.2.4. Disabling handling of configuration files
    +        18.3. Writing builtin.mk files
     
    -        17.3. System startup scripts
    +            18.3.1. Anatomy of a builtin.mk file
    +            18.3.2. Global preferences for native or pkgsrc software
     
    -            17.3.1. Disabling handling of system startup scripts
    +    19. PLIST issues
     
    -        17.4. System users and groups
    -        17.5. System shells
    +        19.1. RCS ID
    +        19.2. Semi-automatic PLIST generation
    +        19.3. Tweaking output of make print-PLIST
    +        19.4. Variable substitution in PLIST
    +        19.5. Man page compression
    +        19.6. Changing PLIST source with PLIST_SRC
    +        19.7. Platform-specific and differing PLISTs
    +        19.8. Build-specific PLISTs
    +        19.9. Sharing directories between packages
     
    -            17.5.1. Disabling shell registration
    +    20. The pkginstall framework
     
    -        17.6. Fonts
    +        20.1. Files and directories outside the installation prefix
     
    -            17.6.1. Disabling automatic update of the fonts databases
    +            20.1.1. Directory manipulation
    +            20.1.2. File manipulation
     
    -    18. Options handling
    +        20.2. Configuration files
     
    -        18.1. Global default options
    -        18.2. Converting packages to use bsd.options.mk
    -        18.3. Option Names
    -        18.4. Determining the options of dependencies
    +            20.2.1. How PKG_SYSCONFDIR is set
    +            20.2.2. Telling the software where configuration files are
    +            20.2.3. Patching installations
    +            20.2.4. Disabling handling of configuration files
     
    -    19. The build process
    +        20.3. System startup scripts
     
    -        19.1. Introduction
    -        19.2. Program location
    -        19.3. Directories used during the build process
    -        19.4. Running a phase
    -        19.5. The fetch phase
    +            20.3.1. Disabling handling of system startup scripts
     
    -            19.5.1. What to fetch and where to get it from
    -            19.5.2. How are the files fetched?
    +        20.4. System users and groups
    +        20.5. System shells
     
    -        19.6. The checksum phase
    -        19.7. The extract phase
    -        19.8. The patch phase
    -        19.9. The tools phase
    -        19.10. The wrapper phase
    -        19.11. The configure phase
    -        19.12. The build phase
    -        19.13. The test phase
    -        19.14. The install phase
    -        19.15. The package phase
    -        19.16. Cleaning up
    -        19.17. Other helpful targets
    +            20.5.1. Disabling shell registration
     
    -    20. Tools needed for building or running
    +        20.6. Fonts
     
    -        20.1. Tools for pkgsrc builds
    -        20.2. Tools needed by packages
    -        20.3. Tools provided by platforms
    +            20.6.1. Disabling automatic update of the fonts databases
     
         21. Making your package work
     
    @@ -365,7 +365,13 @@ II. The pkgsrc developer's guide
     
             21.7. Marking packages as having problems
     
    -    22. Debugging
    +    22. GNOME packaging and porting
    +
    +        22.1. Meta packages
    +        22.2. Packaging a GNOME application
    +        22.3. Updating GNOME to a newer version
    +        22.4. Patching guidelines
    +
         23. Submitting and Committing
     
             23.1. Submitting binary packages
    @@ -378,46 +384,40 @@ II. The pkgsrc developer's guide
             23.8. Moving a package in pkgsrc
     
         24. Frequently Asked Questions
    -    25. GNOME packaging and porting
    -
    -        25.1. Meta packages
    -        25.2. Packaging a GNOME application
    -        25.3. Updating GNOME to a newer version
    -        25.4. Patching guidelines
     
     III. The pkgsrc infrastructure internals
     
    -    26. Design of the pkgsrc infrastructure
    +    25. Design of the pkgsrc infrastructure
     
    -        26.1. The meaning of variable definitions
    -        26.2. Avoiding problems before they arise
    -        26.3. Variable evaluation
    +        25.1. The meaning of variable definitions
    +        25.2. Avoiding problems before they arise
    +        25.3. Variable evaluation
     
    -            26.3.1. At load time
    -            26.3.2. At runtime
    +            25.3.1. At load time
    +            25.3.2. At runtime
     
    -        26.4. How can variables be specified?
    -        26.5. Designing interfaces for Makefile fragments
    +        25.4. How can variables be specified?
    +        25.5. Designing interfaces for Makefile fragments
     
    -            26.5.1. Procedures with parameters
    -            26.5.2. Actions taken on behalf of parameters
    +            25.5.1. Procedures with parameters
    +            25.5.2. Actions taken on behalf of parameters
     
    -        26.6. The order in which files are loaded
    +        25.6. The order in which files are loaded
     
    -            26.6.1. The order in bsd.prefs.mk
    -            26.6.2. The order in bsd.pkg.mk
    +            25.6.1. The order in bsd.prefs.mk
    +            25.6.2. The order in bsd.pkg.mk
     
    -    27. Regression tests
    +    26. Regression tests
     
    -        27.1. Running the regression tests
    -        27.2. Adding a new regression test
    +        26.1. Running the regression tests
    +        26.2. Adding a new regression test
     
    -            27.2.1. Overridable functions
    -            27.2.2. Helper functions
    +            26.2.1. Overridable functions
    +            26.2.2. Helper functions
     
    -    28. Porting pkgsrc
    +    27. Porting pkgsrc
     
    -        28.1. Porting pkgsrc to a new operating system
    +        27.1. Porting pkgsrc to a new operating system
     
     A. A simple example package: bison
     
    @@ -452,8 +452,8 @@ E. Editing guidelines for the pkgsrc gui
     List of Tables
     
     1.1. Platforms supported by pkgsrc
    -13.1. Patching examples
    -25.1. PLIST handling for GNOME packages
    +12.1. Patching examples
    +22.1. PLIST handling for GNOME packages
     
     Chapter 1. What is pkgsrc?
     
    @@ -1477,7 +1477,7 @@ mk.conf, together with some comments tha
         tree. It is possible to have many pkgsrc tree instances.)
     
       * LOCALPATCHES: Directory for local patches that aren't part of pkgsrc. See
    -    Section 13.3, "patches/*" for more information.
    +    Section 12.3, "patches/*" for more information.
     
       * PKGMAKECONF: Location of the mk.conf file used by a package's BSD-style
         Makefile. If this is not set, MAKECONF is set to /dev/null to avoid picking
    @@ -1720,7 +1720,7 @@ a binary package.
     
     7.2. Settings for creation of binary packages
     
    -See Section 19.17, "Other helpful targets".
    +See Section 13.17, "Other helpful targets".
     
     Chapter 8. Creating binary packages for everything in pkgsrc (bulk builds)
     
    @@ -2652,144 +2652,144 @@ more like a reference manual for pkgsrc.
     Table of Contents
     
     11. Getting help
    -12. Creating a new pkgsrc package from scratch
    +12. Package components - files, directories and contents
     
    -    12.1. Common types of packages
    +    12.1. Makefile
    +    12.2. distinfo
    +    12.3. patches/*
     
    -        12.1.1. Perl modules
    -        12.1.2. Python modules and programs
    -        12.1.3. R packages
    -        12.1.4. TeXlive packages
    +        12.3.1. Structure of a single patch file
    +        12.3.2. Creating patch files
    +        12.3.3. Sources where the patch files come from
    +        12.3.4. Patching guidelines
    +        12.3.5. Feedback to the author
     
    -    12.2. Examples
    +    12.4. Other mandatory files
    +    12.5. Optional files
     
    -        12.2.1. How the www/nvu package came into pkgsrc
    +        12.5.1. Files affecting the binary package
    +        12.5.2. Files affecting the build process
    +        12.5.3. Files affecting nothing at all
     
    -13. Package components - files, directories and contents
    +    12.6. work*
    +    12.7. files/*
     
    -    13.1. Makefile
    -    13.2. distinfo
    -    13.3. patches/*
    +13. The build process
     
    -        13.3.1. Structure of a single patch file
    -        13.3.2. Creating patch files
    -        13.3.3. Sources where the patch files come from
    -        13.3.4. Patching guidelines
    -        13.3.5. Feedback to the author
    +    13.1. Introduction
    +    13.2. Program location
    +    13.3. Directories used during the build process
    +    13.4. Running a phase
    +    13.5. The fetch phase
     
    -    13.4. Other mandatory files
    -    13.5. Optional files
    +        13.5.1. What to fetch and where to get it from
    +        13.5.2. How are the files fetched?
     
    -        13.5.1. Files affecting the binary package
    -        13.5.2. Files affecting the build process
    -        13.5.3. Files affecting nothing at all
    +    13.6. The checksum phase
    +    13.7. The extract phase
    +    13.8. The patch phase
    +    13.9. The tools phase
    +    13.10. The wrapper phase
    +    13.11. The configure phase
    +    13.12. The build phase
    +    13.13. The test phase
    +    13.14. The install phase
    +    13.15. The package phase
    +    13.16. Cleaning up
    +    13.17. Other helpful targets
     
    -    13.6. work*
    -    13.7. files/*
    +14. Creating a new pkgsrc package from scratch
     
    -14. Programming in Makefiles
    +    14.1. Common types of packages
     
    -    14.1. Caveats
    -    14.2. Makefile variables
    +        14.1.1. Perl modules
    +        14.1.2. Python modules and programs
    +        14.1.3. R packages
    +        14.1.4. TeXlive packages
     
    -        14.2.1. Naming conventions
    +    14.2. Examples
     
    -    14.3. Code snippets
    +        14.2.1. How the www/nvu package came into pkgsrc
     
    -        14.3.1. Adding things to a list
    -        14.3.2. Echoing a string exactly as-is
    -        14.3.3. Passing CFLAGS to GNU configure scripts
    -        14.3.4. Handling possibly empty variables
    +15. Programming in Makefiles
     
    -15. PLIST issues
    +    15.1. Caveats
    +    15.2. Makefile variables
     
    -    15.1. RCS ID
    -    15.2. Semi-automatic PLIST generation
    -    15.3. Tweaking output of make print-PLIST
    -    15.4. Variable substitution in PLIST
    -    15.5. Man page compression
    -    15.6. Changing PLIST source with PLIST_SRC
    -    15.7. Platform-specific and differing PLISTs
    -    15.8. Build-specific PLISTs
    -    15.9. Sharing directories between packages
    +        15.2.1. Naming conventions
     
    -16. Buildlink methodology
    +    15.3. Code snippets
     
    -    16.1. Converting packages to use buildlink3
    -    16.2. Writing buildlink3.mk files
    +        15.3.1. Adding things to a list
    +        15.3.2. Echoing a string exactly as-is
    +        15.3.3. Passing CFLAGS to GNU configure scripts
    +        15.3.4. Handling possibly empty variables
     
    -        16.2.1. Anatomy of a buildlink3.mk file
    -        16.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
    -            pkg in buildlink3.mk files
    +16. Options handling
     
    -    16.3. Writing builtin.mk files
    +    16.1. Global default options
    +    16.2. Converting packages to use bsd.options.mk
    +    16.3. Option Names
    +    16.4. Determining the options of dependencies
     
    -        16.3.1. Anatomy of a builtin.mk file
    -        16.3.2. Global preferences for native or pkgsrc software
    +17. Tools needed for building or running
     
    -17. The pkginstall framework
    +    17.1. Tools for pkgsrc builds
    +    17.2. Tools needed by packages
    +    17.3. Tools provided by platforms
     
    -    17.1. Files and directories outside the installation prefix
    +18. Buildlink methodology
     
    -        17.1.1. Directory manipulation
    -        17.1.2. File manipulation
    +    18.1. Converting packages to use buildlink3
    +    18.2. Writing buildlink3.mk files
     
    -    17.2. Configuration files
    +        18.2.1. Anatomy of a buildlink3.mk file
    +        18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.
    +            pkg in buildlink3.mk files
     
    -        17.2.1. How PKG_SYSCONFDIR is set
    -        17.2.2. Telling the software where configuration files are
    -        17.2.3. Patching installations
    -        17.2.4. Disabling handling of configuration files
    +    18.3. Writing builtin.mk files
     
    -    17.3. System startup scripts
    +        18.3.1. Anatomy of a builtin.mk file
    +        18.3.2. Global preferences for native or pkgsrc software
     
    -        17.3.1. Disabling handling of system startup scripts
    +19. PLIST issues
     
    -    17.4. System users and groups
    -    17.5. System shells
    +    19.1. RCS ID
    +    19.2. Semi-automatic PLIST generation
    +    19.3. Tweaking output of make print-PLIST
    +    19.4. Variable substitution in PLIST
    +    19.5. Man page compression
    +    19.6. Changing PLIST source with PLIST_SRC
    +    19.7. Platform-specific and differing PLISTs
    +    19.8. Build-specific PLISTs
    +    19.9. Sharing directories between packages
     
    -        17.5.1. Disabling shell registration
    +20. The pkginstall framework
     
    -    17.6. Fonts
    +    20.1. Files and directories outside the installation prefix
     
    -        17.6.1. Disabling automatic update of the fonts databases
    +        20.1.1. Directory manipulation
    +        20.1.2. File manipulation
     
    -18. Options handling
    +    20.2. Configuration files
     
    -    18.1. Global default options
    -    18.2. Converting packages to use bsd.options.mk
    -    18.3. Option Names
    -    18.4. Determining the options of dependencies
    +        20.2.1. How PKG_SYSCONFDIR is set
    +        20.2.2. Telling the software where configuration files are
    +        20.2.3. Patching installations
    +        20.2.4. Disabling handling of configuration files
     
    -19. The build process
    +    20.3. System startup scripts
     
    -    19.1. Introduction
    -    19.2. Program location
    -    19.3. Directories used during the build process
    -    19.4. Running a phase
    -    19.5. The fetch phase
    +        20.3.1. Disabling handling of system startup scripts
     
    -        19.5.1. What to fetch and where to get it from
    -        19.5.2. How are the files fetched?
    +    20.4. System users and groups
    +    20.5. System shells
     
    -    19.6. The checksum phase
    -    19.7. The extract phase
    -    19.8. The patch phase
    -    19.9. The tools phase
    -    19.10. The wrapper phase
    -    19.11. The configure phase
    -    19.12. The build phase
    -    19.13. The test phase
    -    19.14. The install phase
    -    19.15. The package phase
    -    19.16. Cleaning up
    -    19.17. Other helpful targets
    +        20.5.1. Disabling shell registration
     
    -20. Tools needed for building or running
    +    20.6. Fonts
     
    -    20.1. Tools for pkgsrc builds
    -    20.2. Tools needed by packages
    -    20.3. Tools provided by platforms
    +        20.6.1. Disabling automatic update of the fonts databases
     
     21. Making your package work
     
    @@ -2862,7 +2862,13 @@ Table of Contents
     
         21.7. Marking packages as having problems
     
    -22. Debugging
    +22. GNOME packaging and porting
    +
    +    22.1. Meta packages
    +    22.2. Packaging a GNOME application
    +    22.3. Updating GNOME to a newer version
    +    22.4. Patching guidelines
    +
     23. Submitting and Committing
     
         23.1. Submitting binary packages
    @@ -2875,12 +2881,6 @@ Table of Contents
         23.8. Moving a package in pkgsrc
     
     24. Frequently Asked Questions
    -25. GNOME packaging and porting
    -
    -    25.1. Meta packages
    -    25.2. Packaging a GNOME application
    -    25.3. Updating GNOME to a newer version
    -    25.4. Patching guidelines
     
     Chapter 11. Getting help
     
    @@ -2907,607 +2907,219 @@ pkgsrc guide. If you don't find anything
         a specialized chat program such as XChat. Pick any user name and join the
         channel #pkgsrc.
     
    -Chapter 12. Creating a new pkgsrc package from scratch
    +Chapter 12. Package components - files, directories and contents
     
     Table of Contents
     
    -12.1. Common types of packages
    -
    -    12.1.1. Perl modules
    -    12.1.2. Python modules and programs
    -    12.1.3. R packages
    -    12.1.4. TeXlive packages
    -
    -12.2. Examples
    +12.1. Makefile
    +12.2. distinfo
    +12.3. patches/*
    +
    +    12.3.1. Structure of a single patch file
    +    12.3.2. Creating patch files
    +    12.3.3. Sources where the patch files come from
    +    12.3.4. Patching guidelines
    +    12.3.5. Feedback to the author
    +
    +12.4. Other mandatory files
    +12.5. Optional files
    +
    +    12.5.1. Files affecting the binary package
    +    12.5.2. Files affecting the build process
    +    12.5.3. Files affecting nothing at all
     
    -    12.2.1. How the www/nvu package came into pkgsrc
    +12.6. work*
    +12.7. files/*
     
    -When you find a package that is not yet in pkgsrc, you most likely have a URL
    -from where you can download the source code. Starting with this URL, creating a
    -package involves only a few steps.
    +Whenever you're preparing a package, there are a number of files involved which
    +are described in the following sections.
     
    - 1. First, install the packages pkgtools/url2pkg and pkgtools/pkglint.
    +12.1. Makefile
     
    - 2. Then, choose one of the top-level directories as the category in which you
    -    want to place your package. You can also create a directory of your own
    -    (maybe called local). In that category directory, create another directory
    -    for your package and change into it.
    +Building, installation and creation of a binary package are all controlled by
    +the package's Makefile. The Makefile describes various things about a package,
    +for example from where to get it, how to configure, build, and install it.
     
    - 3. Run the program url2pkg, which will ask you for a URL. Enter the URL of the
    -    distribution file (in most cases a .tar.gz file) and watch how the basic
    -    ingredients of your package are created automatically. The distribution
    -    file is extracted automatically to fill in some details in the Makefile
    -    that would otherwise have to be done manually.
    +A package Makefile contains several sections that describe the package.
     
    - 4. Examine the extracted files to determine the dependencies of your package.
    -    Ideally, this is mentioned in some README file, but things may differ. For
    -    each of these dependencies, look where it exists in pkgsrc, and if there is
    -    a file called buildlink3.mk in that directory, add a line to your package
    -    Makefile which includes that file just before the last line. If the
    -    buildlink3.mk file does not exist, it must be created first. The
    -    buildlink3.mk file makes sure that the package's include files and
    -    libraries are provided.
    +In the first section there are the following variables, which should appear
    +exactly in the order given here. The order and grouping of the variables is
    +mostly historical and has no further meaning.
     
    -    If you just need binaries from a package, add a DEPENDS line to the
    -    Makefile, which specifies the version of the dependency and where it can be
    -    found in pkgsrc. This line should be placed in the third paragraph. If the
    -    dependency is only needed for building the package, but not when using it,
    -    use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The difference
    -    between TOOL_DEPENDS and BUILD_DEPENDS occurs when cross-compiling:
    -    TOOL_DEPENDS are native packages, i.e. packages for the architecture where
    -    the package is built; BUILD_DEPENDS are target packages, i.e. packages for
    -    the architecture for which the package is built. There is also
    -    TEST_DEPENDS, which is used to specify a dependency used only for testing
    -    the resulting package built, using the upstream project's included test
    -    suite. Your package may then look like this:
    +  * DISTNAME is the basename of the distribution file to be downloaded from the
    +    package's website.
     
    -    [...]
    +  * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
    +    it if DISTNAME (which is the default) is not a good name for the package in
    +    pkgsrc or DISTNAME is not provided (no distribution file is required).
    +    Usually it is the pkgsrc directory name together with the version number.
    +    It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
    +    is, it starts with a letter or digit, and contains only letters, digits,
    +    dashes, underscores, dots and plus signs.
     
    -    TOOL_DEPENDS+=  libxslt-[0-9]*:../../textproc/libxslt
    -    DEPENDS+=       screen-[0-9]*:../../misc/screen
    -    DEPENDS+=       screen>=4.0:../../misc/screen
    +  * CATEGORIES is a list of categories which the package fits in. You can
    +    choose any of the top-level directories of pkgsrc for it.
     
    -    [...]
    +    Currently the following values are available for CATEGORIES. If more than
    +    one is used, they need to be separated by spaces:
     
    -    .include "../../category/package/buildlink3.mk"
    -    .include "../../devel/glib2/buildlink3.mk"
    -    .include "../../mk/bsd.pkg.mk"
    +    archivers     cross         geography     meta-pkgs     security
    +    audio         databases     graphics      misc          shells
    +    benchmarks    devel         ham           multimedia    sysutils
    +    biology       editors       inputmethod   net           textproc
    +    cad           emulators     lang          news          time
    +    chat          finance       mail          parallel      wm
    +    comms         fonts         math          pkgtools      www
    +    converters    games         mbone         print         x11
     
    - 5. Run pkglint to see what things still need to be done to make your package a
    -    "good" one. If you don't know what pkglint's warnings want to tell you, try
    -    pkglint --explain or pkglint -e, which outputs additional explanations.
    +  * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
    +    are discussed in detail in Section 13.5, "The fetch phase".
     
    - 6. In many cases the package is not yet ready to build. You can find
    -    instructions for the most common cases in the next section, Section 12.1,
    -    "Common types of packages". After you have followed the instructions over
    -    there, you can hopefully continue here.
    +The second section contains information about separately downloaded patches, if
    +any.
     
    - 7. Run bmake clean to clean the working directory from the extracted files.
    -    Besides these files, a lot of cache files and other system information has
    -    been saved in the working directory, which may become wrong after you
    -    edited the Makefile.
    +  * PATCHFILES: Name(s) of additional files that contain distribution patches.
    +    There is no default. pkgsrc will look for them at PATCH_SITES. They will
    +    automatically be uncompressed before patching if the names end with .gz or
    +    .Z.
     
    - 8. Now, run bmake to build the package. For the various things that can go
    -    wrong in this phase, consult Chapter 21, Making your package work.
    +  * PATCH_SITES: Primary location(s) for distribution patch files (see
    +    PATCHFILES above) if not found locally.
     
    - 9. When the package builds fine, the next step is to install the package. Run 
    -    bmake install and hope that everything works.
    +  * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
    +    count to help find the correct files to patch. It defaults to -p0.
     
    -10. Up to now, the file PLIST, which contains a list of the files that are
    -    installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
    -    generate a probably correct list. Check the file using your preferred text
    -    editor to see if the list of files looks plausible.
    +The third section contains the following variables.
     
    -11. Run pkglint again to see if the generated PLIST contains garbage or not.
    +  * MAINTAINER is the email address of the person who feels responsible for
    +    this package, and who is most likely to look at problems or questions
    +    regarding this package which have been reported with send-pr(1). Other
    +    developers may contact the MAINTAINER before making changes to the package,
    +    but are not required to do so. When packaging a new program, set MAINTAINER
    +    to yourself. If you really can't maintain the package for future updates,
    +    set it to .
     
    -12. When you ran bmake install, the package has been registered in the database
    -    of installed files, but with an empty list of files. To fix this, run bmake
    -    deinstall and bmake install again. Now the package is registered with the
    -    list of files from PLIST.
    +  * OWNER should be used instead of MAINTAINER when you do not want other
    +    developers to update or change the package without contacting you first. A
    +    package Makefile should contain one of MAINTAINER or OWNER, but not both.
     
    -13. Run bmake package to create a binary package from the set of installed
    -    files.
    +  * HOMEPAGE is a URL where users can find more information about the package.
     
    -12.1. Common types of packages
    +  * COMMENT is a one-line description of the package (should not include the
    +    package name).
     
    -12.1.1. Perl modules
    +  * LICENSE indicates the license(s) applicable for the package. See
    +    Section 21.1.3, "Handling licenses" for further details.
     
    -Simple Perl modules are handled automatically by url2pkg, including
    -dependencies.
    +Other variables that affect the build:
     
    -12.1.2. Python modules and programs
    +  * WRKSRC: The directory where the interesting distribution files of the
    +    package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
    +    most packages.
     
    -Python modules and programs packages are easily created using a set of
    -predefined variables.
    +    If a package doesn't create a subdirectory for itself (most GNU software
    +    does, for instance), but extracts itself in the current directory, you
    +    should set WRKSRC=${WRKDIR}.
     
    -If some Python versions are not supported by the software, set the
    -PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
    -supported, e.g.
    +    If a package doesn't create a subdirectory with the name of DISTNAME but
    +    some different name, set WRKSRC to point to the proper name in ${WRKDIR},
    +    for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
    +    other examples.
     
    -PYTHON_VERSIONS_INCOMPATIBLE=       27
    +    The name of the working directory created by pkgsrc is taken from the
    +    WRKDIR_BASENAME variable. By default, its value is work. If you want to use
    +    the same pkgsrc tree for building different kinds of binary packages, you
    +    can change the variable according to your needs. Two other variables handle
    +    common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
    +    defined in mk.conf, the first component of the host's name is attached to
    +    the directory name. If OBJMACHINE is defined, the platform name is
    +    attached, which might look like work.i386 or work.sparc.
     
    -If the packaged software is a Python module, include one of ../../lang/python/
    -egg.mk, ../../lang/python/distutils.mk, or ../../lang/python/extension.mk.
    +Please pay attention to the following gotchas:
     
    -Most Python packages use either "distutils" or easy-setup/setuptools ("eggs").
    -If the packaged software is using setuptools, you only need to include "../../
    -lang/python/egg.mk". Otherwise, if the software uses "distutils", include "..
    -/../lang/python/distutils.mk", so pkgsrc will use this framework. "distutils"
    -uses a script called setup.py; if the "distutils" driver is not called
    -setup.py, set the PYSETUP variable to the name of the script.
    +  * Add MANCOMPRESSED if man pages are installed in compressed form by the
    +    package. For packages using BSD-style makefiles which honor MANZ, there is
    +    MANCOMPRESSED_IF_MANZ.
     
    -Either way, the package directory should be called "py-software" and PKGNAME
    -should be set to "${PYPKGPREFIX}-${DISTNAME}", e.g.
    +  * Replace /usr/local with "${PREFIX}" in all files (see patches, below).
     
    -DISTNAME=   foopymodule-1.2.10
    -PKGNAME=    ${PYPKGPREFIX}-${DISTNAME}
    +  * If the package installs any info files, see Section 21.6.7, "Packages
    +    installing info files".
     
    -If it is an application, include "../../lang/python/application.mk". In order
    -to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
    -variable and set it to the list of files (paths relative to WRKSRC) that must
    -be corrected. For example:
    +12.2. distinfo
     
    -REPLACE_PYTHON=   *.py
    +The distinfo file contains the message digest, or checksum, of each distfile
    +needed for the package. This ensures that the distfiles retrieved from the
    +Internet have not been corrupted during transfer or altered by a malign force
    +to introduce a security hole. To provide maximum security, all distfiles are
    +protected using three different message digest algorithms (SHA1, RMD160,
    +SHA512), as well as the file size.
     
    -Some Python modules have separate distributions for Python-2.x and Python-3.x
    -support. In pkgsrc this is handled by the versioned_dependencies.mk file. Set
    -PYTHON_VERSIONED_DEPENDENCIES to the list of packages that should be depended
    -upon and include "../../lang/python/versioned_dependencies.mk", then the pkgsrc
    -infrastructure will depend on the appropriate package version. For example:
    +The distinfo file also contains the checksums for all the patches found in the
    +patches directory (see Section 12.3, "patches/*"). These checksums ensure that
    +patches are only applied intentionally and that they don't accidentally change,
    +e.g. when merging different changes together. They also make sure that new
    +patches are actually added to CVS and old ones are removed. Too see whether the
    +patches and the distinfo file match, run pkglint after changing the patches.
     
    -PYTHON_VERSIONED_DEPENDENCIES=dialog
    +To regenerate the distinfo file, use the make distinfo command.
     
    -Look inside versioned_dependencies.mk for a list of supported packages.
    +Some packages have different sets of distfiles depending on the platform, for
    +example lang/openjdk8. These are kept in the same distinfo file and care should
    +be taken when upgrading such a package to ensure distfile information is not
    +lost.
     
    -12.1.3. R packages
    +12.3. patches/*
     
    -Simple R packages from CRAN are handled automatically by R2pkg, which is
    -available in pkgtools/R2pkg. Individual packages (and optionally their
    -dependencies) may be created and updated. R packages generally follow the same
    -form, and most of the relevant information needed is contained in a DESCRIPTION
    -file as part of each R package on CRAN. Consequently, R2pkg downloads that
    -information and creates or updates a package in the canonical form. The
    -resulting package should be reviewed for correctness.
    +Some packages don't work out-of-the box on the various platforms that are
    +supported by pkgsrc. These packages need to be patched to make them work. The
    +patch files can be found in the patches/ directory.
     
    -12.1.4. TeXlive packages
    +In the patch phase, these patches are applied to the files in WRKSRC directory
    +after extracting them, in alphabetic order.
     
    -TeXlive packages from CTAN are handled automatically by texlive2pkg, which is
    -available in pkgtools/texlive2pkg.
    +12.3.1. Structure of a single patch file
     
    -If the TeXlive package name is not known, it may be useful to search CTAN. A "
    -Contained in" field on the package page typically identifies the basename of
    -the package file in the TeXlive archive.
    +The patch-* files should be in diff -bu format, and apply without a fuzz to
    +avoid problems. (To force patches to apply with fuzz you can set
    +PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
    +a single file, and no file should be patched by more than one patch file. This
    +helps to keep future modifications simple.
     
    -If the TeXlive package name is known, download the files from the TeXlive
    -archive. For package foo, you will need to download foo.tar.xz. Most TeXlive
    -packages also have associated documentation packages, so download
    -foo.doc.tar.xz at the same time. These files should be placed in the
    -appropriate category directory, which is often but not always print. Then run
    -the following command in the category directory.
    +Each patch file is structured as follows: In the first line, there is the RCS
    +Id of the patch itself. The second line should be empty for aesthetic reasons.
    +After that, there should be a comment for each change that the patch does.
    +There are a number of standard cases:
     
    -texlive2pkg foo.tar.xz foo.doc.tar.xz
    +  * Patches for commonly known vulnerabilities should mention the vulnerability
    +    ID (CAN, CVE).
     
    -This will create two packages, tex-foo and tex-foo-doc. Be sure to check that
    -both packages are correct.
    +  * Patches that change source code should mention the platform and other
    +    environment (for example, the compiler) that the patch is needed for.
     
    -Finally, CTAN currently does not include version information in package
    -filenames and changes their contents periodically when updates occur.
    -Consequently, pkgsrc avoids downloading distfiles directly from CTAN and
    -instead relies on the pkgsrc archives. For each new or updated TeXlive package,
    -e.g., the main one and the corresponding documentation, upload the distfiles
    -with the following command in each package directory.
    +The patch should be commented so that any developer who knows the code of the
    +application can make some use of the patch. Special care should be taken for
    +the upstream developers, since we generally want that they accept our patches,
    +so we have less work in the future.
     
    -make upload-distfiles
    +12.3.2. Creating patch files
     
    -12.2. Examples
    +One important thing to mention is to pay attention that no RCS IDs get stored
    +in the patch files, as these will cause problems when later checked into the
    +NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
    +avoid these problems.
     
    -12.2.1. How the www/nvu package came into pkgsrc
    +For even more automation, we recommend using mkpatches from the same package to
    +make a whole set of patches. You just have to backup files before you edit them
    +to filename.orig, e.g. with cp -p filename filename.orig or, easier, by using 
    +pkgvi again from the same package. If you upgrade a package this way, you can
    +easily compare the new set of patches with the previously existing one with 
    +patchdiff. The files in patches are replaced by new files, so carefully check
    +if you want to take all the changes.
     
    -12.2.1.1. The initial package
    -
    -Looking at the file pkgsrc/doc/TODO, I saw that the "nvu" package has not yet
    -been imported into pkgsrc. As the description says it has to do with the web,
    -the obvious choice for the category is "www".
    -
    -$ mkdir www/nvu
    -$ cd www/nvu
    -
    -The web site says that the sources are available as a tar file, so I fed that
    -URL to the url2pkg program:
    -
    -$ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
    -
    -My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
    -package name should not have the word "sources" in it. I also filled in the
    -MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
    -that:
    -
    -# $NetBSD $
    -#
    -
    -DISTNAME=       nvu-1.0-sources
    -PKGNAME=        nvu-1.0
    -CATEGORIES=     www
    -MASTER_SITES=   http://cvs.nvu.com/download/
    -EXTRACT_SUFX=   .tar.bz2
    -
    -MAINTAINER=     rillig@NetBSD.org
    -HOMEPAGE=       http://cvs.nvu.com/
    -COMMENT=        Web Authoring System
    -
    -# url2pkg-marker (please do not remove this line.)
    -.include "../../mk/bsd.pkg.mk"
    -
    -On the first line of output above, an artificial space has been added between
    -NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
    -the guide.
    -
    -Then, I quit the editor and watched pkgsrc downloading a large source archive:
    -
    -url2pkg> Running "make makesum" ...
    -=> Required installed package digest>=20010302: digest-20060826 found
    -=> Fetching nvu-1.0-sources.tar.bz2
    -Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
    -100% |*************************************| 28992 KB  150.77 KB/s00:00 ETA
    -29687976 bytes retrieved in 03:12 (150.77 KB/s)
    -url2pkg> Running "make extract" ...
    -=> Required installed package digest>=20010302: digest-20060826 found
    -=> Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
    -=> Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
    -work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
    -===> Installing dependencies for nvu-1.0
    -===> Overriding tools for nvu-1.0
    -===> Extracting for nvu-1.0
    -url2pkg> Adjusting the Makefile.
    -
    -Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
    -
    -Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
    -
    -12.2.1.2. Fixing all kinds of problems to make the package work
    -
    -Now that the package has been extracted, let's see what's inside it. The
    -package has a README.txt, but that only says something about mozilla, so it's
    -probably useless for seeing what dependencies this package has. But since there
    -is a GNU configure script in the package, let's hope that it will complain
    -about everything it needs.
    -
    -$ bmake
    -=> Required installed package digest>=20010302: digest-20060826 found
    -=> Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
    -=> Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
    -===> Patching for nvu-1.0
    -===> Creating toolchain wrappers for nvu-1.0
    -===> Configuring for nvu-1.0
    -[...]
    -configure: error: Perl 5.004 or higher is required.
    -[...]
    -WARNING: Please add USE_TOOLS+=perl to the package Makefile.
    -[...]
    -
    -That worked quite well. So I opened the package Makefile in my editor, and
    -since it already has a USE_TOOLS line, I just appended "perl" to it. Since the
    -dependencies of the package have changed now, and since a perl wrapper is
    -automatically installed in the "tools" phase, I need to build the package from
    -scratch.
    -
    -$ bmake clean
    -===> Cleaning for nvu-1.0
    -$ bmake
    -[...]
    -*** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
    -GNU Make.  You will not be able to build Mozilla without GNU Make.
    -[...]
    -
    -So I added "gmake" to the USE_TOOLS line and tried again (from scratch).
    -
    -[...]
    -checking for GTK - version >= 1.2.0... no
    -*** Could not run GTK test program, checking why...
    -[...]
    -
    -Now to the other dependencies. The first question is: Where is the GTK package
    -hidden in pkgsrc?
    -
    -$ echo ../../*/gtk*
    -[many packages ...]
    -$ echo ../../*/gtk
    -../../x11/gtk
    -$ echo ../../*/gtk2
    -../../x11/gtk2
    -$ echo ../../*/gtk2/bui*
    -../../x11/gtk2/buildlink3.mk
    -
    -The first try was definitely too broad. The second one had exactly one result,
    -which is very good. But there is one pitfall with GNOME packages. Before GNOME
    -2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
    -able to continue to use these packages, the GNOME 2 packages were imported as
    -separate packages, and their names usually have a "2" appended. So I checked
    -whether this was the case here, and indeed it was.
    -
    -Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
    -easy. I just inserted an .include line before the last line of the package
    -Makefile, so that it now looks like this:
    -
    -[...]
    -.include "../../x11/gtk2/buildlink3.mk"
    -.include "../../mk/bsd.pkg.mk
    -
    -After another bmake clean && bmake, the answer was:
    -
    -[...]
    -checking for gtk-config... /home/roland/pkg/bin/gtk-config
    -checking for GTK - version >= 1.2.0... no
    -*** Could not run GTK test program, checking why...
    -*** The test program failed to compile or link. See the file config.log for the
    -*** exact error that occured. This usually means GTK was incorrectly installed
    -*** or that you have moved GTK since it was installed. In the latter case, you
    -*** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
    -configure: error: Test for GTK failed.
    -[...]
    -
    -In this particular case, the assumption that "every package prefers GNOME 2"
    -had been wrong. The first of the lines above told me that this package really
    -wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
    -it would have looked for pkg-config instead of gtk-config. So I changed the x11
    -/gtk2 to x11/gtk in the package Makefile, and tried again.
    -
    -[...]
    -cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\"  [...]
    -In file included from xpidl.c:42:
    -xpidl.h:53:24: libIDL/IDL.h: No such file or directory
    -In file included from xpidl.c:42:
    -xpidl.h:132: error: parse error before "IDL_ns"
    -[...]
    -
    -The package still does not find all of its dependencies. Now the question is:
    -Which package provides the libIDL/IDL.h header file?
    -
    -$ echo ../../*/*idl*
    -../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
    -$ echo ../../*/*IDL*
    -../../net/libIDL
    -
    -Let's take the one from the second try. So I included the ../../net/libIDL/
    -buildlink3.mk file and tried again. But the error didn't change. After digging
    -through some of the code, I concluded that the build process of the package was
    -broken and couldn't have ever worked, but since the Mozilla source tree is
    -quite large, I didn't want to fix it. So I added the following to the package
    -Makefile and tried again:
    -
    -CPPFLAGS+=              -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
    -BUILDLINK_TRANSFORM+=   l:IDL:IDL-2
    -
    -The latter line is needed because the package expects the library libIDL.so,
    -but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
    -that on the fly.
    -
    -The next problem was related to a recent change of the FreeType interface. I
    -looked up in www/seamonkey which patch files were relevant for this issue and
    -copied them to the patches directory. Then I retried, fixed the patches so that
    -they applied cleanly and retried again. This time, everything worked.
    -
    -12.2.1.3. Installing the package
    -
    -$ bmake CHECK_FILES=no install
    -[...]
    -$ bmake print-PLIST >PLIST
    -$ bmake deinstall
    -$ bmake install
    -
    -Chapter 13. Package components - files, directories and contents
    -
    -Table of Contents
    -
    -13.1. Makefile
    -13.2. distinfo
    -13.3. patches/*
    -
    -    13.3.1. Structure of a single patch file
    -    13.3.2. Creating patch files
    -    13.3.3. Sources where the patch files come from
    -    13.3.4. Patching guidelines
    -    13.3.5. Feedback to the author
    -
    -13.4. Other mandatory files
    -13.5. Optional files
    -
    -    13.5.1. Files affecting the binary package
    -    13.5.2. Files affecting the build process
    -    13.5.3. Files affecting nothing at all
    -
    -13.6. work*
    -13.7. files/*
    -
    -Whenever you're preparing a package, there are a number of files involved which
    -are described in the following sections.
    -
    -13.1. Makefile
    -
    -Building, installation and creation of a binary package are all controlled by
    -the package's Makefile. The Makefile describes various things about a package,
    -for example from where to get it, how to configure, build, and install it.
    -
    -A package Makefile contains several sections that describe the package.
    -
    -In the first section there are the following variables, which should appear
    -exactly in the order given here. The order and grouping of the variables is
    -mostly historical and has no further meaning.
    -
    -  * DISTNAME is the basename of the distribution file to be downloaded from the
    -    package's website.
    -
    -  * PKGNAME is the name of the package, as used by pkgsrc. You need to provide
    -    it if DISTNAME (which is the default) is not a good name for the package in
    -    pkgsrc or DISTNAME is not provided (no distribution file is required).
    -    Usually it is the pkgsrc directory name together with the version number.
    -    It must match the regular expression ^[A-Za-z0-9][A-Za-z0-9-_.+]*$, that
    -    is, it starts with a letter or digit, and contains only letters, digits,
    -    dashes, underscores, dots and plus signs.
    -
    -  * CATEGORIES is a list of categories which the package fits in. You can
    -    choose any of the top-level directories of pkgsrc for it.
    -
    -    Currently the following values are available for CATEGORIES. If more than
    -    one is used, they need to be separated by spaces:
    -
    -    archivers     cross         geography     meta-pkgs     security
    -    audio         databases     graphics      misc          shells
    -    benchmarks    devel         ham           multimedia    sysutils
    -    biology       editors       inputmethod   net           textproc
    -    cad           emulators     lang          news          time
    -    chat          finance       mail          parallel      wm
    -    comms         fonts         math          pkgtools      www
    -    converters    games         mbone         print         x11
    -
    -  * MASTER_SITES, DYNAMIC_MASTER_SITES, DIST_SUBDIR, EXTRACT_SUFX and DISTFILES
    -    are discussed in detail in Section 19.5, "The fetch phase".
    -
    -The second section contains information about separately downloaded patches, if
    -any.
    -
    -  * PATCHFILES: Name(s) of additional files that contain distribution patches.
    -    There is no default. pkgsrc will look for them at PATCH_SITES. They will
    -    automatically be uncompressed before patching if the names end with .gz or
    -    .Z.
    -
    -  * PATCH_SITES: Primary location(s) for distribution patch files (see
    -    PATCHFILES above) if not found locally.
    -
    -  * PATCH_DIST_STRIP: an argument to patch(1) that sets the pathname strip
    -    count to help find the correct files to patch. It defaults to -p0.
    -
    -The third section contains the following variables.
    -
    -  * MAINTAINER is the email address of the person who feels responsible for
    -    this package, and who is most likely to look at problems or questions
    -    regarding this package which have been reported with send-pr(1). Other
    -    developers may contact the MAINTAINER before making changes to the package,
    -    but are not required to do so. When packaging a new program, set MAINTAINER
    -    to yourself. If you really can't maintain the package for future updates,
    -    set it to .
    -
    -  * OWNER should be used instead of MAINTAINER when you do not want other
    -    developers to update or change the package without contacting you first. A
    -    package Makefile should contain one of MAINTAINER or OWNER, but not both.
    -
    -  * HOMEPAGE is a URL where users can find more information about the package.
    -
    -  * COMMENT is a one-line description of the package (should not include the
    -    package name).
    -
    -  * LICENSE indicates the license(s) applicable for the package. See
    -    Section 21.1.3, "Handling licenses" for further details.
    -
    -Other variables that affect the build:
    -
    -  * WRKSRC: The directory where the interesting distribution files of the
    -    package are found. The default is ${WRKDIR}/${DISTNAME}, which works for
    -    most packages.
    -
    -    If a package doesn't create a subdirectory for itself (most GNU software
    -    does, for instance), but extracts itself in the current directory, you
    -    should set WRKSRC=${WRKDIR}.
    -
    -    If a package doesn't create a subdirectory with the name of DISTNAME but
    -    some different name, set WRKSRC to point to the proper name in ${WRKDIR},
    -    for example WRKSRC=${WRKDIR}/${DISTNAME}/unix. See lang/tcl and x11/tk for
    -    other examples.
    -
    -    The name of the working directory created by pkgsrc is taken from the
    -    WRKDIR_BASENAME variable. By default, its value is work. If you want to use
    -    the same pkgsrc tree for building different kinds of binary packages, you
    -    can change the variable according to your needs. Two other variables handle
    -    common cases of setting WRKDIR_BASENAME individually. If OBJHOSTNAME is
    -    defined in mk.conf, the first component of the host's name is attached to
    -    the directory name. If OBJMACHINE is defined, the platform name is
    -    attached, which might look like work.i386 or work.sparc.
    -
    -Please pay attention to the following gotchas:
    -
    -  * Add MANCOMPRESSED if man pages are installed in compressed form by the
    -    package. For packages using BSD-style makefiles which honor MANZ, there is
    -    MANCOMPRESSED_IF_MANZ.
    -
    -  * Replace /usr/local with "${PREFIX}" in all files (see patches, below).
    -
    -  * If the package installs any info files, see Section 21.6.7, "Packages
    -    installing info files".
    -
    -13.2. distinfo
    -
    -The distinfo file contains the message digest, or checksum, of each distfile
    -needed for the package. This ensures that the distfiles retrieved from the
    -Internet have not been corrupted during transfer or altered by a malign force
    -to introduce a security hole. To provide maximum security, all distfiles are
    -protected using three different message digest algorithms (SHA1, RMD160,
    -SHA512), as well as the file size.
    -
    -The distinfo file also contains the checksums for all the patches found in the
    -patches directory (see Section 13.3, "patches/*"). These checksums ensure that
    -patches are only applied intentionally and that they don't accidentally change,
    -e.g. when merging different changes together. They also make sure that new
    -patches are actually added to CVS and old ones are removed. Too see whether the
    -patches and the distinfo file match, run pkglint after changing the patches.
    -
    -To regenerate the distinfo file, use the make distinfo command.
    -
    -Some packages have different sets of distfiles depending on the platform, for
    -example lang/openjdk8. These are kept in the same distinfo file and care should
    -be taken when upgrading such a package to ensure distfile information is not
    -lost.
    -
    -13.3. patches/*
    -
    -Some packages don't work out-of-the box on the various platforms that are
    -supported by pkgsrc. These packages need to be patched to make them work. The
    -patch files can be found in the patches/ directory.
    -
    -In the patch phase, these patches are applied to the files in WRKSRC directory
    -after extracting them, in alphabetic order.
    -
    -13.3.1. Structure of a single patch file
    -
    -The patch-* files should be in diff -bu format, and apply without a fuzz to
    -avoid problems. (To force patches to apply with fuzz you can set
    -PATCH_FUZZ_FACTOR=-F2). Furthermore, each patch should contain only changes for
    -a single file, and no file should be patched by more than one patch file. This
    -helps to keep future modifications simple.
    -
    -Each patch file is structured as follows: In the first line, there is the RCS
    -Id of the patch itself. The second line should be empty for aesthetic reasons.
    -After that, there should be a comment for each change that the patch does.
    -There are a number of standard cases:
    -
    -  * Patches for commonly known vulnerabilities should mention the vulnerability
    -    ID (CAN, CVE).
    -
    -  * Patches that change source code should mention the platform and other
    -    environment (for example, the compiler) that the patch is needed for.
    -
    -The patch should be commented so that any developer who knows the code of the
    -application can make some use of the patch. Special care should be taken for
    -the upstream developers, since we generally want that they accept our patches,
    -so we have less work in the future.
    -
    -13.3.2. Creating patch files
    -
    -One important thing to mention is to pay attention that no RCS IDs get stored
    -in the patch files, as these will cause problems when later checked into the
    -NetBSD CVS tree. Use the pkgdiff command from the pkgtools/pkgdiff package to
    -avoid these problems.
    -
    -For even more automation, we recommend using mkpatches from the same package to
    -make a whole set of patches. You just have to backup files before you edit them
    -to filename.orig, e.g. with cp -p filename filename.orig or, easier, by using 
    -pkgvi again from the same package. If you upgrade a package this way, you can
    -easily compare the new set of patches with the previously existing one with 
    -patchdiff. The files in patches are replaced by new files, so carefully check
    -if you want to take all the changes.
    -
    -When you have finished a package, remember to generate the checksums for the
    -patch files by using the make makepatchsum command, see Section 13.2,
    -"distinfo".
    +When you have finished a package, remember to generate the checksums for the
    +patch files by using the make makepatchsum command, see Section 12.2,
    +"distinfo".
     
     When adding a patch that corrects a problem in the distfile (rather than e.g.
     enforcing pkgsrc's view of where man pages should go), send the patch as a bug
    @@ -3520,7 +3132,7 @@ convention patch-[a-z][a-z], but new pat
     the filename. mkpatches included in pkgtools/pkgdiff takes care of the name
     automatically.
     
    -13.3.3. Sources where the patch files come from
    +12.3.3. Sources where the patch files come from
     
     If you want to share patches between multiple packages in pkgsrc, e.g. because
     they use the same distfiles, set PATCHDIR to the path where the patch files can
    @@ -3540,7 +3152,7 @@ for pkgsrc/graphics/png, keep it in $LOC
     files in the named directory are expected to be patch files, and they are
     applied after pkgsrc patches are applied.
     
    -13.3.4. Patching guidelines
    +12.3.4. Patching guidelines
     
     When fixing a portability issue in the code do not use preprocessor magic to
     check for the current operating system nor platform. Doing so hurts portability
    @@ -3564,7 +3176,7 @@ doesn't work unless it is right!
     
     Some typical examples:
     
    -Table 13.1. Patching examples
    +Table 12.1. Patching examples
     
     +-------------------------------------------------------------------------------------------+
     |  Where  |        Incorrect         |                       Correct                        |
    @@ -3591,7 +3203,7 @@ Table 13.1. Patching examples
     +-------------------------------------------------------------------------------------------+
     
     
    -13.3.5. Feedback to the author
    +12.3.5. Feedback to the author
     
     Always, always, always feed back any portability fixes or improvements you do
     to a package to the mainstream developers. This is the only way to get their
    @@ -3611,7 +3223,7 @@ patch comment.
     
     Support the idea of free software!
     
    -13.4. Other mandatory files
    +12.4. Other mandatory files
     
     DESCR
     
    @@ -3625,12 +3237,12 @@ PLIST
         This file governs the files that are installed on your system: all the
         binaries, manual pages, etc. There are other directives which may be
         entered in this file, to control the creation and deletion of directories,
    -    and the location of inserted files. See Chapter 15, PLIST issues for more
    +    and the location of inserted files. See Chapter 19, PLIST issues for more
         information.
     
    -13.5. Optional files
    +12.5. Optional files
     
    -13.5.1. Files affecting the binary package
    +12.5.1. Files affecting the binary package
     
     INSTALL
     
    @@ -3638,7 +3250,7 @@ INSTALL
         extraction and before files are moved in place, the second time after the
         files to install are moved in place. This can be used to do any custom
         procedures not possible with @exec commands in PLIST. See pkg_add(1) and
    -    pkg_create(1) for more information. See also Section 17.1, "Files and
    +    pkg_create(1) for more information. See also Section 20.1, "Files and
         directories outside the installation prefix". Please note that you can
         modify variables in it easily by using FILES_SUBST in the package's
         Makefile:
    @@ -3685,7 +3297,7 @@ ALTERNATIVES
         Each line of the file contains two filenames, first the wrapper and then
         the alternative provided by the package. Both paths are relative to PREFIX.
     
    -13.5.2. Files affecting the build process
    +12.5.2. Files affecting the build process
     
     Makefile.common
     
    @@ -3698,7 +3310,7 @@ Makefile.common
     buildlink3.mk
     
         This file contains the dependency information for the buildlink3 framework
    -    (see Chapter 16, Buildlink methodology).
    +    (see Chapter 18, Buildlink methodology).
     
     hacks.mk
     
    @@ -3709,1154 +3321,1464 @@ hacks.mk
     options.mk
     
         This file contains the code for the package-specific options (see
    -    Chapter 18, Options handling) that can be selected by the user. If a
    +    Chapter 16, Options handling) that can be selected by the user. If a
         package has only one or two options, it is equally acceptable to put the
         code directly into the Makefile.
     
    -13.5.3. Files affecting nothing at all
    +12.5.3. Files affecting nothing at all
    +
    +README*
    +
    +    These files do not take place in the creation of a package and thus are
    +    purely informative to the package developer.
    +
    +TODO
    +
    +    This file contains things that need to be done to make the package even
    +    better.
    +
    +12.6. work*
    +
    +When you type make, the distribution files are unpacked into the directory
    +denoted by WRKDIR. It can be removed by running make clean. Besides the
    +sources, this directory is also used to keep various timestamp files. The
    +directory gets removed completely on clean. The default is ${.CURDIR}/work or $
    +{.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
    +
    +12.7. files/*
    +
    +If you have any files that you wish to be placed in the package prior to
    +configuration or building, you can place these files here and use a ${CP}
    +command in the "post-extract" target to achieve this.
    +
    +If you want to share files in this way with other packages, set the FILESDIR
    +variable to point to the other package's files directory, e.g.:
    +
    +FILESDIR=       ../../editors/xemacs/files
    +
    +Chapter 13. The build process
    +
    +Table of Contents
    +
    +13.1. Introduction
    +13.2. Program location
    +13.3. Directories used during the build process
    +13.4. Running a phase
    +13.5. The fetch phase
    +
    +    13.5.1. What to fetch and where to get it from
    +    13.5.2. How are the files fetched?
    +
    +13.6. The checksum phase
    +13.7. The extract phase
    +13.8. The patch phase
    +13.9. The tools phase
    +13.10. The wrapper phase
    +13.11. The configure phase
    +13.12. The build phase
    +13.13. The test phase
    +13.14. The install phase
    +13.15. The package phase
    +13.16. Cleaning up
    +13.17. Other helpful targets
    +
    +13.1. Introduction
    +
    +This chapter gives a detailed description on how a package is built. Building a
    +package is separated into different phases (for example fetch, build, install),
    +all of which are described in the following sections. Each phase is split into
    +so-called stages, which take the name of the containing phase, prefixed by one
    +of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
    +actual work is done in the do-* stages.
    +
    +Never override the regular targets (like fetch), if you have to, override the
    +do-* ones instead.
    +
    +The basic steps for building a program are always the same. First the program's
    +source (distfile) must be brought to the local system and then extracted. After
    +any pkgsrc-specific patches to compile properly are applied, the software can
    +be configured, then built (usually by compiling), and finally the generated
    +binaries, etc. can be put into place on the system.
    +
    +To get more details about what is happening at each step, you can set the
    +PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
    +more details about the patch step.
    +
    +13.2. Program location
    +
    +Before outlining the process performed by the NetBSD package system in the next
    +section, here's a brief discussion on where programs are installed, and which
    +variables influence this.
    +
    +The automatic variable PREFIX indicates where all files of the final program
    +shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
    +pkgs in the cross category. The value of PREFIX needs to be put into the
    +various places in the program's source where paths to these files are encoded.
    +See Section 12.3, "patches/*" and Section 21.3.1, "Shared libraries - libtool"
    +for more details.
    +
    +When choosing which of these variables to use, follow the following rules:
    +
    +  * PREFIX always points to the location where the current pkg will be
    +    installed. When referring to a pkg's own installation path, use "${PREFIX}"
    +    .
    +
    +  * LOCALBASE is where all non-X11 pkgs are installed. If you need to construct
    +    a -I or -L argument to the compiler to find includes and libraries
    +    installed by another non-X11 pkg, use "${LOCALBASE}". The name LOCALBASE
    +    stems from FreeBSD, which installed all packages in /usr/local. As pkgsrc
    +    leaves /usr/local for the system administrator, this variable is a
    +    misnomer.
    +
    +  * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
    +    installed. When looking for standard X11 includes (not those installed by a
    +    package), use "${X11BASE}".
    +
    +  * X11-based packages using imake must set USE_IMAKE to be installed correctly
    +    under LOCALBASE.
    +
    +  * Within ${PREFIX}, packages should install files according to hier(7), with
    +    the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
    +    man.
    +
    +13.3. Directories used during the build process
    +
    +When building a package, various directories are used to store source files,
    +temporary files, pkgsrc-internal files, and so on. These directories are
    +explained here.
    +
    +Some of the directory variables contain relative pathnames. There are two
    +common base directories for these relative directories: PKGSRCDIR/PKGPATH is
    +used for directories that are pkgsrc-specific. WRKSRC is used for directories
    +inside the package itself.
    +
    +PKGSRCDIR
    +
    +    This is an absolute pathname that points to the pkgsrc root directory.
    +    Generally, you don't need it.
    +
    +PKGDIR
    +
    +    This is an absolute pathname that points to the current package.
    +
    +PKGPATH
    +
    +    This is a pathname relative to PKGSRCDIR that points to the current
    +    package.
    +
    +WRKDIR
    +
    +    This is an absolute pathname pointing to the directory where all work takes
    +    place. The distfiles are extracted to this directory. It also contains
    +    temporary directories and log files used by the various pkgsrc frameworks,
    +    like buildlink or the wrappers.
    +
    +WRKSRC
    +
    +    This is an absolute pathname pointing to the directory where the distfiles
    +    are extracted. It is usually a direct subdirectory of WRKDIR, and often
    +    it's the only directory entry that isn't hidden. This variable may be
    +    changed by a package Makefile.
    +
    +The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
    +defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
    +created in the pkgsrc entry's directory. If users would like to have their
    +pkgsrc trees behave in a read-only manner, then the value of
    +CREATE_WRKDIR_SYMLINK should be set to no.
    +
    +13.4. Running a phase
    +
    +You can run a particular phase by typing make phase, where phase is the name of
    +the phase. This will automatically run all phases that are required for this
    +phase. The default phase is build, that is, when you run make without
    +parameters in a package directory, the package will be built, but not
    +installed.
    +
    +13.5. The fetch phase
    +
    +The first step in building a package is to fetch the distribution files
    +(distfiles) from the sites that are providing them. This is the task of the 
    +fetch phase.
    +
    +13.5.1. What to fetch and where to get it from
    +
    +In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
    +name is derived from the DISTNAME variable, is fetched. The more complicated
    +cases are described below.
    +
    +The variable DISTFILES specifies the list of distfiles that have to be fetched.
    +Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
    +{EXTRACT_SUFX}, so that most packages don't need to define it at all.
    +EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
    +your package requires additional distfiles to the default one, you cannot just
    +append the additional filenames using the += operator, but you have write for
    +example:
    +
    +DISTFILES=      ${DEFAULT_DISTFILES} additional-files.tar.gz
    +
    +Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
    +package has multiple DISTFILES or multiple PATCHFILES from different sites, you
    +can set SITES.distfile to the list of URLs where the file distfile (including
    +the suffix) can be found.
    +
    +DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
    +DISTFILES+=     foo-file.tar.gz
    +SITES.foo-file.tar.gz= \
    +https://www.somewhere.com/somehow/ \
    +https://www.somewhereelse.com/mirror/somehow/
    +
    +When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
    +gets the name of each distfile appended to it, without an intermediate slash.
    +Therefore, all site values have to end with a slash or other separator
    +character. This allows for example to set MASTER_SITES to a URL of a CGI script
    +that gets the name of the distfile as a parameter. In this case, the definition
    +would look like:
    +
    +MASTER_SITES=   https://www.example.com/download.cgi?file=
    +
    +The exception to this rule are URLs starting with a dash. In that case the URL
    +is taken as is, fetched and the result stored under the name of the distfile.
    +You can use this style for the case when the download URL style does not match
    +the above common case. For example, if permanent download URL is a redirector
    +to the real download URL, or the download file name is offered by an HTTP
    +Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
    +created instead of the default v1.0.0.tar.gz.
    +
    +DISTNAME=       foo-1.0.0
    +MASTER_SITES=   -https://www.example.com/archive/v1.0.0.tar.gz
    +
    +There are some predefined values for MASTER_SITES, which can be used in
    +packages. The names of the variables should speak for themselves.
    +
    +MASTER_SITE_APACHE          MASTER_SITE_BACKUP
    +MASTER_SITE_CRATESIO        MASTER_SITE_CYGWIN
    +MASTER_SITE_DEBIAN          MASTER_SITE_FREEBSD
    +MASTER_SITE_FREEBSD_LOCAL   MASTER_SITE_GENTOO
    +MASTER_SITE_GITHUB          MASTER_SITE_GNOME
    +MASTER_SITE_GNU             MASTER_SITE_GNUSTEP
    +MASTER_SITE_HASKELL_HACKAGE MASTER_SITE_IFARCHIVE
    +MASTER_SITE_KDE             MASTER_SITE_MOZILLA
    +MASTER_SITE_MOZILLA_ALL     MASTER_SITE_MYSQL
    +MASTER_SITE_NETLIB          MASTER_SITE_OPENBSD
    +MASTER_SITE_OPENOFFICE      MASTER_SITE_OSDN
    +MASTER_SITE_PERL_CPAN       MASTER_SITE_PGSQL
    +MASTER_SITE_PYPI            MASTER_SITE_RUBYGEMS
    +MASTER_SITE_R_CRAN          MASTER_SITE_SOURCEFORGE
    +MASTER_SITE_SUNSITE         MASTER_SITE_SUSE
    +MASTER_SITE_TEX_CTAN        MASTER_SITE_XCONTRIB
    +MASTER_SITE_XEMACS          MASTER_SITE_XORG
    +
    +Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
    +contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
    +pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
    +source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
    +distfiles/LOCAL_PORTS/.
    +
    +If you choose one of these predefined sites, you may want to specify a
    +subdirectory of that site. Since these macros may expand to more than one
    +actual site, you must use the following construct to specify a subdirectory:
    +
    +MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
    +MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
    +
    +Note the trailing slash after the subdirectory name.
    +
    +13.5.2. How are the files fetched?
    +
    +The fetch phase makes sure that all the distfiles exist in a local directory
    +(DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
    +are fetched using commands of the form
    +
    +${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
    +
    +where ${site} varies through several possibilities in turn: first,
    +MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
    +defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
    +of MASTER_SITE_BACKUP. The order of all except the first and the last can be
    +optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
    +MASTER_SORT_AWK or MASTER_SORT_REGEX.
    +
    +The specific command and arguments used depend on the FETCH_USING parameter.
    +The example above is for FETCH_USING=custom.
    +
    +The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
    +target to mirror the distfiles, if they are freely distributable. Packages
    +setting NO_SRC_ON_FTP (usually to "${RESTRICTED}") will not have their
    +distfiles mirrored.
    +
    +13.6. The checksum phase
    +
    +After the distfile(s) are fetched, their checksum is generated and compared
    +with the checksums stored in the distinfo file. If the checksums don't match,
    +the build is aborted. This is to ensure the same distfile is used for building,
    +and that the distfile wasn't changed, e.g. by some malign force, deliberately
    +changed distfiles on the master distribution site or network lossage.
     
    -README*
    +13.7. The extract phase
     
    -    These files do not take place in the creation of a package and thus are
    -    purely informative to the package developer.
    +When the distfiles are present on the local system, they need to be extracted,
    +as they usually come in the form of some compressed archive format.
     
    -TODO
    +By default, all DISTFILES are extracted. If you only need some of them, you can
    +set the EXTRACT_ONLY variable to the list of those files.
     
    -    This file contains things that need to be done to make the package even
    -    better.
    +Extracting the files is usually done by a little program, mk/extract/extract,
    +which already knows how to extract various archive formats, so most likely you
    +will not need to change anything here. But if you need, the following variables
    +may help you:
     
    -13.6. work*
    +EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
     
    -When you type make, the distribution files are unpacked into the directory
    -denoted by WRKDIR. It can be removed by running make clean. Besides the
    -sources, this directory is also used to keep various timestamp files. The
    -directory gets removed completely on clean. The default is ${.CURDIR}/work or $
    -{.CURDIR}/work.${MACHINE_ARCH} if OBJMACHINE is set.
    +    Use these variables to override the default options for an extract command,
    +    which are defined in mk/extract/extract.
     
    -13.7. files/*
    +EXTRACT_USING
     
    -If you have any files that you wish to be placed in the package prior to
    -configuration or building, you can place these files here and use a ${CP}
    -command in the "post-extract" target to achieve this.
    +    This variable can be set to bsdtar, gtar, nbtar (which is the default
    +    value), pax, or an absolute pathname pointing to the command with which tar
    +    archives should be extracted. It is preferred to choose bsdtar over gtar if
    +    NetBSD's pax-as-tar is not good enough.
     
    -If you want to share files in this way with other packages, set the FILESDIR
    -variable to point to the other package's files directory, e.g.:
    +If the extract program doesn't serve your needs, you can also override the
    +EXTRACT_CMD variable, which holds the command used for extracting the files.
    +This command is executed in the ${WRKSRC} directory. During execution of this
    +command, the shell variable extract_file holds the absolute pathname of the
    +file that is going to be extracted.
     
    -FILESDIR=       ../../editors/xemacs/files
    +And if that still does not suffice, you can override the do-extract target in
    +the package Makefile.
     
    -Chapter 14. Programming in Makefiles
    +13.8. The patch phase
     
    -Table of Contents
    +After extraction, all the patches named by the PATCHFILES, those present in the
    +patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
    +/usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
    +are uncompressed before they are applied, files ending in .orig or .rej are
    +ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
    +Section 12.3, "patches/*" for more details.
     
    -14.1. Caveats
    -14.2. Makefile variables
    +By default patch(1) is given special arguments to make it fail if the expected
    +text from the patch context is not found in the patched file. If that happens,
    +fix the patch file by comparing it with the actual text in the file to be
    +patched.
     
    -    14.2.1. Naming conventions
    +13.9. The tools phase
     
    -14.3. Code snippets
    +This is covered in Chapter 17, Tools needed for building or running.
     
    -    14.3.1. Adding things to a list
    -    14.3.2. Echoing a string exactly as-is
    -    14.3.3. Passing CFLAGS to GNU configure scripts
    -    14.3.4. Handling possibly empty variables
    +13.10. The wrapper phase
     
    -Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
    -part of the pkgsrc system. Using the make(1) system as a programming language
    -for a big system like pkgsrc requires some discipline to keep the code correct
    -and understandable.
    +This phase creates wrapper programs for the compilers and linkers. The
    +following variables can be used to tweak the wrappers.
     
    -The basic ingredients for Makefile programming are variables and shell
    -commands. Among these shell commands may even be more complex ones like awk(1)
    -programs. To make sure that every shell command runs as intended it is
    -necessary to quote all variables correctly when they are used.
    +ECHO_WRAPPER_MSG
     
    -This chapter describes some patterns that appear quite often in Makefiles,
    -including the pitfalls that come along with them.
    +    The command used to print progress messages. Does nothing by default. Set
    +    to ${ECHO} to see the progress messages.
     
    -14.1. Caveats
    +WRAPPER_DEBUG
     
    -  * When you are creating a file as a target of a rule, always write the data
    -    to a temporary file first and finally rename that file. Otherwise there
    -    might occur an error in the middle of generating the file, and when the
    -    user runs make(1) for the second time, the file exists and will not be
    -    regenerated properly. Example:
    +    This variable can be set to yes (default) or no, depending on whether you
    +    want additional information in the wrapper log file.
     
    -    wrong:
    -            @echo "line 1" > ${.TARGET}
    -            @echo "line 2" >> ${.TARGET}
    -            @false
    +WRAPPER_UPDATE_CACHE
     
    -    correct:
    -            @echo "line 1" > ${.TARGET}.tmp
    -            @echo "line 2" >> ${.TARGET}.tmp
    -            @false
    -            @mv ${.TARGET}.tmp ${.TARGET}
    +    This variable can be set to yes or no, depending on whether the wrapper
    +    should use its cache, which will improve the speed. The default value is
    +    yes, but is forced to no if the platform does not support it.
     
    -    When you run make wrong twice, the file wrong will exist, although there
    -    was an error message in the first run. On the other hand, running make
    -    correct gives an error message twice, as expected.
    +WRAPPER_REORDER_CMDS
     
    -    You might remember that make(1) sometimes removes ${.TARGET} in case of
    -    error, but this only happens when it is interrupted, for example by
    -    pressing Ctrl+C. This does not happen when one of the commands fails (like
    -    false(1) above).
    +    A list of reordering commands. A reordering command has the form reorder:l:
    +    lib1:lib2. It ensures that that -llib1 occurs before -llib2.
     
    -14.2. Makefile variables
    +13.11. The configure phase
     
    -Makefile variables contain strings that can be processed using the five
    -operators =, +=, ?=, := and !=, which are described in the make(1) man page.
    +Most pieces of software need information on the header files, system calls, and
    +library routines which are available on the platform they run on. The process
    +of determining this information is known as configuration, and is usually
    +automated. In most cases, a script is supplied with the distfiles, and its
    +invocation results in generation of header files, Makefiles, etc.
     
    -When a variable's value is parsed from a Makefile, the hash character # and the
    -backslash character \ are handled specially. If a backslash is the last
    -character in a line, that backslash is removed from the line and the line
    -continues with the next line of the file.
    +If the package contains a configure script, this can be invoked by setting
    +HAS_CONFIGURE to "yes". If the configure script is a GNU autoconf script, you
    +should set GNU_CONFIGURE to "yes" instead. What happens in the configure phase
    +is roughly:
     
    -The # character starts a comment that reaches until the end of the line. To get
    -an actual # character, such as in a URL, write \# instead.
    +.for d in ${CONFIGURE_DIRS}
    +        cd ${WRKSRC} \
    +        && cd ${d} \
    +        && env ${CONFIGURE_ENV} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
    +.endfor
     
    -The evaluation of variables either happens immediately or lazy. It happens
    -immediately when the variable occurs on the right-hand side of the := or the !=
    -operator, in a .if condition or a .for loop. In the other cases, it is
    -evaluated lazily.
    +CONFIGURE_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In
    +each of these directories, the configure script is run with the environment
    +CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
    +CONFIGURE_SCRIPT (default: "./configure") and CONFIGURE_ARGS may all be changed
    +by the package.
     
    -Some of the modifiers split the string into words and then operate on the
    -words, others operate on the string as a whole. When a string is split into
    -words, double quotes and single quotes are interpreted as delimiters, just like
    -in sh(1).
    +If the program uses the Perl way of configuration (mainly Perl modules, but not
    +only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
    +module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
    +(e.g., MAKE_PARAMS+=foo=bar
     
    -14.2.1. Naming conventions
    +If the program uses an Imakefile for configuration, the appropriate steps can
    +be invoked by setting USE_IMAKE to "yes". If you only need xmkmf, add it to
    +USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
    +SCRIPTS_ENV variable.
     
    -  * All variable names starting with an underscore are reserved for use by the
    -    pkgsrc infrastructure. They shall not be used by packages.
    +If the program uses cmake for configuration, the appropriate steps can be
    +invoked by setting USE_CMAKE to "yes". You can add variables to cmake's
    +environment by adding them to the CONFIGURE_ENV variable and arguments to cmake
    +by adding them to the CMAKE_ARGS variable. The top directory argument is given
    +by the CMAKE_ARG_PATH variable, that defaults to "." (relative to
    +CONFIGURE_DIRS)
     
    -  * In .for loops you should use lowercase variable names for the iteration
    -    variables.
    +If there is no configure step at all, set NO_CONFIGURE to "yes".
     
    -  * All list variables should have a plural name, such as PKG_OPTIONS or
    -    DISTFILES.
    +13.12. The build phase
     
    -14.3. Code snippets
    +For building a package, a rough equivalent of the following code is executed.
     
    -14.3.1. Adding things to a list
    +.for d in ${BUILD_DIRS}
    +        cd ${WRKSRC} \
    +        && cd ${d} \
    +        && env ${MAKE_ENV} \
    +            ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
    +                -f ${MAKE_FILE} \
    +                ${BUILD_TARGET}
    +.endfor
     
    -When adding a string that possibly contains whitespace or quotes to a list
    -(example 1), it must be quoted using the :Q modifier.
    +BUILD_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In each of
    +these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
    +arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
    +and BUILD_TARGET may all be changed by the package.
     
    -When adding another list to a list (example 2), it must not be quoted, since
    -its elements are already quoted.
    +The default value of MAKE_PROGRAM is "gmake" if USE_TOOLS contains "gmake", "
    +make" otherwise. The default value of MAKE_FILE is "Makefile", and BUILD_TARGET
    +defaults to "all".
     
    -STRING=         foo * bar `date`
    -LIST=           # empty
    -ANOTHER_LIST=   a=b c=d
    +If there is no build step at all, set NO_BUILD to "yes".
     
    -LIST+=          ${STRING:Q}       # 1
    -LIST+=          ${ANOTHER_LIST}   # 2
    +13.13. The test phase
     
    -14.3.2. Echoing a string exactly as-is
    +[TODO]
     
    -Echoing a string containing special characters needs special work.
    +13.14. The install phase
     
    -STRING=         foo bar <    > * `date` $$HOME ' "
    -EXAMPLE_ENV=    string=${STRING:Q} x=multiple\ quoted\ words
    +Once the build stage has completed, the final step is to install the software
    +in public directories, so users can access the programs and files.
     
    -all:
    -        echo ${STRING}                  # 1
    -        echo ${STRING:Q}                # 2
    -        printf '%s\n' ${STRING:Q}''     # 3
    -        env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"'   # 4
    +In the install phase, a rough equivalent of the following code is executed.
    +Additionally, before and after this code, much magic is performed to do
    +consistency checks, registering the package, and so on.
     
    -Example 1 leads to a syntax error in the shell, as the characters are just
    -copied.
    +.for d in ${INSTALL_DIRS}
    +        cd ${WRKSRC} \
    +        && cd ${d} \
    +        && env ${MAKE_ENV} \
    +            ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
    +                -f ${MAKE_FILE} \
    +                ${INSTALL_TARGET}
    +.endfor
     
    -Example 2 quotes the string so that the shell interprets it correctly. But the
    -echo command may additionally interpret strings with a leading dash or those
    -containing backslashes.
    +The variable's meanings are analogous to the ones in the build phase.
    +INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is "install" by default,
    +plus "install.man" if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
    +defined.
     
    -Example 3 can handle arbitrary strings, since printf(1) only interprets the
    -format string, but not the next argument. The trailing single quotes handle the
    -case when the string is empty. In that case, the :Q modifier would result in an
    -empty string too, which would then be skipped by the shell. For printf(1) this
    -doesn't make a difference, but other programs may care.
    +In the install phase, the following variables are useful. They are all
    +variations of the install(1) command that have the owner, group and permissions
    +preset. INSTALL is the plain install command. The specialized variants,
    +together with their intended use, are:
     
    -In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
    -has already been done when adding elements to the list.
    +INSTALL_PROGRAM_DIR
     
    -14.3.3. Passing CFLAGS to GNU configure scripts
    +    directories that contain binaries
     
    -When passing CFLAGS or similar variables to a GNU-style configure script
    -(especially those that call other configure scripts), it must not have leading
    -or trailing whitespace, since otherwise the configure script gets confused. To
    -trim leading and trailing whitespace, use the :M modifier, as in the following
    -example:
    +INSTALL_SCRIPT_DIR
     
    -CPPFLAGS=               # empty
    -CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX}\"
    -CPPFLAGS+=              ${MY_CPPFLAGS}
    +    directories that contain scripts
     
    -CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
    +INSTALL_LIB_DIR
     
    -all:
    -        echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
    -        echo x${CONFIGURE_ARGS:Q}x      # properly trimmed
    +    directories that contain shared and static libraries
     
    -In this example, CPPFLAGS has both leading and trailing whitespace because the
    -+= operator always adds a space.
    +INSTALL_DATA_DIR
     
    -14.3.4. Handling possibly empty variables
    +    directories that contain data files
     
    -When a possibly empty variable is used in a shell program, it may lead to a
    -syntax error.
    +INSTALL_MAN_DIR
     
    -EGFILES=        # empty
    +    directories that contain man pages
     
    -install-examples:   # produces a syntax error in the shell
    -        for egfile in ${EGFILES}; do            \
    -                echo "Installing $$egfile";     \
    -        done
    +INSTALL_GAME_DIR
     
    -The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
    -with an empty string by make(1). To fix this syntax error, use one of the
    -snippets below.
    +    directories that contain data files for games
     
    -EMPTY=          # empty
    +INSTALL_PROGRAM
     
    -install-examples:
    -        for egfile in ${EGFILES} ""; do         \
    -                [ -n "$$egfile" ] || continue;  \
    -                echo "Installing $$egfile";     \
    -        done
    +    binaries that can be stripped from debugging symbols
     
    -In this case, an empty string is appended to the iteration list (to prevent the
    -syntax error) and filtered out later.
    +INSTALL_SCRIPT
     
    -EGFILES=        # empty
    +    binaries that cannot be stripped
     
    -install-examples:
    -.for egfile in ${EGFILES}
    -        echo "Installing ${egfile}"
    -.endfor
    +INSTALL_GAME
     
    -If one of the filenames contains special characters, it should be enclosed in
    -single or double quotes.
    +    game binaries
     
    -To have a shell command test whether a make variable is empty, use the
    -following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
    +INSTALL_LIB
     
    -Chapter 15. PLIST issues
    +    shared and static libraries
     
    -Table of Contents
    +INSTALL_DATA
     
    -15.1. RCS ID
    -15.2. Semi-automatic PLIST generation
    -15.3. Tweaking output of make print-PLIST
    -15.4. Variable substitution in PLIST
    -15.5. Man page compression
    -15.6. Changing PLIST source with PLIST_SRC
    -15.7. Platform-specific and differing PLISTs
    -15.8. Build-specific PLISTs
    -15.9. Sharing directories between packages
    +    data files
     
    -The PLIST file contains a package's "packing list", i.e. a list of files that
    -belong to the package (relative to the ${PREFIX} directory it's been installed
    -in) plus some additional statements - see the pkg_create(1) man page for a full
    -list. This chapter addresses some issues that need attention when dealing with
    -the PLIST file (or files, see below!).
    +INSTALL_GAME_DATA
     
    -15.1. RCS ID
    +    data files for games
     
    -Be sure to add a RCS ID line as the first thing in any PLIST file you write:
    +INSTALL_MAN
     
    -@comment $NetBSD $
    +    man pages
     
    -An artificial space has been added between NetBSD and $, this is a workaround
    -here to prevent CVS expanding to the filename of the guide. When adding the RCS
    -ID the space should be omitted.
    +Some other variables are:
     
    -15.2. Semi-automatic PLIST generation
    +INSTALL_UNSTRIPPED
     
    -You can use the make print-PLIST command to output a PLIST that matches any new
    -files since the package was extracted. See Section 19.17, "Other helpful
    -targets" for more information on this target.
    +    If set to yes, do not run strip(1) when installing binaries. Any debugging
    +    sections and symbols present in binaries will be preserved.
     
    -15.3. Tweaking output of make print-PLIST
    +INSTALLATION_DIRS
     
    -The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
    -used to filter the output of print-PLIST. You can append any chunk of AWK
    -scripting you like to it, but be careful with quoting.
    +    A list of directories relative to PREFIX that are created by pkgsrc at the
    +    beginning of the install phase. The package is supposed to create all
    +    needed directories itself before installing files to it and list all other
    +    directories here.
     
    -For example, to get all files inside the libdata/foo directory removed from the
    -resulting PLIST:
    +In the rare cases that a package shouldn't install anything, set NO_INSTALL to 
    +"yes". This is mostly relevant for packages in the regress category.
     
    -PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
    +13.15. The package phase
     
    -The PRINT_PLIST_AWK transformations are evaluated after the file list and
    -directory list are sorted. EARLY_PRINT_PLIST_AWK is like PRINT_PLIST_AWK except
    -it operates before the file list and directory list are sorted.
    +Once the install stage has completed, a binary package of the installed files
    +can be built. These binary packages can be used for quick installation without
    +previous compilation, e.g. by the make bin-install or by using pkg_add.
     
    -15.4. Variable substitution in PLIST
    +By default, the binary packages are created in ${PACKAGES}/All and symlinks are
    +created in ${PACKAGES}/category, one for each category in the CATEGORIES
    +variable. PACKAGES defaults to pkgsrc/packages.
     
    -A number of variables are substituted automatically in PLISTs when a package is
    -installed on a system. This includes the following variables:
    +13.16. Cleaning up
     
    -${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
    +Once you're finished with a package, you can clean the work directory by
    +running make clean. If you want to clean the work directories of all
    +dependencies too, use make clean-depends.
     
    -    Some packages like emacs and perl embed information about which
    -    architecture they were built on into the pathnames where they install their
    -    files. To handle this case, PLIST will be preprocessed before actually
    -    used, and the symbol "${MACHINE_ARCH}" will be replaced by what uname -p
    -    gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
    -    PLIST somewhere - use this on packages that have GNU autoconf-created
    -    configure scripts.
    +13.17. Other helpful targets
     
    -    Legacy note
    +pre/post-*
     
    -    There used to be a symbol "$ARCH" that was replaced by the output of uname
    -    -m, but that's no longer supported and has been removed.
    +    For any of the main targets described in the previous section (configure,
    +    build, install, etc.), two auxiliary targets exist with "pre-" and "post-"
    +    used as a prefix for the main target's name. These targets are invoked
    +    before and after the main target is called, allowing extra configuration or
    +    installation steps be performed from a package's Makefile, for example,
    +    which a program's configure script or install target omitted.
    +
    +    About 5% of the pkgsrc packages define their custom post-extract target,
    +    another 5% define pre-configure, and 10% define post-install. The other pre
    +    /post-* targets are defined even less often.
     
    -${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
    +do-*
     
    -    Some packages want to embed the OS name and version into some paths. To do
    -    this, use these variables in the PLIST:
    +    Should one of the main targets do the wrong thing, and should there be no
    +    variable to fix this, you can redefine it with the do-* target. (Note that
    +    redefining the target itself instead of the do-* target is a bad idea, as
    +    the pre-* and post-* targets won't be called anymore, etc.)
     
    -      + ${OPSYS} - output of "uname -s"
    +    About 15% of the pkgsrc packages override the default do-install, the other
    +    do-* targets are overridden even less often.
     
    -      + ${LOWER_OPSYS} - lowercase common name (eg. "solaris")
    +reinstall
     
    -      + ${OS_VERSION} - "uname -r"
    +    If you did a make install and you noticed some file was not installed
    +    properly, you can repeat the installation with this target, which will
    +    ignore the "already installed" flag.
     
    -For a list of values which are replaced by default, the output of make help
    -topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
    -PLIST_SUBST should help.
    +    This is the default value of DEPENDS_TARGET except in the case of make
    +    update and make package, where the defaults are "package" and "update",
    +    respectively.
     
    -If you want to change other variables not listed above, you can add variables
    -and their expansions to this variable in the following way, similar to
    -MESSAGE_SUBST (see Section 13.5, "Optional files"):
    +deinstall
     
    -PLIST_SUBST+=   SOMEVAR="somevalue"
    +    This target does a pkg_delete(1) in the current directory, effectively
    +    de-installing the package. The following variables can be used to tune the
    +    behaviour:
     
    -This replaces all occurrences of "${SOMEVAR}" in the PLIST with "somevalue".
    +    PKG_VERBOSE
     
    -The PLIST_VARS variable can be used to simplify the common case of
    -conditionally including some PLIST entries. It can be done by adding
    -PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
    -entry should be included. This will substitute "${PLIST.foo}" in the PLIST with
    -either """" or ""@comment "". For example, in Makefile:
    +        Add a "-v" to the pkg_delete(1) command.
     
    -PLIST_VARS+=    foo
    -.if condition
    -PLIST.foo=      yes
    -.else
    +    DEINSTALLDEPENDS
     
    -And then in PLIST:
    +        Remove all packages that require (depend on) the given package. This
    +        can be used to remove any packages that may have been pulled in by a
    +        given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
    +        pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding "-R
    +        " to the pkg_delete(1) command line.
     
    -@comment $NetBSD $
    -bin/bar
    -man/man1/bar.1
    -${PLIST.foo}bin/foo
    -${PLIST.foo}man/man1/foo.1
    -${PLIST.foo}share/bar/foo.data
    +bin-install
     
    -An artificial space has been added between NetBSD and $, this is a workaround
    -here to prevent CVS expanding to the filename of the guide. When adding the RCS
    -ID the space should be ommited.
    +    Install a binary package from local disk and via FTP from a list of sites
    +    (see the BINPKG_SITES variable), and do a make package if no binary package
    +    is available anywhere. The arguments given to pkg_add can be set via
    +    BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
     
    -15.5. Man page compression
    +install-clean
     
    -Man pages should be installed in compressed form if MANZ is set (in
    -bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
    -suffix ".gz" is appended/removed automatically for man pages according to MANZ
    -and MANCOMPRESSED being set or not, see above for details. This modification of
    -the PLIST file is done on a copy of it, not PLIST itself.
    +    This target removes the state files for the "install" and later phases so
    +    that the "install" target may be re-invoked. This can be used after editing
    +    the PLIST to install the package without rebuilding it.
     
    -15.6. Changing PLIST source with PLIST_SRC
    +build-clean
     
    -To use one or more files as source for the PLIST used in generating the binary
    -package, set the variable PLIST_SRC to the names of that file(s). The files are
    -later concatenated using cat(1), and the order of things is important. The
    -default for PLIST_SRC is ${PKGDIR}/PLIST.
    +    This target removes the state files for the "build" and later phases so
    +    that the "build" target may be re-invoked.
     
    -15.7. Platform-specific and differing PLISTs
    +update
     
    -Some packages decide to install a different set of files based on the operating
    -system being used. These differences can be automatically handled by using the
    -following files:
    +    This target causes the current package to be updated to the latest version.
    +    The package and all depending packages first get de-installed, then current
    +    versions of the corresponding packages get compiled and installed. This is
    +    similar to manually noting which packages are currently installed, then
    +    performing a series of make deinstall and make install (or whatever
    +    UPDATE_TARGET is set to) for these packages.
     
    -  * PLIST.common
    +    You can use the "update" target to resume package updating in case a
    +    previous make update was interrupted for some reason. However, in this
    +    case, make sure you don't call make clean or otherwise remove the list of
    +    dependent packages in WRKDIR. Otherwise, you lose the ability to
    +    automatically update the current package along with the dependent packages
    +    you have installed.
     
    -  * PLIST.${OPSYS}
    +    Resuming an interrupted make update will only work as long as the package
    +    tree remains unchanged. If the source code for one of the packages to be
    +    updated has been changed, resuming make update will most certainly fail!
     
    -  * PLIST.${MACHINE_ARCH}
    +    The following variables can be used either on the command line or in
    +    mk.conf to alter the behaviour of make update:
     
    -  * PLIST.${OPSYS}-${MACHINE_ARCH}
    +    UPDATE_TARGET
     
    -  * PLIST.common_end
    +        Install target to recursively use for the updated package and the
    +        dependent packages. Defaults to DEPENDS_TARGET if set, "install"
    +        otherwise for make update. Other good targets are "package" or "
    +        bin-install". Do not set this to "update" or you will get stuck in an
    +        endless loop!
     
    -15.8. Build-specific PLISTs
    +    NOCLEAN
     
    -Some packages decide to generate hard-to-guess file names during installation
    -that are hard to wire down.
    +        Don't clean up after updating. Useful if you want to leave the work
    +        sources of the updated packages around for inspection or other
    +        purposes. Be sure you eventually clean up the source tree (see the "
    +        clean-update" target below) or you may run into troubles with old
    +        source code still lying around on your next make or make update.
     
    -In such cases, you can set the GENERATE_PLIST variable to shell code terminated
    -(with a semicolon) that will output PLIST entries which will be appended to the
    -PLIST
    +    REINSTALL
     
    -You can find one example in editors/xemacs:
    +        Deinstall each package before installing (making DEPENDS_TARGET). This
    +        may be necessary if the "clean-update" target (see below) was called
    +        after interrupting a running make update.
     
    -GENERATE_PLIST+=        ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
    +    DEPENDS_TARGET
     
    -which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
    +        Allows you to disable recursion and hardcode the target for packages.
    +        The default is "update" for the update target, facilitating a recursive
    +        update of prerequisite packages. Only set DEPENDS_TARGET if you want to
    +        disable recursive updates. Use UPDATE_TARGET instead to just set a
    +        specific target for each package to be installed during make update
    +        (see above).
     
    -15.9. Sharing directories between packages
    +clean-update
     
    -A "shared directory" is a directory where multiple (and unrelated) packages
    -install files. These directories were problematic because you had to add
    -special tricks in the PLIST to conditionally remove them, or have some
    -centralized package handle them.
    +    Clean the source tree for all packages that would get updated if make
    +    update was called from the current directory. This target should not be
    +    used if the current package (or any of its depending packages) have already
    +    been de-installed (e.g., after calling make update) or you may lose some
    +    packages you intended to update. As a rule of thumb: only use this target 
    +    before the first time you run make update and only if you have a dirty
    +    package tree (e.g., if you used NOCLEAN).
     
    -In pkgsrc, it is now easy: Each package should create directories and install
    -files as needed; pkg_delete will remove any directories left empty after
    -uninstalling a package.
    +    If you are unsure about whether your tree is clean, you can either perform
    +    a make clean at the top of the tree, or use the following sequence of
    +    commands from the directory of the package you want to update (before
    +    running make update for the first time, otherwise you lose all the packages
    +    you wanted to update!):
     
    -If a package needs an empty directory to work, create the directory during
    -installation as usual, and also add an entry to the PLIST:
    +    # make clean-update
    +    # make clean CLEANDEPENDS=YES
    +    # make update
     
    -@pkgdir path/to/empty/directory
     
    -or take a look at MAKE_DIRS and OWN_DIRS.
    +    The following variables can be used either on the command line or in
    +    mk.conf to alter the behaviour of make clean-update:
    +
    +    CLEAR_DIRLIST
    +
    +        After make clean, do not reconstruct the list of directories to update
    +        for this package. Only use this if make update successfully installed
    +        all packages you wanted to update. Normally, this is done automatically
    +        on make update, but may have been suppressed by the NOCLEAN variable
    +        (see above).
     
    -Chapter 16. Buildlink methodology
    +replace
     
    -Table of Contents
    +    Update the installation of the current package. This differs from update in
    +    that it does not replace dependent packages. You will need to install
    +    pkgtools/pkg_tarup for this target to work.
     
    -16.1. Converting packages to use buildlink3
    -16.2. Writing buildlink3.mk files
    +    Be careful when using this target! There are no guarantees that dependent
    +    packages will still work, in particular they will most certainly break if
    +    you make replace a library package whose shared library major version
    +    changed between your installed version and the new one. For this reason,
    +    this target is not officially supported and only recommended for advanced
    +    users.
     
    -    16.2.1. Anatomy of a buildlink3.mk file
    -    16.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
    -        buildlink3.mk files
    +info
     
    -16.3. Writing builtin.mk files
    +    This target invokes pkg_info(1) for the current package. You can use this
    +    to check which version of a package is installed.
     
    -    16.3.1. Anatomy of a builtin.mk file
    -    16.3.2. Global preferences for native or pkgsrc software
    +index
     
    -Buildlink is a framework in pkgsrc that controls what headers and libraries are
    -seen by a package's configure and build processes. This is implemented in a two
    -step process:
    +    This is a top-level command, i.e. it should be used in the pkgsrc
    +    directory. It creates a database of all packages in the local pkgsrc tree,
    +    including dependencies, comment, maintainer, and some other useful
    +    information. Individual entries are created by running make describe in the
    +    packages' directories. This index file is saved as pkgsrc/INDEX. It can be
    +    displayed in verbose format by running make print-index. You can search in
    +    it with make search key=something. You can extract a list of all packages
    +    that depend on a particular one by running make show-deps PKG=somepackage.
     
    - 1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
    -    default is a subdirectory of WRKDIR.
    +    Running this command takes a very long time, some hours even on fast
    +    machines!
     
    - 2. Create wrapper scripts that are used in place of the normal compiler tools
    -    that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
    -    references to BUILDLINK_DIR. The wrapper scripts also make native compiler
    -    on some operating systems look like GCC, so that packages that expect GCC
    -    won't require modifications to build with those native compilers.
    +readme
     
    -This normalizes the environment in which a package is built so that the package
    -may be built consistently despite what other software may be installed. Please
    -note that the normal system header and library paths, e.g. /usr/include, /usr/
    -lib, etc., are always searched -- buildlink3 is designed to insulate the
    -package build from non-system-supplied software.
    +    This target generates a README.html file, which can be viewed using a
    +    browser such as www/firefox or www/links. The generated files contain
    +    references to any packages which are in the PACKAGES directory on the local
    +    host. The generated files can be made to refer to URLs based on
    +    FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
    +    README.html files which pointed to binary packages on the local machine, in
    +    the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
    +    FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
    +    subdirectories will be searched for all the binary packages.
     
    -16.1. Converting packages to use buildlink3
    +    The target can be run at the toplevel or in category directories, in which
    +    case it descends recursively.
     
    -The process of converting packages to use the buildlink3 framework ("bl3ifying"
    -) is fairly straightforward. The things to keep in mind are:
    +readme-all
     
    - 1. Ensure that the build always calls the wrapper scripts instead of the
    -    actual toolchain. Some packages are tricky, and the only way to know for
    -    sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
    -    invoked.
    +    This is a top-level command, run it in pkgsrc. Use this target to create a
    +    file README-all.html which contains a list of all packages currently
    +    available in the NetBSD Packages Collection, together with the category
    +    they belong to and a short description. This file is compiled from the
    +    pkgsrc/*/README.html files, so be sure to run this after a make readme.
     
    - 2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
    -    standalone shells, etc., because the code to symlink files into $
    -    {BUILDLINK_DIR} looks for files relative to "pkg_info -qp pkgname".
    +cdrom-readme
     
    - 3. Remember that only the buildlink3.mk files that you list in a package's
    -    Makefile are added as dependencies for that package.
    +    This is very much the same as the "readme" target (see above), but is to be
    +    used when generating a pkgsrc tree to be written to a CD-ROM. This target
    +    also produces README.html files, and can be made to refer to URLs based on
    +    CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
     
    -If a dependency on a particular package is required for its libraries and
    -headers, then we replace:
    +show-distfiles
     
    -DEPENDS+=       foo>=1.1.0:../../category/foo
    +    This target shows which distfiles and patchfiles are needed to build the
    +    package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
    +    patches/*).
     
    -with
    +show-downlevel
     
    -.include "../../category/foo/buildlink3.mk"
    +    This target shows nothing if the package is not installed. If a version of
    +    this package is installed, but is not the version provided in this version
    +    of pkgsrc, then a warning message is displayed. This target can be used to
    +    show which of your installed packages are downlevel, and so the old
    +    versions can be deleted, and the current ones added.
     
    -The buildlink3.mk files usually define the required dependencies. If you need a
    -newer version of the dependency when using buildlink3.mk files, then you can
    -define it in your Makefile; for example:
    +show-pkgsrc-dir
     
    -BUILDLINK_API_DEPENDS.foo+=   foo>=1.1.0
    -.include "../../category/foo/buildlink3.mk"
    +    This target shows the directory in the pkgsrc hierarchy from which the
    +    package can be built and installed. This may not be the same directory as
    +    the one from which the package was installed. This target is intended to be
    +    used by people who may wish to upgrade many packages on a single host, and
    +    can be invoked from the top-level pkgsrc Makefile by using the "
    +    show-host-specific-pkgs" target.
     
    -There are several buildlink3.mk files in pkgsrc/mk that handle special package
    -issues:
    +show-installed-depends
     
    -  * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
    -    implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
    +    This target shows which installed packages match the current package's
    +    DEPENDS. Useful if out of date dependencies are causing build problems.
     
    -  * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
    -    this will take care to install the devel/ncurses package.
    +print-build-depends-list
     
    -  * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
    -    a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
    -    implementation.
    +    This target shows the list of packages that the current package depends on
    +    for building.
     
    -  * motif.buildlink3.mk checks for a system-provided Motif installation or adds
    -    a dependency on x11/lesstif or x11/motif. The user can set MOTIF_TYPE to "
    -    dt", "lesstif" or "motif" to choose which Motif version will be used.
    +print-run-depends-list
     
    -  * readline.buildlink3.mk checks for a system-provided GNU readline or
    -    editline (libedit) installation, or adds a dependency on devel/readline,
    -    devel/editline. The user can set READLINE_DEFAULT to choose readline
    -    implementation. If your package really needs GNU readline library, its
    -    Makefile should include devel/readline/buildlink3.mk instead of
    -    readline.buildlink3.mk.
    +    This target shows the list of packages that the current package depends on
    +    for running.
     
    -  * oss.buildlink3.mk defines several variables that may be used by packages
    -    that use the Open Sound System (OSS) API.
    +check-shlibs
     
    -  * pgsql.buildlink3.mk will accept any of the Postgres versions in the
    -    variable PGSQL_VERSIONS_ACCEPTED and default to the version
    -    PGSQL_VERSION_DEFAULT. See the file for more information.
    +    After a package is installed, check all its binaries and (on ELF platforms)
    +    shared libraries to see if they find the shared libs they need. Run by
    +    default if PKG_DEVELOPER is set in mk.conf.
     
    -  * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
    -    pthreads or adds a dependency on devel/pth as needed.
    +print-PLIST
     
    -  * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
    -    widgets library.
    +    After a "make install" from a new or upgraded pkg, this prints out an
    +    attempt to generate a new PLIST from a find -newer work/.extract_done. An
    +    attempt is made to care for shared libs etc., but it is strongly
    +    recommended to review the result before putting it into PLIST. On upgrades,
    +    it's useful to diff the output of this command against an already existing
    +    PLIST file.
     
    -The comments in those buildlink3.mk files provide a more complete description
    -of how to use them properly.
    +    If the package installs files via tar(1) or other methods that don't update
    +    file access times, be sure to add these files manually to your PLIST, as
    +    the "find -newer" command used by this target won't catch them!
     
    -16.2. Writing buildlink3.mk files
    +    See Section 19.3, "Tweaking output of make print-PLIST" for more
    +    information on this target.
     
    -A package's buildlink3.mk file is included by Makefiles to indicate the need to
    -compile and link against header files and libraries provided by the package. A
    -buildlink3.mk file should always provide enough information to add the correct
    -type of dependency relationship and include any other buildlink3.mk files that
    -it needs to find headers and libraries that it needs in turn.
    +Chapter 14. Creating a new pkgsrc package from scratch
     
    -To generate an initial buildlink3.mk file for further editing, Rene Hexel's
    -pkgtools/createbuildlink package is highly recommended. For most packages, the
    -following command will generate a good starting point for buildlink3.mk files:
    +Table of Contents
     
    -% cd pkgsrc/category/pkgdir
    -% createbuildlink >buildlink3.mk
    +14.1. Common types of packages
     
    +    14.1.1. Perl modules
    +    14.1.2. Python modules and programs
    +    14.1.3. R packages
    +    14.1.4. TeXlive packages
     
    -16.2.1. Anatomy of a buildlink3.mk file
    +14.2. Examples
     
    -The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
    -tiff:
    +    14.2.1. How the www/nvu package came into pkgsrc
     
    -# $NetBSD: buildlink3.mk,v 1.16 2009/03/20 19:24:45 joerg Exp $
    +When you find a package that is not yet in pkgsrc, you most likely have a URL
    +from where you can download the source code. Starting with this URL, creating a
    +package involves only a few steps.
     
    -BUILDLINK_TREE+=        tiff
    + 1. In your mk.conf, set PKG_DEVELOPER=yes to enable the basic quality checks.
     
    -.if !defined(TIFF_BUILDLINK3_MK)
    -TIFF_BUILDLINK3_MK:=
    + 2. Install the package meta-pkgs/pkg_developer, which among others will
    +    install the utilities url2pkg, pkglint, pkgvi and mkpatches:
     
    -BUILDLINK_API_DEPENDS.tiff+=    tiff>=3.6.1
    -BUILDLINK_ABI_DEPENDS.tiff+=    tiff>=3.7.2nb1
    -BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
    +    $ cd /usr/pkgsrc
    +    $ (cd meta-pkgs/pkg_developer && bmake update)
     
    -.include "../../devel/zlib/buildlink3.mk"
    -.include "../../graphics/jpeg/buildlink3.mk"
    -.endif # TIFF_BUILDLINK3_MK
    + 3. Choose one of the top-level directories as the category in which you want
    +    to place your package. You can also create a directory of your own (maybe
    +    called local). In that category directory, create another directory for
    +    your package and change into it:
     
    -BUILDLINK_TREE+=        -tiff
    +    $ mkdir category/package
    +    $ cd category/package
     
    -The header and footer manipulate BUILDLINK_TREE, which is common across all
    -buildlink3.mk files and is used to track the dependency tree.
    + 4. Run the program url2pkg, which will ask you for a URL. Enter the URL of the
    +    distribution file (in most cases a .tar.gz file) and watch how the basic
    +    ingredients of your package are created automatically. The distribution
    +    file is extracted automatically to fill in some details in the Makefile
    +    that would otherwise have to be done manually:
     
    -The main section is protected from multiple inclusion and controls how the
    -dependency on pkg is added. Several important variables are set in the section:
    +    $ url2pkg https://www.example.org/packages/package-1.0.tar.gz
     
    -  * BUILDLINK_API_DEPENDS.pkg is the dependency version recorded in the
    -    installed package; this should always be set using += to ensure that we're
    -    appending to any pre-existing list of values. This variable should be set
    -    to the last version of the package that had an backwards-incompatible API
    -    change.
    + 5. Examine the extracted files to determine the dependencies of your package.
    +    Ideally, this is mentioned in some README file, but things may differ. For
    +    each of these dependencies, look where it exists in pkgsrc, and if there is
    +    a file called buildlink3.mk in that directory, add a line to your package
    +    Makefile which includes that file just before the last line. If the
    +    buildlink3.mk file does not exist, it must be created first. The
    +    buildlink3.mk file makes sure that the package's include files and
    +    libraries are provided.
     
    -  * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
    +    If you just need binaries from a package, add a DEPENDS line to the
    +    Makefile, which specifies the version of the dependency and where it can be
    +    found in pkgsrc. This line should be placed in the third paragraph. If the
    +    dependency is only needed for building the package, but not when using it,
    +    use TOOL_DEPENDS or BUILD_DEPENDS instead of DEPENDS. The difference
    +    between TOOL_DEPENDS and BUILD_DEPENDS occurs when cross-compiling:
    +    TOOL_DEPENDS are native packages, i.e. packages for the architecture where
    +    the package is built; BUILD_DEPENDS are target packages, i.e. packages for
    +    the architecture for which the package is built. There is also
    +    TEST_DEPENDS, which is used to specify a dependency used only for testing
    +    the resulting package built, using the upstream project's included test
    +    suite. Your package may then look like this:
     
    -  * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
    -    BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
    -    is selected by setting BUILDLINK_DEPMETHOD.pkg to "build". By default, the
    -    full dependency is used.
    +    [...]
     
    -  * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
    -    of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
    -    library search paths. These default to "include" and "lib" respectively.
    +    TOOL_DEPENDS+=  libxslt-[0-9]*:../../textproc/libxslt
    +    DEPENDS+=       screen-[0-9]*:../../misc/screen
    +    DEPENDS+=       screen>=4.0:../../misc/screen
     
    -  * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
    -    to add to CPPFLAGS, which are passed on to the configure and build phases.
    -    The "-I" option should be avoided and instead be handled using
    -    BUILDLINK_INCDIRS.pkg as above.
    +    [...]
     
    -The following variables are all optionally defined within this second section
    -(protected against multiple inclusion) and control which package files are
    -symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
    -symlinking:
    +    .include "../../category/package/buildlink3.mk"
    +    .include "../../devel/glib2/buildlink3.mk"
    +    .include "../../mk/bsd.pkg.mk"
     
    -  * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
    -    {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
    -    *.h.
    + 6. Run pkglint to see what things still need to be done to make your package a
    +    "good" one. If you don't know what pkglint's warnings want to tell you, try
    +    pkglint --explain or pkglint -e, which outputs additional explanations.
     
    -  * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
    -    to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
    -    resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
    -    takes the +CONTENTS of a pkg and filters it through $
    -    {BUILDLINK_CONTENTS_FILTER.pkg}.
    + 7. In many cases the package is not yet ready to build. You can find
    +    instructions for the most common cases in the next section, Section 14.1,
    +    "Common types of packages". After you have followed the instructions over
    +    there, you can hopefully continue here.
     
    -  * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
    -    filters +CONTENTS input into a list of files relative to $
    -    {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
    -    outputs the contents of the include and lib directories in the package
    -    +CONTENTS.
    + 8. Run bmake clean to clean the working directory from the extracted files.
    +    Besides these files, a lot of cache files and other system information has
    +    been saved in the working directory, which may become wrong after you
    +    edited the Makefile.
     
    -  * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
    -    used to transform the name of the source filename into a destination
    -    filename, e.g. -e "s|/curses.h|/ncurses.h|g".
    + 9. Now, run bmake to build the package. For the various things that can go
    +    wrong in this phase, consult Chapter 21, Making your package work.
     
    -This section can additionally include any buildlink3.mk needed for pkg's
    -library dependencies. Including these buildlink3.mk files means that the
    -headers and libraries for these dependencies are also symlinked into $
    -{BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
    -are only added for directly include buildlink3.mk files.
    +    If the extracted files from the package need to be fixed, run multiple
    +    rounds of these commands:
     
    -When providing a buildlink3.mk and including other buildlink3.mk files in it,
    -please only add necessary ones, i.e., those whose libraries or header files are
    -automatically exposed when the package is use.
    +    $ make
    +    $ pkgvi ${WRKSRC}/some/file/that/does/not/compile
    +    $ mkpatches
    +    $ make mps
    +    $ make clean
     
    -In particular, if only an executable (bin/foo) is linked against a library,
    -that library does not need to be propagated in the buildlink3.mk file.
    +10. When the package builds fine, the next step is to install the package. Run 
    +    bmake install and hope that everything works.
     
    -The following steps should help you decide if a buildlink3.mk file needs to be
    -included:
    +11. Up to now, the file PLIST, which contains a list of the files that are
    +    installed by the package, is nearly empty. Run bmake print-PLIST >PLIST to
    +    generate a probably correct list. Check the file using your preferred text
    +    editor to see if the list of files looks plausible.
     
    -  * Look at the installed header files: What headers do they include? The
    -    packages providing these files must be buildlinked.
    +12. Run pkglint again to see if the generated PLIST contains garbage or not.
     
    -  * Run ldd on all installed libraries and look against what other libraries
    -    they link. Some of the packages providing these probably need to be
    -    buildlinked; however, it's not automatic, since e.g. GTK on some systems
    -    pulls in the X libraries, so they will show up in the ldd output, while on
    -    others (like OS X) it won't. ldd output can thus only be used as a hint.
    +13. When you ran bmake install, the package had been registered in the database
    +    of installed files, but with an empty list of files. To fix this, run bmake
    +    deinstall and bmake install again. Now the package is registered with the
    +    list of files from PLIST.
     
    -16.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
    -buildlink3.mk files
    +14. Run bmake package to create a binary package from the set of installed
    +    files.
     
    -Both variables set lower bounds for a version of this package. The two
    -variables differ in that one describes source compatibility (API) and the other
    -binary compatibility (ABI). The difference is that a change in the API breaks
    -compilation of programs while changes in the ABI stop compiled programs from
    -running.
    -
    -The BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk should be changed
    -very rarely. (One possible scenario: If all packages using this package need a
    -higher version than defined in the buildlink3.mk, BUILDLINK_API_DEPENDS.pkg
    -could be updated to that higher version.)
    -
    -On the other hand, changes to BUILDLINK_ABI_DEPENDS.pkg are more common. The
    -variable will need to be updated every time the major version of one of its
    -shared libraries is changed, or any other change where a binary built against
    -the previous version of the package will not run against the new version any
    -longer.
    -
    -In such a case, the package's BUILDLINK_ABI_DEPENDS.pkg must be increased to
    -require the new package version. Then the PKGREVISION of all packages that
    -depend on this package need to be increased, and if they have buildlink3.mk
    -files, their BUILDLINK_ABI_DEPENDS.pkg must be increased to the new version as
    -well. This is required so that a package will pull in the versions of the
    -packages that use the new ABI and that the packages' PKGREVISIONs uniquely
    -identify the packages built against the new ABI. The pkgtools/revbump package
    -can help with these updates.
    +15. Run bmake clean update to run everything from above again in a single step,
    +    making sure that the PLIST is correct and the whole package is created as
    +    intended.
     
    -See Section 21.1.5, "Handling dependencies" for more information about
    -dependencies on other packages, including the BUILDLINK_API_DEPENDS
    -definitions.
    +16. Run pkglint to see if there's anything left to do.
     
    -Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
    -BUILDLINK_ABI_DEPENDS.pkg in a buildlink3.mk file as we don't want to cause
    -unneeded package deletions and rebuilds. In many cases, new versions of
    -packages work just fine with older dependencies.
    +17. Commit the package to pkgsrc-wip or main pkgsrc; see Chapter 23, Submitting
    +    and Committing.
     
    -Also it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
    -BUILDLINK_API_DEPENDS.pkg.
    +14.1. Common types of packages
     
    -16.3. Writing builtin.mk files
    +14.1.1. Perl modules
     
    -Some packages in pkgsrc install headers and libraries that coincide with
    -headers and libraries present in the base system. Aside from a buildlink3.mk
    -file, these packages should also include a builtin.mk file that includes the
    -necessary checks to decide whether using the built-in software or the pkgsrc
    -software is appropriate.
    +Simple Perl modules are handled automatically by url2pkg, including
    +dependencies.
     
    -The only requirements of a builtin.mk file for pkg are:
    +14.1.2. Python modules and programs
     
    - 1. It should set USE_BUILTIN.pkg to either "yes" or "no" after it is included.
    +Python modules and programs packages are easily created using a set of
    +predefined variables.
     
    - 2. It should not override any USE_BUILTIN.pkg which is already set before the
    -    builtin.mk file is included.
    +If some Python versions are not supported by the software, set the
    +PYTHON_VERSIONS_INCOMPATIBLE variable to the Python versions that are not
    +supported, e.g.
     
    - 3. It should be written to allow multiple inclusion. This is very important
    -    and takes careful attention to Makefile coding.
    +PYTHON_VERSIONS_INCOMPATIBLE=       27
     
    -16.3.1. Anatomy of a builtin.mk file
    +If the packaged software is a Python module, include one of ../../lang/python/
    +egg.mk, ../../lang/python/distutils.mk, or ../../lang/python/extension.mk.
     
    -The following is the recommended template for builtin.mk files:
    +Most Python packages use either "distutils" or easy-setup/setuptools ("eggs").
    +If the packaged software is using setuptools, you only need to include "../../
    +lang/python/egg.mk". Otherwise, if the software uses "distutils", include "..
    +/../lang/python/distutils.mk", so pkgsrc will use this framework. "distutils"
    +uses a script called setup.py; if the "distutils" driver is not called
    +setup.py, set the PYSETUP variable to the name of the script.
     
    -.if !defined(IS_BUILTIN.foo)
    -#
    -# IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
    -# genuinely exists in the system or not.
    -#
    -IS_BUILTIN.foo?=        no
    +Either way, the package directory should be called "py-software" and PKGNAME
    +should be set to "${PYPKGPREFIX}-${DISTNAME}", e.g.
     
    -# BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
    -# version can be determined.
    -#
    -.  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
    -BUILTIN_PKG.foo?=       foo-1.0
    -.  endif
    -.endif  # IS_BUILTIN.foo
    +DISTNAME=   foopymodule-1.2.10
    +PKGNAME=    ${PYPKGPREFIX}-${DISTNAME}
     
    -.if !defined(USE_BUILTIN.foo)
    -USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
    -.  if defined(BUILTIN_PKG.foo)
    -.    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
    -.      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
    -USE_BUILTIN.foo!=                                                       \
    -        ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}            \
    -        && ${ECHO} "yes" || ${ECHO} "no"
    -.      endif
    -.    endfor
    -.  endif
    -.endif  # USE_BUILTIN.foo
    +If it is an application, include "../../lang/python/application.mk". In order
    +to correctly set the path to the Python interpreter, use the REPLACE_PYTHON
    +variable and set it to the list of files (paths relative to WRKSRC) that must
    +be corrected. For example:
     
    -CHECK_BUILTIN.foo?=     no
    -.if !empty(CHECK_BUILTIN.foo:M[nN][oO])
    -#
    -# Here we place code that depends on whether USE_BUILTIN.foo is set to
    -# "yes" or "no".
    -#
    -.endif  # CHECK_BUILTIN.foo
    +REPLACE_PYTHON=   *.py
     
    -The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
    -base system. This should not be a base system software with similar
    -functionality to pkg; it should only be "yes" if the actual package is included
    -as part of the base system. This variable is only used internally within the
    -builtin.mk file.
    +Some Python modules have separate distributions for Python-2.x and Python-3.x
    +support. In pkgsrc this is handled by the versioned_dependencies.mk file. Set
    +PYTHON_VERSIONED_DEPENDENCIES to the list of packages that should be depended
    +upon and include "../../lang/python/versioned_dependencies.mk", then the pkgsrc
    +infrastructure will depend on the appropriate package version. For example:
     
    -The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
    -system if it exists (if IS_BUILTIN.pkg is "yes"). This variable is only used
    -internally within the builtin.mk file.
    +PYTHON_VERSIONED_DEPENDENCIES=dialog
     
    -The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
    -The code in this section must make the determination whether the built-in
    -software is adequate to satisfy the dependencies listed in
    -BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
    -against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg 
    -must be set to the correct value by the end of the builtin.mk file. Note that
    -USE_BUILTIN.pkg may be "yes" even if IS_BUILTIN.pkg is "no" because we may make
    -the determination that the built-in version of the software is similar enough
    -to be used as a replacement.
    +Look inside versioned_dependencies.mk for a list of supported packages.
     
    -The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
    -the value of USE_BUILTIN.pkg set in the previous section. This typically
    -includes, e.g., adding additional dependency restrictions and listing
    -additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
    +14.1.3. R packages
     
    -16.3.2. Global preferences for native or pkgsrc software
    +Simple R packages from CRAN are handled automatically by R2pkg, which is
    +available in pkgtools/R2pkg. Individual packages (and optionally their
    +dependencies) may be created and updated. R packages generally follow the same
    +form, and most of the relevant information needed is contained in a DESCRIPTION
    +file as part of each R package on CRAN. Consequently, R2pkg downloads that
    +information and creates or updates a package in the canonical form. The
    +resulting package should be reviewed for correctness.
     
    -When building packages, it's possible to choose whether to set a global
    -preference for using either the built-in (native) version or the pkgsrc version
    -of software to satisfy a dependency. This is controlled by setting
    -PREFER_PKGSRC and PREFER_NATIVE. These variables take values of either "yes", "
    -no", or a list of packages. PREFER_PKGSRC tells pkgsrc to use the pkgsrc
    -versions of software, while PREFER_NATIVE tells pkgsrc to use the built-in
    -versions. Preferences are determined by the most specific instance of the
    -package in either PREFER_PKGSRC or PREFER_NATIVE. If a package is specified in
    -neither or in both variables, then PREFER_PKGSRC has precedence over
    -PREFER_NATIVE. For example, to require using pkgsrc versions of software for
    -all but the most basic bits on a NetBSD system, you can set:
    +14.1.4. TeXlive packages
     
    -PREFER_PKGSRC=  yes
    -PREFER_NATIVE=  getopt skey tcp_wrappers
    +TeXlive packages from CTAN are handled automatically by texlive2pkg, which is
    +available in pkgtools/texlive2pkg.
     
    -A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
    -it is simply ignored in that list.
    +If the TeXlive package name is not known, it may be useful to search CTAN. A "
    +Contained in" field on the package page typically identifies the basename of
    +the package file in the TeXlive archive.
     
    -Setting PREFER_NATIVE should be performed straight after bootstrap and
    -PREFER_PKGSRC during bootstrap. Switching between settings globally at a later
    -date can introduce complications with dependency resolution. This is caused by
    -packages built with the opposite preference being installed alongside each
    -other.
    +If the TeXlive package name is known, download the files from the TeXlive
    +archive. For package foo, you will need to download foo.tar.xz. Most TeXlive
    +packages also have associated documentation packages, so download
    +foo.doc.tar.xz at the same time. These files should be placed in the
    +appropriate category directory, which is often but not always print. Then run
    +the following command in the category directory.
     
    -# ./bootstrap --prefer-pkgsrc yes
    +texlive2pkg foo.tar.xz foo.doc.tar.xz
    +
    +This will create two packages, tex-foo and tex-foo-doc. Be sure to check that
    +both packages are correct.
     
    -Chapter 17. The pkginstall framework
    +Finally, CTAN currently does not include version information in package
    +filenames and changes their contents periodically when updates occur.
    +Consequently, pkgsrc avoids downloading distfiles directly from CTAN and
    +instead relies on the pkgsrc archives. For each new or updated TeXlive package,
    +e.g., the main one and the corresponding documentation, upload the distfiles
    +with the following command in each package directory.
     
    -Table of Contents
    +make upload-distfiles
    +
    +14.2. Examples
     
    -17.1. Files and directories outside the installation prefix
    +14.2.1. How the www/nvu package came into pkgsrc
     
    -    17.1.1. Directory manipulation
    -    17.1.2. File manipulation
    +14.2.1.1. The initial package
     
    -17.2. Configuration files
    +Looking at the file pkgsrc/doc/TODO, I saw that the "nvu" package has not yet
    +been imported into pkgsrc. As the description says it has to do with the web,
    +the obvious choice for the category is "www".
     
    -    17.2.1. How PKG_SYSCONFDIR is set
    -    17.2.2. Telling the software where configuration files are
    -    17.2.3. Patching installations
    -    17.2.4. Disabling handling of configuration files
    +$ mkdir www/nvu
    +$ cd www/nvu
     
    -17.3. System startup scripts
    +The web site says that the sources are available as a tar file, so I fed that
    +URL to the url2pkg program:
     
    -    17.3.1. Disabling handling of system startup scripts
    +$ url2pkg http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
     
    -17.4. System users and groups
    -17.5. System shells
    +My editor popped up, and I added a PKGNAME line below the DISTNAME line, as the
    +package name should not have the word "sources" in it. I also filled in the
    +MAINTAINER, HOMEPAGE and COMMENT fields. Then the package Makefile looked like
    +that:
     
    -    17.5.1. Disabling shell registration
    +# $NetBSD $
    +#
     
    -17.6. Fonts
    +DISTNAME=       nvu-1.0-sources
    +PKGNAME=        nvu-1.0
    +CATEGORIES=     www
    +MASTER_SITES=   http://cvs.nvu.com/download/
    +EXTRACT_SUFX=   .tar.bz2
     
    -    17.6.1. Disabling automatic update of the fonts databases
    +MAINTAINER=     rillig@NetBSD.org
    +HOMEPAGE=       http://cvs.nvu.com/
    +COMMENT=        Web Authoring System
     
    -This chapter describes the framework known as pkginstall, whose key features
    -are:
    +# url2pkg-marker (please do not remove this line.)
    +.include "../../mk/bsd.pkg.mk"
     
    -  * Generic installation and manipulation of directories and files outside the
    -    pkgsrc-handled tree, LOCALBASE.
    +On the first line of output above, an artificial space has been added between
    +NetBSD and $, this is a workaround to prevent CVS expanding to the filename of
    +the guide.
     
    -  * Automatic handling of configuration files during installation, provided
    -    that packages are correctly designed.
    +Then, I quit the editor and watched pkgsrc downloading a large source archive:
     
    -  * Generation and installation of system startup scripts.
    +url2pkg> Running "make makesum" ...
    +=> Required installed package digest>=20010302: digest-20060826 found
    +=> Fetching nvu-1.0-sources.tar.bz2
    +Requesting http://cvs.nvu.com/download/nvu-1.0-sources.tar.bz2
    +100% |*************************************| 28992 KB  150.77 KB/s00:00 ETA
    +29687976 bytes retrieved in 03:12 (150.77 KB/s)
    +url2pkg> Running "make extract" ...
    +=> Required installed package digest>=20010302: digest-20060826 found
    +=> Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
    +=> Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
    +work.bacc -> /tmp/roland/pkgsrc/www/nvu/work.bacc
    +===> Installing dependencies for nvu-1.0
    +===> Overriding tools for nvu-1.0
    +===> Extracting for nvu-1.0
    +url2pkg> Adjusting the Makefile.
     
    -  * Registration of system users and groups.
    +Remember to correct CATEGORIES, HOMEPAGE, COMMENT, and DESCR when you're done!
     
    -  * Registration of system shells.
    +Good luck! (See pkgsrc/doc/pkgsrc.txt for some more help :-)
     
    -  * Automatic updating of fonts databases.
    +14.2.1.2. Fixing all kinds of problems to make the package work
     
    -The following sections inspect each of the above points in detail.
    +Now that the package has been extracted, let's see what's inside it. The
    +package has a README.txt, but that only says something about mozilla, so it's
    +probably useless for seeing what dependencies this package has. But since there
    +is a GNU configure script in the package, let's hope that it will complain
    +about everything it needs.
     
    -You may be thinking that many of the things described here could be easily done
    -with simple code in the package's post-installation target (post-install). This
    -is incorrect, as the code in them is only executed when building from source.
    -Machines using binary packages could not benefit from it at all (as the code
    -itself could be unavailable). Therefore, the only way to achieve any of the
    -items described above is by means of the installation scripts, which are
    -automatically generated by pkginstall.
    +$ bmake
    +=> Required installed package digest>=20010302: digest-20060826 found
    +=> Checksum SHA1 OK for nvu-1.0-sources.tar.bz2
    +=> Checksum RMD160 OK for nvu-1.0-sources.tar.bz2
    +===> Patching for nvu-1.0
    +===> Creating toolchain wrappers for nvu-1.0
    +===> Configuring for nvu-1.0
    +[...]
    +configure: error: Perl 5.004 or higher is required.
    +[...]
    +WARNING: Please add USE_TOOLS+=perl to the package Makefile.
    +[...]
     
    -17.1. Files and directories outside the installation prefix
    +That worked quite well. So I opened the package Makefile in my editor, and
    +since it already has a USE_TOOLS line, I just appended "perl" to it. Since the
    +dependencies of the package have changed now, and since a perl wrapper is
    +automatically installed in the "tools" phase, I need to build the package from
    +scratch.
     
    -As you already know, the PLIST file holds a list of files and directories that
    -belong to a package. The names used in it are relative to the installation
    -prefix (${PREFIX}), which means that it cannot register files outside this
    -directory (absolute path names are not allowed). Despite this restriction, some
    -packages need to install files outside this location; e.g., under ${VARBASE} or
    -${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
    -installation time by using installation scripts.
    +$ bmake clean
    +===> Cleaning for nvu-1.0
    +$ bmake
    +[...]
    +*** /tmp/roland/pkgsrc/www/nvu/work.bacc/.tools/bin/make is not \
    +GNU Make.  You will not be able to build Mozilla without GNU Make.
    +[...]
     
    -The generic installation scripts are shell scripts that can contain arbitrary
    -code. The list of scripts to execute is taken from the INSTALL_FILE variable,
    -which defaults to INSTALL. A similar variable exists for package removal
    -(DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
    -commands, so they have the potential to create and manage files anywhere in the
    -file system.
    +So I added "gmake" to the USE_TOOLS line and tried again (from scratch).
     
    -Using these general installation files is not recommended, but may be needed in
    -some special cases. One reason for avoiding them is that the user has to trust
    -the packager that there is no unwanted or simply erroneous code included in the
    -installation script. Also, previously there were many similar scripts for the
    -same functionality, and fixing a common error involved finding and changing all
    -of them.
    +[...]
    +checking for GTK - version >= 1.2.0... no
    +*** Could not run GTK test program, checking why...
    +[...]
     
    -The pkginstall framework offers another, standardized way. It provides generic
    -scripts to abstract the manipulation of such files and directories based on
    -variables set in the package's Makefile. The rest of this section describes
    -these variables.
    +Now to the other dependencies. The first question is: Where is the GTK package
    +hidden in pkgsrc?
     
    -17.1.1. Directory manipulation
    +$ echo ../../*/gtk*
    +[many packages ...]
    +$ echo ../../*/gtk
    +../../x11/gtk
    +$ echo ../../*/gtk2
    +../../x11/gtk2
    +$ echo ../../*/gtk2/bui*
    +../../x11/gtk2/buildlink3.mk
     
    -The following variables can be set to request the creation of directories
    -anywhere in the file system:
    +The first try was definitely too broad. The second one had exactly one result,
    +which is very good. But there is one pitfall with GNOME packages. Before GNOME
    +2 had been released, there were already many GNOME 1 packages in pkgsrc. To be
    +able to continue to use these packages, the GNOME 2 packages were imported as
    +separate packages, and their names usually have a "2" appended. So I checked
    +whether this was the case here, and indeed it was.
     
    -  * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
    -    and should attempt to be destroyed by the installation scripts. The
    -    difference between the two is that the latter prompts the administrator to
    -    remove any directories that may be left after deinstallation (because they
    -    were not empty), while the former does not. Example:
    +Since the GTK2 package has a buildlink3.mk file, adding the dependency is very
    +easy. I just inserted an .include line before the last line of the package
    +Makefile, so that it now looks like this:
     
    -    MAKE_DIRS+=             ${VARBASE}/foo/private
    +[...]
    +.include "../../x11/gtk2/buildlink3.mk"
    +.include "../../mk/bsd.pkg.mk
     
    -  * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
    -    which directories should be created and should attempt to be destroyed by
    -    the installation scripts. Each tuple holds the following values, separated
    -    by spaces: the directory name, its owner, its group and its numerical mode.
    -    For example:
    +After another bmake clean && bmake, the answer was:
     
    -    MAKE_DIRS_PERMS+=       ${VARBASE}/foo/private \
    -                            ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
    +[...]
    +checking for gtk-config... /home/roland/pkg/bin/gtk-config
    +checking for GTK - version >= 1.2.0... no
    +*** Could not run GTK test program, checking why...
    +*** The test program failed to compile or link. See the file config.log for the
    +*** exact error that occured. This usually means GTK was incorrectly installed
    +*** or that you have moved GTK since it was installed. In the latter case, you
    +*** may want to edit the gtk-config script: /home/roland/pkg/bin/gtk-config
    +configure: error: Test for GTK failed.
    +[...]
     
    -    The difference between the two is exactly the same as their non-PERMS
    -    counterparts.
    +In this particular case, the assumption that "every package prefers GNOME 2"
    +had been wrong. The first of the lines above told me that this package really
    +wanted to have the GNOME 1 version of GTK. If the package had looked for GTK2,
    +it would have looked for pkg-config instead of gtk-config. So I changed the x11
    +/gtk2 to x11/gtk in the package Makefile, and tried again.
     
    -17.1.2. File manipulation
    +[...]
    +cc -o xpidl.o -c -DOSTYPE=\"NetBSD3\" -DOSARCH=\"NetBSD\"  [...]
    +In file included from xpidl.c:42:
    +xpidl.h:53:24: libIDL/IDL.h: No such file or directory
    +In file included from xpidl.c:42:
    +xpidl.h:132: error: parse error before "IDL_ns"
    +[...]
     
    -Creating non-empty files outside the installation prefix is tricky because the
    -PLIST forces all files to be inside it. To overcome this problem, the only
    -solution is to extract the file in the known place (i.e., inside the
    -installation prefix) and copy it to the appropriate location during
    -installation (done by the installation scripts generated by pkginstall). We
    -will call the former the master file in the following paragraphs, which
    -describe the variables that can be used to automatically and consistently
    -handle files outside the installation prefix:
    +The package still does not find all of its dependencies. Now the question is:
    +Which package provides the libIDL/IDL.h header file?
     
    -  * CONF_FILES and REQD_FILES are pairs of master and target files. During
    -    installation time, the master file is copied to the target one if and only
    -    if the latter does not exist. Upon deinstallation, the target file is
    -    removed provided that it was not modified by the installation.
    +$ echo ../../*/*idl*
    +../../devel/py-idle ../../wip/idled ../../x11/acidlaunch
    +$ echo ../../*/*IDL*
    +../../net/libIDL
     
    -    The difference between the two is that the latter prompts the administrator
    -    to remove any files that may be left after deinstallation (because they
    -    were not empty), while the former does not.
    +Let's take the one from the second try. So I included the ../../net/libIDL/
    +buildlink3.mk file and tried again. But the error didn't change. After digging
    +through some of the code, I concluded that the build process of the package was
    +broken and couldn't have ever worked, but since the Mozilla source tree is
    +quite large, I didn't want to fix it. So I added the following to the package
    +Makefile and tried again:
     
    -  * CONF_FILES_PERMS and REQD_FILES_PERMS contain tuples describing master
    -    files as well as their target locations. For each of them, it also
    -    specifies their owner, their group and their numeric permissions, in this
    -    order. For example:
    +CPPFLAGS+=              -I${BUILDLINK_PREFIX.libIDL}/include/libIDL-2.0
    +BUILDLINK_TRANSFORM+=   l:IDL:IDL-2
     
    -    REQD_FILES_PERMS+=      ${PREFIX}/share/somefile ${VARBASE}/somefile \
    -                            ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
    +The latter line is needed because the package expects the library libIDL.so,
    +but only libIDL-2.so is available. So I told the compiler wrapper to rewrite
    +that on the fly.
     
    -    The difference between the two is exactly the same as their non-PERMS
    -    counterparts.
    +The next problem was related to a recent change of the FreeType interface. I
    +looked up in www/seamonkey which patch files were relevant for this issue and
    +copied them to the patches directory. Then I retried, fixed the patches so that
    +they applied cleanly and retried again. This time, everything worked.
     
    -17.2. Configuration files
    +14.2.1.3. Installing the package
     
    -Configuration files are special in the sense that they are installed in their
    -own specific directory, PKG_SYSCONFDIR, and need special treatment during
    -installation (most of which is automated by pkginstall). The main concept you
    -must bear in mind is that files marked as configuration files are automatically
    -copied to the right place (somewhere inside PKG_SYSCONFDIR) during installation
    -if and only if they didn't exist before. Similarly, they will not be removed if
    -they have local modifications. This ensures that administrators never lose any
    -custom changes they may have made.
    +$ bmake CHECK_FILES=no install
    +[...]
    +$ bmake print-PLIST >PLIST
    +$ bmake deinstall
    +$ bmake install
     
    -17.2.1. How PKG_SYSCONFDIR is set
    +Chapter 15. Programming in Makefiles
     
    -As said before, the PKG_SYSCONFDIR variable specifies where configuration files
    -shall be installed. Its contents are set based upon the following variables:
    +Table of Contents
     
    -  * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
    -    etc although it may be overridden by the user to point to his preferred
    -    location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
    +15.1. Caveats
    +15.2. Makefile variables
     
    -  * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
    -    configuration files for the package being built shall be installed. The
    -    definition of this variable only makes sense in the package's Makefile
    -    (i.e., it is not user-customizable).
    +    15.2.1. Naming conventions
     
    -    As an example, consider the Apache package, www/apache24, which places its
    -    configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
    -    should be set in the package Makefile.
    +15.3. Code snippets
     
    -  * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
    -    package's configuration directory (if different from PKG_SYSCONFBASE). It
    -    defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
    +    15.3.1. Adding things to a list
    +    15.3.2. Echoing a string exactly as-is
    +    15.3.3. Passing CFLAGS to GNU configure scripts
    +    15.3.4. Handling possibly empty variables
     
    -  * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
    -    configuration files for the package identified by PKG_SYSCONFVAR's shall be
    -    placed.
    +Pkgsrc consists of many Makefile fragments, each of which forms a well-defined
    +part of the pkgsrc system. Using the make(1) system as a programming language
    +for a big system like pkgsrc requires some discipline to keep the code correct
    +and understandable.
     
    -Based on the above variables, pkginstall determines the value of
    -PKG_SYSCONFDIR, which is the only variable that can be used within a package to
    -refer to its configuration directory. The algorithm used to set its value is
    -basically the following:
    +The basic ingredients for Makefile programming are variables and shell
    +commands. Among these shell commands may even be more complex ones like awk(1)
    +programs. To make sure that every shell command runs as intended it is
    +necessary to quote all variables correctly when they are used.
     
    - 1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
    +This chapter describes some patterns that appear quite often in Makefiles,
    +including the pitfalls that come along with them.
     
    - 2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
    -    package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
    -    {PKG_SYSCONFSUBDIR}.
    +15.1. Caveats
     
    - 3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
    +  * When you are creating a file as a target of a rule, always write the data
    +    to a temporary file first and finally rename that file. Otherwise there
    +    might occur an error in the middle of generating the file, and when the
    +    user runs make(1) for the second time, the file exists and will not be
    +    regenerated properly. Example:
     
    -It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
    -OWN_DIRS. See Section 17.1.1, "Directory manipulation" what this means. This
    -does not apply to subdirectories of ${PKG_SYSCONFDIR}, they still have to be
    -created with OWN_DIRS or MAKE_DIRS.
    +    wrong:
    +            @echo "line 1" > ${.TARGET}
    +            @echo "line 2" >> ${.TARGET}
    +            @false
     
    -17.2.2. Telling the software where configuration files are
    +    correct:
    +            @echo "line 1" > ${.TARGET}.tmp
    +            @echo "line 2" >> ${.TARGET}.tmp
    +            @false
    +            @mv ${.TARGET}.tmp ${.TARGET}
     
    -Given that pkgsrc (and users!) expect configuration files to be in a known
    -place, you need to teach each package where it shall install its files. In some
    -cases you will have to patch the package Makefiles to achieve it. If you are
    -lucky, though, it may be as easy as passing an extra flag to the configuration
    -script; this is the case of GNU Autoconf- generated files:
    +    When you run make wrong twice, the file wrong will exist, although there
    +    was an error message in the first run. On the other hand, running make
    +    correct gives an error message twice, as expected.
     
    -CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
    +    You might remember that make(1) sometimes removes ${.TARGET} in case of
    +    error, but this only happens when it is interrupted, for example by
    +    pressing Ctrl+C. This does not happen when one of the commands fails (like
    +    false(1) above).
     
    -Note that this specifies where the package has to look for its configuration
    -files, not where they will be originally installed (although the difference is
    -never explicit, unfortunately).
    +15.2. Makefile variables
     
    -17.2.3. Patching installations
    +Makefile variables contain strings that can be processed using the five
    +operators =, +=, ?=, := and !=, which are described in the make(1) man page.
     
    -As said before, pkginstall automatically handles configuration files. This
    -means that the packages themselves must not touch the contents of $
    -{PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
    -will, out of the box, mess with the contents of that directory. So what is the
    -correct procedure to fix this issue?
    +When a variable's value is parsed from a Makefile, the hash character # and the
    +backslash character \ are handled specially. If a backslash is the last
    +character in a line, that backslash is removed from the line and the line
    +continues with the next line of the file.
     
    -You must teach the package (usually by manually patching it) to install any
    -configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
    -This way, the PLIST registers them and the administrator always has the
    -original copies available.
    +The # character starts a comment that reaches until the end of the line. To get
    +an actual # character, such as in a URL, write \# instead.
     
    -Once the required configuration files are in place (i.e., under the examples
    -hierarchy), the pkginstall framework can use them as master copies during the
    -package installation to update what is in ${PKG_SYSCONFDIR}. To achieve this,
    -the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
    -Section 17.1.2, "File manipulation" for information about their syntax and
    -their purpose. Here is an example, taken from the mail/mutt package:
    +The evaluation of variables either happens immediately or lazy. It happens
    +immediately when the variable occurs on the right-hand side of the := or the !=
    +operator, in a .if condition or a .for loop. In the other cases, it is
    +evaluated lazily.
     
    -EGDIR=        ${PREFIX}/share/doc/mutt/samples
    -CONF_FILES=   ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
    +Some of the modifiers split the string into words and then operate on the
    +words, others operate on the string as a whole. When a string is split into
    +words, double quotes and single quotes are interpreted as delimiters, just like
    +in sh(1).
     
    -Note that the EGDIR variable is specific to that package and has no meaning
    -outside it.
    +15.2.1. Naming conventions
     
    -17.2.4. Disabling handling of configuration files
    +  * All variable names starting with an underscore are reserved for use by the
    +    pkgsrc infrastructure. They shall not be used by packages.
     
    -The automatic copying of config files can be toggled by setting the environment
    -variable PKG_CONFIG prior to package installation.
    +  * In .for loops you should use lowercase variable names for the iteration
    +    variables.
     
    -17.3. System startup scripts
    +  * All list variables should have a plural name, such as PKG_OPTIONS or
    +    DISTFILES.
     
    -System startup scripts are special files because they must be installed in a
    -place known by the underlying OS, usually outside the installation prefix.
    -Therefore, the same rules described in Section 17.1, "Files and directories
    -outside the installation prefix" apply, and the same solutions can be used.
    -However, pkginstall provides a special mechanism to handle these files.
    +15.3. Code snippets
     
    -In order to provide system startup scripts, the package has to:
    +15.3.1. Adding things to a list
     
    - 1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
    -    Considering the print/cups package as an example, it has a cupsd.sh in its
    -    files directory.
    +When adding a string that possibly contains whitespace or quotes to a list
    +(example 1), it must be quoted using the :Q modifier.
     
    - 2. Tell pkginstall to handle it, appending the name of the script, without its
    -    extension, to the RCD_SCRIPTS variable. Continuing the previous example:
    +When adding another list to a list (example 2), it must not be quoted, since
    +its elements are already quoted.
     
    -    RCD_SCRIPTS+=   cupsd
    +STRING=         foo * bar `date`
    +LIST=           # empty
    +ANOTHER_LIST=   a=b c=d
     
    -Once this is done, pkginstall will do the following steps for each script in an
    -automated fashion:
    +LIST+=          ${STRING:Q}       # 1
    +LIST+=          ${ANOTHER_LIST}   # 2
     
    - 1. Process the file found in the files directory applying all the
    -    substitutions described in the FILES_SUBST variable.
    +15.3.2. Echoing a string exactly as-is
     
    - 2. Copy the script from the files directory to the examples hierarchy, $
    -    {PREFIX}/share/examples/rc.d/. Note that this master file must be
    -    explicitly registered in the PLIST.
    +Echoing a string containing special characters needs special work.
     
    - 3. Add code to the installation scripts to copy the startup script from the
    -    examples hierarchy into the system-wide startup scripts directory.
    +STRING=         foo bar <    > * `date` $$HOME ' "
    +EXAMPLE_ENV=    string=${STRING:Q} x=multiple\ quoted\ words
     
    -17.3.1. Disabling handling of system startup scripts
    +all:
    +        echo ${STRING}                  # 1
    +        echo ${STRING:Q}                # 2
    +        printf '%s\n' ${STRING:Q}''     # 3
    +        env ${EXAMPLE_ENV} sh -c 'echo "$$string"; echo "$$x"'   # 4
     
    -The automatic copying of config files can be toggled by setting the environment
    -variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
    -will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
    -rc.d/, no matter what the value of this variable is.
    +Example 1 leads to a syntax error in the shell, as the characters are just
    +copied.
     
    -17.4. System users and groups
    +Example 2 quotes the string so that the shell interprets it correctly. But the
    +echo command may additionally interpret strings with a leading dash or those
    +containing backslashes.
     
    -If a package needs to create special users and/or groups during installation,
    -it can do so by using the pkginstall framework.
    +Example 3 can handle arbitrary strings, since printf(1) only interprets the
    +format string, but not the next argument. The trailing single quotes handle the
    +case when the string is empty. In that case, the :Q modifier would result in an
    +empty string too, which would then be skipped by the shell. For printf(1) this
    +doesn't make a difference, but other programs may care.
     
    -Users can be created by adding entries to the PKG_USERS variable. Each entry
    -has the following syntax:
    +In example 4, the EXAMPLE_ENV does not need to be quoted because the quoting
    +has already been done when adding elements to the list.
     
    -user:group
    +15.3.3. Passing CFLAGS to GNU configure scripts
     
    -Further specification of user details may be done by setting per-user
    -variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
    -user's description or comment. PKG_HOME.user is the user's home directory, and
    -defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
    -and defaults to /sbin/nologin if not specified.
    +When passing CFLAGS or similar variables to a GNU-style configure script
    +(especially those that call other configure scripts), it must not have leading
    +or trailing whitespace, since otherwise the configure script gets confused. To
    +trim leading and trailing whitespace, use the :M modifier, as in the following
    +example:
     
    -Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
    -whose syntax is:
    +CPPFLAGS=               # empty
    +CPPFLAGS+=              -Wundef -DPREFIX=\"${PREFIX}\"
    +CPPFLAGS+=              ${MY_CPPFLAGS}
     
    -group
    +CONFIGURE_ARGS+=        CPPFLAGS=${CPPFLAGS:M*:Q}
     
    -The numeric GID of the group may be set by defining PKG_GID.group.
    +all:
    +        echo x${CPPFLAGS:Q}x            # leading and trailing whitespace
    +        echo x${CONFIGURE_ARGS:Q}x      # properly trimmed
     
    -If a package needs to create the users and groups at an earlier stage, then it
    -can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
    -the phase before which the users and groups are created. In this case, the
    -numeric UIDs and GIDs of the created users and groups are automatically
    -hardcoded into the final installation scripts.
    +In this example, CPPFLAGS has both leading and trailing whitespace because the
    ++= operator always adds a space.
     
    -17.5. System shells
    +15.3.4. Handling possibly empty variables
     
    -Packages that install system shells should register them in the shell database,
    -/etc/shells, to make things easier to the administrator. This must be done from
    -the installation scripts to keep binary packages working on any system.
    -pkginstall provides an easy way to accomplish this task.
    +When a possibly empty variable is used in a shell program, it may lead to a
    +syntax error.
     
    -When a package provides a shell interpreter, it has to set the PKG_SHELL
    -variable to its absolute file name. This will add some hooks to the
    -installation scripts to handle it. Consider the following example, taken from
    -shells/zsh:
    +EGFILES=        # empty
     
    -PKG_SHELL=      ${PREFIX}/bin/zsh
    +install-examples:   # produces a syntax error in the shell
    +        for egfile in ${EGFILES}; do            \
    +                echo "Installing $$egfile";     \
    +        done
     
    -17.5.1. Disabling shell registration
    +The shell only sees the text for egfile in ; do, since ${EGFILES} is replaced
    +with an empty string by make(1). To fix this syntax error, use one of the
    +snippets below.
     
    -The automatic registration of shell interpreters can be disabled by the
    -administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
    +EMPTY=          # empty
     
    -17.6. Fonts
    +install-examples:
    +        for egfile in ${EGFILES} ""; do         \
    +                [ -n "$$egfile" ] || continue;  \
    +                echo "Installing $$egfile";     \
    +        done
     
    -Packages that install X11 fonts should update the database files that index the
    -fonts within each fonts directory. This can easily be accomplished within the
    -pkginstall framework.
    +In this case, an empty string is appended to the iteration list (to prevent the
    +syntax error) and filtered out later.
     
    -When a package installs X11 fonts, it must list the directories in which fonts
    -are installed in the FONTS_DIRS.type variables, where type can be one of "ttf",
    -"type1" or "x11". This will add hooks to the installation scripts to run the
    -appropriate commands to update the fonts database files within each of those
    -directories. For convenience, if the directory path is relative, it is taken to
    -be relative to the package's installation prefix. Consider the following
    -example, taken from fonts/dbz-ttf:
    +EGFILES=        # empty
     
    -FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
    +install-examples:
    +.for egfile in ${EGFILES}
    +        echo "Installing ${egfile}"
    +.endfor
     
    -17.6.1. Disabling automatic update of the fonts databases
    +If one of the filenames contains special characters, it should be enclosed in
    +single or double quotes.
     
    -The automatic update of fonts databases can be disabled by the administrator by
    -setting the PKG_UPDATE_FONTS_DB environment variable to NO.
    +To have a shell command test whether a make variable is empty, use the
    +following code: ${TEST} -z ${POSSIBLY_EMPTY:Q}"".
     
    -Chapter 18. Options handling
    +Chapter 16. Options handling
     
     Table of Contents
     
    -18.1. Global default options
    -18.2. Converting packages to use bsd.options.mk
    -18.3. Option Names
    -18.4. Determining the options of dependencies
    +16.1. Global default options
    +16.2. Converting packages to use bsd.options.mk
    +16.3. Option Names
    +16.4. Determining the options of dependencies
     
     Many packages have the ability to be built to support different sets of
     features. bsd.options.mk is a framework in pkgsrc that provides generic
    @@ -4893,13 +4815,13 @@ A further consideration is licensing. No
     non-free dependencies (especially plugins) should almost always be split if
     feasible.
     
    -18.1. Global default options
    +16.1. Global default options
     
     Global default options are listed in PKG_DEFAULT_OPTIONS, which is a list of
     the options that should be built into every package if that option is
     supported. This variable should be set in mk.conf.
     
    -18.2. Converting packages to use bsd.options.mk
    +16.2. Converting packages to use bsd.options.mk
     
     The following example shows how bsd.options.mk should be used by the
     hypothetical ``wibble'' package, either in the package Makefile, or in a file,
    @@ -5017,7 +4939,7 @@ PKG_OPTIONS:
     
     .if !empty(PKG_OPTIONS:Moption)
     
    -18.3. Option Names
    +16.3. Option Names
     
     Options that enable similar features in different packages (like optional
     support for a library) should use a common name in all packages that support it
    @@ -5038,7 +4960,7 @@ description. The description should be a
     uppercase letter and ending with a period) that describes what enabling the
     option does. E. g. "Enable ispell support." The file is sorted by option names.
     
    -18.4. Determining the options of dependencies
    +16.4. Determining the options of dependencies
     
     When writing buildlink3.mk files, it is often necessary to list different
     dependencies based on the options with which the package was built. For
    @@ -5057,865 +4979,965 @@ PKG_BUILD_OPTIONS.libpurple to the build
     which can then be queried like PKG_OPTIONS in the options.mk file. See the file
     pkg-build-options.mk for more details.
     
    -Chapter 19. The build process
    +Chapter 17. Tools needed for building or running
     
     Table of Contents
     
    -19.1. Introduction
    -19.2. Program location
    -19.3. Directories used during the build process
    -19.4. Running a phase
    -19.5. The fetch phase
    -
    -    19.5.1. What to fetch and where to get it from
    -    19.5.2. How are the files fetched?
    -
    -19.6. The checksum phase
    -19.7. The extract phase
    -19.8. The patch phase
    -19.9. The tools phase
    -19.10. The wrapper phase
    -19.11. The configure phase
    -19.12. The build phase
    -19.13. The test phase
    -19.14. The install phase
    -19.15. The package phase
    -19.16. Cleaning up
    -19.17. Other helpful targets
    +17.1. Tools for pkgsrc builds
    +17.2. Tools needed by packages
    +17.3. Tools provided by platforms
     
    -19.1. Introduction
    +The USE_TOOLS definition is used both internally by pkgsrc and also for
    +individual packages to define what commands are needed for building a package
    +(like TOOL_DEPENDS) or for later run-time of an installed packaged (such as
    +DEPENDS). If the native system provides an adequate tool, then in many cases, a
    +pkgsrc package will not be used.
     
    -This chapter gives a detailed description on how a package is built. Building a
    -package is separated into different phases (for example fetch, build, install),
    -all of which are described in the following sections. Each phase is split into
    -so-called stages, which take the name of the containing phase, prefixed by one
    -of pre-, do- or post-. (Examples are pre-configure, post-build.) Most of the
    -actual work is done in the do-* stages.
    +When building a package, the replacement tools are made available in a
    +directory (as symlinks or wrapper scripts) that is early in the executable
    +search path. Just like the buildlink system, this helps with consistent builds.
     
    -Never override the regular targets (like fetch), if you have to, override the
    -do-* ones instead.
    +A tool may be needed to help build a specific package. For example, perl, GNU
    +make (gmake) or yacc may be needed.
     
    -The basic steps for building a program are always the same. First the program's
    -source (distfile) must be brought to the local system and then extracted. After
    -any pkgsrc-specific patches to compile properly are applied, the software can
    -be configured, then built (usually by compiling), and finally the generated
    -binaries, etc. can be put into place on the system.
    +Also a tool may be needed, for example, because the native system's supplied
    +tool may be inefficient for building a package with pkgsrc. For example, a
    +package may need GNU awk, bison (instead of yacc) or a better sed.
    +
    +The tools used by a package can be listed by running make show-tools.
    +
    +17.1. Tools for pkgsrc builds
    +
    +The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
    +standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
    +seen by running: make show-var VARNAME=USE_TOOLS.
    +
    +If a package needs a specific program to build then the USE_TOOLS variable can
    +be used to define the tools needed.
    +
    +17.2. Tools needed by packages
    +
    +In the following examples, the :run means that it is needed at run-time (and
    +becomes a DEPENDS). The default is a build dependency which can be set with
    +:build. (So in this example, it is the same as gmake:build and
    +pkg-config:build.)
    +
    +USE_TOOLS+=     gmake perl:run pkg-config
    +
    +When using the tools framework, a TOOLS_PATH.foo variable is defined which
    +contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
    +could be "/bin/bash" on Linux systems.
    +
    +If you always need a pkgsrc version of the tool at run-time, then just use
    +DEPENDS instead.
    +
    +17.3. Tools provided by platforms
    +
    +When improving or porting pkgsrc to a new platform, have a look at (or create)
    +the corresponding platform specific make file fragment under pkgsrc/mk/tools/
    +tools.${OPSYS}.mk which defines the name of the common tools. For example:
    +
    +.if exists(/usr/bin/bzcat)
    +TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
    +.elif exists(/usr/bin/bzip2)
    +TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
    +.endif
    +
    +TOOLS_PLATFORM.true?=           true                    # shell builtin
    +
    +Chapter 18. Buildlink methodology
    +
    +Table of Contents
    +
    +18.1. Converting packages to use buildlink3
    +18.2. Writing buildlink3.mk files
    +
    +    18.2.1. Anatomy of a buildlink3.mk file
    +    18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
    +        buildlink3.mk files
    +
    +18.3. Writing builtin.mk files
    +
    +    18.3.1. Anatomy of a builtin.mk file
    +    18.3.2. Global preferences for native or pkgsrc software
    +
    +Buildlink is a framework in pkgsrc that controls what headers and libraries are
    +seen by a package's configure and build processes. This is implemented in a two
    +step process:
    +
    + 1. Symlink headers and libraries for dependencies into BUILDLINK_DIR, which by
    +    default is a subdirectory of WRKDIR.
    +
    + 2. Create wrapper scripts that are used in place of the normal compiler tools
    +    that translate -I${LOCALBASE}/include and -L${LOCALBASE}/lib into
    +    references to BUILDLINK_DIR. The wrapper scripts also make native compiler
    +    on some operating systems look like GCC, so that packages that expect GCC
    +    won't require modifications to build with those native compilers.
    +
    +This normalizes the environment in which a package is built so that the package
    +may be built consistently despite what other software may be installed. Please
    +note that the normal system header and library paths, e.g. /usr/include, /usr/
    +lib, etc., are always searched -- buildlink3 is designed to insulate the
    +package build from non-system-supplied software.
    +
    +18.1. Converting packages to use buildlink3
    +
    +The process of converting packages to use the buildlink3 framework ("bl3ifying"
    +) is fairly straightforward. The things to keep in mind are:
     
    -To get more details about what is happening at each step, you can set the
    -PKG_VERBOSE variable, or the PATCH_DEBUG variable if you are just interested in
    -more details about the patch step.
    + 1. Ensure that the build always calls the wrapper scripts instead of the
    +    actual toolchain. Some packages are tricky, and the only way to know for
    +    sure is the check ${WRKDIR}/.work.log to see if the wrappers are being
    +    invoked.
     
    -19.2. Program location
    + 2. Don't override PREFIX from within the package Makefile, e.g. Java VMs,
    +    standalone shells, etc., because the code to symlink files into $
    +    {BUILDLINK_DIR} looks for files relative to "pkg_info -qp pkgname".
     
    -Before outlining the process performed by the NetBSD package system in the next
    -section, here's a brief discussion on where programs are installed, and which
    -variables influence this.
    + 3. Remember that only the buildlink3.mk files that you list in a package's
    +    Makefile are added as dependencies for that package.
     
    -The automatic variable PREFIX indicates where all files of the final program
    -shall be installed. It is usually set to LOCALBASE (/usr/pkg), or CROSSBASE for
    -pkgs in the cross category. The value of PREFIX needs to be put into the
    -various places in the program's source where paths to these files are encoded.
    -See Section 13.3, "patches/*" and Section 21.3.1, "Shared libraries - libtool"
    -for more details.
    +If a dependency on a particular package is required for its libraries and
    +headers, then we replace:
     
    -When choosing which of these variables to use, follow the following rules:
    +DEPENDS+=       foo>=1.1.0:../../category/foo
     
    -  * PREFIX always points to the location where the current pkg will be
    -    installed. When referring to a pkg's own installation path, use "${PREFIX}"
    -    .
    +with
     
    -  * LOCALBASE is where all non-X11 pkgs are installed. If you need to construct
    -    a -I or -L argument to the compiler to find includes and libraries
    -    installed by another non-X11 pkg, use "${LOCALBASE}". The name LOCALBASE
    -    stems from FreeBSD, which installed all packages in /usr/local. As pkgsrc
    -    leaves /usr/local for the system administrator, this variable is a
    -    misnomer.
    +.include "../../category/foo/buildlink3.mk"
     
    -  * X11BASE is where the actual X11 distribution (from xsrc, etc.) is
    -    installed. When looking for standard X11 includes (not those installed by a
    -    package), use "${X11BASE}".
    +The buildlink3.mk files usually define the required dependencies. If you need a
    +newer version of the dependency when using buildlink3.mk files, then you can
    +define it in your Makefile; for example:
     
    -  * X11-based packages using imake must set USE_IMAKE to be installed correctly
    -    under LOCALBASE.
    +BUILDLINK_API_DEPENDS.foo+=   foo>=1.1.0
    +.include "../../category/foo/buildlink3.mk"
     
    -  * Within ${PREFIX}, packages should install files according to hier(7), with
    -    the exception that manual pages go into ${PREFIX}/man, not ${PREFIX}/share/
    -    man.
    +There are several buildlink3.mk files in pkgsrc/mk that handle special package
    +issues:
     
    -19.3. Directories used during the build process
    +  * bdb.buildlink3.mk chooses either the native or a pkgsrc Berkeley DB
    +    implementation based on the values of BDB_ACCEPTED and BDB_DEFAULT.
     
    -When building a package, various directories are used to store source files,
    -temporary files, pkgsrc-internal files, and so on. These directories are
    -explained here.
    +  * curses.buildlink3.mk: If the system comes with neither Curses nor NCurses,
    +    this will take care to install the devel/ncurses package.
     
    -Some of the directory variables contain relative pathnames. There are two
    -common base directories for these relative directories: PKGSRCDIR/PKGPATH is
    -used for directories that are pkgsrc-specific. WRKSRC is used for directories
    -inside the package itself.
    +  * krb5.buildlink3.mk uses the value of KRB5_ACCEPTED to choose between adding
    +    a dependency on Heimdal or MIT-krb5 for packages that require a Kerberos 5
    +    implementation.
     
    -PKGSRCDIR
    +  * motif.buildlink3.mk checks for a system-provided Motif installation or adds
    +    a dependency on x11/lesstif or x11/motif. The user can set MOTIF_TYPE to "
    +    dt", "lesstif" or "motif" to choose which Motif version will be used.
     
    -    This is an absolute pathname that points to the pkgsrc root directory.
    -    Generally, you don't need it.
    +  * readline.buildlink3.mk checks for a system-provided GNU readline or
    +    editline (libedit) installation, or adds a dependency on devel/readline,
    +    devel/editline. The user can set READLINE_DEFAULT to choose readline
    +    implementation. If your package really needs GNU readline library, its
    +    Makefile should include devel/readline/buildlink3.mk instead of
    +    readline.buildlink3.mk.
     
    -PKGDIR
    +  * oss.buildlink3.mk defines several variables that may be used by packages
    +    that use the Open Sound System (OSS) API.
     
    -    This is an absolute pathname that points to the current package.
    +  * pgsql.buildlink3.mk will accept any of the Postgres versions in the
    +    variable PGSQL_VERSIONS_ACCEPTED and default to the version
    +    PGSQL_VERSION_DEFAULT. See the file for more information.
     
    -PKGPATH
    +  * pthread.buildlink3.mk uses the value of PTHREAD_OPTS and checks for native
    +    pthreads or adds a dependency on devel/pth as needed.
     
    -    This is a pathname relative to PKGSRCDIR that points to the current
    -    package.
    +  * xaw.buildlink3.mk uses the value of XAW_TYPE to choose a particular Athena
    +    widgets library.
     
    -WRKDIR
    +The comments in those buildlink3.mk files provide a more complete description
    +of how to use them properly.
     
    -    This is an absolute pathname pointing to the directory where all work takes
    -    place. The distfiles are extracted to this directory. It also contains
    -    temporary directories and log files used by the various pkgsrc frameworks,
    -    like buildlink or the wrappers.
    +18.2. Writing buildlink3.mk files
     
    -WRKSRC
    +A package's buildlink3.mk file is included by Makefiles to indicate the need to
    +compile and link against header files and libraries provided by the package. A
    +buildlink3.mk file should always provide enough information to add the correct
    +type of dependency relationship and include any other buildlink3.mk files that
    +it needs to find headers and libraries that it needs in turn.
     
    -    This is an absolute pathname pointing to the directory where the distfiles
    -    are extracted. It is usually a direct subdirectory of WRKDIR, and often
    -    it's the only directory entry that isn't hidden. This variable may be
    -    changed by a package Makefile.
    +To generate an initial buildlink3.mk file for further editing, Rene Hexel's
    +pkgtools/createbuildlink package is highly recommended. For most packages, the
    +following command will generate a good starting point for buildlink3.mk files:
     
    -The CREATE_WRKDIR_SYMLINK definition takes either the value yes or no and
    -defaults to no. It indicates whether a symbolic link to the WRKDIR is to be
    -created in the pkgsrc entry's directory. If users would like to have their
    -pkgsrc trees behave in a read-only manner, then the value of
    -CREATE_WRKDIR_SYMLINK should be set to no.
    +% cd pkgsrc/category/pkgdir
    +% createbuildlink >buildlink3.mk
     
    -19.4. Running a phase
     
    -You can run a particular phase by typing make phase, where phase is the name of
    -the phase. This will automatically run all phases that are required for this
    -phase. The default phase is build, that is, when you run make without
    -parameters in a package directory, the package will be built, but not
    -installed.
    +18.2.1. Anatomy of a buildlink3.mk file
     
    -19.5. The fetch phase
    +The following real-life example buildlink3.mk is taken from pkgsrc/graphics/
    +tiff:
     
    -The first step in building a package is to fetch the distribution files
    -(distfiles) from the sites that are providing them. This is the task of the 
    -fetch phase.
    +# $NetBSD: buildlink3.mk,v 1.16 2009/03/20 19:24:45 joerg Exp $
     
    -19.5.1. What to fetch and where to get it from
    +BUILDLINK_TREE+=        tiff
     
    -In simple cases, MASTER_SITES defines all URLs from where the distfile, whose
    -name is derived from the DISTNAME variable, is fetched. The more complicated
    -cases are described below.
    +.if !defined(TIFF_BUILDLINK3_MK)
    +TIFF_BUILDLINK3_MK:=
     
    -The variable DISTFILES specifies the list of distfiles that have to be fetched.
    -Its value defaults to ${DEFAULT_DISTFILES} and its value is ${DISTNAME}$
    -{EXTRACT_SUFX}, so that most packages don't need to define it at all.
    -EXTRACT_SUFX is .tar.gz by default, but can be changed freely. Note that if
    -your package requires additional distfiles to the default one, you cannot just
    -append the additional filenames using the += operator, but you have write for
    -example:
    +BUILDLINK_API_DEPENDS.tiff+=    tiff>=3.6.1
    +BUILDLINK_ABI_DEPENDS.tiff+=    tiff>=3.7.2nb1
    +BUILDLINK_PKGSRCDIR.tiff?=      ../../graphics/tiff
     
    -DISTFILES=      ${DEFAULT_DISTFILES} additional-files.tar.gz
    +.include "../../devel/zlib/buildlink3.mk"
    +.include "../../graphics/jpeg/buildlink3.mk"
    +.endif # TIFF_BUILDLINK3_MK
     
    -Each distfile is fetched from a list of sites, usually MASTER_SITES. If the
    -package has multiple DISTFILES or multiple PATCHFILES from different sites, you
    -can set SITES.distfile to the list of URLs where the file distfile (including
    -the suffix) can be found.
    +BUILDLINK_TREE+=        -tiff
     
    -DISTFILES=      ${DISTNAME}${EXTRACT_SUFX}
    -DISTFILES+=     foo-file.tar.gz
    -SITES.foo-file.tar.gz= \
    -https://www.somewhere.com/somehow/ \
    -https://www.somewhereelse.com/mirror/somehow/
    +The header and footer manipulate BUILDLINK_TREE, which is common across all
    +buildlink3.mk files and is used to track the dependency tree.
     
    -When actually fetching the distfiles, each item from MASTER_SITES or SITES.*
    -gets the name of each distfile appended to it, without an intermediate slash.
    -Therefore, all site values have to end with a slash or other separator
    -character. This allows for example to set MASTER_SITES to a URL of a CGI script
    -that gets the name of the distfile as a parameter. In this case, the definition
    -would look like:
    +The main section is protected from multiple inclusion and controls how the
    +dependency on pkg is added. Several important variables are set in the section:
     
    -MASTER_SITES=   https://www.example.com/download.cgi?file=
    +  * BUILDLINK_API_DEPENDS.pkg is the actual dependency recorded in the
    +    installed package; this should always be set using += to ensure that we're
    +    appending to any pre-existing list of values. This variable should be set
    +    to the first version of the package that had an backwards-incompatible API
    +    change.
     
    -The exception to this rule are URLs starting with a dash. In that case the URL
    -is taken as is, fetched and the result stored under the name of the distfile.
    -You can use this style for the case when the download URL style does not match
    -the above common case. For example, if permanent download URL is a redirector
    -to the real download URL, or the download file name is offered by an HTTP
    -Content-Disposition header. In the following example, foo-1.0.0.tar.gz will be
    -created instead of the default v1.0.0.tar.gz.
    +  * BUILDLINK_PKGSRCDIR.pkg is the location of the pkg pkgsrc directory.
     
    -DISTNAME=       foo-1.0.0
    -MASTER_SITES=   -https://www.example.com/archive/v1.0.0.tar.gz
    +  * BUILDLINK_DEPMETHOD.pkg (not shown above) controls whether we use
    +    BUILD_DEPENDS or DEPENDS to add the dependency on pkg. The build dependency
    +    is selected by setting BUILDLINK_DEPMETHOD.pkg to "build". By default, the
    +    full dependency is used.
     
    -There are some predefined values for MASTER_SITES, which can be used in
    -packages. The names of the variables should speak for themselves.
    +  * BUILDLINK_INCDIRS.pkg and BUILDLINK_LIBDIRS.pkg (not shown above) are lists
    +    of subdirectories of ${BUILDLINK_PREFIX.pkg} to add to the header and
    +    library search paths. These default to "include" and "lib" respectively.
     
    -MASTER_SITE_APACHE          MASTER_SITE_BACKUP
    -MASTER_SITE_CRATESIO        MASTER_SITE_CYGWIN
    -MASTER_SITE_DEBIAN          MASTER_SITE_FREEBSD
    -MASTER_SITE_FREEBSD_LOCAL   MASTER_SITE_GENTOO
    -MASTER_SITE_GITHUB          MASTER_SITE_GNOME
    -MASTER_SITE_GNU             MASTER_SITE_GNUSTEP
    -MASTER_SITE_HASKELL_HACKAGE MASTER_SITE_IFARCHIVE
    -MASTER_SITE_KDE             MASTER_SITE_MOZILLA
    -MASTER_SITE_MOZILLA_ALL     MASTER_SITE_MYSQL
    -MASTER_SITE_NETLIB          MASTER_SITE_OPENBSD
    -MASTER_SITE_OPENOFFICE      MASTER_SITE_OSDN
    -MASTER_SITE_PERL_CPAN       MASTER_SITE_PGSQL
    -MASTER_SITE_PYPI            MASTER_SITE_RUBYGEMS
    -MASTER_SITE_R_CRAN          MASTER_SITE_SOURCEFORGE
    -MASTER_SITE_SUNSITE         MASTER_SITE_SUSE
    -MASTER_SITE_TEX_CTAN        MASTER_SITE_XCONTRIB
    -MASTER_SITE_XEMACS          MASTER_SITE_XORG
    +  * BUILDLINK_CPPFLAGS.pkg (not shown above) is the list of preprocessor flags
    +    to add to CPPFLAGS, which are passed on to the configure and build phases.
    +    The "-I" option should be avoided and instead be handled using
    +    BUILDLINK_INCDIRS.pkg as above.
     
    -Some explanations for the less self-explaining ones: MASTER_SITE_BACKUP
    -contains backup sites for packages that are maintained in ftp://ftp.NetBSD.org/
    -pub/pkgsrc/distfiles/${DIST_SUBDIR}. MASTER_SITE_LOCAL contains local package
    -source distributions that are maintained in ftp://ftp.NetBSD.org/pub/pkgsrc/
    -distfiles/LOCAL_PORTS/.
    +The following variables are all optionally defined within this second section
    +(protected against multiple inclusion) and control which package files are
    +symlinked into ${BUILDLINK_DIR} and how their names are transformed during the
    +symlinking:
     
    -If you choose one of these predefined sites, you may want to specify a
    -subdirectory of that site. Since these macros may expand to more than one
    -actual site, you must use the following construct to specify a subdirectory:
    +  * BUILDLINK_FILES.pkg (not shown above) is a shell glob pattern relative to $
    +    {BUILDLINK_PREFIX.pkg} to be symlinked into ${BUILDLINK_DIR}, e.g. include/
    +    *.h.
     
    -MASTER_SITES=   ${MASTER_SITE_GNU:=subdirectory/name/}
    -MASTER_SITES=   ${MASTER_SITE_SOURCEFORGE:=project_name/}
    +  * BUILDLINK_FILES_CMD.pkg (not shown above) is a shell pipeline that outputs
    +    to stdout a list of files relative to ${BUILDLINK_PREFIX.pkg}. The
    +    resulting files are to be symlinked into ${BUILDLINK_DIR}. By default, this
    +    takes the +CONTENTS of a pkg and filters it through $
    +    {BUILDLINK_CONTENTS_FILTER.pkg}.
     
    -Note the trailing slash after the subdirectory name.
    +  * BUILDLINK_CONTENTS_FILTER.pkg (not shown above) is a filter command that
    +    filters +CONTENTS input into a list of files relative to $
    +    {BUILDLINK_PREFIX.pkg} on stdout. By default, BUILDLINK_CONTENTS_FILTER.pkg
    +    outputs the contents of the include and lib directories in the package
    +    +CONTENTS.
     
    -19.5.2. How are the files fetched?
    +  * BUILDLINK_FNAME_TRANSFORM.pkg (not shown above) is a list of sed arguments
    +    used to transform the name of the source filename into a destination
    +    filename, e.g. -e "s|/curses.h|/ncurses.h|g".
     
    -The fetch phase makes sure that all the distfiles exist in a local directory
    -(DISTDIR, which can be set by the pkgsrc user). If the files do not exist, they
    -are fetched using commands of the form
    +This section can additionally include any buildlink3.mk needed for pkg's
    +library dependencies. Including these buildlink3.mk files means that the
    +headers and libraries for these dependencies are also symlinked into $
    +{BUILDLINK_DIR} whenever the pkg buildlink3.mk file is included. Dependencies
    +are only added for directly include buildlink3.mk files.
    +
    +When providing a buildlink3.mk and including other buildlink3.mk files in it,
    +please only add necessary ones, i.e., those whose libraries or header files are
    +automatically exposed when the package is use.
     
    -${FETCH_CMD} ${FETCH_BEFORE_ARGS} ${site}${file} ${FETCH_AFTER_ARGS}
    +In particular, if only an executable (bin/foo) is linked against a library,
    +that library does not need to be propagated in the buildlink3.mk file.
     
    -where ${site} varies through several possibilities in turn: first,
    -MASTER_SITE_OVERRIDE is tried, then the sites specified in either SITES.file if
    -defined, else MASTER_SITES or PATCH_SITES, as applies, then finally the value
    -of MASTER_SITE_BACKUP. The order of all except the first and the last can be
    -optionally sorted by the user, via setting either MASTER_SORT_RANDOM, and
    -MASTER_SORT_AWK or MASTER_SORT_REGEX.
    +The following steps should help you decide if a buildlink3.mk file needs to be
    +included:
     
    -The specific command and arguments used depend on the FETCH_USING parameter.
    -The example above is for FETCH_USING=custom.
    +  * Look at the installed header files: What headers do they include? The
    +    packages providing these files must be buildlinked.
     
    -The distfiles mirror run by the NetBSD Foundation uses the mirror-distfiles
    -target to mirror the distfiles, if they are freely distributable. Packages
    -setting NO_SRC_ON_FTP (usually to "${RESTRICTED}") will not have their
    -distfiles mirrored.
    +  * Run ldd on all installed libraries and look against what other libraries
    +    they link. Some of the packages providing these probably need to be
    +    buildlinked; however, it's not automatic, since e.g. GTK on some systems
    +    pulls in the X libraries, so they will show up in the ldd output, while on
    +    others (like OS X) it won't. ldd output can thus only be used as a hint.
     
    -19.6. The checksum phase
    +18.2.2. Updating BUILDLINK_API_DEPENDS.pkg and BUILDLINK_ABI_DEPENDS.pkg in
    +buildlink3.mk files
     
    -After the distfile(s) are fetched, their checksum is generated and compared
    -with the checksums stored in the distinfo file. If the checksums don't match,
    -the build is aborted. This is to ensure the same distfile is used for building,
    -and that the distfile wasn't changed, e.g. by some malign force, deliberately
    -changed distfiles on the master distribution site or network lossage.
    +These two variables differ in that one describes source compatibility (API) and
    +the other binary compatibility (ABI). The difference is that a change in the
    +API breaks compilation of programs while changes in the ABI stop compiled
    +programs from running.
    +
    +Changes to the BUILDLINK_API_DEPENDS.pkg variable in a buildlink3.mk file
    +happen very rarely. One possible reason is that all packages depending on this
    +already need a newer version. In case it is bumped see the description below.
    +
    +The most common example of an ABI change is that the major version of a shared
    +library is increased. In this case, BUILDLINK_ABI_DEPENDS.pkg should be
    +adjusted to require at least the new package version. Then the packages that
    +depend on this package need their PKGREVISIONs increased and, if they have
    +buildlink3.mk files, their BUILDLINK_ABI_DEPENDS.pkg adjusted, too. This is
    +needed so pkgsrc will require the correct package dependency and not settle for
    +an older one when building the source.
     
    -19.7. The extract phase
    +See Section 21.1.5, "Handling dependencies" for more information about
    +dependencies on other packages, including the BUILDLINK_ABI_DEPENDS and
    +ABI_DEPENDS definitions.
     
    -When the distfiles are present on the local system, they need to be extracted,
    -as they usually come in the form of some compressed archive format.
    +Please take careful consideration before adjusting BUILDLINK_API_DEPENDS.pkg or
    +BUILDLINK_ABI_DEPENDS.pkg as we don't want to cause unneeded package deletions
    +and rebuilds. In many cases, new versions of packages work just fine with older
    +dependencies.
     
    -By default, all DISTFILES are extracted. If you only need some of them, you can
    -set the EXTRACT_ONLY variable to the list of those files.
    +Also it is not needed to set BUILDLINK_ABI_DEPENDS.pkg when it is identical to
    +BUILDLINK_API_DEPENDS.pkg.
     
    -Extracting the files is usually done by a little program, mk/extract/extract,
    -which already knows how to extract various archive formats, so most likely you
    -will not need to change anything here. But if you need, the following variables
    -may help you:
    +18.3. Writing builtin.mk files
     
    -EXTRACT_OPTS_{BIN,LHA,PAX,RAR,TAR,ZIP,ZOO}
    +Some packages in pkgsrc install headers and libraries that coincide with
    +headers and libraries present in the base system. Aside from a buildlink3.mk
    +file, these packages should also include a builtin.mk file that includes the
    +necessary checks to decide whether using the built-in software or the pkgsrc
    +software is appropriate.
     
    -    Use these variables to override the default options for an extract command,
    -    which are defined in mk/extract/extract.
    +The only requirements of a builtin.mk file for pkg are:
     
    -EXTRACT_USING
    + 1. It should set USE_BUILTIN.pkg to either "yes" or "no" after it is included.
     
    -    This variable can be set to bsdtar, gtar, nbtar (which is the default
    -    value), pax, or an absolute pathname pointing to the command with which tar
    -    archives should be extracted. It is preferred to choose bsdtar over gtar if
    -    NetBSD's pax-as-tar is not good enough.
    + 2. It should not override any USE_BUILTIN.pkg which is already set before the
    +    builtin.mk file is included.
     
    -If the extract program doesn't serve your needs, you can also override the
    -EXTRACT_CMD variable, which holds the command used for extracting the files.
    -This command is executed in the ${WRKSRC} directory. During execution of this
    -command, the shell variable extract_file holds the absolute pathname of the
    -file that is going to be extracted.
    + 3. It should be written to allow multiple inclusion. This is very important
    +    and takes careful attention to Makefile coding.
     
    -And if that still does not suffice, you can override the do-extract target in
    -the package Makefile.
    +18.3.1. Anatomy of a builtin.mk file
     
    -19.8. The patch phase
    +The following is the recommended template for builtin.mk files:
     
    -After extraction, all the patches named by the PATCHFILES, those present in the
    -patches subdirectory of the package as well as in $LOCALPATCHES/$PKGPATH (e.g.
    -/usr/local/patches/graphics/png) are applied. Patchfiles ending in .Z or .gz
    -are uncompressed before they are applied, files ending in .orig or .rej are
    -ignored. Any special options to patch(1) can be handed in PATCH_DIST_ARGS. See
    -Section 13.3, "patches/*" for more details.
    +.if !defined(IS_BUILTIN.foo)
    +#
    +# IS_BUILTIN.foo is set to "yes" or "no" depending on whether "foo"
    +# genuinely exists in the system or not.
    +#
    +IS_BUILTIN.foo?=        no
     
    -By default patch(1) is given special arguments to make it fail if the expected
    -text from the patch context is not found in the patched file. If that happens,
    -fix the patch file by comparing it with the actual text in the file to be
    -patched.
    +# BUILTIN_PKG.foo should be set here if "foo" is built-in and its package
    +# version can be determined.
    +#
    +.  if !empty(IS_BUILTIN.foo:M[yY][eE][sS])
    +BUILTIN_PKG.foo?=       foo-1.0
    +.  endif
    +.endif  # IS_BUILTIN.foo
     
    -19.9. The tools phase
    +.if !defined(USE_BUILTIN.foo)
    +USE_BUILTIN.foo?=       ${IS_BUILTIN.foo}
    +.  if defined(BUILTIN_PKG.foo)
    +.    for _depend_ in ${BUILDLINK_API_DEPENDS.foo}
    +.      if !empty(USE_BUILTIN.foo:M[yY][eE][sS])
    +USE_BUILTIN.foo!=                                                       \
    +        ${PKG_ADMIN} pmatch '${_depend_}' ${BUILTIN_PKG.foo}            \
    +        && ${ECHO} "yes" || ${ECHO} "no"
    +.      endif
    +.    endfor
    +.  endif
    +.endif  # USE_BUILTIN.foo
     
    -This is covered in Chapter 20, Tools needed for building or running.
    +CHECK_BUILTIN.foo?=     no
    +.if !empty(CHECK_BUILTIN.foo:M[nN][oO])
    +#
    +# Here we place code that depends on whether USE_BUILTIN.foo is set to
    +# "yes" or "no".
    +#
    +.endif  # CHECK_BUILTIN.foo
     
    -19.10. The wrapper phase
    +The first section sets IS_BUILTIN.pkg depending on if pkg really exists in the
    +base system. This should not be a base system software with similar
    +functionality to pkg; it should only be "yes" if the actual package is included
    +as part of the base system. This variable is only used internally within the
    +builtin.mk file.
     
    -This phase creates wrapper programs for the compilers and linkers. The
    -following variables can be used to tweak the wrappers.
    +The second section sets BUILTIN_PKG.pkg to the version of pkg in the base
    +system if it exists (if IS_BUILTIN.pkg is "yes"). This variable is only used
    +internally within the builtin.mk file.
     
    -ECHO_WRAPPER_MSG
    +The third section sets USE_BUILTIN.pkg and is required in all builtin.mk files.
    +The code in this section must make the determination whether the built-in
    +software is adequate to satisfy the dependencies listed in
    +BUILDLINK_API_DEPENDS.pkg. This is typically done by comparing BUILTIN_PKG.pkg
    +against each of the dependencies in BUILDLINK_API_DEPENDS.pkg. USE_BUILTIN.pkg 
    +must be set to the correct value by the end of the builtin.mk file. Note that
    +USE_BUILTIN.pkg may be "yes" even if IS_BUILTIN.pkg is "no" because we may make
    +the determination that the built-in version of the software is similar enough
    +to be used as a replacement.
     
    -    The command used to print progress messages. Does nothing by default. Set
    -    to ${ECHO} to see the progress messages.
    +The last section is guarded by CHECK_BUILTIN.pkg, and includes code that uses
    +the value of USE_BUILTIN.pkg set in the previous section. This typically
    +includes, e.g., adding additional dependency restrictions and listing
    +additional files to symlink into ${BUILDLINK_DIR} (via BUILDLINK_FILES.pkg).
     
    -WRAPPER_DEBUG
    +18.3.2. Global preferences for native or pkgsrc software
     
    -    This variable can be set to yes (default) or no, depending on whether you
    -    want additional information in the wrapper log file.
    +When building packages, it's possible to choose whether to set a global
    +preference for using either the built-in (native) version or the pkgsrc version
    +of software to satisfy a dependency. This is controlled by setting
    +PREFER_PKGSRC and PREFER_NATIVE. These variables take values of either "yes", "
    +no", or a list of packages. PREFER_PKGSRC tells pkgsrc to use the pkgsrc
    +versions of software, while PREFER_NATIVE tells pkgsrc to use the built-in
    +versions. Preferences are determined by the most specific instance of the
    +package in either PREFER_PKGSRC or PREFER_NATIVE. If a package is specified in
    +neither or in both variables, then PREFER_PKGSRC has precedence over
    +PREFER_NATIVE. For example, to require using pkgsrc versions of software for
    +all but the most basic bits on a NetBSD system, you can set:
     
    -WRAPPER_UPDATE_CACHE
    +PREFER_PKGSRC=  yes
    +PREFER_NATIVE=  getopt skey tcp_wrappers
     
    -    This variable can be set to yes or no, depending on whether the wrapper
    -    should use its cache, which will improve the speed. The default value is
    -    yes, but is forced to no if the platform does not support it.
    +A package must have a builtin.mk file to be listed in PREFER_NATIVE, otherwise
    +it is simply ignored in that list.
     
    -WRAPPER_REORDER_CMDS
    +Setting PREFER_NATIVE should be performed straight after bootstrap and
    +PREFER_PKGSRC during bootstrap. Switching between settings globally at a later
    +date can introduce complications with dependency resolution. This is caused by
    +packages built with the opposite preference being installed alongside each
    +other.
     
    -    A list of reordering commands. A reordering command has the form reorder:l:
    -    lib1:lib2. It ensures that that -llib1 occurs before -llib2.
    +# ./bootstrap --prefer-pkgsrc yes
     
    -19.11. The configure phase
    +Chapter 19. PLIST issues
     
    -Most pieces of software need information on the header files, system calls, and
    -library routines which are available on the platform they run on. The process
    -of determining this information is known as configuration, and is usually
    -automated. In most cases, a script is supplied with the distfiles, and its
    -invocation results in generation of header files, Makefiles, etc.
    +Table of Contents
     
    -If the package contains a configure script, this can be invoked by setting
    -HAS_CONFIGURE to "yes". If the configure script is a GNU autoconf script, you
    -should set GNU_CONFIGURE to "yes" instead. What happens in the configure phase
    -is roughly:
    +19.1. RCS ID
    +19.2. Semi-automatic PLIST generation
    +19.3. Tweaking output of make print-PLIST
    +19.4. Variable substitution in PLIST
    +19.5. Man page compression
    +19.6. Changing PLIST source with PLIST_SRC
    +19.7. Platform-specific and differing PLISTs
    +19.8. Build-specific PLISTs
    +19.9. Sharing directories between packages
     
    -.for d in ${CONFIGURE_DIRS}
    -        cd ${WRKSRC} \
    -        && cd ${d} \
    -        && env ${CONFIGURE_ENV} ${CONFIGURE_SCRIPT} ${CONFIGURE_ARGS}
    -.endfor
    +The PLIST file contains a package's "packing list", i.e. a list of files that
    +belong to the package (relative to the ${PREFIX} directory it's been installed
    +in) plus some additional statements - see the pkg_create(1) man page for a full
    +list. This chapter addresses some issues that need attention when dealing with
    +the PLIST file (or files, see below!).
     
    -CONFIGURE_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In
    -each of these directories, the configure script is run with the environment
    -CONFIGURE_ENV and arguments CONFIGURE_ARGS. The variables CONFIGURE_ENV,
    -CONFIGURE_SCRIPT (default: "./configure") and CONFIGURE_ARGS may all be changed
    -by the package.
    +19.1. RCS ID
     
    -If the program uses the Perl way of configuration (mainly Perl modules, but not
    -only), i.e. a file called Makefile.PL, it should include ../../lang/perl5/
    -module.mk. To set any parameter for Makefile.PL use the MAKE_PARAMS variable
    -(e.g., MAKE_PARAMS+=foo=bar
    +Be sure to add a RCS ID line as the first thing in any PLIST file you write:
     
    -If the program uses an Imakefile for configuration, the appropriate steps can
    -be invoked by setting USE_IMAKE to "yes". If you only need xmkmf, add it to
    -USE_TOOLS. You can add variables to xmkmf's environment by adding them to the
    -SCRIPTS_ENV variable.
    +@comment $NetBSD $
     
    -If the program uses cmake for configuration, the appropriate steps can be
    -invoked by setting USE_CMAKE to "yes". You can add variables to cmake's
    -environment by adding them to the CONFIGURE_ENV variable and arguments to cmake
    -by adding them to the CMAKE_ARGS variable. The top directory argument is given
    -by the CMAKE_ARG_PATH variable, that defaults to "." (relative to
    -CONFIGURE_DIRS)
    +An artificial space has been added between NetBSD and $, this is a workaround
    +here to prevent CVS expanding to the filename of the guide. When adding the RCS
    +ID the space should be omitted.
     
    -If there is no configure step at all, set NO_CONFIGURE to "yes".
    +19.2. Semi-automatic PLIST generation
     
    -19.12. The build phase
    +You can use the make print-PLIST command to output a PLIST that matches any new
    +files since the package was extracted. See Section 13.17, "Other helpful
    +targets" for more information on this target.
     
    -For building a package, a rough equivalent of the following code is executed.
    +19.3. Tweaking output of make print-PLIST
     
    -.for d in ${BUILD_DIRS}
    -        cd ${WRKSRC} \
    -        && cd ${d} \
    -        && env ${MAKE_ENV} \
    -            ${MAKE_PROGRAM} ${BUILD_MAKE_FLAGS} \
    -                -f ${MAKE_FILE} \
    -                ${BUILD_TARGET}
    -.endfor
    +The PRINT_PLIST_AWK variable takes a set of AWK patterns and actions that are
    +used to filter the output of print-PLIST. You can append any chunk of AWK
    +scripting you like to it, but be careful with quoting.
     
    -BUILD_DIRS (default: ".") is a list of pathnames relative to WRKSRC. In each of
    -these directories, MAKE_PROGRAM is run with the environment MAKE_ENV and
    -arguments BUILD_MAKE_FLAGS. The variables MAKE_ENV, BUILD_MAKE_FLAGS, MAKE_FILE
    -and BUILD_TARGET may all be changed by the package.
    +For example, to get all files inside the libdata/foo directory removed from the
    +resulting PLIST:
     
    -The default value of MAKE_PROGRAM is "gmake" if USE_TOOLS contains "gmake", "
    -make" otherwise. The default value of MAKE_FILE is "Makefile", and BUILD_TARGET
    -defaults to "all".
    +PRINT_PLIST_AWK+=       /^libdata\/foo/ { next; }
     
    -If there is no build step at all, set NO_BUILD to "yes".
    +19.4. Variable substitution in PLIST
    +
    +A number of variables are substituted automatically in PLISTs when a package is
    +installed on a system. This includes the following variables:
     
    -19.13. The test phase
    +${MACHINE_ARCH}, ${MACHINE_GNU_ARCH}
     
    -[TODO]
    +    Some packages like emacs and perl embed information about which
    +    architecture they were built on into the pathnames where they install their
    +    files. To handle this case, PLIST will be preprocessed before actually
    +    used, and the symbol "${MACHINE_ARCH}" will be replaced by what uname -p
    +    gives. The same is done if the string ${MACHINE_GNU_ARCH} is embedded in
    +    PLIST somewhere - use this on packages that have GNU autoconf-created
    +    configure scripts.
     
    -19.14. The install phase
    +    Legacy note
     
    -Once the build stage has completed, the final step is to install the software
    -in public directories, so users can access the programs and files.
    +    There used to be a symbol "$ARCH" that was replaced by the output of uname
    +    -m, but that's no longer supported and has been removed.
     
    -In the install phase, a rough equivalent of the following code is executed.
    -Additionally, before and after this code, much magic is performed to do
    -consistency checks, registering the package, and so on.
    +${OPSYS}, ${LOWER_OPSYS}, ${OS_VERSION}
     
    -.for d in ${INSTALL_DIRS}
    -        cd ${WRKSRC} \
    -        && cd ${d} \
    -        && env ${MAKE_ENV} \
    -            ${MAKE_PROGRAM} ${INSTALL_MAKE_FLAGS} \
    -                -f ${MAKE_FILE} \
    -                ${INSTALL_TARGET}
    -.endfor
    +    Some packages want to embed the OS name and version into some paths. To do
    +    this, use these variables in the PLIST:
     
    -The variable's meanings are analogous to the ones in the build phase.
    -INSTALL_DIRS defaults to BUILD_DIRS. INSTALL_TARGET is "install" by default,
    -plus "install.man" if USE_IMAKE is defined and NO_INSTALL_MANPAGES is not
    -defined.
    +      + ${OPSYS} - output of "uname -s"
     
    -In the install phase, the following variables are useful. They are all
    -variations of the install(1) command that have the owner, group and permissions
    -preset. INSTALL is the plain install command. The specialized variants,
    -together with their intended use, are:
    +      + ${LOWER_OPSYS} - lowercase common name (eg. "solaris")
     
    -INSTALL_PROGRAM_DIR
    +      + ${OS_VERSION} - "uname -r"
     
    -    directories that contain binaries
    +For a list of values which are replaced by default, the output of make help
    +topic=PLIST_SUBST as well as searching the pkgsrc/mk directory with grep for
    +PLIST_SUBST should help.
     
    -INSTALL_SCRIPT_DIR
    +If you want to change other variables not listed above, you can add variables
    +and their expansions to this variable in the following way, similar to
    +MESSAGE_SUBST (see Section 12.5, "Optional files"):
     
    -    directories that contain scripts
    +PLIST_SUBST+=   SOMEVAR="somevalue"
     
    -INSTALL_LIB_DIR
    +This replaces all occurrences of "${SOMEVAR}" in the PLIST with "somevalue".
     
    -    directories that contain shared and static libraries
    +The PLIST_VARS variable can be used to simplify the common case of
    +conditionally including some PLIST entries. It can be done by adding
    +PLIST_VARS+=foo and setting the corresponding PLIST.foo variable to yes if the
    +entry should be included. This will substitute "${PLIST.foo}" in the PLIST with
    +either """" or ""@comment "". For example, in Makefile:
     
    -INSTALL_DATA_DIR
    +PLIST_VARS+=    foo
    +.if condition
    +PLIST.foo=      yes
    +.else
     
    -    directories that contain data files
    +And then in PLIST:
     
    -INSTALL_MAN_DIR
    +@comment $NetBSD $
    +bin/bar
    +man/man1/bar.1
    +${PLIST.foo}bin/foo
    +${PLIST.foo}man/man1/foo.1
    +${PLIST.foo}share/bar/foo.data
     
    -    directories that contain man pages
    +An artificial space has been added between NetBSD and $, this is a workaround
    +here to prevent CVS expanding to the filename of the guide. When adding the RCS
    +ID the space should be ommited.
     
    -INSTALL_GAME_DIR
    +19.5. Man page compression
     
    -    directories that contain data files for games
    +Man pages should be installed in compressed form if MANZ is set (in
    +bsd.own.mk), and uncompressed otherwise. To handle this in the PLIST file, the
    +suffix ".gz" is appended/removed automatically for man pages according to MANZ
    +and MANCOMPRESSED being set or not, see above for details. This modification of
    +the PLIST file is done on a copy of it, not PLIST itself.
     
    -INSTALL_PROGRAM
    +19.6. Changing PLIST source with PLIST_SRC
     
    -    binaries that can be stripped from debugging symbols
    +To use one or more files as source for the PLIST used in generating the binary
    +package, set the variable PLIST_SRC to the names of that file(s). The files are
    +later concatenated using cat(1), and the order of things is important. The
    +default for PLIST_SRC is ${PKGDIR}/PLIST.
     
    -INSTALL_SCRIPT
    +19.7. Platform-specific and differing PLISTs
     
    -    binaries that cannot be stripped
    +Some packages decide to install a different set of files based on the operating
    +system being used. These differences can be automatically handled by using the
    +following files:
     
    -INSTALL_GAME
    +  * PLIST.common
     
    -    game binaries
    +  * PLIST.${OPSYS}
     
    -INSTALL_LIB
    +  * PLIST.${MACHINE_ARCH}
     
    -    shared and static libraries
    +  * PLIST.${OPSYS}-${MACHINE_ARCH}
     
    -INSTALL_DATA
    +  * PLIST.common_end
     
    -    data files
    +19.8. Build-specific PLISTs
     
    -INSTALL_GAME_DATA
    +Some packages decide to generate hard-to-guess file names during installation
    +that are hard to wire down.
     
    -    data files for games
    +In such cases, you can set the GENERATE_PLIST variable to shell code terminated
    +(with a semicolon) that will output PLIST entries which will be appended to the
    +PLIST
     
    -INSTALL_MAN
    +You can find one example in editors/xemacs:
     
    -    man pages
    +GENERATE_PLIST+=        ${ECHO} bin/${DISTNAME}-`${WRKSRC}/src/xemacs -sd`.dmp ;
     
    -Some other variables are:
    +which will append something like bin/xemacs-21.4.23-54e8ea71.dmp to the PLIST.
     
    -INSTALL_UNSTRIPPED
    +19.9. Sharing directories between packages
     
    -    If set to yes, do not run strip(1) when installing binaries. Any debugging
    -    sections and symbols present in binaries will be preserved.
    +A "shared directory" is a directory where multiple (and unrelated) packages
    +install files. These directories were problematic because you had to add
    +special tricks in the PLIST to conditionally remove them, or have some
    +centralized package handle them.
     
    -INSTALLATION_DIRS
    +In pkgsrc, it is now easy: Each package should create directories and install
    +files as needed; pkg_delete will remove any directories left empty after
    +uninstalling a package.
     
    -    A list of directories relative to PREFIX that are created by pkgsrc at the
    -    beginning of the install phase. The package is supposed to create all
    -    needed directories itself before installing files to it and list all other
    -    directories here.
    +If a package needs an empty directory to work, create the directory during
    +installation as usual, and also add an entry to the PLIST:
     
    -In the rare cases that a package shouldn't install anything, set NO_INSTALL to 
    -"yes". This is mostly relevant for packages in the regress category.
    +@pkgdir path/to/empty/directory
     
    -19.15. The package phase
    +or take a look at MAKE_DIRS and OWN_DIRS.
     
    -Once the install stage has completed, a binary package of the installed files
    -can be built. These binary packages can be used for quick installation without
    -previous compilation, e.g. by the make bin-install or by using pkg_add.
    +Chapter 20. The pkginstall framework
     
    -By default, the binary packages are created in ${PACKAGES}/All and symlinks are
    -created in ${PACKAGES}/category, one for each category in the CATEGORIES
    -variable. PACKAGES defaults to pkgsrc/packages.
    +Table of Contents
     
    -19.16. Cleaning up
    +20.1. Files and directories outside the installation prefix
     
    -Once you're finished with a package, you can clean the work directory by
    -running make clean. If you want to clean the work directories of all
    -dependencies too, use make clean-depends.
    +    20.1.1. Directory manipulation
    +    20.1.2. File manipulation
     
    -19.17. Other helpful targets
    +20.2. Configuration files
     
    -pre/post-*
    +    20.2.1. How PKG_SYSCONFDIR is set
    +    20.2.2. Telling the software where configuration files are
    +    20.2.3. Patching installations
    +    20.2.4. Disabling handling of configuration files
     
    -    For any of the main targets described in the previous section, two
    -    auxiliary targets exist with "pre-" and "post-" used as a prefix for the
    -    main target's name. These targets are invoked before and after the main
    -    target is called, allowing extra configuration or installation steps be
    -    performed from a package's Makefile, for example, which a program's
    -    configure script or install target omitted.
    +20.3. System startup scripts
     
    -do-*
    +    20.3.1. Disabling handling of system startup scripts
     
    -    Should one of the main targets do the wrong thing, and should there be no
    -    variable to fix this, you can redefine it with the do-* target. (Note that
    -    redefining the target itself instead of the do-* target is a bad idea, as
    -    the pre-* and post-* targets won't be called anymore, etc.) You will not
    -    usually need to do this.
    +20.4. System users and groups
    +20.5. System shells
     
    -reinstall
    +    20.5.1. Disabling shell registration
     
    -    If you did a make install and you noticed some file was not installed
    -    properly, you can repeat the installation with this target, which will
    -    ignore the "already installed" flag.
    +20.6. Fonts
     
    -    This is the default value of DEPENDS_TARGET except in the case of make
    -    update and make package, where the defaults are "package" and "update",
    -    respectively.
    +    20.6.1. Disabling automatic update of the fonts databases
     
    -deinstall
    +This chapter describes the framework known as pkginstall, whose key features
    +are:
     
    -    This target does a pkg_delete(1) in the current directory, effectively
    -    de-installing the package. The following variables can be used to tune the
    -    behaviour:
    +  * Generic installation and manipulation of directories and files outside the
    +    pkgsrc-handled tree, LOCALBASE.
     
    -    PKG_VERBOSE
    +  * Automatic handling of configuration files during installation, provided
    +    that packages are correctly designed.
     
    -        Add a "-v" to the pkg_delete(1) command.
    +  * Generation and installation of system startup scripts.
     
    -    DEINSTALLDEPENDS
    +  * Registration of system users and groups.
     
    -        Remove all packages that require (depend on) the given package. This
    -        can be used to remove any packages that may have been pulled in by a
    -        given package, e.g. if make deinstall DEINSTALLDEPENDS=1 is done in
    -        pkgsrc/x11/kde, this is likely to remove whole KDE. Works by adding "-R
    -        " to the pkg_delete(1) command line.
    +  * Registration of system shells.
     
    -bin-install
    +  * Automatic updating of fonts databases.
     
    -    Install a binary package from local disk and via FTP from a list of sites
    -    (see the BINPKG_SITES variable), and do a make package if no binary package
    -    is available anywhere. The arguments given to pkg_add can be set via
    -    BIN_INSTALL_FLAGS e.g., to do verbose operation, etc.
    +The following sections inspect each of the above points in detail.
     
    -install-clean
    +You may be thinking that many of the things described here could be easily done
    +with simple code in the package's post-installation target (post-install). This
    +is incorrect, as the code in them is only executed when building from source.
    +Machines using binary packages could not benefit from it at all (as the code
    +itself could be unavailable). Therefore, the only way to achieve any of the
    +items described above is by means of the installation scripts, which are
    +automatically generated by pkginstall.
     
    -    This target removes the state files for the "install" and later phases so
    -    that the "install" target may be re-invoked. This can be used after editing
    -    the PLIST to install the package without rebuilding it.
    +20.1. Files and directories outside the installation prefix
     
    -build-clean
    +As you already know, the PLIST file holds a list of files and directories that
    +belong to a package. The names used in it are relative to the installation
    +prefix (${PREFIX}), which means that it cannot register files outside this
    +directory (absolute path names are not allowed). Despite this restriction, some
    +packages need to install files outside this location; e.g., under ${VARBASE} or
    +${PKG_SYSCONFDIR}. The only way to achieve this is to create such files during
    +installation time by using installation scripts.
     
    -    This target removes the state files for the "build" and later phases so
    -    that the "build" target may be re-invoked.
    +The generic installation scripts are shell scripts that can contain arbitrary
    +code. The list of scripts to execute is taken from the INSTALL_FILE variable,
    +which defaults to INSTALL. A similar variable exists for package removal
    +(DEINSTALL_FILE, whose default is DEINSTALL). These scripts can run arbitrary
    +commands, so they have the potential to create and manage files anywhere in the
    +file system.
     
    -update
    +Using these general installation files is not recommended, but may be needed in
    +some special cases. One reason for avoiding them is that the user has to trust
    +the packager that there is no unwanted or simply erroneous code included in the
    +installation script. Also, previously there were many similar scripts for the
    +same functionality, and fixing a common error involved finding and changing all
    +of them.
     
    -    This target causes the current package to be updated to the latest version.
    -    The package and all depending packages first get de-installed, then current
    -    versions of the corresponding packages get compiled and installed. This is
    -    similar to manually noting which packages are currently installed, then
    -    performing a series of make deinstall and make install (or whatever
    -    UPDATE_TARGET is set to) for these packages.
    +The pkginstall framework offers another, standardized way. It provides generic
    +scripts to abstract the manipulation of such files and directories based on
    +variables set in the package's Makefile. The rest of this section describes
    +these variables.
     
    -    You can use the "update" target to resume package updating in case a
    -    previous make update was interrupted for some reason. However, in this
    -    case, make sure you don't call make clean or otherwise remove the list of
    -    dependent packages in WRKDIR. Otherwise, you lose the ability to
    -    automatically update the current package along with the dependent packages
    -    you have installed.
    +20.1.1. Directory manipulation
     
    -    Resuming an interrupted make update will only work as long as the package
    -    tree remains unchanged. If the source code for one of the packages to be
    -    updated has been changed, resuming make update will most certainly fail!
    +The following variables can be set to request the creation of directories
    +anywhere in the file system:
     
    -    The following variables can be used either on the command line or in
    -    mk.conf to alter the behaviour of make update:
    +  * MAKE_DIRS and OWN_DIRS contain a list of directories that should be created
    +    and should attempt to be destroyed by the installation scripts. The
    +    difference between the two is that the latter prompts the administrator to
    +    remove any directories that may be left after deinstallation (because they
    +    were not empty), while the former does not. Example:
     
    -    UPDATE_TARGET
    +    MAKE_DIRS+=             ${VARBASE}/foo/private
     
    -        Install target to recursively use for the updated package and the
    -        dependent packages. Defaults to DEPENDS_TARGET if set, "install"
    -        otherwise for make update. Other good targets are "package" or "
    -        bin-install". Do not set this to "update" or you will get stuck in an
    -        endless loop!
    +  * MAKE_DIRS_PERMS and OWN_DIRS_PERMS contain a list of tuples describing
    +    which directories should be created and should attempt to be destroyed by
    +    the installation scripts. Each tuple holds the following values, separated
    +    by spaces: the directory name, its owner, its group and its numerical mode.
    +    For example:
     
    -    NOCLEAN
    +    MAKE_DIRS_PERMS+=       ${VARBASE}/foo/private \
    +                            ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
     
    -        Don't clean up after updating. Useful if you want to leave the work
    -        sources of the updated packages around for inspection or other
    -        purposes. Be sure you eventually clean up the source tree (see the "
    -        clean-update" target below) or you may run into troubles with old
    -        source code still lying around on your next make or make update.
    +    The difference between the two is exactly the same as their non-PERMS
    +    counterparts.
     
    -    REINSTALL
    +20.1.2. File manipulation
     
    -        Deinstall each package before installing (making DEPENDS_TARGET). This
    -        may be necessary if the "clean-update" target (see below) was called
    -        after interrupting a running make update.
    +Creating non-empty files outside the installation prefix is tricky because the
    +PLIST forces all files to be inside it. To overcome this problem, the only
    +solution is to extract the file in the known place (i.e., inside the
    +installation prefix) and copy it to the appropriate location during
    +installation (done by the installation scripts generated by pkginstall). We
    +will call the former the master file in the following paragraphs, which
    +describe the variables that can be used to automatically and consistently
    +handle files outside the installation prefix:
     
    -    DEPENDS_TARGET
    +  * CONF_FILES and REQD_FILES are pairs of master and target files. During
    +    installation time, the master file is copied to the target one if and only
    +    if the latter does not exist. Upon deinstallation, the target file is
    +    removed provided that it was not modified by the installation.
     
    -        Allows you to disable recursion and hardcode the target for packages.
    -        The default is "update" for the update target, facilitating a recursive
    -        update of prerequisite packages. Only set DEPENDS_TARGET if you want to
    -        disable recursive updates. Use UPDATE_TARGET instead to just set a
    -        specific target for each package to be installed during make update
    -        (see above).
    +    The difference between the two is that the latter prompts the administrator
    +    to remove any files that may be left after deinstallation (because they
    +    were not empty), while the former does not.
     
    -clean-update
    +  * CONF_FILES_PERMS and REQD_FILES_PERMS contain tuples describing master
    +    files as well as their target locations. For each of them, it also
    +    specifies their owner, their group and their numeric permissions, in this
    +    order. For example:
     
    -    Clean the source tree for all packages that would get updated if make
    -    update was called from the current directory. This target should not be
    -    used if the current package (or any of its depending packages) have already
    -    been de-installed (e.g., after calling make update) or you may lose some
    -    packages you intended to update. As a rule of thumb: only use this target 
    -    before the first time you run make update and only if you have a dirty
    -    package tree (e.g., if you used NOCLEAN).
    +    REQD_FILES_PERMS+=      ${PREFIX}/share/somefile ${VARBASE}/somefile \
    +                            ${REAL_ROOT_USER} ${REAL_ROOT_GROUP} 0700
     
    -    If you are unsure about whether your tree is clean, you can either perform
    -    a make clean at the top of the tree, or use the following sequence of
    -    commands from the directory of the package you want to update (before
    -    running make update for the first time, otherwise you lose all the packages
    -    you wanted to update!):
    +    The difference between the two is exactly the same as their non-PERMS
    +    counterparts.
     
    -    # make clean-update
    -    # make clean CLEANDEPENDS=YES
    -    # make update
    +20.2. Configuration files
     
    +Configuration files are special in the sense that they are installed in their
    +own specific directory, PKG_SYSCONFDIR, and need special treatment during
    +installation (most of which is automated by pkginstall). The main concept you
    +must bear in mind is that files marked as configuration files are automatically
    +copied to the right place (somewhere inside PKG_SYSCONFDIR) during installation
    +if and only if they didn't exist before. Similarly, they will not be removed if
    +they have local modifications. This ensures that administrators never lose any
    +custom changes they may have made.
     
    -    The following variables can be used either on the command line or in
    -    mk.conf to alter the behaviour of make clean-update:
    +20.2.1. How PKG_SYSCONFDIR is set
     
    -    CLEAR_DIRLIST
    +As said before, the PKG_SYSCONFDIR variable specifies where configuration files
    +shall be installed. Its contents are set based upon the following variables:
     
    -        After make clean, do not reconstruct the list of directories to update
    -        for this package. Only use this if make update successfully installed
    -        all packages you wanted to update. Normally, this is done automatically
    -        on make update, but may have been suppressed by the NOCLEAN variable
    -        (see above).
    +  * PKG_SYSCONFBASE: The configuration's root directory. Defaults to ${PREFIX}/
    +    etc although it may be overridden by the user to point to his preferred
    +    location (e.g., /etc, /etc/pkg, etc.). Packages must not use it directly.
     
    -replace
    +  * PKG_SYSCONFSUBDIR: A subdirectory of PKG_SYSCONFBASE under which the
    +    configuration files for the package being built shall be installed. The
    +    definition of this variable only makes sense in the package's Makefile
    +    (i.e., it is not user-customizable).
     
    -    Update the installation of the current package. This differs from update in
    -    that it does not replace dependent packages. You will need to install
    -    pkgtools/pkg_tarup for this target to work.
    +    As an example, consider the Apache package, www/apache24, which places its
    +    configuration files under the httpd/ subdirectory of PKG_SYSCONFBASE. This
    +    should be set in the package Makefile.
     
    -    Be careful when using this target! There are no guarantees that dependent
    -    packages will still work, in particular they will most certainly break if
    -    you make replace a library package whose shared library major version
    -    changed between your installed version and the new one. For this reason,
    -    this target is not officially supported and only recommended for advanced
    -    users.
    +  * PKG_SYSCONFVAR: Specifies the name of the variable that holds this
    +    package's configuration directory (if different from PKG_SYSCONFBASE). It
    +    defaults to PKGBASE's value, and is always prefixed with PKG_SYSCONFDIR.
     
    -info
    +  * PKG_SYSCONFDIR.${PKG_SYSCONFVAR}: Holds the directory where the
    +    configuration files for the package identified by PKG_SYSCONFVAR's shall be
    +    placed.
     
    -    This target invokes pkg_info(1) for the current package. You can use this
    -    to check which version of a package is installed.
    +Based on the above variables, pkginstall determines the value of
    +PKG_SYSCONFDIR, which is the only variable that can be used within a package to
    +refer to its configuration directory. The algorithm used to set its value is
    +basically the following:
     
    -index
    + 1. If PKG_SYSCONFDIR.${PKG_SYSCONFVAR} is set, its value is used.
     
    -    This is a top-level command, i.e. it should be used in the pkgsrc
    -    directory. It creates a database of all packages in the local pkgsrc tree,
    -    including dependencies, comment, maintainer, and some other useful
    -    information. Individual entries are created by running make describe in the
    -    packages' directories. This index file is saved as pkgsrc/INDEX. It can be
    -    displayed in verbose format by running make print-index. You can search in
    -    it with make search key=something. You can extract a list of all packages
    -    that depend on a particular one by running make show-deps PKG=somepackage.
    + 2. If the previous variable is not defined but PKG_SYSCONFSUBDIR is set in the
    +    package's Makefile, the resulting value is ${PKG_SYSCONFBASE}/$
    +    {PKG_SYSCONFSUBDIR}.
     
    -    Running this command takes a very long time, some hours even on fast
    -    machines!
    + 3. Otherwise, it is set to ${PKG_SYSCONFBASE}.
     
    -readme
    +It is worth mentioning that ${PKG_SYSCONFDIR} is automatically added to
    +OWN_DIRS. See Section 20.1.1, "Directory manipulation" what this means. This
    +does not apply to subdirectories of ${PKG_SYSCONFDIR}, they still have to be
    +created with OWN_DIRS or MAKE_DIRS.
     
    -    This target generates a README.html file, which can be viewed using a
    -    browser such as www/firefox or www/links. The generated files contain
    -    references to any packages which are in the PACKAGES directory on the local
    -    host. The generated files can be made to refer to URLs based on
    -    FTP_PKG_URL_HOST and FTP_PKG_URL_DIR. For example, if I wanted to generate
    -    README.html files which pointed to binary packages on the local machine, in
    -    the directory /usr/packages, set FTP_PKG_URL_HOST=file://localhost and
    -    FTP_PKG_URL_DIR=/usr/packages. The ${PACKAGES} directory and its
    -    subdirectories will be searched for all the binary packages.
    +20.2.2. Telling the software where configuration files are
     
    -    The target can be run at the toplevel or in category directories, in which
    -    case it descends recursively.
    +Given that pkgsrc (and users!) expect configuration files to be in a known
    +place, you need to teach each package where it shall install its files. In some
    +cases you will have to patch the package Makefiles to achieve it. If you are
    +lucky, though, it may be as easy as passing an extra flag to the configuration
    +script; this is the case of GNU Autoconf- generated files:
     
    -readme-all
    +CONFIGURE_ARGS+= --sysconfdir=${PKG_SYSCONFDIR}
     
    -    This is a top-level command, run it in pkgsrc. Use this target to create a
    -    file README-all.html which contains a list of all packages currently
    -    available in the NetBSD Packages Collection, together with the category
    -    they belong to and a short description. This file is compiled from the
    -    pkgsrc/*/README.html files, so be sure to run this after a make readme.
    +Note that this specifies where the package has to look for its configuration
    +files, not where they will be originally installed (although the difference is
    +never explicit, unfortunately).
     
    -cdrom-readme
    +20.2.3. Patching installations
     
    -    This is very much the same as the "readme" target (see above), but is to be
    -    used when generating a pkgsrc tree to be written to a CD-ROM. This target
    -    also produces README.html files, and can be made to refer to URLs based on
    -    CDROM_PKG_URL_HOST and CDROM_PKG_URL_DIR.
    +As said before, pkginstall automatically handles configuration files. This
    +means that the packages themselves must not touch the contents of $
    +{PKG_SYSCONFDIR} directly. Bad news is that many software installation scripts
    +will, out of the box, mess with the contents of that directory. So what is the
    +correct procedure to fix this issue?
     
    -show-distfiles
    +You must teach the package (usually by manually patching it) to install any
    +configuration files under the examples hierarchy, share/examples/${PKGBASE}/.
    +This way, the PLIST registers them and the administrator always has the
    +original copies available.
     
    -    This target shows which distfiles and patchfiles are needed to build the
    -    package (ALLFILES, which contains all DISTFILES and PATCHFILES, but not
    -    patches/*).
    +Once the required configuration files are in place (i.e., under the examples
    +hierarchy), the pkginstall framework can use them as master copies during the
    +package installation to update what is in ${PKG_SYSCONFDIR}. To achieve this,
    +the variables CONF_FILES and CONF_FILES_PERMS are used. Check out
    +Section 20.1.2, "File manipulation" for information about their syntax and
    +their purpose. Here is an example, taken from the mail/mutt package:
     
    -show-downlevel
    +EGDIR=        ${PREFIX}/share/doc/mutt/samples
    +CONF_FILES=   ${EGDIR}/Muttrc ${PKG_SYSCONFDIR}/Muttrc
     
    -    This target shows nothing if the package is not installed. If a version of
    -    this package is installed, but is not the version provided in this version
    -    of pkgsrc, then a warning message is displayed. This target can be used to
    -    show which of your installed packages are downlevel, and so the old
    -    versions can be deleted, and the current ones added.
    +Note that the EGDIR variable is specific to that package and has no meaning
    +outside it.
     
    -show-pkgsrc-dir
    +20.2.4. Disabling handling of configuration files
     
    -    This target shows the directory in the pkgsrc hierarchy from which the
    -    package can be built and installed. This may not be the same directory as
    -    the one from which the package was installed. This target is intended to be
    -    used by people who may wish to upgrade many packages on a single host, and
    -    can be invoked from the top-level pkgsrc Makefile by using the "
    -    show-host-specific-pkgs" target.
    +The automatic copying of config files can be toggled by setting the environment
    +variable PKG_CONFIG prior to package installation.
     
    -show-installed-depends
    +20.3. System startup scripts
     
    -    This target shows which installed packages match the current package's
    -    DEPENDS. Useful if out of date dependencies are causing build problems.
    +System startup scripts are special files because they must be installed in a
    +place known by the underlying OS, usually outside the installation prefix.
    +Therefore, the same rules described in Section 20.1, "Files and directories
    +outside the installation prefix" apply, and the same solutions can be used.
    +However, pkginstall provides a special mechanism to handle these files.
     
    -print-build-depends-list
    +In order to provide system startup scripts, the package has to:
     
    -    This target shows the list of packages that the current package depends on
    -    for building.
    + 1. Store the script inside ${FILESDIR}, with the .sh suffix appended.
    +    Considering the print/cups package as an example, it has a cupsd.sh in its
    +    files directory.
     
    -print-run-depends-list
    + 2. Tell pkginstall to handle it, appending the name of the script, without its
    +    extension, to the RCD_SCRIPTS variable. Continuing the previous example:
     
    -    This target shows the list of packages that the current package depends on
    -    for running.
    +    RCD_SCRIPTS+=   cupsd
     
    -check-shlibs
    +Once this is done, pkginstall will do the following steps for each script in an
    +automated fashion:
     
    -    After a package is installed, check all its binaries and (on ELF platforms)
    -    shared libraries to see if they find the shared libs they need. Run by
    -    default if PKG_DEVELOPER is set in mk.conf.
    + 1. Process the file found in the files directory applying all the
    +    substitutions described in the FILES_SUBST variable.
     
    -print-PLIST
    + 2. Copy the script from the files directory to the examples hierarchy, $
    +    {PREFIX}/share/examples/rc.d/. Note that this master file must be
    +    explicitly registered in the PLIST.
     
    -    After a "make install" from a new or upgraded pkg, this prints out an
    -    attempt to generate a new PLIST from a find -newer work/.extract_done. An
    -    attempt is made to care for shared libs etc., but it is strongly
    -    recommended to review the result before putting it into PLIST. On upgrades,
    -    it's useful to diff the output of this command against an already existing
    -    PLIST file.
    + 3. Add code to the installation scripts to copy the startup script from the
    +    examples hierarchy into the system-wide startup scripts directory.
     
    -    If the package installs files via tar(1) or other methods that don't update
    -    file access times, be sure to add these files manually to your PLIST, as
    -    the "find -newer" command used by this target won't catch them!
    +20.3.1. Disabling handling of system startup scripts
     
    -    See Section 15.3, "Tweaking output of make print-PLIST" for more
    -    information on this target.
    +The automatic copying of config files can be toggled by setting the environment
    +variable PKG_RCD_SCRIPTS prior to package installation. Note that the scripts
    +will be always copied inside the examples hierarchy, ${PREFIX}/share/examples/
    +rc.d/, no matter what the value of this variable is.
     
    -Chapter 20. Tools needed for building or running
    +20.4. System users and groups
     
    -Table of Contents
    +If a package needs to create special users and/or groups during installation,
    +it can do so by using the pkginstall framework.
     
    -20.1. Tools for pkgsrc builds
    -20.2. Tools needed by packages
    -20.3. Tools provided by platforms
    +Users can be created by adding entries to the PKG_USERS variable. Each entry
    +has the following syntax:
     
    -The USE_TOOLS definition is used both internally by pkgsrc and also for
    -individual packages to define what commands are needed for building a package
    -(like TOOL_DEPENDS) or for later run-time of an installed packaged (such as
    -DEPENDS). If the native system provides an adequate tool, then in many cases, a
    -pkgsrc package will not be used.
    +user:group
    +
    +Further specification of user details may be done by setting per-user
    +variables. PKG_UID.user is the numeric UID for the user. PKG_GECOS.user is the
    +user's description or comment. PKG_HOME.user is the user's home directory, and
    +defaults to /nonexistent if not specified. PKG_SHELL.user is the user's shell,
    +and defaults to /sbin/nologin if not specified.
     
    -When building a package, the replacement tools are made available in a
    -directory (as symlinks or wrapper scripts) that is early in the executable
    -search path. Just like the buildlink system, this helps with consistent builds.
    +Similarly, groups can be created by adding entries to the PKG_GROUPS variable,
    +whose syntax is:
     
    -A tool may be needed to help build a specific package. For example, perl, GNU
    -make (gmake) or yacc may be needed.
    +group
     
    -Also a tool may be needed, for example, because the native system's supplied
    -tool may be inefficient for building a package with pkgsrc. For example, a
    -package may need GNU awk, bison (instead of yacc) or a better sed.
    +The numeric GID of the group may be set by defining PKG_GID.group.
     
    -The tools used by a package can be listed by running make show-tools.
    +If a package needs to create the users and groups at an earlier stage, then it
    +can set USERGROUP_PHASE to either configure,build, or pre-install to indicate
    +the phase before which the users and groups are created. In this case, the
    +numeric UIDs and GIDs of the created users and groups are automatically
    +hardcoded into the final installation scripts.
     
    -20.1. Tools for pkgsrc builds
    +20.5. System shells
     
    -The default set of tools used by pkgsrc is defined in bsd.pkg.mk. This includes
    -standard Unix tools, such as: cat, awk, chmod, test, and so on. These can be
    -seen by running: make show-var VARNAME=USE_TOOLS.
    +Packages that install system shells should register them in the shell database,
    +/etc/shells, to make things easier to the administrator. This must be done from
    +the installation scripts to keep binary packages working on any system.
    +pkginstall provides an easy way to accomplish this task.
     
    -If a package needs a specific program to build then the USE_TOOLS variable can
    -be used to define the tools needed.
    +When a package provides a shell interpreter, it has to set the PKG_SHELL
    +variable to its absolute file name. This will add some hooks to the
    +installation scripts to handle it. Consider the following example, taken from
    +shells/zsh:
     
    -20.2. Tools needed by packages
    +PKG_SHELL=      ${PREFIX}/bin/zsh
     
    -In the following examples, the :run means that it is needed at run-time (and
    -becomes a DEPENDS). The default is a build dependency which can be set with
    -:build. (So in this example, it is the same as gmake:build and
    -pkg-config:build.)
    +20.5.1. Disabling shell registration
     
    -USE_TOOLS+=     gmake perl:run pkg-config
    +The automatic registration of shell interpreters can be disabled by the
    +administrator by setting the PKG_REGISTER_SHELLS environment variable to NO.
     
    -When using the tools framework, a TOOLS_PATH.foo variable is defined which
    -contains the full path to the appropriate tool. For example, TOOLS_PATH.bash
    -could be "/bin/bash" on Linux systems.
    +20.6. Fonts
     
    -If you always need a pkgsrc version of the tool at run-time, then just use
    -DEPENDS instead.
    +Packages that install X11 fonts should update the database files that index the
    +fonts within each fonts directory. This can easily be accomplished within the
    +pkginstall framework.
     
    -20.3. Tools provided by platforms
    +When a package installs X11 fonts, it must list the directories in which fonts
    +are installed in the FONTS_DIRS.type variables, where type can be one of "ttf",
    +"type1" or "x11". This will add hooks to the installation scripts to run the
    +appropriate commands to update the fonts database files within each of those
    +directories. For convenience, if the directory path is relative, it is taken to
    +be relative to the package's installation prefix. Consider the following
    +example, taken from fonts/dbz-ttf:
     
    -When improving or porting pkgsrc to a new platform, have a look at (or create)
    -the corresponding platform specific make file fragment under pkgsrc/mk/tools/
    -tools.${OPSYS}.mk which defines the name of the common tools. For example:
    +FONTS_DIRS.ttf= ${PREFIX}/share/fonts/X11/TTF
     
    -.if exists(/usr/bin/bzcat)
    -TOOLS_PLATFORM.bzcat?=          /usr/bin/bzcat
    -.elif exists(/usr/bin/bzip2)
    -TOOLS_PLATFORM.bzcat?=          /usr/bin/bzip2 -cd
    -.endif
    +20.6.1. Disabling automatic update of the fonts databases
     
    -TOOLS_PLATFORM.true?=           true                    # shell builtin
    +The automatic update of fonts databases can be disabled by the administrator by
    +setting the PKG_UPDATE_FONTS_DB environment variable to NO.
     
     Chapter 21. Making your package work
     
    @@ -6184,13 +6206,13 @@ various ways of expressing this dependen
     BUILD_DEPENDS, TOOL_DEPENDS, and TEST_DEPENDS definitions, the USE_TOOLS
     definition, as well as dependencies via buildlink3.mk, which is the preferred
     way to handle dependencies, and which uses the variables named above. See
    -Chapter 16, Buildlink methodology for more information.
    +Chapter 18, Buildlink methodology for more information.
     
     The basic difference is that the DEPENDS definition registers that
     pre-requisite in the binary package so it will be pulled in when the binary
     package is later installed, whilst the BUILD_DEPENDS, TOOL_DEPENDS, and
     TEST_DEPENDS definitions do not, marking a dependency that is only needed for
    -building or testing the resulting package. See also Chapter 12, Creating a new
    +building or testing the resulting package. See also Chapter 14, Creating a new
     pkgsrc package from scratch for more information.
     
     This means that if you only need a package present whilst you are building or
    @@ -6880,7 +6902,7 @@ NO in the package Makefile.
     
     Compilers for the C, C++, and Fortran languages comes with the NetBSD base
     system. By default, pkgsrc assumes that a package is written in C and will hide
    -all other compilers (via the wrapper framework, see Chapter 16, Buildlink
    +all other compilers (via the wrapper framework, see Chapter 18, Buildlink
     methodology).
     
     To declare which language's compiler a package needs, set the USE_LANGUAGES
    @@ -7385,7 +7407,7 @@ Packages that use GNU_CONFIGURE but do n
     CONFIGURE_HAS_MANDIR to "no". Or if the ./configure script uses a non-standard
     use of --mandir, you can set GNU_CONFIGURE_MANDIR as needed.
     
    -See Section 15.5, "Man page compression" for information on installation of
    +See Section 19.5, "Man page compression" for information on installation of
     compressed manual pages.
     
     21.6.9. Packages installing GConf data files
    @@ -7614,87 +7636,255 @@ be shown this message, and the build wil
     
     BROKEN packages are removed from pkgsrc in irregular intervals.
     
    -Chapter 22. Debugging
    +Chapter 22. GNOME packaging and porting
    +
    +Table of Contents
    +
    +22.1. Meta packages
    +22.2. Packaging a GNOME application
    +22.3. Updating GNOME to a newer version
    +22.4. Patching guidelines
    +
    +Quoting GNOME's web site:
    +
    +    The GNOME project provides two things: The GNOME desktop environment, an
    +    intuitive and attractive desktop for users, and the GNOME development
    +    platform, an extensive framework for building applications that integrate
    +    into the rest of the desktop.
    +
    +pkgsrc provides a seamless way to automatically build and install a complete
    +GNOME environment under many different platforms. We can say with confidence
    +that pkgsrc is one of the most advanced build and packaging systems for GNOME
    +due to its included technologies buildlink3, the wrappers and tools framework
    +and automatic configuration file management. Lots of efforts are put into
    +achieving a completely clean deinstallation of installed software components.
    +
    +Given that pkgsrc is NetBSD's official packaging system, the above also means
    +that great efforts are put into making GNOME work under this operating system.
    +Recently, DragonFly BSD also adopted pkgsrc as its preferred packaging system,
    +contributing lots of portability fixes to make GNOME build and install under
    +it.
    +
    +This chapter is aimed at pkgsrc developers and other people interested in
    +helping our GNOME porting and packaging efforts. It provides instructions on
    +how to manage the existing packages and some important information regarding
    +their internals.
    +
    +We need your help!
    +
    +Should you have some spare cycles to devote to NetBSD, pkgsrc and GNOME and are
    +willing to learn new exciting stuff, please jump straight to the pending work
    +list! There is still a long way to go to get a fully-functional GNOME desktop
    +under NetBSD and we need your help to achieve it!
    +
    +22.1. Meta packages
    +
    +pkgsrc includes three GNOME-related meta packages:
    +
    +  * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
    +    includes the necessary bits to get it to boot correctly, although it may
    +    lack important functionality for daily operation. The idea behind this
    +    package is to let end users build their own configurations on top of this
    +    one, first installing this meta package to achieve a functional setup and
    +    then adding individual applications.
    +
    +  * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
    +    desktop as defined by the GNOME project; this is based on the components
    +    distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
    +    directories of the official FTP server. Developer-only tools found in those
    +    directories are not installed unless required by some other component to
    +    work properly. Similarly, packages from the bindings set (bindings/x.y/
    +    x.y.z/sources) are not pulled in unless required as a dependency for an
    +    end-user component. This package "extends" meta-pkgs/gnome-base.
    +
    +  * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
    +    component when fetched from the CVS repository. These are required to let
    +    the autogen.sh scripts work appropriately.
    +
    +In all these packages, the DEPENDS lines are sorted in a way that eases
    +updates: a package may depend on other packages listed before it but not on any
    +listed after it. It is very important to keep this order to ease updates so... 
    +do not change it to alphabetical sorting!
    +
    +22.2. Packaging a GNOME application
    +
    +Almost all GNOME applications are written in C and use a common set of tools as
    +their build system. Things get different with the new bindings to other
    +languages (such as Python), but the following will give you a general idea on
    +the minimum required tools:
    +
    +  * Almost all GNOME applications use the GNU Autotools as their build system.
    +    As a general rule you will need to tell this to your package:
    +
    +    GNU_CONFIGURE=yes
    +    USE_LIBTOOL=yes
    +    USE_TOOLS+=gmake
    +
    +  * If the package uses pkg-config to detect dependencies, add this tool to the
    +    list of required utilities:
    +
    +    USE_TOOLS+=pkg-config
    +
    +    Also use pkgtools/verifypc at the end of the build process to ensure that
    +    you did not miss to specify any dependency in your package and that the
    +    version requirements are all correct.
    +
    +  * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
    +    handle dependencies and to force the package to use the latest available
    +    version.
    +
    +  * If the package uses gtk-doc (a documentation generation utility), do not
    +    add a dependency on it. The tool is rather big and the distfile should come
    +    with pregenerated documentation anyway; if it does not, it is a bug that
    +    you ought to report. For such packages you should disable gtk-doc (unless
    +    it is the default):
    +
    +    CONFIGURE_ARGS+=--disable-gtk-doc
    +
    +    The default location of installed HTML files (share/gtk-doc/)
    +    is correct and should not be changed unless the package insists on
    +    installing them somewhere else. Otherwise programs as devhelp will not be
    +    able to open them. You can do that with an entry similar to:
     
    -To check out all the gotchas when building a package, here are the steps that I
    -do in order to get a package working. Please note this is basically the same as
    -what was explained in the previous sections, only with some debugging aids.
    +    CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...
     
    -  * Be sure to set PKG_DEVELOPER=yes in mk.conf.
    +GNOME uses multiple shared directories and files under the installation prefix
    +to maintain databases. In this context, shared means that those exact same
    +directories and files are used among several different packages, leading to
    +conflicts in the PLIST. pkgsrc currently includes functionality to handle the
    +most common cases, so you have to forget about using @unexec ${RMDIR} lines in
    +your file lists and omitting shared files from them. If you find yourself doing
    +those, your package is most likely incorrect.
     
    -  * Install pkgtools/url2pkg, create a directory for a new package, change into
    -    it, then run url2pkg:
    +The following table lists the common situations that result in using shared
    +directories or files. For each of them, the appropriate solution is given.
    +After applying the solution be sure to regenerate the package's file list with 
    +make print-PLIST and ensure it is correct.
     
    -    % mkdir /usr/pkgsrc/category/examplepkg
    -    % cd /usr/pkgsrc/category/examplepkg
    -    % url2pkg https://www.example.com/path/to/distfile.tar.gz
    +Table 22.1. PLIST handling for GNOME packages
     
    -  * Edit the Makefile as requested.
    ++-----------------------------------------------------------------------------+
    +|             If the package...             |             Then...             |
    +|-------------------------------------------+---------------------------------|
    +|                                           |See Section 21.6.10, "Packages   |
    +|Installs OMF files under share/omf.        |installing scrollkeeper/rarian   |
    +|                                           |data files".                     |
    +|-------------------------------------------+---------------------------------|
    +|Installs icons under the share/icons/      |See Section 21.6.19, "Packages   |
    +|hicolor hierarchy or updates share/icons/  |installing hicolor theme icons". |
    +|hicolor/icon-theme.cache.                  |                                 |
    +|-------------------------------------------+---------------------------------|
    +|                                           |See Section 21.6.14, "Packages   |
    +|Installs files under share/mime/packages.  |installing extensions to the MIME|
    +|                                           |database".                       |
    +|-------------------------------------------+---------------------------------|
    +|Installs .desktop files under share/       |See Section 21.6.20, "Packages   |
    +|applications and these include MIME        |installing desktop files".       |
    +|information.                               |                                 |
    ++-----------------------------------------------------------------------------+
     
    -  * Fill in the DESCR file
     
    -  * Run make configure
    +22.3. Updating GNOME to a newer version
     
    -  * Add any dependencies glimpsed from documentation and the configure step to
    -    the package's Makefile.
    +When seeing GNOME as a whole, there are two kinds of updates:
     
    -  * Make the package compile, doing multiple rounds of
    +Major update
     
    -    % make
    -    % pkgvi ${WRKSRC}/some/file/that/does/not/compile
    -    % mkpatches
    -    % patchdiff
    -    % mv ${WRKDIR}/.newpatches/* patches
    -    % make mps
    -    % make clean
    +    Given that there is still a very long way for GNOME 3 (if it ever appears),
    +    we consider a major update one that goes from a 2.X version to a 2.Y one,
    +    where Y is even and greater than X. These are hard to achieve because they
    +    introduce lots of changes in the components' code and almost all GNOME
    +    distfiles are updated to newer versions. Some of them can even break API
    +    and ABI compatibility with the previous major version series. As a result,
    +    the update needs to be done all at once to minimize breakage.
     
    -    Doing this step as non-root user will ensure that no files are modified
    -    that shouldn't be, especially during the build phase. mkpatches, patchdiff
    -    and pkgvi are from the pkgtools/pkgdiff package.
    +    A major update typically consists of around 80 package updates and the
    +    addition of some new ones.
     
    -  * Look at the Makefile, fix if necessary; see Section 13.1, "Makefile".
    +Minor update
     
    -  * Generate a PLIST:
    +    We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
    +    one where Y is greater than X. These are easy to achieve because they do
    +    not update all GNOME components, can be done in an incremental way and do
    +    not break API nor ABI compatibility.
     
    -    # make install
    -    # make print-PLIST >PLIST
    -    # make deinstall
    -    # make install
    -    # make deinstall
    +    A minor update typically consists of around 50 package updates, although
    +    the numbers here may vary a lot.
     
    -    You usually need to be root to do this. Look if there are any files left:
    +In order to update the GNOME components in pkgsrc to a new stable release
    +(either major or minor), the following steps should be followed:
     
    -    # make print-PLIST
    + 1. Get a list of all the tarballs that form the new release by using the
    +    following commands. These will leave the full list of the components'
    +    distfiles into the list.txt file:
     
    -    If this reveals any files that are missing in PLIST, add them.
    +    % echo ls "*.tar.bz2" | \
    +        ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
    +        awk '{ print $9 }' >list.txt
    +    % echo ls "*.tar.bz2" | \
    +        ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
    +        awk '{ print $9 }' >>list.txt
     
    -  * Now that the PLIST is OK, install the package again and make a binary
    -    package:
    + 2. Open each meta package's Makefile and bump their version to the release you
    +    are updating them to. The three meta packages should be always consistent
    +    with versioning. Obviously remove any PKGREVISIONs that might be in them.
     
    -    # make reinstall
    -    # make package
    + 3. For each meta package, update all its DEPENDS lines to match the latest
    +    versions as shown by the above commands. Do not list any newer version
    +    (even if found in the FTP) because the meta packages are supposed to list
    +    the exact versions that form a specific GNOME release. Exceptions are
    +    permitted here if a newer version solves a serious issue in the overall
    +    desktop experience; these typically come in the form of a revision bump in
    +    pkgsrc, not in newer versions from the developers.
     
    -  * Delete the installed package:
    +    Packages not listed in the list.txt file should be updated to the latest
    +    version available (if found in pkgsrc). This is the case, for example, of
    +    the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
    +    package.
     
    -    # pkg_delete examplepkg
    + 4. Generate a patch from the modified meta packages and extract the list of
    +    "new" lines. This will provide you an outline on what packages need to be
    +    updated in pkgsrc and in what order:
     
    -  * Repeat the above make print-PLIST command, which shouldn't find anything
    -    now:
    +    % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
     
    -    # make print-PLIST
    + 5. For major desktop updates it is recommended to zap all your installed
    +    packages and start over from scratch at this point.
     
    -  * Reinstall the binary package:
    + 6. Now comes the longest step by far: iterate over the contents of todo.txt
    +    and update the packages listed in it in order. For major desktop updates
    +    none of these should be committed until the entire set is completed because
    +    there are chances of breaking not-yet-updated packages.
     
    -    # pkg_add .../examplepkg.tgz
    + 7. Once the packages are up to date and working, commit them to the tree one
    +    by one with appropriate log messages. At the end, commit the three meta
    +    package updates and all the corresponding changes to the doc/CHANGES-
    +    and pkgsrc/doc/TODO files.
     
    -  * Play with it. Make sure everything works.
    +22.4. Patching guidelines
     
    -  * Run pkglint from pkgtools/pkglint, and fix the problems it reports:
    +GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
    +it is very important that you always, always, always feed back any portability
    +fixes you do to a GNOME package to the mainstream developers (see
    +Section 12.3.5, "Feedback to the author"). This is the only way to get their
    +attention on portability issues and to ensure that future versions can be built
    +out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
    +updates are. Those developers in charge of issuing major GNOME updates will be
    +grateful if you do that.
     
    -    # pkglint
    +The most common places to report bugs are the GNOME's Bugzilla and the
    +freedesktop.org's Bugzilla. Not all components use these to track bugs, but
    +most of them do. Do not be short on your reports: always provide detailed
    +explanations of the current failure, how it can be improved to achieve maximum
    +portability and, if at all possible, provide a patch against CVS head. The more
    +verbose you are, the higher chances of your patch being accepted.
     
    -  * Submit (or commit, if you have cvs access); see Chapter 23, Submitting and
    -    Committing.
    +Also, please avoid using preprocessor magic to fix portability issues. While
    +the FreeBSD GNOME people are doing a great job in porting GNOME to their
    +operating system, the official GNOME sources are now plagued by conditionals
    +that check for __FreeBSD__ and similar macros. This hurts portability. Please
    +see our patching guidelines (Section 12.3.4, "Patching guidelines") for more
    +details.
     
     Chapter 23. Submitting and Committing
     
    @@ -7721,13 +7911,14 @@ Creating binary packages for everything 
     23.2. Submitting source packages (for non-NetBSD-developers)
     
     First, check that your package is complete, compiles and runs well; see
    -Chapter 22, Debugging and the rest of this document. Next, generate an
    -uuencoded gzipped tar(1) archive that contains all files that make up the
    -package. Finally, send this package to the pkgsrc bug tracking system, either
    -with the send-pr(1) command, or if you don't have that, go to the web page
    -https://www.NetBSD.org/support/send-pr.html, which contains some instructions
    -and a link to a form where you can submit packages. The sysutils/gtk-send-pr
    -package is also available as a substitute for either of the above two tools.
    +Chapter 14, Creating a new pkgsrc package from scratch and the rest of this
    +document. Next, generate an uuencoded gzipped tar(1) archive that contains all
    +files that make up the package. Finally, send this package to the pkgsrc bug
    +tracking system, either with the send-pr(1) command, or if you don't have that,
    +go to the web page https://www.NetBSD.org/support/send-pr.html, which contains
    +some instructions and a link to a form where you can submit packages. The
    +sysutils/gtk-send-pr package is also available as a substitute for either of
    +the above two tools.
     
     In the form of the problem report, the category should be "pkg", the synopsis
     should include the package name and version number, and the description field
    @@ -8052,256 +8243,6 @@ pkgsrc-users mailing list.
             * Review packages for which review was requested on the tech-pkg
               mailing list.
     
    -Chapter 25. GNOME packaging and porting
    -
    -Table of Contents
    -
    -25.1. Meta packages
    -25.2. Packaging a GNOME application
    -25.3. Updating GNOME to a newer version
    -25.4. Patching guidelines
    -
    -Quoting GNOME's web site:
    -
    -    The GNOME project provides two things: The GNOME desktop environment, an
    -    intuitive and attractive desktop for users, and the GNOME development
    -    platform, an extensive framework for building applications that integrate
    -    into the rest of the desktop.
    -
    -pkgsrc provides a seamless way to automatically build and install a complete
    -GNOME environment under many different platforms. We can say with confidence
    -that pkgsrc is one of the most advanced build and packaging systems for GNOME
    -due to its included technologies buildlink3, the wrappers and tools framework
    -and automatic configuration file management. Lots of efforts are put into
    -achieving a completely clean deinstallation of installed software components.
    -
    -Given that pkgsrc is NetBSD's official packaging system, the above also means
    -that great efforts are put into making GNOME work under this operating system.
    -Recently, DragonFly BSD also adopted pkgsrc as its preferred packaging system,
    -contributing lots of portability fixes to make GNOME build and install under
    -it.
    -
    -This chapter is aimed at pkgsrc developers and other people interested in
    -helping our GNOME porting and packaging efforts. It provides instructions on
    -how to manage the existing packages and some important information regarding
    -their internals.
    -
    -We need your help!
    -
    -Should you have some spare cycles to devote to NetBSD, pkgsrc and GNOME and are
    -willing to learn new exciting stuff, please jump straight to the pending work
    -list! There is still a long way to go to get a fully-functional GNOME desktop
    -under NetBSD and we need your help to achieve it!
    -
    -25.1. Meta packages
    -
    -pkgsrc includes three GNOME-related meta packages:
    -
    -  * meta-pkgs/gnome-base: Provides the core GNOME desktop environment. It only
    -    includes the necessary bits to get it to boot correctly, although it may
    -    lack important functionality for daily operation. The idea behind this
    -    package is to let end users build their own configurations on top of this
    -    one, first installing this meta package to achieve a functional setup and
    -    then adding individual applications.
    -
    -  * meta-pkgs/gnome: Provides a complete installation of the GNOME platform and
    -    desktop as defined by the GNOME project; this is based on the components
    -    distributed in the platform/x.y/x.y.z/sources and desktop/x.y/x.y.z/sources
    -    directories of the official FTP server. Developer-only tools found in those
    -    directories are not installed unless required by some other component to
    -    work properly. Similarly, packages from the bindings set (bindings/x.y/
    -    x.y.z/sources) are not pulled in unless required as a dependency for an
    -    end-user component. This package "extends" meta-pkgs/gnome-base.
    -
    -  * meta-pkgs/gnome-devel: Installs all the tools required to build a GNOME
    -    component when fetched from the CVS repository. These are required to let
    -    the autogen.sh scripts work appropriately.
    -
    -In all these packages, the DEPENDS lines are sorted in a way that eases
    -updates: a package may depend on other packages listed before it but not on any
    -listed after it. It is very important to keep this order to ease updates so... 
    -do not change it to alphabetical sorting!
    -
    -25.2. Packaging a GNOME application
    -
    -Almost all GNOME applications are written in C and use a common set of tools as
    -their build system. Things get different with the new bindings to other
    -languages (such as Python), but the following will give you a general idea on
    -the minimum required tools:
    -
    -  * Almost all GNOME applications use the GNU Autotools as their build system.
    -    As a general rule you will need to tell this to your package:
    -
    -    GNU_CONFIGURE=yes
    -    USE_LIBTOOL=yes
    -    USE_TOOLS+=gmake
    -
    -  * If the package uses pkg-config to detect dependencies, add this tool to the
    -    list of required utilities:
    -
    -    USE_TOOLS+=pkg-config
    -
    -    Also use pkgtools/verifypc at the end of the build process to ensure that
    -    you did not miss to specify any dependency in your package and that the
    -    version requirements are all correct.
    -
    -  * If the package uses intltool, be sure to add intltool to the USE_TOOLS to
    -    handle dependencies and to force the package to use the latest available
    -    version.
    -
    -  * If the package uses gtk-doc (a documentation generation utility), do not
    -    add a dependency on it. The tool is rather big and the distfile should come
    -    with pregenerated documentation anyway; if it does not, it is a bug that
    -    you ought to report. For such packages you should disable gtk-doc (unless
    -    it is the default):
    -
    -    CONFIGURE_ARGS+=--disable-gtk-doc
    -
    -    The default location of installed HTML files (share/gtk-doc/)
    -    is correct and should not be changed unless the package insists on
    -    installing them somewhere else. Otherwise programs as devhelp will not be
    -    able to open them. You can do that with an entry similar to:
    -
    -    CONFIGURE_ARGS+=--with-html-dir=${PREFIX}/share/gtk-doc/...
    -
    -GNOME uses multiple shared directories and files under the installation prefix
    -to maintain databases. In this context, shared means that those exact same
    -directories and files are used among several different packages, leading to
    -conflicts in the PLIST. pkgsrc currently includes functionality to handle the
    -most common cases, so you have to forget about using @unexec ${RMDIR} lines in
    -your file lists and omitting shared files from them. If you find yourself doing
    -those, your package is most likely incorrect.
    -
    -The following table lists the common situations that result in using shared
    -directories or files. For each of them, the appropriate solution is given.
    -After applying the solution be sure to regenerate the package's file list with 
    -make print-PLIST and ensure it is correct.
    -
    -Table 25.1. PLIST handling for GNOME packages
    -
    -+-----------------------------------------------------------------------------+
    -|             If the package...             |             Then...             |
    -|-------------------------------------------+---------------------------------|
    -|                                           |See Section 21.6.10, "Packages   |
    -|Installs OMF files under share/omf.        |installing scrollkeeper/rarian   |
    -|                                           |data files".                     |
    -|-------------------------------------------+---------------------------------|
    -|Installs icons under the share/icons/      |See Section 21.6.19, "Packages   |
    -|hicolor hierarchy or updates share/icons/  |installing hicolor theme icons". |
    -|hicolor/icon-theme.cache.                  |                                 |
    -|-------------------------------------------+---------------------------------|
    -|                                           |See Section 21.6.14, "Packages   |
    -|Installs files under share/mime/packages.  |installing extensions to the MIME|
    -|                                           |database".                       |
    -|-------------------------------------------+---------------------------------|
    -|Installs .desktop files under share/       |See Section 21.6.20, "Packages   |
    -|applications and these include MIME        |installing desktop files".       |
    -|information.                               |                                 |
    -+-----------------------------------------------------------------------------+
    -
    -
    -25.3. Updating GNOME to a newer version
    -
    -When seeing GNOME as a whole, there are two kinds of updates:
    -
    -Major update
    -
    -    Given that there is still a very long way for GNOME 3 (if it ever appears),
    -    we consider a major update one that goes from a 2.X version to a 2.Y one,
    -    where Y is even and greater than X. These are hard to achieve because they
    -    introduce lots of changes in the components' code and almost all GNOME
    -    distfiles are updated to newer versions. Some of them can even break API
    -    and ABI compatibility with the previous major version series. As a result,
    -    the update needs to be done all at once to minimize breakage.
    -
    -    A major update typically consists of around 80 package updates and the
    -    addition of some new ones.
    -
    -Minor update
    -
    -    We consider a minor update one that goes from a 2.A.X version to a 2.A.Y
    -    one where Y is greater than X. These are easy to achieve because they do
    -    not update all GNOME components, can be done in an incremental way and do
    -    not break API nor ABI compatibility.
    -
    -    A minor update typically consists of around 50 package updates, although
    -    the numbers here may vary a lot.
    -
    -In order to update the GNOME components in pkgsrc to a new stable release
    -(either major or minor), the following steps should be followed:
    -
    - 1. Get a list of all the tarballs that form the new release by using the
    -    following commands. These will leave the full list of the components'
    -    distfiles into the list.txt file:
    -
    -    % echo ls "*.tar.bz2" | \
    -        ftp -V ftp://ftp.gnome.org/pub/gnome/platform/x.y/x.y.z/sources/ | \
    -        awk '{ print $9 }' >list.txt
    -    % echo ls "*.tar.bz2" | \
    -        ftp -V ftp://ftp.gnome.org/pub/gnome/desktop/x.y/x.y.z/sources/ | \
    -        awk '{ print $9 }' >>list.txt
    -
    - 2. Open each meta package's Makefile and bump their version to the release you
    -    are updating them to. The three meta packages should be always consistent
    -    with versioning. Obviously remove any PKGREVISIONs that might be in them.
    -
    - 3. For each meta package, update all its DEPENDS lines to match the latest
    -    versions as shown by the above commands. Do not list any newer version
    -    (even if found in the FTP) because the meta packages are supposed to list
    -    the exact versions that form a specific GNOME release. Exceptions are
    -    permitted here if a newer version solves a serious issue in the overall
    -    desktop experience; these typically come in the form of a revision bump in
    -    pkgsrc, not in newer versions from the developers.
    -
    -    Packages not listed in the list.txt file should be updated to the latest
    -    version available (if found in pkgsrc). This is the case, for example, of
    -    the dependencies on the GNU Autotools in the meta-pkgs/gnome-devel meta
    -    package.
    -
    - 4. Generate a patch from the modified meta packages and extract the list of
    -    "new" lines. This will provide you an outline on what packages need to be
    -    updated in pkgsrc and in what order:
    -
    -    % cvs diff -u gnome-devel gnome-base gnome | grep '^+D' >todo.txt
    -
    - 5. For major desktop updates it is recommended to zap all your installed
    -    packages and start over from scratch at this point.
    -
    - 6. Now comes the longest step by far: iterate over the contents of todo.txt
    -    and update the packages listed in it in order. For major desktop updates
    -    none of these should be committed until the entire set is completed because
    -    there are chances of breaking not-yet-updated packages.
    -
    - 7. Once the packages are up to date and working, commit them to the tree one
    -    by one with appropriate log messages. At the end, commit the three meta
    -    package updates and all the corresponding changes to the doc/CHANGES-
    -    and pkgsrc/doc/TODO files.
    -
    -25.4. Patching guidelines
    -
    -GNOME is a very big component in pkgsrc which approaches 100 packages. Please,
    -it is very important that you always, always, always feed back any portability
    -fixes you do to a GNOME package to the mainstream developers (see
    -Section 13.3.5, "Feedback to the author"). This is the only way to get their
    -attention on portability issues and to ensure that future versions can be built
    -out-of-the box on NetBSD. The less custom patches in pkgsrc, the easier further
    -updates are. Those developers in charge of issuing major GNOME updates will be
    -grateful if you do that.
    -
    -The most common places to report bugs are the GNOME's Bugzilla and the
    -freedesktop.org's Bugzilla. Not all components use these to track bugs, but
    -most of them do. Do not be short on your reports: always provide detailed
    -explanations of the current failure, how it can be improved to achieve maximum
    -portability and, if at all possible, provide a patch against CVS head. The more
    -verbose you are, the higher chances of your patch being accepted.
    -
    -Also, please avoid using preprocessor magic to fix portability issues. While
    -the FreeBSD GNOME people are doing a great job in porting GNOME to their
    -operating system, the official GNOME sources are now plagued by conditionals
    -that check for __FreeBSD__ and similar macros. This hurts portability. Please
    -see our patching guidelines (Section 13.3.4, "Patching guidelines") for more
    -details.
    -
     Part III. The pkgsrc infrastructure internals
     
     This part of the guide deals with everything from the infrastructure that is
    @@ -8310,65 +8251,65 @@ maintainer should not need anything from
     
     Table of Contents
     
    -26. Design of the pkgsrc infrastructure
    +25. Design of the pkgsrc infrastructure
     
    -    26.1. The meaning of variable definitions
    -    26.2. Avoiding problems before they arise
    -    26.3. Variable evaluation
    +    25.1. The meaning of variable definitions
    +    25.2. Avoiding problems before they arise
    +    25.3. Variable evaluation
     
    -        26.3.1. At load time
    -        26.3.2. At runtime
    +        25.3.1. At load time
    +        25.3.2. At runtime
     
    -    26.4. How can variables be specified?
    -    26.5. Designing interfaces for Makefile fragments
    +    25.4. How can variables be specified?
    +    25.5. Designing interfaces for Makefile fragments
     
    -        26.5.1. Procedures with parameters
    -        26.5.2. Actions taken on behalf of parameters
    +        25.5.1. Procedures with parameters
    +        25.5.2. Actions taken on behalf of parameters
     
    -    26.6. The order in which files are loaded
    +    25.6. The order in which files are loaded
     
    -        26.6.1. The order in bsd.prefs.mk
    -        26.6.2. The order in bsd.pkg.mk
    +        25.6.1. The order in bsd.prefs.mk
    +        25.6.2. The order in bsd.pkg.mk
     
    -27. Regression tests
    +26. Regression tests
     
    -    27.1. Running the regression tests
    -    27.2. Adding a new regression test
    +    26.1. Running the regression tests
    +    26.2. Adding a new regression test
     
    -        27.2.1. Overridable functions
    -        27.2.2. Helper functions
    +        26.2.1. Overridable functions
    +        26.2.2. Helper functions
     
    -28. Porting pkgsrc
    +27. Porting pkgsrc
     
    -    28.1. Porting pkgsrc to a new operating system
    +    27.1. Porting pkgsrc to a new operating system
     
    -Chapter 26. Design of the pkgsrc infrastructure
    +Chapter 25. Design of the pkgsrc infrastructure
     
     Table of Contents
     
    -26.1. The meaning of variable definitions
    -26.2. Avoiding problems before they arise
    -26.3. Variable evaluation
    +25.1. The meaning of variable definitions
    +25.2. Avoiding problems before they arise
    +25.3. Variable evaluation
     
    -    26.3.1. At load time
    -    26.3.2. At runtime
    +    25.3.1. At load time
    +    25.3.2. At runtime
     
    -26.4. How can variables be specified?
    -26.5. Designing interfaces for Makefile fragments
    +25.4. How can variables be specified?
    +25.5. Designing interfaces for Makefile fragments
     
    -    26.5.1. Procedures with parameters
    -    26.5.2. Actions taken on behalf of parameters
    +    25.5.1. Procedures with parameters
    +    25.5.2. Actions taken on behalf of parameters
     
    -26.6. The order in which files are loaded
    +25.6. The order in which files are loaded
     
    -    26.6.1. The order in bsd.prefs.mk
    -    26.6.2. The order in bsd.pkg.mk
    +    25.6.1. The order in bsd.prefs.mk
    +    25.6.2. The order in bsd.pkg.mk
     
     The pkgsrc infrastructure consists of many small Makefile fragments. Each such
     fragment needs a properly specified interface. This chapter explains how such
     an interface looks like.
     
    -26.1. The meaning of variable definitions
    +25.1. The meaning of variable definitions
     
     Whenever a variable is defined in the pkgsrc infrastructure, the location and
     the way of definition provide much information about the intended use of that
    @@ -8395,7 +8336,7 @@ Note
     These conventions are currently not applied consistently to the complete pkgsrc
     infrastructure.
     
    -26.2. Avoiding problems before they arise
    +25.2. Avoiding problems before they arise
     
     All variables that contain lists of things should default to being empty. Two
     examples that do not follow this rule are USE_LANGUAGES and DISTFILES. These
    @@ -8412,9 +8353,9 @@ package Makefiles. Similarly for USE_LAN
     value ("c") is so short that it doesn't stand out. Nevertheless it is mentioned
     in many files.
     
    -26.3. Variable evaluation
    +25.3. Variable evaluation
     
    -26.3.1. At load time
    +25.3.1. At load time
     
     Variable evaluation takes place either at load time or at runtime, depending on
     the context in which they occur. The contexts where variables are evaluated at
    @@ -8449,26 +8390,26 @@ paragraph, the -Wall is appended to the 
     appear in CONFIGURE_ARGS. In actual code, the three paragraphs from above
     typically occur in completely unrelated files.
     
    -26.3.2. At runtime
    +25.3.2. At runtime
     
     After all the files have been loaded, the values of the variables cannot be
     changed anymore. Variables that are used in the shell commands are expanded at
     this point.
     
    -26.4. How can variables be specified?
    +25.4. How can variables be specified?
     
     There are many ways in which the definition and use of a variable can be
     restricted in order to detect bugs and violations of the (mostly unwritten)
     policies. A package can be checked with pkglint -Wall to see whether it meets
     these rules.
     
    -26.5. Designing interfaces for Makefile fragments
    +25.5. Designing interfaces for Makefile fragments
     
     Most of the .mk files fall into one of the following classes. Cases where a
     file falls into more than one class should be avoided as it often leads to
     subtle bugs.
     
    -26.5.1. Procedures with parameters
    +25.5.1. Procedures with parameters
     
     In a traditional imperative programming language some of the .mk files could be
     described as procedures. They take some input parameters and?after
    @@ -8496,7 +8437,7 @@ Examples for procedures are mk/bsd.optio
     To express that the parameters are evaluated at load time, they should be
     assigned using the := operator, which should be used only for this purpose.
     
    -26.5.2. Actions taken on behalf of parameters
    +25.5.2. Actions taken on behalf of parameters
     
     Action files take some input parameters and may define runtime variables. They
     shall not define loadtime variables. There are action files that are included
    @@ -8505,7 +8446,7 @@ explicitly.
     
     An example for action files is mk/subst.mk.
     
    -26.6. The order in which files are loaded
    +25.6. The order in which files are loaded
     
     Package Makefiles usually consist of a set of variable definitions, and include
     the file ../../mk/bsd.pkg.mk in the very last line. Before that, they may also
    @@ -8517,7 +8458,7 @@ the files are loaded matters.
     This section describes at which point the various files are loaded and gives
     reasons for that order.
     
    -26.6.1. The order in bsd.prefs.mk
    +25.6.1. The order in bsd.prefs.mk
     
     The very first action in bsd.prefs.mk is to define some essential variables
     like OPSYS, OS_VERSION and MACHINE_ARCH.
    @@ -8537,7 +8478,7 @@ As the last steps, some essential variab
     system flavor are loaded, as well as the variables that have been cached in
     earlier phases of a package build.
     
    -26.6.2. The order in bsd.pkg.mk
    +25.6.2. The order in bsd.pkg.mk
     
     First, bsd.prefs.mk is loaded.
     
    @@ -8564,15 +8505,15 @@ execution, though the actual order shoul
     At last, some more files are included that don't set any interesting variables
     but rather just define make targets to be executed.
     
    -Chapter 27. Regression tests
    +Chapter 26. Regression tests
     
     Table of Contents
     
    -27.1. Running the regression tests
    -27.2. Adding a new regression test
    +26.1. Running the regression tests
    +26.2. Adding a new regression test
     
    -    27.2.1. Overridable functions
    -    27.2.2. Helper functions
    +    26.2.1. Overridable functions
    +    26.2.2. Helper functions
     
     The pkgsrc infrastructure consists of a large codebase, and there are many
     corners where every little bit of a file is well thought out, making pkgsrc
    @@ -8581,20 +8522,20 @@ changes from breaking anything, a suite 
     with every important part of the pkgsrc infrastructure. This chapter describes
     how regression tests work in pkgsrc and how you can add new tests.
     
    -27.1. Running the regression tests
    +26.1. Running the regression tests
     
     You first need to install the pkgtools/pkg_regress package, which provides the 
     pkg_regress command. Then you can simply run that command, which will run all
     tests in the regress/ directory.
     
    -27.2. Adding a new regression test
    +26.2. Adding a new regression test
     
     Every directory in the regress/ directory that contains a file called spec is
     considered a regression test. This file is a shell program that is included by
     the pkg_regress command. The following functions can be overridden to suit your
     needs.
     
    -27.2.1. Overridable functions
    +26.2.1. Overridable functions
     
     These functions do not take any parameters. Although they are called in "set -e
     " mode, they don't stop at the first failing command. See this Stack Overflow
    @@ -8637,7 +8578,7 @@ do_cleanup
         This function cleans everything up after the test has been run. By default
         it does nothing.
     
    -27.2.2. Helper functions
    +26.2.2. Helper functions
     
     regress_fail message...
     
    @@ -8663,17 +8604,17 @@ output_prohibit regex...
         () does not match the extended regular expression. If any of the regular
         expressions matches, the test will fail.
     
    -Chapter 28. Porting pkgsrc
    +Chapter 27. Porting pkgsrc
     
     Table of Contents
     
    -28.1. Porting pkgsrc to a new operating system
    +27.1. Porting pkgsrc to a new operating system
     
     The pkgsrc system has already been ported to many operating systems, hardware
     architectures and compilers. This chapter explains the necessary steps to make
     pkgsrc even more portable.
     
    -28.1. Porting pkgsrc to a new operating system
    +27.1. Porting pkgsrc to a new operating system
     
     To port pkgsrc to a new operating system (called MyOS in this example), you
     need to touch the following files:
    @@ -8783,7 +8724,7 @@ Create the directory where the package l
     # cd bison
     # mkdir patches
     
    -Create Makefile, DESCR and PLIST (see Chapter 13, Package components - files,
    +Create Makefile, DESCR and PLIST (see Chapter 12, Package components - files,
     directories and contents) then continue with fetching the distfile:
     
     # make fetch
    
    
    --_----------=_15926311323080--