8.3. 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, for example, which program's configure script or install target omitted. For any of these auxiliary targets, scripts of the same name can be placed in the package's scripts-subdirectory that will be executed at the given time, see scripts/*.

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.

deinstall:

This target does a pkg_delete(1) in the current directory, effectively de-installing the package. The following variables can be used either on the command line or in /etc/mk.conf to tune the behaviour:

PKG_VERBOSE:

Add a "-v" flag 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 x11/kde, this is likely to remove whole KDE. Works by adding a "-R" to the pkg_delete command line.

update:

This target causes the current package to be updated to the latest version. The package and all depending packages first get deinstalled, 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'' 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 /etc/mk.conf to alter the behaviour of ``make update'':

DEPENDS_TARGET:

Install target to use for the updated package and the dependent packages. Defaults to install. E.g. ``make update DEPENDS_TARGET=package''

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:

Use "reinstall" instead of ${DEPENDS_TARGET} for every package that gets updated. Be sure you know the implications of using the "reinstall" target when using this variable.

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 deinstalled (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 call ``make update'' and only if you have a dirty package tree (e.g., if you used NOCLEAN). The following variables can be used either on the command line or in /etc/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).

readme:

This target generates a README.html file, which can be viewed using a browser such as netscape (pkgsrc/www/mozilla) or lynx (pkgsrc/www/lynx). 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.)

readme-all:

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. (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 target "show-host-specific-pkgs".

check-shlibs:

After a package is installed, check all it's binaries and (on ELF platforms) shared libraries if they find the shared libs they need. Run by default if PKG_DEVELOPER is set in /etc/mk.conf.