configure: new option --enable-gcc-warnings
[bpt/emacs.git] / m4 / warnings.m4
CommitLineData
b8df54ff
PE
1# warnings.m4 serial 6
2dnl Copyright (C) 2008-2012 Free Software Foundation, Inc.
3dnl This file is free software; the Free Software Foundation
4dnl gives unlimited permission to copy and/or distribute it,
5dnl with or without modifications, as long as this notice is preserved.
6
7dnl From Simon Josefsson
8
9# gl_AS_VAR_APPEND(VAR, VALUE)
10# ----------------------------
11# Provide the functionality of AS_VAR_APPEND if Autoconf does not have it.
12m4_ifdef([AS_VAR_APPEND],
13[m4_copy([AS_VAR_APPEND], [gl_AS_VAR_APPEND])],
14[m4_define([gl_AS_VAR_APPEND],
15[AS_VAR_SET([$1], [AS_VAR_GET([$1])$2])])])
16
17
18# gl_WARN_ADD(PARAMETER, [VARIABLE = WARN_CFLAGS])
19# ------------------------------------------------
20# Adds parameter to WARN_CFLAGS if the compiler supports it. For example,
21# gl_WARN_ADD([-Wparentheses]).
22#
23# If VARIABLE is a variable name, AC_SUBST it.
24AC_DEFUN([gl_WARN_ADD],
25dnl FIXME: gl_Warn must be used unquoted until we can assume
26dnl autoconf 2.64 or newer.
27[AS_VAR_PUSHDEF([gl_Warn], [gl_cv_warn_[]_AC_LANG_ABBREV[]_$1])dnl
28AS_VAR_PUSHDEF([gl_Flags], [_AC_LANG_PREFIX[]FLAGS])dnl
29AC_CACHE_CHECK([whether _AC_LANG compiler handles $1], m4_defn([gl_Warn]), [
30 gl_save_compiler_FLAGS="$gl_Flags"
31 gl_Flags="$gl_Flags $1"
32 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
33 [AS_VAR_SET(gl_Warn, [yes])],
34 [AS_VAR_SET(gl_Warn, [no])])
35 gl_Flags="$gl_save_compiler_FLAGS"
36])
37AS_VAR_IF(gl_Warn, [yes],
38 [gl_AS_VAR_APPEND(m4_if([$2], [], [[WARN_CFLAGS]], [[$2]]), [" $1"])])
39AS_VAR_POPDEF([gl_Flags])dnl
40AS_VAR_POPDEF([gl_Warn])dnl
41m4_ifval([$2], [AS_LITERAL_IF([$2], [AC_SUBST([$2])], [])])dnl
42])