summaryrefslogtreecommitdiff
path: root/m4/ac_warnflags.m4
blob: 84128c052ec4cf5596609b424fba0e0f673e36f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
dnl Copyright (C) 2008 Kim Woelders
dnl This code is public domain and can be freely used or copied.

dnl Macro to set compiler warning flags

dnl Provides configure argument --enable-werror to stop compilation on warnings

dnl Usage: AC_C_WARNFLAGS([LANG])
dnl Set LANG to 'cpp' when compiling for C++

AC_DEFUN([AC_C_WARNFLAGS], [
  define(ac_c_compile_cpp, ifelse([$1], [cpp], [yes], [no]))

  AC_ARG_ENABLE(werror,
    [  --enable-werror         treat compiler warnings as errors @<:@default=no@:>@],,
    enable_werror=no)

  if test "x$GCC" = "xyes"; then
    CWARNFLAGS="-W -Wall -Waggregate-return -Wcast-align -Wpointer-arith -Wshadow -Wwrite-strings"
dnl # ignore some warnings for now...
    CWARNFLAGS="$CWARNFLAGS -Wno-unused-parameter"
    ifelse(ac_c_compile_cpp, no, [
      CWARNFLAGS="$CWARNFLAGS -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes"
    ],)

    if test "x$enable_werror" = "xyes"; then
      CWARNFLAGS="$CWARNFLAGS -Werror"
    fi
  fi
  AC_SUBST(CWARNFLAGS)
])