I found a way to get the arguments with an equal sign (=)! The answer is especially an addition to @lesmana 's answer (as it is the most complete and explained one here), but it would be too big to write it as a comment. Again, I repeat his message: TL;DR don't try to do this!
I needed a way to treat my argument --xyz-enabled=false
(since the default is true), which we all know by now that this is not a make target and thus not part of $(MAKECMDGOALS)
.
While looking into all variables of make by echoing the $(.VARIABLES)
i got these interesting outputs:
[...] -*-command-variables-*- --xyz-enabled [...]
This allows us to go two ways: either getting all starting with a --
(if that applies to your case), or look into the GNU make specific (probably not intended for us to use) variable -*-command-variables-*-
. ** See footer for additional options ** In my case this variable held:
--xyz-enabled=false
With this variable we can combine it with the already existing solution with $(MAKECMDGOALS)
and thus by defining:
# the other technique to invalidate other targets is still required, see linked post
run:
@echo ./prog $(-*-command-variables-*-) $(filter-out $@,$(MAKECMDGOALS))`
and using it with (explicitly mixing up order of arguments):
make run -- config --xyz-enabled=false over=9000 --foo=bar show isit=alwaysreversed? --help
returned:
./prog isit=alwaysreversed? --foo=bar over=9000 --xyz-enabled=false config show --help
As you can see, we loose the total order of the args. The part with the "assignment"-args seem to have been reversed, the order of the "target"-args are kept. I placed the "assignment"-args in the beginning, hopefully your program doesn't care where the argument is placed.
Update: following make variables look promising as well:
MAKEFLAGS = -- isit=alwaysreverse? --foo=bar over=9000 --xyz-enabled=false
MAKEOVERRIDES = isit=alwaysreverse? --foo=bar over=9000 --xyz-enabled=false