I would like to create a Makefile that recognizes if a given program exists in the system and run another target (or commands) if not. Please, read my post scriptum (P.S.) at the end of the question before mark it as duplicated.
In summary, I would like do something like the following pseudocode:
if (myProgram.exists()):
myProgram arg0 arg1 arg2
else:
otherProgram arg0 arg1 arg2 #suppose that otherProgram will always exists
I've tried some solutions following the best answer of this SO question, that tells me to do something like that:
check: ; @which myProgram > /dev/null
mytarget: check
myProgram arg0 arg1 arg2
The solution actually works, but this aborts the program instead of executing another makefile target / command. I tried a lot of different implementations, but none solved my issue.
How can I achieve something like that in a Makefile?
P.S: this question isn't a duplicated question from "Check if a program exists from a Makefile" because the latter aims to stop execution if the program doesn't exist, while the former aims to run another target if the program doesn't exist.