| # -*- Autoconf -*- |
| # Process this file with autoconf to produce a configure script. |
| |
| # Copyright 2016-2017 The nlfaultinjection Authors. |
| # |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| # |
| |
| # |
| # Description: |
| # This file is the GNU autoconf input source file for Nest |
| # Labs Fault Injection. |
| # |
| |
| # |
| # Declare autoconf version requirements |
| # |
| AC_PREREQ([2.68]) |
| |
| # |
| # Initialize autoconf for the package |
| # |
| AC_INIT([NLFAULTINJECTION], |
| m4_esyscmd([third_party/nlbuild-autotools/repo/scripts/mkversion -b `cat .default-version` .]), |
| [developer@nest.com], |
| [nlfaultinjection], |
| [http://developer.nest.com/]) |
| |
| # Tell the rest of the build system the absolute path where the |
| # nlbuild-autotools repository is rooted at. |
| |
| AC_SUBST(nlbuild_autotools_stem,[third_party/nlbuild-autotools/repo]) |
| AC_SUBST(abs_top_nlbuild_autotools_dir,[\${abs_top_srcdir}/\${nlbuild_autotools_stem}]) |
| |
| # |
| # nlfaultinjection interface current, revision, and age versions. |
| # |
| # Maintainters: Please manage these fields as follows: |
| # |
| # Interfaces removed: CURRENT++, AGE = 0, REVISION = 0 |
| # Interfaces added: CURRENT++, AGE++, REVISION = 0 |
| # No interfaces changed: REVISION++ |
| # |
| # |
| AC_SUBST(LIBNLFAULTINJECTION_VERSION_CURRENT, [1]) |
| AC_SUBST(LIBNLFAULTINJECTION_VERSION_AGE, [0]) |
| AC_SUBST(LIBNLFAULTINJECTION_VERSION_REVISION, [0]) |
| AC_SUBST(LIBNLFAULTINJECTION_VERSION_INFO, [${LIBNLFAULTINJECTION_VERSION_CURRENT}:${LIBNLFAULTINJECTION_VERSION_REVISION}:${LIBNLFAULTINJECTION_VERSION_AGE}]) |
| |
| # |
| # Check the sanity of the source directory by checking for the |
| # presence of a key watch file |
| # |
| AC_CONFIG_SRCDIR([include/nlfaultinjection.hpp]) |
| |
| # |
| # Tell autoconf where to find auxilliary build tools (e.g. config.guess, |
| # install-sh, missing, etc.) |
| # |
| AC_CONFIG_AUX_DIR([third_party/nlbuild-autotools/repo/third_party/autoconf]) |
| |
| # |
| # Tell autoconf where to find auxilliary M4 macros |
| # |
| AC_CONFIG_MACRO_DIRS([third_party/nlbuild-autotools/repo/third_party/autoconf/m4 third_party/nlbuild-autotools/repo/autoconf/m4]) |
| |
| # |
| # Tell autoconf what file the package is using to aggregate C preprocessor |
| # defines. |
| # |
| AC_CONFIG_HEADERS([include/nlfaultinjection-config.h]) |
| |
| # |
| # Figure out what the canonical build, host and target tuples are. |
| # |
| AC_CANONICAL_BUILD |
| AC_CANONICAL_HOST |
| AC_CANONICAL_TARGET |
| |
| # |
| # Mac OS X / Darwin ends up putting some versioning cruft on the end of its |
| # tuple that we don't care about in this script. Create "clean" variables |
| # devoid of it. |
| # |
| |
| NL_FILTERED_CANONICAL_BUILD |
| NL_FILTERED_CANONICAL_HOST |
| NL_FILTERED_CANONICAL_TARGET |
| |
| # |
| # Configure automake with the desired options, indicating that this is not |
| # a native GNU package, that we want "silent" build rules, and that we want |
| # objects built in the same subdirectory as their source rather than collapsed |
| # together at the top-level directory. |
| # |
| # Disable silent build rules by either passing --disable-silent-rules to |
| # configure or passing V=1 to make |
| # |
| AM_INIT_AUTOMAKE([1.14 foreign silent-rules subdir-objects tar-pax]) |
| |
| # |
| # Silent build rules requires at least automake-1.11. Employ |
| # techniques for not breaking earlier versions of automake. |
| # |
| m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) |
| AM_SILENT_RULES([yes]) |
| |
| # |
| # Enable maintainer mode to prevent the package from constantly trying |
| # to rebuild configure, Makefile.in, etc. Rebuilding such files rarely, |
| # if ever, needs to be done "in the field". |
| # |
| # Use the included 'bootstrap' script instead when necessary. |
| # |
| AM_MAINTAINER_MODE |
| |
| # |
| # Checks for build host programs |
| # |
| |
| # If we are cross-compiling and we are on an embedded target that |
| # doesn't support independent, standalone executables, then all |
| # compiler tests that attempt to create an executable will fail. In |
| # such circumstances, set AC_NO_EXECUTABLES (see http://sourceware.org/ |
| # ml/newlib/2006/msg00353.html). |
| |
| AC_MSG_CHECKING([whether to disable executable checking]) |
| if test "$cross_compiling" = yes; then |
| AC_NO_EXECUTABLES |
| AC_MSG_RESULT([yes]) |
| else |
| AC_MSG_RESULT([no]) |
| fi |
| |
| # Passing -Werror to GCC-based or -compatible compilers breaks some |
| # autoconf tests (see |
| # http://lists.gnu.org/archive/html/autoconf-patches/2008-09/msg00014.html). |
| # |
| # If -Werror has been passed transform it into -Wno-error. We'll |
| # transform it back later with NL_RESTORE_WERROR. |
| |
| NL_SAVE_WERROR |
| |
| # Check for compilers. |
| # |
| # These should be checked BEFORE we check for and, implicitly, |
| # initialize libtool such that libtool knows what languages it has to |
| # work with. |
| |
| AC_PROG_CPP |
| AC_PROG_CPP_WERROR |
| |
| AC_PROG_CC |
| AC_PROG_CC_C_O |
| |
| AC_PROG_CXXCPP |
| |
| AC_PROG_CXX |
| AC_PROG_CXX_C_O |
| |
| # Check for other compiler toolchain tools. |
| |
| AC_CHECK_TOOL(AR, ar) |
| AC_CHECK_TOOL(RANLIB, ranlib) |
| AC_CHECK_TOOL(OBJCOPY, objcopy) |
| AC_CHECK_TOOL(STRIP, strip) |
| |
| # Check for other host tools. |
| |
| AC_PROG_INSTALL |
| AC_PROG_LN_S |
| |
| # |
| # Checks for specific compiler characteristics |
| # |
| |
| # |
| # Common compiler flags we would like to have. |
| # Note that in gcc, -Wconversion implies -Wsign-conversion (but only for C) |
| # |
| |
| PROSPECTIVE_CFLAGS="-Wall -Wextra -Wshadow -Werror -std=c99 -pedantic-errors -Wconversion -Wsign-conversion" |
| PROSPECTIVE_CXXFLAGS="-Wall -Wextra -Wshadow -Werror -Wconversion -Wsign-conversion" |
| |
| TARGET_STYLE= |
| AC_MSG_CHECKING([for target style]) |
| |
| # The user may have attempted to explicitly specify the target |
| # style. Sanity check it or default to 'auto'. |
| |
| AC_ARG_WITH(target-style, |
| [AS_HELP_STRING([--with-target-style=TARGET], |
| [Specify the target style from one of: auto, embedded or unix @<:@default=auto@:>@.])], |
| [ |
| case "${with_target_style}" in |
| |
| auto|embedded|unix) |
| ;; |
| |
| *) |
| AC_MSG_ERROR([Invalid value ${with_target_style} for --with-target-style]) |
| ;; |
| |
| esac |
| ], |
| [with_target_style=auto]) |
| |
| # At this point, the target style is one of the allowed |
| # values. If it's 'auto' we autodetect it. |
| |
| if test "${with_target_style}" = "auto"; then |
| case ${target_os} in |
| |
| *cygwin*|*darwin*|*linux*|*freebsd*|*netbsd*|*openbsd*) |
| with_target_style=unix |
| ;; |
| |
| *freertos*) |
| with_target_style=embedded |
| ;; |
| |
| *) |
| AC_MSG_RESULT([unknown]) |
| AC_MSG_ERROR([Unsupported target OS ${target_os}]) |
| ;; |
| |
| esac |
| fi |
| |
| TARGET_STYLE=${with_target_style} |
| |
| AC_MSG_RESULT(${TARGET_STYLE}) |
| |
| AC_SUBST(TARGET_STYLE) |
| AC_DEFINE_UNQUOTED([TARGET_STYLE],[${TARGET_STYLE}],[Target style]) |
| |
| if test "${TARGET_STYLE}" = "unix"; then |
| PROSPECTIVE_CFLAGS="${PROSPECTIVE_CFLAGS} -fPIC -fno-stack-protector" |
| PROSPECTIVE_CXXFLAGS="${PROSPECTIVE_CXXFLAGS} -fPIC -fno-exceptions" |
| fi |
| |
| |
| AC_CACHE_CHECK([whether $CC is Clang], |
| [nl_cv_clang], |
| [nl_cv_clang=no |
| if test "x${GCC}" = "xyes"; then |
| AC_EGREP_CPP([NL_CC_IS_CLANG], |
| [/* Note: Clang 2.7 lacks __clang_[a-z]+__ */ |
| # if defined(__clang__) && defined(__llvm__) |
| NL_CC_IS_CLANG |
| # endif |
| ], |
| [nl_cv_clang=yes]) |
| fi |
| ]) |
| |
| AX_CHECK_COMPILER_OPTIONS([C], ${PROSPECTIVE_CFLAGS}) |
| AX_CHECK_COMPILER_OPTIONS([C++], ${PROSPECTIVE_CXXFLAGS}) |
| |
| # Check for and initialize libtool |
| |
| LT_INIT |
| |
| # |
| # Debug instances |
| # |
| AC_MSG_NOTICE([checking whether to build debug instances]) |
| |
| # Debug |
| |
| NL_ENABLE_DEBUG([no]) |
| |
| AM_CONDITIONAL([NLFAULTINJECTION_BUILD_DEBUG], [test "${nl_cv_build_debug}" = "yes"]) |
| |
| # |
| # Code coverage and compiler optimization |
| # |
| |
| # Coverage |
| |
| NL_ENABLE_COVERAGE([no]) |
| |
| AM_CONDITIONAL([NLFAULTINJECTION_BUILD_COVERAGE], [test "${nl_cv_build_coverage}" = "yes"]) |
| |
| NL_ENABLE_COVERAGE_REPORTS([auto]) |
| |
| AM_CONDITIONAL([NLFAULTINJECTION_BUILD_COVERAGE_REPORTS], [test "${nl_cv_build_coverage_reports}" = "yes"]) |
| |
| # Optimization |
| |
| NL_ENABLE_OPTIMIZATION([yes]) |
| |
| AM_CONDITIONAL([NLFAULTINJECTION_BUILD_OPTIMIZED], [test "${nl_cv_build_optimized}" = "yes"]) |
| |
| # |
| # Code style |
| # |
| AC_SUBST(PRETTY_CHECK, ["\${PERL} \${abs_top_srcdir}/third_party/cstyle/repo/cstyle.pl"]) |
| AC_SUBST(PRETTY_CHECK_ARGS, ["\$(shell cat \${abs_top_srcdir}/build/cstyle/cstyle.options)"]) |
| |
| # |
| # Tests |
| # |
| AC_MSG_NOTICE([checking whether to build tests]) |
| |
| # Tests |
| |
| NL_ENABLE_TESTS([yes]) |
| |
| AM_CONDITIONAL([NLFAULTINJECTION_BUILD_TESTS], [test "${nl_cv_build_tests}" = "yes"]) |
| |
| # |
| # Documentation |
| # |
| |
| # Determine whether or not documentation (via Doxygen) should be built |
| # or not, with 'auto' as the default and establish a default support |
| # value for GraphViz 'dot' support. |
| |
| NL_ENABLE_DOCS([auto],[NO]) |
| |
| AM_CONDITIONAL(NLFAULTINJECTION_BUILD_DOCS, [test "${nl_cv_build_docs}" = "yes"]) |
| |
| # |
| # Checks for libraries and packages. |
| # |
| # At minimum, the following packages are required: |
| # |
| # * nlassert |
| # |
| # The following are optional, depending on configuration: |
| # |
| # * nlunittest |
| # |
| # All of these are supplied "in package"; however, they may be also |
| # supplied out of package. |
| # |
| AC_MSG_NOTICE([checking required package dependencies]) |
| |
| # Check if the build host has pkg-config |
| |
| AC_PATH_PROG([PKG_CONFIG],[pkg-config]) |
| |
| # |
| # Nlunittest |
| # |
| |
| if test "${nl_cv_build_tests}" = "yes"; then |
| AC_CHECK_HEADERS([time.h]) |
| |
| NL_WITH_REQUIRED_INTERNAL_PACKAGE( |
| [Nlunittest], |
| [NLUNITTEST], |
| [nlunittest], |
| [-lnlunittest], |
| [ |
| # At this point, the internal Nlunittest package will be neither |
| # configured nor built, so the normal checks we undertake for an |
| # external package cannot be run here. Simply set the appropriate |
| # variables and trust all will be well. |
| |
| NLUNITTEST_CPPFLAGS="-I\${abs_top_srcdir}/third_party/nltest/repo/src" |
| NLUNITTEST_LDFLAGS="-L${ac_pwd}/third_party/nltest/repo/src" |
| NLUNITTEST_LIBS="-lnlunittest" |
| ], |
| [ |
| # Check for required Nlunittest headers. |
| |
| AC_CHECK_HEADERS([nltest.h], |
| [], |
| [ |
| AC_MSG_ERROR(The nlunittest header "$ac_header" is required but cannot be found.) |
| ]) |
| ]) |
| fi |
| |
| AM_CONDITIONAL([NLFAULTINJECTION_WITH_NLUNITTEST_INTERNAL], [test "${nl_with_nlunittest}" = "internal"]) |
| |
| NL_WITH_REQUIRED_INTERNAL_PACKAGE( |
| [Nlassert], |
| [NLASSERT], |
| [nlassert], |
| [], |
| [ |
| # At this point, the internal Nlunittest package will be neither |
| # configured nor built, so the normal checks we undertake for an |
| # external package cannot be run here. Simply set the appropriate |
| # variables and trust all will be well. |
| |
| NLASSERT_CPPFLAGS="-I\${abs_top_srcdir}/third_party/nlassert/repo/include" |
| ], |
| [ |
| # Check for required Nlassert headers. |
| |
| AC_CHECK_HEADERS([nlassert.h], |
| [], |
| [ |
| AC_MSG_ERROR(The nlassert header "$ac_header" is required but cannot be found.) |
| ]) |
| ]) |
| |
| AM_CONDITIONAL([NLFAULTINJECTION_WITH_NLASSERT_INTERNAL], [test "${nl_with_nlassert}" = "internal"]) |
| |
| # |
| # Check for headers |
| # |
| AC_HEADER_STDBOOL |
| AC_HEADER_STDC |
| |
| AC_CHECK_HEADERS([stdint.h]) |
| AC_CHECK_HEADERS([string.h]) |
| AC_CHECK_HEADERS([stdlib.h]) |
| |
| # |
| # Check for types and structures |
| # |
| AC_TYPE_INT8_T |
| AC_TYPE_INT16_T |
| AC_TYPE_INT32_T |
| AC_TYPE_INT64_T |
| AC_TYPE_UINT8_T |
| AC_TYPE_UINT16_T |
| AC_TYPE_UINT32_T |
| AC_TYPE_UINT64_T |
| |
| # |
| # Checks for library functions |
| # |
| |
| if test "${ac_no_link}" != "yes"; then |
| AC_CHECK_FUNCS([rand]) |
| fi |
| |
| # Add any nlunittest CPPFLAGS, LDFLAGS, and LIBS |
| |
| CPPFLAGS="${CPPFLAGS} ${NLUNITTEST_CPPFLAGS}" |
| LDFLAGS="${LDFLAGS} ${NLUNITTEST_LDFLAGS}" |
| LIBS="${LIBS} ${NLUNITTEST_LIBS}" |
| |
| # Add any nlassert CPPFLAGS, LDFLAGS, and LIBS |
| |
| CPPFLAGS="${CPPFLAGS} ${NLASSERT_CPPFLAGS}" |
| |
| # Add any code coverage CPPFLAGS and LDFLAGS |
| |
| CPPFLAGS="${CPPFLAGS} ${NL_COVERAGE_CPPFLAGS}" |
| LDFLAGS="${LDFLAGS} ${NL_COVERAGE_LDFLAGS}" |
| |
| # At this point, we can restore the compiler flags to whatever the |
| # user passed in, now that we're clear of an -Werror issues by |
| # transforming -Wno-error back to -Werror. |
| |
| NL_RESTORE_WERROR |
| |
| AC_CONFIG_SUBDIRS([third_party/nltest/repo]) |
| AC_CONFIG_SUBDIRS([third_party/nlassert/repo]) |
| |
| # |
| # Identify the various makefiles and auto-generated files for the package |
| # |
| AC_CONFIG_FILES([ |
| Makefile |
| third_party/Makefile |
| include/Makefile |
| src/Makefile |
| tests/Makefile |
| doc/Makefile |
| ]) |
| |
| # |
| # Generate the auto-generated files for the package |
| # |
| AC_OUTPUT |
| |
| # |
| # Summarize the package configuration |
| # |
| |
| AC_MSG_NOTICE([ |
| |
| Configuration Summary |
| --------------------- |
| Package : ${PACKAGE_NAME} |
| Version : ${PACKAGE_VERSION} |
| Interface : ${LIBNLFAULTINJECTION_VERSION_INFO//:/.} |
| Build system : ${build} |
| Host system : ${host} |
| Target system : ${target} |
| Target architecture : ${target_cpu} |
| Target OS : ${target_os} |
| Target style : ${TARGET_STYLE} |
| Cross compiling : ${cross_compiling} |
| Build shared libraries : ${enable_shared} |
| Build static libraries : ${enable_static} |
| Build debug libraries : ${nl_cv_build_debug} |
| Build optimized libraries : ${nl_cv_build_optimized} |
| Build coverage libraries : ${nl_cv_build_coverage} |
| Build coverage reports : ${nl_cv_build_coverage_reports} |
| Lcov : ${LCOV:--} |
| Genhtml : ${GENHTML:--} |
| Build tests : ${nl_cv_build_tests} |
| NLFAULTINJECTION tests : ${with_tests} |
| Prefix : ${prefix} |
| Documentation support : ${nl_cv_build_docs} |
| Doxygen : ${DOXYGEN:--} |
| GraphViz dot : ${DOT:--} |
| C Preprocessor : ${CPP} |
| C Compiler : ${CC} |
| C++ Preprocessor : ${CXXCPP} |
| C++ Compiler : ${CXX} |
| Archiver : ${AR} |
| Archive Indexer : ${RANLIB} |
| Symbol Stripper : ${STRIP} |
| Object Copier : ${OBJCOPY} |
| C Preprocessor flags : ${CPPFLAGS:--} |
| C Compile flags : ${CFLAGS:--} |
| C++ Compile flags : ${CXXFLAGS:--} |
| Link flags : ${LDFLAGS:--} |
| Link libraries : ${LIBS} |
| Pretty : ${PRETTY:--} |
| Pretty args : ${PRETTY_ARGS:--} |
| Pretty check : ${PRETTY_CHECK:--} |
| Pretty check args : ${PRETTY_CHECK_ARGS:--} |
| ]) |