[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Change the default shell from an environment variable
From: |
Masahiro Yamada |
Subject: |
Change the default shell from an environment variable |
Date: |
Sun, 25 Jul 2021 23:51:48 +0900 |
Hi.
GNU Make uses /bin/sh by default for
running recipe lines and $(shell ) functions.
You can change the shell by setting the
'SHELL' variable.
One note for this variable is that
SHELL is never set from the environment.
This is clearly documented [1].
The build system of a large project is often
divided into multiple sub-makes.
The top Makefile, and several sub-Makefiles.
Other variables can be set in the top
Makefile, and exported down to sub-makes.
For example:
export CC := gcc
export LD := ld
export OBJCOPY := objcopy
...
But, since it is not possible to propagate SHELL
down to sub-makes, we end up with adding the same setup:
SHELL := /bin/bash
in every sub-makefiles.
So, here is one suggestion.
Does it make sense to add an environment variable
with a less common name? It functions in the same
way as SHELL, but the difference is that it can be set
from the environment.
For example, 'MAKE_SHELL'.
In the top Makefile, you can do:
export MAKE_SHELL := /bin/bash
then, GNU Make will use /bin/bash
not only in the top Makefile but also
in sub-makefiles.
[1] https://www.gnu.org/software/make/manual/html_node/Choosing-the-Shell.html
--
Best Regards
Masahiro Yamada
- Change the default shell from an environment variable,
Masahiro Yamada <=