Browse Source

[Makefile.rules] Add function "cc-option" to check available GCC options

The "cc-option" must be used to conditionally add compiler options only
in those environments which support these options (e.g., older verions
of gcc may not support some options, thus they must be declared via
"cc-option").
Isaku Yamahata 5 years ago
parent
commit
91cb93f95d
1 changed files with 6 additions and 0 deletions
  1. 6 0
      Makefile.rules

+ 6 - 0
Makefile.rules

@@ -58,3 +58,9 @@ CLEAN_FILES += generated_offsets.py generated_offsets.pyc
 
 quiet_cmd_ln_sf = [ $@ ]
       cmd_ln_sf = ln -sf $(abspath $<) $@
+
+
+cc-option = $(shell set -e; \
+	if ($(CC) -Werror $(1) -c -x c /dev/null -o /dev/null) >/dev/null 2>&1; \
+	then echo "$(1)"; \
+	fi)