Subject: make with MAKEOBJDIR failures
To: None <tech-toolchain@netbsd.org>
From: Juergen Hannken-Illjes <hannken@eis.cs.tu-bs.de>
List: tech-toolchain
Date: 11/16/2001 16:31:32
Trying to build todays sources with MAKEOBJDIR set fails in:

	$ pwd
	/usr/src/tools/toolchain

	$ /usr/obj/tools.i386/bin/nbmake-i386 install
	cd: can't cd to build
	*** Error code 2

	Stop.
	nbmake: stopped in /usr/src/tools/toolchain

The reason is the function `Check_Cwd_av' in usr.bin/make/main.c

The shell command

	@if [ ! -f .install_done ] || [ .build_done -nt .install_done ]; then \
		(cd build && ${MAKE} ${MAKE_ARGS} ${INSTALL_TARGET}); \
	fi

is run in .CURDIR instead of .OBJDIR. After taking a look into the
function `Check_Cwd_av' I suppose this should never be needed.

The example in the comment is simply bad style. Instead of

	build:
		${MAKE} includes

it should read

	build:
		cd ${.CURDIR} && ${MAKE} includes

The much too simple shell parser in `Check_Cwd_av' behaves wrong on
commands that are followed by commands like `if', `then' and so on.
I don't understand why the presence of a `cd' before the `make' causes
this check to stop either.

Would it be better to remove these checks and fix the Makefiles instead?

-- 
Juergen Hannken-Illjes - hannken@eis.cs.tu-bs.de - TU Braunschweig (Germany)