aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-11-16 21:17:00 +0300
committerEvgeny Grin (Karlson2k) <k2k@narod.ru>2016-11-16 21:17:00 +0300
commitc99bb7febbe4ad5f36b1882c94c51e6429a0e7d4 (patch)
tree3db4273daf30a0400333a0fe89ad3490dd9ab84d
parent194d72e1f9628d9dd3e732ef2e199f7d4c43afd6 (diff)
downloadlibmicrohttpd-c99bb7febbe4ad5f36b1882c94c51e6429a0e7d4.tar.gz
libmicrohttpd-c99bb7febbe4ad5f36b1882c94c51e6429a0e7d4.zip
configure.ac: check for "true" and "false" and substitute a replacement if required.
This will allow to use "true" and "false" in code, even if compiler don't support them internally.
-rw-r--r--configure.ac57
1 files changed, 57 insertions, 0 deletions
diff --git a/configure.ac b/configure.ac
index 9f2d9e04..a72df1a5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -126,6 +126,63 @@ AC_CHECK_HEADER([stdbool.h],
126 [AC_INCLUDES_DEFAULT] 126 [AC_INCLUDES_DEFAULT]
127) 127)
128 128
129AC_CACHE_CHECK([[whether "true" is defined or builtin]], [[mhd_cv_macro_true_defined]],
130 [AC_COMPILE_IFELSE(
131 [AC_LANG_PROGRAM(
132 [[
133#ifdef HAVE_STDBOOL_H
134#include <stdbool.h>
135#endif
136 ]], [[
137#if defined(true)
138 /* dummy */
139#else
140 (void)true;
141#endif
142 ]])
143 ], [[mhd_cv_macro_true_defined='yes']], [[mhd_cv_macro_true_defined='no']])
144 ])
145AS_VAR_IF([[mhd_cv_macro_true_defined]], [["yes"]], [[:]],
146 [AC_DEFINE([[true]],[[(!0)]], [Define to value interpreted by compiler as boolean "true", if "true" is not defined by system headers.])])
147
148AC_CACHE_CHECK([[whether "false" is defined or builtin]], [[mhd_cv_macro_false_defined]],
149 [AC_COMPILE_IFELSE(
150 [AC_LANG_PROGRAM(
151 [[
152#ifdef HAVE_STDBOOL_H
153#include <stdbool.h>
154#endif
155 ]], [[
156#if !defined(false)
157 (void)false;
158#else
159 /* dummy */
160#endif
161 ]])
162 ], [[mhd_cv_macro_false_defined='yes']], [[mhd_cv_macro_false_defined='no']])
163 ])
164AS_VAR_IF([[mhd_cv_macro_false_defined]], [["yes"]], [[:]],
165 [AC_DEFINE([[false]],[[0]], [Define to value interpreted by compiler as boolean "false", if "false" is not defined by system headers.])])
166
167AC_CACHE_CHECK([[whether "true" and "false" could be used]], [[mhd_cv_macro_true_false_valid]],
168 [AC_COMPILE_IFELSE(
169 [AC_LANG_PROGRAM(
170 [[
171#ifdef HAVE_STDBOOL_H
172#include <stdbool.h>
173#endif
174 ]], [[
175 int var1[true ? 1 : -1] = { 1 };
176 int var2[false ? -1 : 1] = { 2 };
177 if (var1[0] == var2[0])
178 return 1;
179 ]])
180 ], [[mhd_cv_macro_true_false_valid='yes']], [[mhd_cv_macro_true_false_valid='no']])
181 ])
182AS_VAR_IF([[mhd_cv_macro_true_false_valid]], [["yes"]], [[:]],
183 [AC_MSG_ERROR([[Value of "true" or value of "false" is not valid. Check config.log for details.]])])
184
185
129AX_CHECK_COMPILE_FLAG([[-Werror=attributes]], 186AX_CHECK_COMPILE_FLAG([[-Werror=attributes]],
130 [[errattr_CFLAGS="-Werror=attributes"]], 187 [[errattr_CFLAGS="-Werror=attributes"]],
131 [[errattr_CFLAGS=""]], [], []) 188 [[errattr_CFLAGS=""]], [], [])