Subject: making objdirs automatically
To: None <>
From: Simon J. Gerraty <>
List: tech-toolchain
Date: 04/17/2004 16:08:22

further to our conversation (and one with a colleague) the other day ,
the following simple makefile demonstrates how objdirs can be made
automatically - without the need for a separate 'make obj' pass.

$ cat ~/make-tests/aobj

.if !exists(${__objdir})
__objdir:= ${__objdir:!umask ${OBJDIR_UMASK:U002}; mkdir -p ${__objdir}; echo ${__objdir}!}

.OBJDIR:	${__objdir}

	@echo "here is=`pwd`"
	@echo ".OBJDIR=${.OBJDIR}"
	@echo ".CURDIR=${.CURDIR}"

$ rm -rf /tmp/obj-sjg-i386; make -f /homes/sjg/make-tests/aobj all
here is=/tmp/obj-sjg-i386/h/users/sjg

of course, how you arrive at what value to use for __objdir is
orthogonal.  The important thing is you can ensure consitent results
regardless of the starting environment.