I have a makefile section that has this structure:
bob: ifdef DEBUG @echo running endif @echo chug chug chug ifdef DEBUG @echo done endif bobit: @echo "before" @make bob @echo "after"
I greatly simplify here, all echoes are actually non-trivial blocks of commands, and there is more conditional material, but this reflects the essence of my problem.
For technical reasons, I donโt want to go into it right now, I need to get rid of this fake, but since the echo is a non-trivial amount of code, I donโt just want to copy and drive the beanโs body to its place of feeding.
Ideally, what I would like to do is something like this
define BOB_BODY ifdef DEBUG @echo running endif @echo chug chug chug ifdef DEBUG @echo done endif endef bob: $(BOB_BODY) bobit: @echo "before" $(BOB_BODY) @echo "after"
Unfortunately, conditional expressions seem to throw me in, they produce "ifdef: Command not found" errors, I tried to get around this with various combinations of eval and call, but it can't seem to work.
How do I do this job? and is this even the right way to approach the problem?
source share