5. Compatibility and interoperability

5.1. Making FreeBSD's make(1) invoke penv automatically

As far as I know, there are no compatibility problems that might arise if using penv with other programs. However, there may be situations when the abilities of penv to examine and set environment settings may appear to be inadequate. A simple example is, again, the FreeBSD Ports Collection. There are some ports which ``depend'' on other ports for their build, installation or correct operation. If penv is used to define settings for e.g. the mail/qmail port, those settings will not be ``picked up'' when building the mail/vpopmail port, which has a dependency on mail/qmail. The reason is simple - penv make issued in the mail/vpopmail/ directory would only honor the settings in the /var/db/penv/mail/vpopmail/ environment directory, and completely ignore those placed in /var/db/penv/mail/qmail/. It is somewhat uncomfortable to install/update each port individually, so that make(1) builds it with the correct settings, instead of just building the ``highest-level'' port and having the ``lower-level'' ports be installed with the correct settings right away.

This is why I have developed a simple patch to the FreeBSD make(1) program. It examines the values of the MAKEENVPROC and MAKEENVDIR variables each time make(1) is invoked, and, if needed, invokes an environment processor. The processor's name and arguments are defined in the MAKEENVPROC variable; make(1) invokes it using /bin/sh, so beware of shell metacharacters and such. To avoid unnecessary overheard, the processor is only invoked if the current working directory matches a regular expression pattern defined in the MAKEENVDIR variable.

The patch may be obtained from http://people.FreeBSD.org/~roam/bsd/makeenvproc.patch. An example use would be to set MAKEENVPROC to penv -L and MAKEENVDIR to /ports/. This would make make(1) invoke penv -L automatically in each directory under /usr/ports/ or /home/roam/fbsd/ports/, yet not affect e.g. building the FreeBSD base system in /usr/src/. Of course, this may be further refined by setting MAKEENVDIR to e.g. /ports/|/usr/home/roam/(.*/)?(doc|www)(/|$); this would cause make(1) to invoke penv in any directory containing a ports path component, and in any directory under /usr/home/roam/ which either contains or ends in doc or www. A needlessly complicated example, maybe, but one that I use nevertheless :)

This, and other documents, can be downloaded from http://devel.ringlet.net/.

For questions about this documentation, e-mail <roam@ringlet.net>.