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