Subject: bsd.pkg.mk proposal 1: recrsive make
To: None <tech-pkg@netbsd.org>
From: Todd Vierling <tv@pobox.com>
List: tech-pkg
Date: 05/20/1999 17:02:32
Comments, please.

=====

$Revision: 1.1 $

The bsd.pkg.mk Makefile fragment, and Makefiles which include it, suffer
from various problems when using a recursive call to make(1) (done as part
of the normal build and install procedure).  This results in some variables,
set with the += make(1) operator, to result in significantly redundant
strings (such as CFLAGS="-O2 -O2 -pipe -pipe -O2 -O2 -pipe -pipe").

Additionally, the extra reprocessing caused by the rather large Makefile
fragments makes the package system slow down in a noticeable way, and we
pass more information than intended from the environment into third party
applications.

I propose the following changes at a high level (details of implementation
to be worked out):

- /etc/mk.conf and <bsd.own.mk> will be skipped if __BSD_PREFS_MK__ has
  already been set before include "bsd.prefs.mk".  (Hence, it will only
  be included once, at the top level.)

  NOTE: This proposal does NOT provide for a twice-over inclusion of
  mk.conf (once before and once after all the bsd.pkg.mk goop).  If there
  is a pressing need for this kind of conditional, please explain why it's
  needed, as the proposal may provide a better solution.

- Variable assignments in bsd.pkg.mk which involve a shell command (!=)
  will be skipped if __BSD_PKG_MK__ and/or that variable name (depending on
  the variable) has already been set before including "bsd.pkg.mk".  Such
  variables will inherit values from the environment.

- Variable assignments in bsd.pkg.mk which involve adding words (+=) will
  be skipped if __BSD_PKG_MK__ has already been set before including
  "bsd.pkg.mk".  Such variables will inherit values from the environment.

- The SETENV macro will be changed to use "env -i", in order to clean out
  the environment for configuration scripts and third party Makefiles.

- Recursive make(1) calls which call package targets in bsd.pkg.mk will
  not use ${SETENV} or any other environment altering arguments; all
  Makefile generated variables will be passed down.

- The following variables will be added to the existing list of values
  passed to CONFIGURE_ENV:
    CXX, CXXFLAGS, CPPFLAGS, INSTALL_SCRIPT, INSTALL_DATA, INSTALL_MAN,
  (This list will likely be expanded before the final draft.)

- The following extra settings will be added to CONFIGURE_ENV:
    PERL_PATH="${LOCALBASE}/bin/perl"
    PATH_PERL="${LOCALBASE}/bin/perl"
  (This list will likely be expanded before the final draft.)

- The following variables will be added to the existing list of values
  passed to MAKE_ENV:
    CXX, CXXFLAGS, CPPFLAGS
  (This list will likely be expanded before the final draft.)

- The value MAKECONF=/dev/null will be added to MAKE_ENV in order to prevent
  packages which use BSD Makefiles from using unintended defaults from
  /etc/mk.conf.  (This may be accompanied by other NOxxxxx=1 variables which
  uniformly lay out the functionality of BSD Makefile based packages.)

- Makefiles for individual packages will be pruned to clean up places where
  new values in CONFIGURE_ENV/MAKE_ENV are added, and similar situations
  resolved by the above proposal.

=====

-- 
-- Todd Vierling (Personal tv@pobox.com; Bus. todd_vierling@xn.xerox.com)