Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / third_party / nlassert / repo / configure.ac
1 #
2 #    Copyright 2015-2018 Nest Labs Inc. All Rights Reserved.
3 #
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
7 #
8 #    http://www.apache.org/licenses/LICENSE-2.0
9 #
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.
15 #
16
17 #
18 #    Description:
19 #      This file is the GNU autoconf input source file for the Nest
20 #      Labs runtime assertion library.
21 #
22
23 #                                               -*- Autoconf -*-
24 # Process this file with autoconf to produce a configure script.
25
26 #
27 # Declare autoconf version requirements
28 #
29 AC_PREREQ([2.68])
30
31 #
32 # Initialize autoconf for the package
33 #
34 AC_INIT([nlassert],
35         m4_esyscmd([third_party/nlbuild-autotools/repo/scripts/mkversion -b `cat .default-version` .]),
36         [nlassert-users@google.com],
37         [nlassert],
38         [https://github.com/nestlabs/nlassert/])
39
40 # Tell the rest of the build system the absolute path where the
41 # nlbuild-autotools repository is rooted at.
42
43 AC_SUBST(nlbuild_autotools_stem,[third_party/nlbuild-autotools/repo])
44 AC_SUBST(abs_top_nlbuild_autotools_dir,[\${abs_top_srcdir}/\${nlbuild_autotools_stem}])
45
46 #
47 # NLASSERT interface current, revision, and age versions.
48 #
49 # Maintainters: Please manage these fields as follows:
50 #
51 #   Interfaces removed:    CURRENT++, AGE = 0, REVISION = 0
52 #   Interfaces added:      CURRENT++, AGE++,   REVISION = 0
53 #   No interfaces changed:                     REVISION++
54 #
55 #
56 AC_SUBST(LIBNLASSERT_VERSION_CURRENT,  [1])
57 AC_SUBST(LIBNLASSERT_VERSION_AGE,      [0])
58 AC_SUBST(LIBNLASSERT_VERSION_REVISION, [0])
59 AC_SUBST(LIBNLASSERT_VERSION_INFO,     [${LIBNLASSERT_VERSION_CURRENT}:${LIBNLASSERT_VERSION_REVISION}:${LIBNLASSERT_VERSION_AGE}])
60
61 #
62 # Check the sanity of the source directory by checking for the
63 # presence of a key watch file
64 #
65 AC_CONFIG_SRCDIR([include/nlassert.h])
66
67 #
68 # Tell autoconf where to find auxilliary build tools (e.g. config.guess,
69 # install-sh, missing, etc.)
70 #
71 AC_CONFIG_AUX_DIR([third_party/nlbuild-autotools/repo/third_party/autoconf])
72
73 #
74 # Tell autoconf where to find auxilliary M4 macros
75 #
76 AC_CONFIG_MACRO_DIRS([third_party/nlbuild-autotools/repo/third_party/autoconf/m4 third_party/nlbuild-autotools/repo/autoconf/m4])
77
78 #
79 # Tell autoconf what file the package is using to aggregate C preprocessor
80 # defines.
81 #
82 AC_CONFIG_HEADERS([include/nlassert-config.h])
83
84 #
85 # Figure out what the canonical build, host and target tuples are.
86 #
87 AC_CANONICAL_BUILD
88 AC_CANONICAL_HOST
89 AC_CANONICAL_TARGET
90
91 #
92 # Mac OS X / Darwin ends up putting some versioning cruft on the end of its
93 # tuple that we don't care about in this script. Create "clean" variables
94 # devoid of it.
95 #
96
97 NL_FILTERED_CANONICAL_BUILD
98 NL_FILTERED_CANONICAL_HOST
99 NL_FILTERED_CANONICAL_TARGET
100
101 #
102 # Configure automake with the desired options, indicating that this is not
103 # a native GNU package, that we want "silent" build rules, and that we want
104 # objects built in the same subdirectory as their source rather than collapsed
105 # together at the top-level directory.
106 #
107 # Disable silent build rules by either passing --disable-silent-rules to
108 # configure or passing V=1 to make
109 #
110 AM_INIT_AUTOMAKE([1.14 foreign silent-rules subdir-objects tar-pax])
111
112 #
113 # Silent build rules requires at least automake-1.11. Employ
114 # techniques for not breaking earlier versions of automake.
115 #
116 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
117 AM_SILENT_RULES([yes])
118
119 #
120 # Enable maintainer mode to prevent the package from constantly trying
121 # to rebuild configure, Makefile.in, etc. Rebuilding such files rarely,
122 # if ever, needs to be done "in the field".
123 #
124 # Use the included 'bootstrap' script instead when necessary.
125 #
126 AM_MAINTAINER_MODE
127
128 #
129 # Checks for build host programs
130 #
131
132 # If we are cross-compiling and we are on an embedded target that
133 # doesn't support independent, standalone executables, then all
134 # compiler tests that attempt to create an executable will fail. In
135 # such circumstances, set AC_NO_EXECUTABLES (see http://sourceware.org/
136 # ml/newlib/2006/msg00353.html).
137
138 AC_MSG_CHECKING([whether to disable executable checking])
139 if test "$cross_compiling" = yes; then
140     AC_NO_EXECUTABLES
141     AC_MSG_RESULT([yes])
142 else
143     AC_MSG_RESULT([no])
144 fi
145
146 # Passing -Werror to GCC-based or -compatible compilers breaks some
147 # autoconf tests (see
148 # http://lists.gnu.org/archive/html/autoconf-patches/2008-09/msg00014.html).
149 #
150 # If -Werror has been passed transform it into -Wno-error. We'll
151 # transform it back later with NL_RESTORE_WERROR.
152
153 NL_SAVE_WERROR
154
155 # Check for compilers.
156 #
157 # These should be checked BEFORE we check for and, implicitly,
158 # initialize libtool such that libtool knows what languages it has to
159 # work with.
160
161 AC_PROG_CPP
162 AC_PROG_CPP_WERROR
163
164 AC_PROG_CC
165 AC_PROG_CC_C_O
166
167 AC_PROG_CXXCPP
168
169 AC_PROG_CXX
170 AC_PROG_CXX_C_O
171
172 # Check for other compiler toolchain tools.
173
174 AC_CHECK_TOOL(AR, ar)
175 AC_CHECK_TOOL(RANLIB, ranlib)
176 AC_CHECK_TOOL(OBJCOPY, objcopy)
177 AC_CHECK_TOOL(STRIP, strip)
178
179 # Check for other host tools.
180
181 AC_PROG_INSTALL
182 AC_PROG_LN_S
183
184 AC_PATH_PROG(CMP, cmp)
185 AC_PATH_PROG(PERL, perl)
186
187 #
188 # Checks for specific preprocessor and compiler characteristics
189 #
190
191 #
192 # Common preprocessor flags we would like to have.
193 #
194 #   -isystem ${top_srcdir}/include/stdc
195 #
196 # We use -isystem, if available, to check the Standard C Library
197 # assert() and assert.h workalike macro and header, respectively,
198 # functionality by forcing the preprocessor to pick-up this package's
199 # provisions for this rather than the toolchain's.
200 #
201
202 PROSPECTIVE_CPPFLAG="-isystem \${top_srcdir}/include/stdc"
203
204 AX_CHECK_PREPROCESSOR_OPTION([C], ISYSTEM_CPPFLAGS, ${PROSPECTIVE_CPPFLAG})
205
206 AC_SUBST(ISYSTEM_CPPFLAGS)
207
208 if test "x${ISYSTEM_CPPFLAGS}" != "x"; then
209     AC_DEFINE([NLASSERT_TEST_STDC],1,[Define to 1 if the Standard C Library assert() workalike should be unit tested])
210 fi
211
212 #
213 # Common compiler flags we would like to have.
214 #
215 #   -Wall                        CC
216 #
217
218 PROSPECTIVE_CFLAGS="-Wall"
219
220 AX_CHECK_COMPILER_OPTIONS([C],   ${PROSPECTIVE_CFLAGS})
221
222 # Check for and initialize libtool
223
224 LT_INIT
225
226 #
227 # Debug instances
228 #
229 AC_MSG_NOTICE([checking whether to build debug instances])
230
231 # Debug
232
233 NL_ENABLE_DEBUG([no])
234
235 AM_CONDITIONAL([NLASSERT_BUILD_DEBUG], [test "${nl_cv_build_debug}" = "yes"])
236
237 #
238 # Code coverage and compiler optimization
239 #
240
241 # Coverage
242
243 NL_ENABLE_COVERAGE([no])
244
245 AM_CONDITIONAL([NLASSERT_BUILD_COVERAGE], [test "${nl_cv_build_coverage}" = "yes"])
246
247 NL_ENABLE_COVERAGE_REPORTS([auto])
248
249 AM_CONDITIONAL([NLASSERT_BUILD_COVERAGE_REPORTS], [test "${nl_cv_build_coverage_reports}" = "yes"])
250
251 # Optimization
252
253 NL_ENABLE_OPTIMIZATION([yes])
254
255 AM_CONDITIONAL([NLASSERT_BUILD_OPTIMIZED], [test "${nl_cv_build_optimized}" = "yes"])
256
257 #
258 # Tests
259 #
260 AC_MSG_NOTICE([checking whether to build tests])
261
262 # Tests
263
264 NL_ENABLE_TESTS([yes])
265
266 AM_CONDITIONAL([NLASSERT_BUILD_TESTS], [test "${nl_cv_build_tests}" = "yes"])
267
268 #
269 # Documentation
270 #
271
272 # Determine whether or not documentation (via Doxygen) should be built
273 # or not, with 'auto' as the default and establish a default support
274 # value for GraphViz 'dot' support.
275
276 NL_ENABLE_DOCS([auto],[NO])
277
278 AM_CONDITIONAL(NLASSERT_BUILD_DOCS, [test "${nl_cv_build_docs}" = "yes"])
279
280 #
281 # Checks for libraries and packages.
282 #
283 # At minimum, the following packages are optional, depending on
284 # configuration:
285 #
286 #   * nlunit-test
287 #
288 AC_MSG_NOTICE([checking required package dependencies])
289
290 # Check if the build host has pkg-config
291
292 AC_PATH_PROG([PKG_CONFIG],[pkg-config])
293
294 #
295 # Nlunit-test
296 #
297
298 if test "${nl_cv_build_tests}" = "yes"; then
299     NL_WITH_PACKAGE(
300         [Nlunit-test],
301         [NLUNIT_TEST],
302         [nlunit_test],
303         [-lnlunit-test],
304         [
305             # At this point, the internal Nlunit-test package will be neither
306             # configured nor built, so the normal checks we undertake for an
307             # external package cannot be run here. Simply set the appropriate
308             # variables and trust all will be well.
309
310             NLUNIT_TEST_CPPFLAGS="-I\${abs_top_srcdir}/third_party/nlunit-test/repo/src"
311             NLUNIT_TEST_LDFLAGS="-L${ac_pwd}/third_party/nlunit-test/repo/src"
312             NLUNIT_TEST_LIBS="-lnlunit-test"
313         ],
314         [
315             # Check for required nlunit-test headers.
316
317             AC_CHECK_HEADERS([nlunit-test.h],
318             [],
319             [
320                 AC_MSG_ERROR(The nlunit-test header "$ac_header" is required but cannot be found.)
321             ])
322         ])
323 fi
324
325 # Depending on whether nlunit-test has been configured for an internal
326 # location, its directory stem within this package needs to be set
327 # accordingly. In addition, if the location is internal, then we need
328 # to attempt to pull it down using the bootstrap makefile.
329
330 if test "${nl_with_nlunit_test}" = "internal"; then
331     maybe_nlunit_test_dirstem="nlunit-test/repo"
332     nlunit_test_dirstem="third_party/${maybe_nlunit_test_dirstem}"
333
334     AC_MSG_NOTICE([attempting to create internal ${nlunit_test_dirstem}])
335
336     ${MAKE-make} --no-print-directory -C ${srcdir} -f Makefile-bootstrap ${nlunit_test_dirstem}
337
338     if test $? -ne 0; then
339         AC_MSG_ERROR([failed to create ${nlunit_test_dirstem}. Please check your network connection or the correctness of 'repos.conf'])
340     fi
341 else
342     maybe_nlunit_test_dirstem=""
343 fi
344
345 AC_SUBST(NLUNIT_TEST_SUBDIRS, [${maybe_nlunit_test_dirstem}])
346 AM_CONDITIONAL([NLASSERT_WITH_NLUNIT_TEST_INTERNAL], [test "${nl_with_nlunit_test}" = "internal"])
347
348 #
349 # Check for headers
350 #
351 AC_HEADER_STDBOOL
352 AC_HEADER_STDC
353
354 AC_CHECK_HEADERS([stdint.h])
355 AC_CHECK_HEADERS([string.h])
356
357 #
358 # Check for types and structures
359 #
360 AC_TYPE_INT8_T
361 AC_TYPE_INT16_T
362 AC_TYPE_INT32_T
363 AC_TYPE_INT64_T
364 AC_TYPE_UINT8_T
365 AC_TYPE_UINT16_T
366 AC_TYPE_UINT32_T
367 AC_TYPE_UINT64_T
368
369 #
370 # Checks for library functions
371 #
372
373 if test "${ac_no_link}" != "yes"; then
374     AC_CHECK_FUNCS([memcpy])
375 fi
376
377 # Add any nlunit-test CPPFLAGS, LDFLAGS, and LIBS
378
379 CPPFLAGS="${CPPFLAGS} ${NLUNIT_TEST_CPPFLAGS}"
380 LDFLAGS="${LDFLAGS} ${NLUNIT_TEST_LDFLAGS}"
381 LIBS="${LIBS} ${NLUNIT_TEST_LIBS}"
382
383 # Add any code coverage CPPFLAGS and LIBS
384
385 CPPFLAGS="${CPPFLAGS} ${NL_COVERAGE_CPPFLAGS}"
386 LDFLAGS="${LDFLAGS} ${NL_COVERAGE_LDFLAGS}"
387 LIBS="${LIBS} ${NL_COVERAGE_LIBS}"
388
389 # At this point, we can restore the compiler flags to whatever the
390 # user passed in, now that we're clear of any -Werror issues by
391 # transforming -Wno-error back to -Werror.
392
393 NL_RESTORE_WERROR
394
395 # Configure any autotools-based subdirectories
396
397 if test "${nl_with_nlunit_test}" = "internal"; then
398     AC_CONFIG_SUBDIRS([third_party/nlunit-test/repo])
399     AC_SUBST(NLUNIT_TEST_FOREIGN_SUBDIR_DEPENDENCY,["${ac_pwd}/third_party/nlunit-test/repo/src"])
400 fi
401
402 #
403 # Identify the various makefiles and auto-generated files for the package
404 #
405 AC_CONFIG_FILES([
406 Makefile
407 third_party/Makefile
408 include/Makefile
409 tests/Makefile
410 doc/Makefile
411 ])
412
413 #
414 # Generate the auto-generated files for the package
415 #
416 AC_OUTPUT
417
418 #
419 # Summarize the package configuration
420 #
421
422 AC_MSG_NOTICE([
423
424   Configuration Summary
425   ---------------------
426   Package                                     : ${PACKAGE_NAME}
427   Version                                     : ${PACKAGE_VERSION}
428   Interface                                   : ${LIBNLASSERT_VERSION_INFO//:/.}
429   Build system                                : ${build}
430   Host system                                 : ${host}
431   Target system                               : ${target}
432   Target architecture                         : ${target_cpu}
433   Target OS                                   : ${target_os}
434   Cross compiling                             : ${cross_compiling}
435   Build shared libraries                      : ${enable_shared}
436   Build static libraries                      : ${enable_static}
437   Build debug libraries                       : ${nl_cv_build_debug}
438   Build optimized libraries                   : ${nl_cv_build_optimized}
439   Build coverage libraries                    : ${nl_cv_build_coverage}
440   Build coverage reports                      : ${nl_cv_build_coverage_reports}
441   Lcov                                        : ${LCOV:--}
442   Genhtml                                     : ${GENHTML:--}
443   Build tests                                 : ${nl_cv_build_tests}
444   Prefix                                      : ${prefix}
445   Shadow directory program                    : ${LNDIR}
446   Documentation support                       : ${nl_cv_build_docs}
447   Doxygen                                     : ${DOXYGEN:--}
448   GraphViz dot                                : ${DOT:--}
449   PERL                                        : ${PERL:--}
450   Nlunit-test source                          : ${nl_with_nlunit_test:--}
451   Nlunit-test compile flags                   : ${NLUNIT_TEST_CPPFLAGS:--}
452   Nlunit-test link flags                      : ${NLUNIT_TEST_LDFLAGS:--}
453   Nlunit-test link libraries                  : ${NLUNIT_TEST_LIBS:--}
454   Nlunit-test foreign subdirectory dependency : ${NLUNIT_TEST_FOREIGN_SUBDIR_DEPENDENCY:--}
455   C Preprocessor                              : ${CPP}
456   C Compiler                                  : ${CC}
457   C++ Preprocessor                            : ${CXXCPP}
458   C++ Compiler                                : ${CXX}
459   Archiver                                    : ${AR}
460   Archive Indexer                             : ${RANLIB}
461   Symbol Stripper                             : ${STRIP}
462   Object Copier                               : ${OBJCOPY}
463   C Preprocessor flags                        : ${CPPFLAGS:--}
464   C Compile flags                             : ${CFLAGS:--}
465   C++ Compile flags                           : ${CXXFLAGS:--}
466   Link flags                                  : ${LDFLAGS:--}
467   Link libraries                              : ${LIBS}
468 ])