Subject: Re: .mk "subroutine" for getting objdir locations
To: Todd Vierling <tv@wasabisystems.com>
From: Simon J. Gerraty <sjg@quick.com.au>
List: tech-toolchain
Date: 08/07/2001 10:28:35
>.elif defined(MAKEOBJDIR)
>if exists(${GETOBJ_SRC}/${MAKEOBJDIR})
>${GETOBJ_VAR}:= ${GETOBJ_SRC}/${MAKEOBJDIR}
>.endif
This one will not always be correct. Our make does var substitution on
MAKEOBJDIR* and if MAKEOBJDIR is an absolute path, it uses that.
I use this in a number of my trees btw. So that
/path/src/usr.bin/cat has
/path/obj/usr.bin/cat as its object directory.
You can put something like this in a top-level Makefile.inc:
.ifndef SRCTOP
SRCTOP!= cd ${.PARSEDIR}; pwd
.endif
.ifndef OBJTOP
.ifdef MAKEOBJDIRPREFIX
OBJTOP=${MAKEOBJDIRPREFIX}${SRCTOP}
.endif
# etc
.endif
Once you have SRCTOP and OBJTOP you can use these to refer to other locations
within the tree. There are a bunch of other useful vars you can derrive using
SRCTOP and .CURDIR such as the sub-dir portion of .CURDIR, the relative
path from .CURDIR to SRCTOP (probably just .PARSEDIR, but...)
HTH
--sjg