Subject: misc/9350: make build with DESTDIR set uses old *.mk files
To: None <>
From: None <>
List: netbsd-bugs
Date: 02/04/2000 10:06:38
>Number:         9350
>Category:       misc
>Synopsis:       make build with DESTDIR set uses old *.mk files
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people (Misc Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Feb  4 10:06:00 2000
>Originator:     Jim Bernard
	Speaking for myself
>Release:        February 4, 2000
System: NetBSD nool 1.4R NetBSD 1.4R (NOOL-$Revision: 1.6 $) #0: Thu Feb 3 08:50:33 MST 2000 jbernard@nool:/home/tmp/compile/sys/arch/i386/compile/NOOL i386

	If one does a "make build", the system makefiles that are used
	by .include statements in the source-tree makefiles are those that
	are in the default location, /usr/share/mk.  If DESTDIR is /, this
	isn't usually a problem, since those files are updated early in the
	build process.  However, with a non-default value of DESTDIR, those
	aren't updated, and critical changes since the build-system's
	installation can be missed.  It would be nice not to have to alter
	the build-system's installation in order to build successfully

	I noticed this during a build following the recent changes (Jan.
	22-ish, IIRC) from "all" to "realall" targets, which caused some
	things not to build, even after I updated the installed make program
	(but not the system makefiles).

	One way to work around this is to always give the "-m" flag to
	make when using DESTDIR (e.g., make -m /usr/src/share/mk ...).
	At the very least, a comment to this effect should be put into
	the top-level Makefile to warn about this.  However, it seems
	reasonable to use .MAKEFLAGS to do this automatically within
	the Makefile itself.  Indeed, it might be best just to do this
	for all builds, even if DESTDIR is not set, but the patch below
	only does it if DESTDIR is set.  Note that it uses the source mk
	directory rather than that in DESTDIR/usr/share/mk, since the
	latter doesn't exist at the beginning of a build.  One could use
	two instances of "-m" to build up a path containing DESTDIR/...
	and /usr/share/mk, if one felt a real need to use the DESTDIR
	files, but it doesn't seem necessary to do that.

	The patch is untested, other than to verify that it does indeed
	set MAKEFLAGS when and only when DESTDIR is set.

--- Makefile-dist	Fri Feb  4 10:22:26 2000
+++ Makefile	Fri Feb  4 10:34:19 2000
@@ -42,10 +42,14 @@
 .if defined(NBUILDJOBS)
+.ifdef DESTDIR
+.MAKEFLAGS+= -m ${.CURDIR}/share/mk
 SUBDIR+= lib include bin libexec sbin usr.bin usr.sbin share sys
 includes-lib: includes-include includes-sys