summaryrefslogtreecommitdiff
path: root/m4/jhflags.m4
diff options
context:
space:
mode:
Diffstat (limited to 'm4/jhflags.m4')
-rw-r--r--m4/jhflags.m421
1 files changed, 21 insertions, 0 deletions
diff --git a/m4/jhflags.m4 b/m4/jhflags.m4
new file mode 100644
index 0000000..222e4b0
--- /dev/null
+++ b/m4/jhflags.m4
@@ -0,0 +1,21 @@
+dnl
+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])