Subject: .mk "subroutine" for getting objdir locations
To: None <>
From: Todd Vierling <>
List: tech-toolchain
Date: 08/06/2001 20:52:35
The following I plan to add as src/share/mk/ by Wednesday
evening if there are no major objections (mainly, I'm testing the waters to
see what people think of the *name* ... I couldn't come up with many good

This .mk file is intended to replace the very ugly, and quite slow,
shellcode hacks that have been used to find out the proper obj subdirectory
of a given source directory.  Currently a recursive make is called from a
!=, which is very high overhead, particularly on slower architectures.  In
the toolchain hacking I've been doing, there are loads of these !=
constructs, and I want to flatten them.

Feel free to discuss, but I feel this probably doesn't warrant a long

#	$NetBSD$

# Subroutine to obtains the object directory of a given subdirectory,
# without the overhead of a subshell invocation.  Can be included
# multiple times as needed.
# Set the following:
# GETOBJ_SRC	Source directory to resolve to an objdir
# GETOBJ_VAR	Variable to set with objdir location

.include <>

# The following follow the make(1) rules, not those in <> --
# we care what exists, not what the user requested in /etc/mk.conf.

.undef ${GETOBJ_VAR}

# Fallback to same path.



.elif defined(MAKEOBJDIR)

.if exists(${GETOBJ_SRC}/${MAKEOBJDIR})

.elif exists(${GETOBJ_SRC}/obj.${MACHINE})


.elif exists(${GETOBJ_SRC}/obj)



-- Todd Vierling <>  *  Wasabi NetBSD:  Run with it.
-- NetBSD 1.5 now available on CD-ROM  --