Created
February 4, 2023 05:38
-
-
Save andy5995/89a53cde95a50b93ffce3cd1f57fc357 to your computer and use it in GitHub Desktop.
Check for supported compiler flags in a Makefile
This file contains 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
Minor adaptation of example at https://stackoverflow.com/a/61634784/6838037 | |
CHECK_CC_FLAGS := -Wall -Wextra -I. --std=gnu89 -fPIC -flto=auto | |
define check_cc_flag | |
$(shell echo 'int main() { return 0; }' | $(CC) $(1) -xc - 2>/dev/null && echo $(1)) | |
endef | |
HAVE_FLAGS += $(foreach flag,$(CHECK_CC_FLAGS),$(call check_cc_flag,$(flag))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment