2 # Copyright 2015-2018 Nest Labs Inc. All Rights Reserved.
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
8 # http://www.apache.org/licenses/LICENSE-2.0
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.
19 # This file is the GNU autoconf input source file for the Nest
20 # Labs Memory-mapped I/O package.
23 # Process this file with autoconf to produce a configure script.
26 # Declare autoconf version requirements
31 # Initialize autoconf for the package
34 m4_esyscmd([third_party/nlbuild-autotools/repo/scripts/mkversion -b `cat .default-version` .]),
35 [nlio-users@google.com],
37 [https://github.com/nestlabs/nlio/])
39 # Tell the rest of the build system the absolute path where the
40 # nlbuild-autotools repository is rooted at.
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}])
46 # NLIO interface current, revision, and age versions.
48 # NOTE: At present, NLIO makes NO ABI compatibility
49 # commitments. Consequently, these simply serve as documentation
50 # for how the interfaces have evolved.
52 # Maintainters: Please manage these fields as follows:
54 # Interfaces removed: CURRENT++, AGE = 0, REVISION = 0
55 # Interfaces added: CURRENT++, AGE++, REVISION = 0
56 # No interfaces changed: REVISION++
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}])
65 # Check the sanity of the source directory by checking for the
66 # presence of a key watch file
68 AC_CONFIG_SRCDIR([include/nlio.h])
71 # Tell autoconf where to find auxilliary build tools (e.g. config.guess,
72 # install-sh, missing, etc.)
74 AC_CONFIG_AUX_DIR([third_party/nlbuild-autotools/repo/third_party/autoconf])
77 # Tell autoconf where to find auxilliary M4 macros
79 AC_CONFIG_MACRO_DIRS([third_party/nlbuild-autotools/repo/third_party/autoconf/m4 third_party/nlbuild-autotools/repo/autoconf/m4])
82 # Tell autoconf what file the package is using to aggregate C preprocessor
85 AC_CONFIG_HEADERS([include/nlio-config.h])
88 # Figure out what the canonical build, host and target tuples are.
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
100 NL_FILTERED_CANONICAL_BUILD
101 NL_FILTERED_CANONICAL_HOST
102 NL_FILTERED_CANONICAL_TARGET
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.
110 # Disable silent build rules by either passing --disable-silent-rules to
111 # configure or passing V=1 to make
113 AM_INIT_AUTOMAKE([1.14 foreign silent-rules subdir-objects tar-pax])
116 # Silent build rules requires at least automake-1.11. Employ
117 # techniques for not breaking earlier versions of automake.
119 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
120 AM_SILENT_RULES([yes])
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".
127 # Use the included 'bootstrap' script instead when necessary.
132 # Checks for build host programs
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).
141 AC_MSG_CHECKING([whether to disable executable checking])
142 if test "$cross_compiling" = yes; then
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).
153 # If -Werror has been passed transform it into -Wno-error. We'll
154 # transform it back later with NL_RESTORE_WERROR.
158 # Check for compilers.
160 # These should be checked BEFORE we check for and, implicitly,
161 # initialize libtool such that libtool knows what languages it has to
175 # Check for other compiler toolchain tools.
177 AC_CHECK_TOOL(AR, ar)
178 AC_CHECK_TOOL(RANLIB, ranlib)
179 AC_CHECK_TOOL(OBJCOPY, objcopy)
180 AC_CHECK_TOOL(STRIP, strip)
182 # Check for other host tools.
187 AC_PATH_PROG(CMP, cmp)
188 AC_PATH_PROG(PERL, perl)
191 # Checks for specific compiler characteristics
195 # Common compiler flags we would like to have.
200 PROSPECTIVE_CFLAGS="-Wall"
201 PROSPECTIVE_CXXFLAGS=""
203 AX_CHECK_COMPILER_OPTIONS([C], ${PROSPECTIVE_CFLAGS})
204 AX_CHECK_COMPILER_OPTIONS([C++], ${PROSPECTIVE_CFLAGS} ${PROSPECTIVE_CXXFLAGS})
206 # Check for and initialize libtool
213 AC_MSG_NOTICE([checking whether to build debug instances])
217 NL_ENABLE_DEBUG([no])
219 AM_CONDITIONAL([NLIO_BUILD_DEBUG], [test "${nl_cv_build_debug}" = "yes"])
222 # Code coverage and compiler optimization
227 NL_ENABLE_COVERAGE([no])
229 AM_CONDITIONAL([NLIO_BUILD_COVERAGE], [test "${nl_cv_build_coverage}" = "yes"])
231 NL_ENABLE_COVERAGE_REPORTS([auto])
233 AM_CONDITIONAL([NLIO_BUILD_COVERAGE_REPORTS], [test "${nl_cv_build_coverage_reports}" = "yes"])
237 NL_ENABLE_OPTIMIZATION([yes])
239 AM_CONDITIONAL([NLIO_BUILD_OPTIMIZED], [test "${nl_cv_build_optimized}" = "yes"])
244 AC_MSG_NOTICE([checking whether to build tests])
248 NL_ENABLE_TESTS([yes])
250 AM_CONDITIONAL([NLIO_BUILD_TESTS], [test "${nl_cv_build_tests}" = "yes"])
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.
260 NL_ENABLE_DOCS([auto],[NO])
262 AM_CONDITIONAL(NLIO_BUILD_DOCS, [test "${nl_cv_build_docs}" = "yes"])
265 # Checks for libraries and packages.
267 # At minimum, the following packages are optional, depending on
272 AC_MSG_NOTICE([checking required package dependencies])
274 # Check if the build host has pkg-config
276 AC_PATH_PROG([PKG_CONFIG],[pkg-config])
282 if test "${nl_cv_build_tests}" = "yes"; then
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.
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"
299 # Check for required nlunit-test headers.
301 AC_CHECK_HEADERS([nlunit-test.h],
304 AC_MSG_ERROR(The nlunit-test header "$ac_header" is required but cannot be found.)
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.
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}"
318 AC_MSG_NOTICE([attempting to create internal ${nlunit_test_dirstem}])
320 ${MAKE-make} --no-print-directory -C ${srcdir} -f Makefile-bootstrap ${nlunit_test_dirstem}
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'])
326 maybe_nlunit_test_dirstem=""
329 AC_SUBST(NLUNIT_TEST_SUBDIRS, [${maybe_nlunit_test_dirstem}])
330 AM_CONDITIONAL([NLIO_WITH_NLUNIT_TEST_INTERNAL], [test "${nl_with_nlunit_test}" = "internal"])
338 AC_CHECK_HEADERS([stdint.h])
339 AC_CHECK_HEADERS([string.h])
342 # Figure out whether the target uses endian.h or machine/endian.h.
344 AC_CHECK_HEADERS([endian.h])
345 AC_CHECK_HEADERS([machine/endian.h])
348 # Check for types and structures
360 # Checks for library functions
363 if test "${ac_no_link}" != "yes"; then
364 AC_CHECK_FUNCS([memcpy])
367 # Add any nlunit-test CPPFLAGS, LDFLAGS, and LIBS
369 CPPFLAGS="${CPPFLAGS} ${NLUNIT_TEST_CPPFLAGS}"
370 LDFLAGS="${LDFLAGS} ${NLUNIT_TEST_LDFLAGS}"
371 LIBS="${LIBS} ${NLUNIT_TEST_LIBS}"
373 # Add any code coverage CPPFLAGS and LIBS
375 CPPFLAGS="${CPPFLAGS} ${NL_COVERAGE_CPPFLAGS}"
376 LDFLAGS="${LDFLAGS} ${NL_COVERAGE_LDFLAGS}"
377 LIBS="${LIBS} ${NL_COVERAGE_LIBS}"
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.
385 # Configure any autotools-based subdirectories
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"])
393 # Identify the various makefiles and auto-generated files for the package
404 # Generate the auto-generated files for the package
409 # Summarize the package configuration
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}
432 Genhtml : ${GENHTML:--}
433 Build tests : ${nl_cv_build_tests}
435 Shadow directory program : ${LNDIR}
436 Documentation support : ${nl_cv_build_docs}
437 Doxygen : ${DOXYGEN:--}
438 GraphViz dot : ${DOT:--}
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}
447 C++ Preprocessor : ${CXXCPP}
448 C++ Compiler : ${CXX}
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}