Subject: misc/3823: New simpler
To: None <gnats-bugs@gnats.netbsd.org>
From: None <dholland@eecs.harvard.edu>
List: netbsd-bugs
Date: 07/02/1997 18:09:19
>Number:         3823
>Category:       misc
>Synopsis:       New simpler <bsd.subdir.mk>
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    misc-bug-people (Misc Bug People)
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu Jul  3 23:05:00 1997
>Last-Modified:
>Originator:     David A. Holland <dholland@eecs.harvard.edu>
>Organization:
   - David A. Holland             |    VINO project home page:
     dholland@eecs.harvard.edu    | http://www.eecs.harvard.edu/vino
>Release:        NetBSD-current 19970410
>Environment:

System: NetBSD bordeaux 1.2C NetBSD 1.2C (BORDEAUX.PROF) #28: Sat Mar 1 16:28:54 EST 1997 abrown@bordeaux:/usr/src/sys/arch/i386/compile/BORDEAUX.PROF i386

(This was actually built with a make slightly modified for supporting
cross-compilations from BSD/OS to VINO.)

>Description:

	The old <bsd.subdir.mk> breaks on out of date and buggy versions 
	of /bin/sh, such as the 4.4BSD ash that BSD/OS uses. This new one 
	does not; furthermore it is smaller and simpler and sacrifices no
	functionality.

	It was built out of <bsd.subdir.mk> from -current of last April,
	so if you would like me to merge it up to today's -current, I'll
	be happy to do so.

>How-To-Repeat:

	Using netbsd's make and <bsd.subdir.mk> on a BSD/OS machine chokes
	with "Bad substitute".

>Fix:

	Here's a new <bsd.subdir.mk>.

    -------- SNIP --------

#	$NetBSD: bsd.subdir.mk,v 1.14 1997/03/29 08:02:56 mikel Exp $
#	@(#)bsd.subdir.mk	8.1 (Berkeley) 6/8/93

.include <bsd.own.mk>

.if !target(.MAIN)
.MAIN: all
.endif

#
# Look for any machine-specific versions of subdirs

.for __DIR in ${SUBDIR}
.if exists(${__DIR}.${MACHINE}) 
__REALSUBDIR+=${__DIR}.${MACHINE}
.else
__REALSUBDIR+=${__DIR}
.endif
.endfor


#
# These targets are propagated to subdirs.

__SUBDIRTARGETS=all install realinstall clean cleandir includes \
		depend lint obj tags

# 
# _THISDIR_ is a mechanism for printing the subdirectories nicely,
# since ${.CURDIR} gives full paths.

.if !defined(_THISDIR_)
_THISDIR_=
.endif

#
# Issue rules of the form "target-subdir"
#
# NB. Change the echos to 
#      @echo make[1]: Entering directory \`${.CURDIR}/${dir}\'
# and
#      @echo make[1]: Leaving directory \`${.CURDIR}/${dir}\'
#
# for compatibility with gmake and thus with emacs's compile mode.
# What echos to use should probably be parameterized.

.for dir in ${__REALSUBDIR}
.for tgt in ${__SUBDIRTARGETS}
${tgt}-${dir}:
	@echo "===> ${_THISDIR_}${dir}"
	@cd ${.CURDIR}/${dir}; \
	${MAKE} "_THISDIR_=${_THISDIR_}${dir}/" ${tgt:S/realinstall/install/}
.endfor


# Backward-compatibility with the old rules.  If this went away,
# 'xlint' could become 'lint', 'xinstall' could become 'install', etc.
${dir}: all-${dir}
.endfor


_SUBDIRUSE: .USE ${__REALSUBDIR:S/^/${.TARGET}-/}


.if !target(install)
.if !target(beforeinstall)
beforeinstall:
.endif
.if !target(afterinstall)
afterinstall:
.endif
install: ${MANINSTALL}
${MANINSTALL}: afterinstall
afterinstall: realinstall
realinstall: beforeinstall _SUBDIRUSE
.endif

#
# Put anything needing special handling above this so the .if will 
# always be false.

.for tgt in ${__SUBDIRTARGETS}
.if !target(${tgt})
${tgt}: _SUBDIRUSE
.endif
.endfor

.include <bsd.own.mk>

>Audit-Trail:
>Unformatted: