Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / nlio / repo / third_party / nlbuild-autotools / repo / autoconf / m4 / nl_enable_debug.m4
1 #
2 #    Copyright 2020 Project nlbuild-autotools Authors. All Rights Reserved.
3 #    Copyright 2015-2016 Nest Labs Inc. All Rights Reserved.
4 #
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
8 #
9 #    http://www.apache.org/licenses/LICENSE-2.0
10 #
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.
16 #
17
18 #
19 #    Description:
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
23 #      and libraries.
24 #
25
26 #
27 # NL_ENABLE_DEBUG(default)
28 #
29 #   default - Whether the option should be enabled (yes) or disabled (no)
30 #             by default.
31 #
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.
35 #
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.
40 #
41 #------------------------------------------------------------------------------
42 AC_DEFUN([NL_ENABLE_DEBUG],
43 [
44     # Check whether or not a default value has been passed in.
45
46     m4_case([$1],
47         [yes],[],
48         [no],[],
49         [m4_fatal([$0: invalid default value '$1'; must be 'yes' or 'no'])])
50
51     AC_CACHE_CHECK([whether to build debug instances of programs and libraries],
52         [nl_cv_build_debug],
53         [
54             AC_ARG_ENABLE(debug,
55                 [AS_HELP_STRING([--enable-debug],[Enable the generation of debug instances @<:@default=$1@:>@.])],
56                 [
57                     case "${enableval}" in 
58
59                     no|yes)
60                         nl_cv_build_debug=${enableval}
61                         ;;
62
63                     *)
64                         AC_MSG_ERROR([Invalid value ${enableval} for --enable-debug])
65                         ;;
66
67                     esac
68                 ],
69                 [
70                     nl_cv_build_debug=$1
71                 ])
72     ])
73
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"
79     fi
80
81 ])