Blame gnulib/m4/warnings.m4

Packit eba2e2
# warnings.m4 serial 11
Packit eba2e2
dnl Copyright (C) 2008-2014 Free Software Foundation, Inc.
Packit eba2e2
dnl This file is free software; the Free Software Foundation
Packit eba2e2
dnl gives unlimited permission to copy and/or distribute it,
Packit eba2e2
dnl with or without modifications, as long as this notice is preserved.
Packit eba2e2
Packit eba2e2
dnl From Simon Josefsson
Packit eba2e2
Packit eba2e2
# gl_AS_VAR_APPEND(VAR, VALUE)
Packit eba2e2
# ----------------------------
Packit eba2e2
# Provide the functionality of AS_VAR_APPEND if Autoconf does not have it.
Packit eba2e2
m4_ifdef([AS_VAR_APPEND],
Packit eba2e2
[m4_copy([AS_VAR_APPEND], [gl_AS_VAR_APPEND])],
Packit eba2e2
[m4_define([gl_AS_VAR_APPEND],
Packit eba2e2
[AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])])
Packit eba2e2
Packit eba2e2
Packit eba2e2
# gl_COMPILER_OPTION_IF(OPTION, [IF-SUPPORTED], [IF-NOT-SUPPORTED],
Packit eba2e2
#                       [PROGRAM = AC_LANG_PROGRAM()])
Packit eba2e2
# -----------------------------------------------------------------
Packit eba2e2
# Check if the compiler supports OPTION when compiling PROGRAM.
Packit eba2e2
#
Packit eba2e2
# FIXME: gl_Warn must be used unquoted until we can assume Autoconf
Packit eba2e2
# 2.64 or newer.
Packit eba2e2
AC_DEFUN([gl_COMPILER_OPTION_IF],
Packit eba2e2
[AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl
Packit eba2e2
AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl
Packit eba2e2
AS_LITERAL_IF([$1],
Packit eba2e2
  [m4_pushdef([gl_Positive], m4_bpatsubst([$1], [^-Wno-], [-W]))],
Packit eba2e2
  [gl_positive="$1"
Packit eba2e2
case $gl_positive in
Packit eba2e2
  -Wno-*) gl_positive=-W`expr "X$gl_positive" : 'X-Wno-\(.*\)'` ;;
Packit eba2e2
esac
Packit eba2e2
m4_pushdef([gl_Positive], [$gl_positive])])dnl
Packit eba2e2
AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], m4_defn([gl_Warn]), [
Packit eba2e2
  gl_save_compiler_FLAGS="$gl_Flags"
Packit eba2e2
  gl_AS_VAR_APPEND(m4_defn([gl_Flags]),
Packit eba2e2
    [" $gl_unknown_warnings_are_errors ]m4_defn([gl_Positive])["])
Packit eba2e2
  AC_LINK_IFELSE([m4_default([$4], [AC_LANG_PROGRAM([])])],
Packit eba2e2
                 [AS_VAR_SET(gl_Warn, [yes])],
Packit eba2e2
                 [AS_VAR_SET(gl_Warn, [no])])
Packit eba2e2
  gl_Flags="$gl_save_compiler_FLAGS"
Packit eba2e2
])
Packit eba2e2
AS_VAR_IF(gl_Warn, [yes], [$2], [$3])
Packit eba2e2
m4_popdef([gl_Positive])dnl
Packit eba2e2
AS_VAR_POPDEF([gl_Flags])dnl
Packit eba2e2
AS_VAR_POPDEF([gl_Warn])dnl
Packit eba2e2
])
Packit eba2e2
Packit eba2e2
# gl_UNKNOWN_WARNINGS_ARE_ERRORS
Packit eba2e2
# ------------------------------
Packit eba2e2
# Clang doesn't complain about unknown warning options unless one also
Packit eba2e2
# specifies -Wunknown-warning-option -Werror.  Detect this.
Packit eba2e2
AC_DEFUN([gl_UNKNOWN_WARNINGS_ARE_ERRORS],
Packit eba2e2
[gl_COMPILER_OPTION_IF([-Werror -Wunknown-warning-option],
Packit eba2e2
   [gl_unknown_warnings_are_errors='-Wunknown-warning-option -Werror'],
Packit eba2e2
   [gl_unknown_warnings_are_errors=])])
Packit eba2e2
Packit eba2e2
# gl_WARN_ADD(OPTION, [VARIABLE = WARN_CFLAGS],
Packit eba2e2
#             [PROGRAM = AC_LANG_PROGRAM()])
Packit eba2e2
# ---------------------------------------------
Packit eba2e2
# Adds parameter to WARN_CFLAGS if the compiler supports it when
Packit eba2e2
# compiling PROGRAM.  For example, gl_WARN_ADD([-Wparentheses]).
Packit eba2e2
#
Packit eba2e2
# If VARIABLE is a variable name, AC_SUBST it.
Packit eba2e2
AC_DEFUN([gl_WARN_ADD],
Packit eba2e2
[AC_REQUIRE([gl_UNKNOWN_WARNINGS_ARE_ERRORS])
Packit eba2e2
gl_COMPILER_OPTION_IF([$1],
Packit eba2e2
  [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])],
Packit eba2e2
  [],
Packit eba2e2
  [$3])
Packit eba2e2
m4_ifval([$2],
Packit eba2e2
         [AS_LITERAL_IF([$2], [AC_SUBST([$2])])],
Packit eba2e2
         [AC_SUBST([WARN_CFLAGS])])dnl
Packit eba2e2
])
Packit eba2e2
Packit eba2e2
# Local Variables:
Packit eba2e2
# mode: autoconf
Packit eba2e2
# End: