I'd like to enable a verbose compilation in my makefile, but I can't figure out how to make a conditional OR
.
Let me explain: I want to be able to specify a verbose compilation either by setting V=1
or VERBOSE=1
. I want to keep VERBOSE=1
available because we have some scripts that make use of it (and use other makefiles only aware of VERBOSE
)
So the result must be that these two commands are the same:
make all VERBOSE=1 # pain to write
make all V=1
Now, my makefile looks like this today:
ifdef VERBOSE
[issue compilation commands with verbose mode]
endif
What I'd like to achieve is close to the preprocessor in C:
if defined(VERBOSE) || defined(V)
[issue compilation commands with verbose mode]
endif
Do you know how to do that?
Syntax of ConditionalsThe text-if-true may be any lines of text, to be considered as part of the makefile if the condition is true. If the condition is false, no text is used instead. If the condition is true, text-if-true is used; otherwise, text-if-false is used instead.
The file name of the target of the rule. If the target is an archive member, then ' $@ ' is the name of the archive file. In a pattern rule that has multiple targets (see Introduction to Pattern Rules), ' $@ ' is the name of whichever target caused the rule's recipe to be run.
The ifdef directive begins the conditional, and specifies the condition. It contains single argument. If the given argument is true then condition becomes true. The ifndef directive begins the conditional, and specifies the condition.
I do like this:
ifneq "$(or $(LINUX_TARGET),$(OSX_TARGET))" ""
endif
Similar to the $(strip approach, but using the more intuitive $(or keyword
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With