2 # Copyright 2020 Project nlbuild-autotools Authors. All Rights Reserved.
3 # Copyright 2015-2016 Nest Labs Inc. All Rights Reserved.
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
20 # This file defines a GNU autoconf M4-style macro that adds an
21 # --enable-debug configuration option to the package and controls
22 # whether the package will be built for debug instances of programs
27 # NL_ENABLE_DEBUG(default)
29 # default - Whether the option should be enabled (yes) or disabled (no)
32 # Adds an --enable-debug configuration option to the package with a
33 # default value of 'default' (should be either 'no' or 'yes') and controls
34 # whether the package will be built with or without -DDEBUG enabled.
36 # The value 'nl_cv_build_debug' will be set to the result. In
37 # addition, the contents of CFLAGS, CXXFLAGS, OBJCFLAGS, and
38 # OBJCXXFLAGS may be altered by the use of this macro, adding -DDEBUG
39 # if this option is asserted.
41 #------------------------------------------------------------------------------
42 AC_DEFUN([NL_ENABLE_DEBUG],
44 # Check whether or not a default value has been passed in.
49 [m4_fatal([$0: invalid default value '$1'; must be 'yes' or 'no'])])
51 AC_CACHE_CHECK([whether to build debug instances of programs and libraries],
55 [AS_HELP_STRING([--enable-debug],[Enable the generation of debug instances @<:@default=$1@:>@.])],
57 case "${enableval}" in
60 nl_cv_build_debug=${enableval}
64 AC_MSG_ERROR([Invalid value ${enableval} for --enable-debug])
74 if test "${nl_cv_build_debug}" = "yes"; then
75 CFLAGS="${CFLAGS} -DDEBUG"
76 CXXFLAGS="${CXXFLAGS} -DDEBUG"
77 OBJCFLAGS="${OBJCFLAGS} -DDEBUG"
78 OBJCXXFLAGS="${OBJCXXFLAGS} -DDEBUG"