Last active
February 8, 2021 23:50
-
-
Save CMCDragonkai/75157d37e6907b6fbaa02b8f04598d87 to your computer and use it in GitHub Desktop.
Runtime Conditionals in Makefiles
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this phony target shows how to use a conditional within a recipe | |
# this conditional is executed at "run-time" | |
# rather than at "build-time" which is when the Makefile `ifeq` are evaluated | |
# notice how everything in the conditional must be joined up as one line | |
test_conditional: | |
@echo 'NESTED CONDITIONAL' | |
[ "$$(echo 1)" -lt 2 ] && { \ | |
echo 'oh no'; \ | |
exit 1; \ | |
} || { \ | |
[ -f issomefilethere ] && { \ | |
echo 'true'; \ | |
} || { \ | |
echo 'false'; \ | |
} \ | |
} | |
.PHONY test_conditional |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you for sharing this :)