Variables and $(shell ...)
Tomas Volf <[email protected]> Mon, 25 Mar 2024 23:35:48 +0100
| Newsgroups | gmane.comp.gnu.make.general |
|---|---|
| Message-ID | <ZgH8ROuLCW5CmVS3@ws> |
Hello,
I am currently trying to figure out how to correctly pass CC variable to the
make. Passing it as an make variable (`make CC=gcc') seems to work in almost
all cases, but it fails for the `$(shell ...)' construct.
Given this simple Makefile:
yyy = $(shell env | grep ^foo=)
xxx:
echo /$(yyy)/
env | grep ^foo=
When executed, I get this output:
$ make foo=foof
echo //
//
env | grep ^foo=
foo=foof
As we can see, the `env | grep ^foo=' in the `xxx' target does see the value of
`foo'. However the `yyy', set using `$(shell ...)' is empty, so the `foo' is
not propagated there.
That seems somewhat limiting, I originally hit this when trying to figure out
why some detection scripts ran using `$(shell ...)' fail to find the C compiler.
Is this a bug or is this intentional? Is there an option I could use to change
the behavior?
I (think I) can just swap the order and do `CC=gcc make' in order to work around
the issue (is that correct assumption?), but would like to understand why it
behaves like this.
Have a nice day,
Tomas Volf
--
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.
signature.asc
(application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmYB/EQACgkQL7/ufbZ/ wanWGRAAnSnDGnqDdcOMGA3KPG6lCuSDffYK8eHs7yvEj6ig3gQF84xsT0xnEXqB Tnx7W7EHBgdP88JASmLJOPOwqjfhTzQm/MDYu5k6Uwl4/smynPx/bZB9E9YjFaZm tF56qURa8q1nDwoPHq9f9I88/CmRTBvZg5uGH5URrVlF42vrvINk5E96iknCmeW+ KwHFKoIXFYSPr1+D7W9dJ7XWwHoCReMvpFDjkT56eIqOeYVmkFkD5Ef9h5qYAFl0 O99vGujEp+z8wfcb7MdneBrxW5h5yJHFDJrYykGNw/uuDnLjDZPVSlJ7t+SSDCDT F/tY5YQiFXMEdE8fkUm9jWvU3uwelzib/88z9HU6e5CBxgxCkkMN8b8JXlizHLR5 oerFPFUdEl9ajBSw8/gusiwm6+42/FhUnlrwbC6k9ikh22qMgJLQMqo3/LHkQOym 4KGmI1Bc2/ocgeQna9iHyxG9CwYdjb9yqYC8mO8IEPEAX7SO/UIzrksPl/W+96TV lBlS70tSoyXc8QShWRwHUrCTG0gyFdKk+X7JDh15d53WQjqAkHR/5ZJ+WbLgkGJd 9QHhsXOVink0LfOx+f8Bz0gqoLHkXEDeDivWYHiMw3ZKK6K3JUA+tanzAtxpPVN1 w6bAqnyUBkLD4ZZQhafbTzCSU/cStlreY7J45oX+DWH2ipDpKYE= =15/r -----END PGP SIGNATURE-----