2 # Copyright 2015-2016 Nest Labs Inc. All Rights Reserved.
4 # Licensed under the Apache License, Version 2.0 (the "License");
5 # you may not use this file except in compliance with the License.
6 # You may obtain a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
19 # This file defines a GNU autoconf M4-style macro that adds an
20 # --enable-warnings-as-errors configuration option to the package
21 # and controls whether the package will be built to treat all
22 # compilation warnings as errors. #
25 # NL_ENABLE_WERROR(default)
27 # default - Whether the option should be enabled (yes) or disabled (no)
30 # Adds an --enable-warnings-as-errors configuration option to the
31 # package with a default value of 'default' (should be either 'no' or
32 # 'yes') and controls whether the package will be built with or
33 # without -Werror enabled.
35 # The value 'nl_cv_warnings_as_errors' will be set to the result. In
36 # addition, the variable NL_WERROR_CPPFLAGS will be set to the
37 # compiler-specific flag necessary to assert this option.
39 #------------------------------------------------------------------------------
40 AC_DEFUN([NL_ENABLE_WERROR],
42 # Check whether or not a default value has been passed in.
47 [m4_fatal([$0: invalid default value '$1'; must be 'yes' or 'no'])])
49 AC_CACHE_CHECK([whether to treat all compilation warnings as errors],
50 nl_cv_warnings_as_errors,
52 AC_ARG_ENABLE(warnings-as-errors,
53 [AS_HELP_STRING([--enable-warnings-as-errors],[Treat all compilation warnings as errors @<:@default=$1@:>@.])],
55 case "${enableval}" in
58 nl_cv_warnings_as_errors=${enableval}
62 AC_MSG_ERROR([Invalid value ${enableval} for --enable-warnings-as-errors])
68 nl_cv_warnings_as_errors=$1
72 if test "${nl_cv_warnings_as_errors}" = "yes"; then
73 AX_CHECK_COMPILER_OPTION([C], NL_WERROR_CPPFLAGS, [-Werror])
74 if test "x${NL_WERROR_CPPFLAGS}" = "x"; then
75 AC_MSG_ERROR([Could not determine how to treat warnings as errors for your compiler ${CC}])