summaryrefslogtreecommitdiff
path: root/m4/jh-add-cflag.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/jh-add-cflag.m4')
-rw-r--r--m4/jh-add-cflag.m420
1 files changed, 20 insertions, 0 deletions
diff --git a/m4/jh-add-cflag.m4 b/m4/jh-add-cflag.m4
new file mode 100644
index 0000000..75fa78c
--- /dev/null
+++ b/m4/jh-add-cflag.m4
@@ -0,0 +1,20 @@
+dnl JH_ADD_CFLAG(FLAG)
+dnl checks whether the C compiler supports the given flag, and if so, adds
+dnl it to $CFLAGS. If the flag is already present in the list, then the
+dnl check is not performed.
+AC_DEFUN([JH_ADD_CFLAG],
+[
+case " $CFLAGS " in
+*@<:@\ \ @:>@$1@<:@\ \ @:>@*)
+ ;;
+*)
+ save_CFLAGS="$CFLAGS"
+ CFLAGS="$CFLAGS $1"
+ AC_MSG_CHECKING([whether [$]CC understands $1])
+ AC_TRY_COMPILE([], [], [jh_has_option=yes], [jh_has_option=no])
+ AC_MSG_RESULT($jh_has_option)
+ if test $jh_has_option = no; then
+ CFLAGS="$save_CFLAGS"
+ fi
+ ;;
+esac])