594ff97b486bb79c4236b3f879c4cf74b139e547
[gnulib.git] / m4 / warnings.m4
1 # warnings.m4 serial 1
2 dnl Copyright (C) 2008 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
6
7 dnl From Simon Josefsson
8
9 # gl_WARN_INIT
10 # Initializes WARN_CFLAGS variable.
11 AC_DEFUN([gl_WARN_INIT],
12 [
13   AC_ARG_VAR(WARN_CFLAGS, [C compiler warning flags])
14 ])
15
16 # gl_WARN_ADD([parameter]) adds parameter to WARN_CFLAGS if compiler
17 # supports it.  For example, use gl_WARN_ADD([-Werror]).
18 AC_DEFUN([gl_WARN_ADD],
19 [
20   pushdef([param],[translit([$1],[ABCDEFGHIJKLMNOPQRSTUVWXYZ./-],
21                                  [abcdefghijklmnopqrstuvwxyz___])])
22
23   AC_CACHE_CHECK([whether compiler handles $1], [gl_cv_warn[]param[]], [
24     save_CFLAGS="$CFLAGS"
25     CFLAGS="${CFLAGS} $1"
26     AC_PREPROC_IFELSE([AC_LANG_PROGRAM([])],
27                        gl_cv_warn[]param=yes, gl_cv_warn[]param=no)
28     CFLAGS="$save_CFLAGS"
29   ])
30
31   if test $gl_cv_warn[]param = "yes"; then
32     WARN_CFLAGS="$WARN_CFLAGS $1"
33   fi
34 ])