Subject: bin/4102: make(1) needs makefile relative exists() or .include
To: None <gnats-bugs@gnats.netbsd.org>
From: Simon J. Gerraty <sjg@quick.com.au>
List: netbsd-bugs
Date: 09/10/1997 20:33:05
>Number:         4102
>Category:       bin
>Synopsis:       one should be able to .include a file it it exists relative to the current makefile
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people (Utility Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Sep 10 03:35:00 1997
>Last-Modified:
>Originator:     Simon J. Gerraty
>Organization:
Zen Programming...
>Release:        1.2G
>Environment:
	
System: NetBSD zen.quick.com.au 1.2G NetBSD 1.2G (ZEN) #2: Mon Jul 14 00:52:17 EST 1997 root@zen.quick.com.au:/usr/src/sys/arch/i386/compile/ZEN i386


>Description:
	
make(1) allows for .include "" to act relative to the current makefile
for example, it is common practice for Makefile.inc to contain
.include "../Makefile.inc"
this process proceeds up the tree...

At various points in the tree one would like to be able to do:

.include "Makefile.${MACHINE}.inc" 

if it exits.  As things stand, because .include fails if the file cannot be found, and because exists() does not handle the same ``relaive to the current makefile'' logic as .include, one must do things like:

.if exists(${.CURDIR}/../Makefile.${MACHINE}.inc)
.include "${.CURDIR}/../Makefile.${MACHINE}.inc"
.elif exists(${.CURDIR}/../../Makefile.${MACHINE}.inc)
...
...
.endif

Either an exists_here() function so one could do
# Makefile.inc
.include "../Makefile.inc"
.if exists_here("Makefile.${MACHINE}.inc")
.include "Makefile.${MACHINE}.inc"
.endif

or an .include version that does not vomit if it fails, would 
be a very useful enhancement.

>How-To-Repeat:
	
>Fix:
	
>Audit-Trail:
>Unformatted: