Hi.

My question is very similar to this:
https://stackoverflow.com/questions/31443920/remove-target-from-makecmdgoals

When a particular flag is set, I want to do something extra.
I know this is hard, but please forgive me to repeat a similar question
in case somebody in the list may know something.


The following Makefile illustrates what I'd like to do.
Of course, it does not work since MAKECMDGOALS is read-only.


----------->8-------------
ifdef GENERATE_B_AS_WELL
# When this flag is set, we want to generate %.b as well.
# I know I cannot update MAKECMDGOALS...
MAKECMDGOALS := $(patsubst %.a, %.b, $(MAKECMDGOALS))
endif


%.a:
        touch

%.b: %.a
        cp $< $@
----------->8-------------


Then, I hope the following would happen.


$ make x.a
   -> create x.a


$ make x.a GENERATE_B_AS_WELL=1
   -> create x.b as well as x.a






If recursion is allowed, the following might work, but
I'd hope to find something simpler in a single invocation of Make.

-------------------->8----------------
ifdef GENERATE_B_AS_WELL

%a:
        $(MAKE) $(patsubst %.a,%.b,$@) GENERATE_B_AS_WELL=

else

%.a:
        touch

%.b: %.a
        cp $< $@

endif
-------------------->8----------------







-- 
Best Regards
Masahiro Yamada

Reply via email to