2008-11-15 09:33:31 -08:00
|
|
|
dnl Copyright (C) 2008 Kim Woelders
|
|
|
|
dnl This code is public domain and can be freely used or copied.
|
|
|
|
|
2013-08-09 00:36:11 -07:00
|
|
|
dnl Macro to set compiler warning flags in CFLAGS_WARNINGS
|
2008-11-15 09:33:31 -08:00
|
|
|
|
|
|
|
dnl Provides configure argument --enable-werror to stop compilation on warnings
|
|
|
|
|
2013-08-08 23:31:57 -07:00
|
|
|
dnl Usage: EC_C_WARNINGS([LANG])
|
2008-11-15 09:33:31 -08:00
|
|
|
dnl Set LANG to 'cpp' when compiling for C++
|
|
|
|
|
2013-08-08 23:31:57 -07:00
|
|
|
AC_DEFUN([EC_C_WARNINGS], [
|
2020-05-05 11:09:20 -07:00
|
|
|
m4_define([ec_c_compile_cpp], ifelse([$1], [cpp], [yes], [no]))
|
2008-11-15 09:33:31 -08:00
|
|
|
|
|
|
|
AC_ARG_ENABLE(werror,
|
2020-05-05 13:28:46 -07:00
|
|
|
[AS_HELP_STRING([--enable-werror],
|
|
|
|
[treat compiler warnings as errors @<:@default=no@:>@])],,
|
2008-11-15 09:33:31 -08:00
|
|
|
enable_werror=no)
|
|
|
|
|
|
|
|
if test "x$GCC" = "xyes"; then
|
2015-01-17 12:07:31 -08:00
|
|
|
CFLAGS_WARNINGS="-W -Wall -Waggregate-return -Wcast-align=strict -Wpointer-arith -Wshadow -Wwrite-strings"
|
2013-08-08 23:31:57 -07:00
|
|
|
ifelse(ec_c_compile_cpp, no, [
|
2013-08-09 00:36:11 -07:00
|
|
|
CFLAGS_WARNINGS="$CFLAGS_WARNINGS -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes"
|
2022-04-23 04:09:03 -07:00
|
|
|
], [
|
|
|
|
CFLAGS_WARNINGS="$CFLAGS_WARNINGS -Wno-missing-field-initializers"
|
2020-05-05 11:09:20 -07:00
|
|
|
])
|
2008-11-15 09:33:31 -08:00
|
|
|
|
|
|
|
if test "x$enable_werror" = "xyes"; then
|
2013-08-09 00:36:11 -07:00
|
|
|
CFLAGS_WARNINGS="$CFLAGS_WARNINGS -Werror"
|
2008-11-15 09:33:31 -08:00
|
|
|
fi
|
|
|
|
fi
|
2013-08-09 00:36:11 -07:00
|
|
|
AC_SUBST(CFLAGS_WARNINGS)
|
2008-11-15 09:33:31 -08:00
|
|
|
])
|