[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: MAKECMDGOALS and spaces
From: |
Kaz Kylheku (gmake) |
Subject: |
Re: MAKECMDGOALS and spaces |
Date: |
Sat, 13 Feb 2021 11:44:11 -0800 |
User-agent: |
Roundcube Webmail/0.9.2 |
On 2021-02-13 10:35, Christof Warlich wrote:
Hi,
please consider this Maklefile:
$(MAKECMDGOALS):; echo "Goals: $(MAKECMDGOALS)"
For each goal being passed, it prints the list of all goals, e.g.:
$ make hi ho
echo "Goals: hi ho"
Goals: hi ho
echo "Goals: hi ho"
Goals: hi ho
But it fails when goals contain spaces:
$ make "hi ho"
make "hi ho"
make: *** No rule to make target 'hi ho'. Stop.
I think to make use of this, you need to define a target that has
a space. It seems this is possible as follows
hi\ ho:
[tab]echo yes
Then make "hi ho" runs the recipe and "yes" is echoed.
In order to do this with a generated rule from $(MAKECMDGOALS),
you would need some way to do the expansion such that the
spaces are similarly escaped.
There is no obvious way to refer to the value $(MAKECMDGOALS)
without that expanding to a word list.
Maybe Guile scripting needs to be involved?
Pardon the pontificating, but 've never worked with or seen
a Makefile that had spaces in a target name; that kind of
thing is best avoided.
The cultural assumption is that stuff will break if you
allow spaces in the build system.
Build systems exploit breaking into spaces. For instance,
environment variables like CC and CFLAGS contain multiple
items that need to turn into separate arguments.
The use cases for taking every target mentioned on the command
line and materializing it with a generated rule are also
not many. I've seen that done in byzantine build systems to
do things like redirecting a command to another Makefile in
a different directory:
$(MAKECMDGOALS):
$(MAKE) -C $(SOMEWHERE_ELSE) $@
or something like that.
- MAKECMDGOALS and spaces, Christof Warlich, 2021/02/13
- Re: MAKECMDGOALS and spaces,
Kaz Kylheku (gmake) <=
- Re: MAKECMDGOALS and spaces, Christof Warlich, 2021/02/13
- Re: MAKECMDGOALS and spaces, Sébastien Hinderer, 2021/02/17
- Re: MAKECMDGOALS and spaces, David, 2021/02/17
- Re: MAKECMDGOALS and spaces, Sébastien Hinderer, 2021/02/19
- Re: MAKECMDGOALS and spaces, David, 2021/02/19
- Re: MAKECMDGOALS and spaces, Eli Zaretskii, 2021/02/20
- Re: MAKECMDGOALS and spaces, Marco Atzeri, 2021/02/20
- Re: MAKECMDGOALS and spaces, Paul Smith, 2021/02/20
- Re: MAKECMDGOALS and spaces, Stefan Monnier, 2021/02/20