After reading the answer given by @MadScientist, I came up with a different approach.
Not knowing if the shell conditions would work in any environment (windows vs. linux), I wrapped the rules inside the conditional expression instead of having the conditional rule inside the rule. i.e.
ifdef MY_FLAG %.o: %.c $(CC) -o $@ -c $^ $(CFLAGS) else %.o: %.c @$(CC) -o $@ -c $^ $(CFLAGS) endif
Good luck to everyone who has been here.
EDIT
As James Moore noted in the comments, this different approach requires caution and notification about when and how variables are defined with respect to the placement of the if in the control flow.
source share