Subject: Cross building on a host with a bad /bin/sh
To: None <tech-toolchain@NetBSD.org>
From: Alan Barrett <apb@cequrux.com>
List: tech-toolchain
Date: 09/11/2006 22:00:47
On Tue, 05 Sep 2006, Garrett D'Amore wrote:
> I've learned that if the following environment variables are set, I can
> bootstrap gcc4.  It would be nice if build.sh could detect this and set
> them up itself.  Here they are:
> 
> CONFIG_SH=/usr/xpg4/bin/sh
> BSHELL=/usr/xpg4/bin/sh
> HOST_SH=/usr/xpg4/bin/sh

ftp://ftp.netbsd.org/pub/NetBSD/misc/apb/HOST_SH.20060911.diff
contains a patch for this and several other issues:

* build.sh tries to detect a suitable value for HOST_SH,
  and passes it to the rest of the build as all three of
  HOST_SH, BSHELL, and CONFIG_SHELL.
* make accepts a new compile time flag (_BASENAME_DEFSHELL) to
  override the basename of the default shell.
* The configure script for the tools version of make passes the
  new _BASENAME_DEFSHELL flag in CFLAGS.
* Many Makefiles and scripts under gnu/dist now use ${CONFIG_SHELL}
  to run move-if-change.
* Some other minor details.

I have successfully built an i386 system using these patches in
a chroot environment in which /bin/sh was replaced with a wrapper
that logged every time it was invoked; it was invoked only because
/usr/bin/true starts with "#!/bin/sh".

--apb (Alan Barrett)