Subject: misc/4129: bsd.dep.mk rule for mkdep doesn't obey DESTDIR
To: None <gnats-bugs@gnats.netbsd.org>
From: Jeremy Cooper <jeremy@broder.com>
List: netbsd-bugs
Date: 09/21/1997 00:47:43
>Number:         4129
>Category:       misc
>Synopsis:       bsd.own.mk doesn't use correct header flags when DESTDIR is set
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people (Misc Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Sep 21 00:50:01 1997
>Last-Modified:
>Originator:     Jeremy Cooper
>Organization:
>Release:        NetBSD-current-9-20-1997
>Environment:
	n/a
>Description:

When building the source tree with the environment variable DESTDIR set,
all compiler tools should prevent the inclusion of header files from
/usr/include and use $DESTDIR/usr/include instead.  This is to prevent the
header files of belonging to the build system from being used during the
build process.  While it currently works correctly for the compilation phase
of the build, the dependency generation phase that usually preceeds it
(make depend) does not.

The problem likely lies in the ``depend'' rule in bsd.own.mk.  It uses the
variable CPPFLAGS where all other build rules use CFLAGS.  While this is
probably correct, since mkdep is a pre-processor scanner rather than compiler,
the inconsistency of header flags between the two variables needs to be
addressed.

>How-To-Repeat:
(This example shows how to repeat an error message noticed
 by using a NetBSD-1.2 m68k system to build NetBSD-current.)

  # set DESTDIR environment variable  (here, /mnt/build)
  # cd /mnt/src/lib/csu && make depend
  ===> m68k
  mkdep -a -DLIBC_SCCS -I/mnt/src/lib/csu/m68k/.. -DDYNAMIC crt0.c
  In file included from crt0.c:43:
  /mnt/src/lib/csu/m68k/../common.h:52: link.h: No such file or directory

The mkdep line above should have additionally included the flags:
  -nostdinc -I/mnt/build/usr/include
>Fix:
>Audit-Trail:
>Unformatted: