help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: how to use a different /bin/sh with GNU Make?


From: Paul Smith
Subject: Re: how to use a different /bin/sh with GNU Make?
Date: Tue, 13 Oct 2015 08:02:53 -0400

On Tue, 2015-10-13 at 04:35 +0000, Mark Galeck wrote:
> as root, I replaced the default /bin/sh with a shell compiled by me
> with custom changes.  I expected GNU Make will use that shell by
> default , but it does not - it still uses the original /bin/sh (which
> was really bash) even though it is not there anymore.

It would be very helpful if you provided an example of the recipe you're
using.  Without that we can only speculate.

GNU make contains a special "fast path" capability.  If it knows that
the shell is a POSIX-compliant shell (because the shell is one of a set
of known POSIX-compliant shells such as /bin/sh, /bin/bash, or others...
for the complete list see the unix_shells[] array in the jobs.c file in
the GNU make source code), and it determines that the recipe is "simple
enough": it's a single command, has no IO redirection or pipes, the
quoting is straightforward, and there are no shell variables in it, then
make runs the command directly rather than invoking a shell.

So for example, this recipe is run directly by make rather than starting
a shell:

   cc -Wall -o foo.o -c foo.c

but this recipe would always start a shell:

   cc -Wall -o foo.o -c foo.c; echo "Compilation complete"

If you want to force make to always start a shell and never use the fast
path the best way is to name your shell something else, like /bin/mgsh
or something, then set make's SHELL variable to that path.  Since make
is no longer sure if your shell is a POSIX shell, it will never use the
fast path.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]