diff options
Diffstat (limited to 'unit/atf-src/m4')
-rw-r--r-- | unit/atf-src/m4/compiler-flags.m4 | 211 | ||||
-rw-r--r-- | unit/atf-src/m4/cxx-std-funcs.m4 | 2 | ||||
-rw-r--r-- | unit/atf-src/m4/developer-mode.m4 | 184 | ||||
-rw-r--r-- | unit/atf-src/m4/module-application.m4 | 42 | ||||
-rw-r--r-- | unit/atf-src/m4/module-defs.m4 | 75 | ||||
-rw-r--r-- | unit/atf-src/m4/module-env.m4 | 2 | ||||
-rw-r--r-- | unit/atf-src/m4/module-fs.m4 | 19 | ||||
-rw-r--r-- | unit/atf-src/m4/module-sanity.m4 | 2 | ||||
-rw-r--r-- | unit/atf-src/m4/module-signals.m4 | 26 |
9 files changed, 343 insertions, 220 deletions
diff --git a/unit/atf-src/m4/compiler-flags.m4 b/unit/atf-src/m4/compiler-flags.m4 index c9bf4d1a..480e5c74 100644 --- a/unit/atf-src/m4/compiler-flags.m4 +++ b/unit/atf-src/m4/compiler-flags.m4 @@ -1,110 +1,159 @@ -dnl -dnl Automated Testing Framework (atf) -dnl -dnl Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. +dnl Copyright 2010 Google Inc. dnl All rights reserved. dnl dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions -dnl are met: -dnl 1. Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl 2. Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. -dnl -dnl THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND -dnl CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, -dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -dnl IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY -dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -dnl GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -dnl IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +dnl modification, are permitted provided that the following conditions are +dnl met: dnl +dnl * Redistributions of source code must retain the above copyright +dnl notice, this list of conditions and the following disclaimer. +dnl * Redistributions in binary form must reproduce the above copyright +dnl notice, this list of conditions and the following disclaimer in the +dnl documentation and/or other materials provided with the distribution. +dnl * Neither the name of Google Inc. nor the names of its contributors +dnl may be used to endorse or promote products derived from this software +dnl without specific prior written permission. +dnl +dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +dnl \file compiler-flags.m4 +dnl +dnl Macros to check for the existence of compiler flags. The macros in this +dnl file support both C and C++. +dnl +dnl Be aware that, in order to detect a flag accurately, we may need to enable +dnl strict warning checking in the compiler (i.e. enable -Werror). Some +dnl compilers, e.g. Clang, report unknown -W flags as warnings unless -Werror is +dnl selected. This fact would confuse the flag checks below because we would +dnl conclude that a flag is valid while in reality it is not. To resolve this, +dnl the macros below will pass -Werror to the compiler along with any other flag +dnl being checked. -dnl ----------------------------------------------------------------------- -dnl Check for C/C++ compiler flags -dnl ----------------------------------------------------------------------- +dnl Checks for a compiler flag and sets a result variable. +dnl +dnl This is an auxiliary macro for the implementation of _KYUA_FLAG. dnl -dnl ATF_CC_FLAG(flag_name, accum_var) -dnl -dnl Checks whether the C compiler supports the flag 'flag_name' and, if -dnl found, appends it to the variable 'accum_var'. -dnl -AC_DEFUN([ATF_CC_FLAG], [ - AC_LANG_PUSH(C) - AC_MSG_CHECKING(whether ${CC} supports $1) - saved_cflags="${CFLAGS}" - valid_cflag=no - CFLAGS="${CFLAGS} $1" - AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])], - AC_MSG_RESULT(yes) - valid_cflag=yes, - AC_MSG_RESULT(no)) - CFLAGS="${saved_cflags}" - AC_LANG_POP() +dnl \param 1 The shell variable containing the compiler name. Used for +dnl reporting purposes only. C or CXX. +dnl \param 2 The shell variable containing the flags for the compiler. +dnl CFLAGS or CXXFLAGS. +dnl \param 3 The name of the compiler flag to check for. +dnl \param 4 The shell variable to set with the result of the test. Will +dnl be set to 'yes' if the flag is valid, 'no' otherwise. +dnl \param 5 Additional, optional flags to pass to the C compiler while +dnl looking for the flag in $3. We use this here to pass -Werror to the +dnl flag checks (unless we are checking for -Werror already). +AC_DEFUN([_KYUA_FLAG_AUX], [ + if test x"${$4-unset}" = xunset; then + AC_MSG_CHECKING(whether ${$1} supports $3) + saved_flags="${$2}" + $4=no + $2="${$2} $5 $3" + AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])], + AC_MSG_RESULT(yes) + $4=yes, + AC_MSG_RESULT(no)) + $2="${saved_flags}" + fi +]) - if test ${valid_cflag} = yes; then - $2="${$2} $1" + +dnl Checks for a compiler flag and appends it to a result variable. +dnl +dnl \param 1 The shell variable containing the compiler name. Used for +dnl reporting purposes only. CC or CXX. +dnl \param 2 The shell variable containing the flags for the compiler. +dnl CFLAGS or CXXFLAGS. +dnl \param 3 The name of the compiler flag to check for. +dnl \param 4 The shell variable to which to append $3 if the flag is valid. +AC_DEFUN([_KYUA_FLAG], [ + _KYUA_FLAG_AUX([$1], [$2], [-Werror], [kyua_$1_has_werror]) + if test "$3" = "-Werror"; then + found=${kyua_$1_has_werror} + else + found=unset + if test ${kyua_$1_has_werror} = yes; then + _KYUA_FLAG_AUX([$1], [$2], [$3], [found], [-Werror]) + else + _KYUA_FLAG_AUX([$1], [$2], [$3], [found], []) + fi fi + if test ${found} = yes; then + $4="${$4} $3" + fi +]) + + +dnl Checks for a C compiler flag and appends it to a variable. +dnl +dnl \pre The current language is C. +dnl +dnl \param 1 The name of the compiler flag to check for. +dnl \param 2 The shell variable to which to append $1 if the flag is valid. +AC_DEFUN([KYUA_CC_FLAG], [ + AC_LANG_ASSERT([C]) + _KYUA_FLAG([CC], [CFLAGS], [$1], [$2]) +]) + + +dnl Checks for a C++ compiler flag and appends it to a variable. +dnl +dnl \pre The current language is C++. +dnl +dnl \param 1 The name of the compiler flag to check for. +dnl \param 2 The shell variable to which to append $1 if the flag is valid. +AC_DEFUN([KYUA_CXX_FLAG], [ + AC_LANG_ASSERT([C++]) + _KYUA_FLAG([CXX], [CXXFLAGS], [$1], [$2]) ]) + +dnl Checks for a set of C compiler flags and appends them to CFLAGS. dnl -dnl ATF_CC_FLAGS(flag_names, accum_var) -dnl Checks whether the C compiler supports the flags 'flag_names', one by -dnl one, and appends the valid ones to 'accum_var'. +dnl The checks are performed independently and only when all the checks are +dnl done, the output variable is modified. dnl -AC_DEFUN([ATF_CC_FLAGS], [ +dnl \param 1 Whitespace-separated list of C flags to check. +AC_DEFUN([KYUA_CC_FLAGS], [ + AC_LANG_PUSH([C]) valid_cflags= for f in $1; do - ATF_CC_FLAG(${f}, valid_cflags) + KYUA_CC_FLAG(${f}, valid_cflags) done if test -n "${valid_cflags}"; then - $2="${$2} ${valid_cflags}" + CFLAGS="${CFLAGS} ${valid_cflags}" fi + AC_LANG_POP([C]) ]) -dnl -dnl ATF_CXX_FLAG(flag_name, accum_var) -dnl -dnl Checks whether the C++ compiler supports the flag 'flag_name' and, if -dnl found, appends it to the variable 'accum_var'. -dnl -AC_DEFUN([ATF_CXX_FLAG], [ - AC_LANG_PUSH(C++) - AC_MSG_CHECKING(whether ${CXX} supports $1) - saved_cxxflags="${CXXFLAGS}" - valid_cxxflag=no - CXXFLAGS="${CXXFLAGS} $1" - AC_LINK_IFELSE([AC_LANG_PROGRAM([], [return 0;])], - AC_MSG_RESULT(yes) - valid_cxxflag=yes, - AC_MSG_RESULT(no)) - CXXFLAGS="${saved_cxxflags}" - AC_LANG_POP() - - if test ${valid_cxxflag} = yes; then - $2="${$2} $1" - fi -]) +dnl Checks for a set of C++ compiler flags and appends them to CXXFLAGS. +dnl +dnl The checks are performed independently and only when all the checks are +dnl done, the output variable is modified. dnl -dnl ATF_CXX_FLAGS(flag_names, accum_var) -dnl Checks whether the C++ compiler supports the flags 'flag_names', one by -dnl one, and appends the valid ones to 'accum_var'. +dnl \pre The current language is C++. dnl -AC_DEFUN([ATF_CXX_FLAGS], [ +dnl \param 1 Whitespace-separated list of C flags to check. +AC_DEFUN([KYUA_CXX_FLAGS], [ + AC_LANG_PUSH([C++]) valid_cxxflags= for f in $1; do - ATF_CXX_FLAG(${f}, valid_cxxflags) + KYUA_CXX_FLAG(${f}, valid_cxxflags) done if test -n "${valid_cxxflags}"; then - $2="${$2} ${valid_cxxflags}" + CXXFLAGS="${CXXFLAGS} ${valid_cxxflags}" fi + AC_LANG_POP([C++]) ]) diff --git a/unit/atf-src/m4/cxx-std-funcs.m4 b/unit/atf-src/m4/cxx-std-funcs.m4 index be949c8d..d2266b4d 100644 --- a/unit/atf-src/m4/cxx-std-funcs.m4 +++ b/unit/atf-src/m4/cxx-std-funcs.m4 @@ -1,7 +1,7 @@ dnl dnl Automated Testing Framework (atf) dnl -dnl Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. +dnl Copyright (c) 2007 The NetBSD Foundation, Inc. dnl All rights reserved. dnl dnl Redistribution and use in source and binary forms, with or without diff --git a/unit/atf-src/m4/developer-mode.m4 b/unit/atf-src/m4/developer-mode.m4 index d6fcd20e..9c9118bf 100644 --- a/unit/atf-src/m4/developer-mode.m4 +++ b/unit/atf-src/m4/developer-mode.m4 @@ -1,110 +1,112 @@ -dnl -dnl Automated Testing Framework (atf) -dnl -dnl Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc. +dnl Copyright 2010 Google Inc. dnl All rights reserved. dnl dnl Redistribution and use in source and binary forms, with or without -dnl modification, are permitted provided that the following conditions -dnl are met: -dnl 1. Redistributions of source code must retain the above copyright -dnl notice, this list of conditions and the following disclaimer. -dnl 2. Redistributions in binary form must reproduce the above copyright -dnl notice, this list of conditions and the following disclaimer in the -dnl documentation and/or other materials provided with the distribution. +dnl modification, are permitted provided that the following conditions are +dnl met: dnl -dnl THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND -dnl CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, -dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -dnl MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. -dnl IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS BE LIABLE FOR ANY -dnl DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -dnl DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE -dnl GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -dnl INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER -dnl IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN -dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +dnl * Redistributions of source code must retain the above copyright +dnl notice, this list of conditions and the following disclaimer. +dnl * Redistributions in binary form must reproduce the above copyright +dnl notice, this list of conditions and the following disclaimer in the +dnl documentation and/or other materials provided with the distribution. +dnl * Neither the name of Google Inc. nor the names of its contributors +dnl may be used to endorse or promote products derived from this software +dnl without specific prior written permission. dnl +dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +dnl "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +dnl OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +dnl SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +dnl LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +dnl DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +dnl THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +dnl (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +dnl OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -dnl ----------------------------------------------------------------------- -dnl Set up the developer mode -dnl ----------------------------------------------------------------------- - +dnl \file developer-mode.m4 dnl -dnl ATF_DEVELOPER_MODE +dnl "Developer mode" is a mode in which the build system reports any +dnl build-time warnings as fatal errors. This helps in minimizing the +dnl amount of trivial coding problems introduced in the code. +dnl Unfortunately, this is not bullet-proof due to the wide variety of +dnl compilers available and their different warning diagnostics. dnl -dnl Adds a --enable-developer flag to the configure script and, when given, -dnl checks for and enables several flags useful during development. +dnl When developer mode support is added to a package, the compilation will +dnl gain a bunch of extra warning diagnostics. These will NOT be enforced +dnl unless developer mode is enabled. dnl -AC_DEFUN([ATF_DEVELOPER_MODE], [ - AC_ARG_ENABLE(developer, - AS_HELP_STRING(--enable-developer, - [enable developer features]),, - [case ${PACKAGE_VERSION} in - 0.*|*99*|*alpha*|*beta*) - enable_developer=yes - ;; - *) - enable_developer=no - ;; - esac]) +dnl Developer mode is enabled when the user requests it through the +dnl configure command line, or when building from the repository. The +dnl latter is to minimize the risk of committing new code with warnings +dnl into the tree. - if test ${enable_developer} = yes; then - try_werror=yes - try_c_cxx_flags="-g \ - -Wall \ - -Wcast-qual \ - -Wextra \ - -Wno-unused-parameter \ - -Wpointer-arith \ - -Wredundant-decls \ - -Wreturn-type \ - -Wshadow \ - -Wsign-compare \ - -Wswitch \ - -Wwrite-strings" +dnl Adds "developer mode" support to the package. +dnl +dnl This macro performs the actual definition of the --enable-developer +dnl flag and implements all of its logic. See the file-level comment for +dnl details as to what this implies. +AC_DEFUN([KYUA_DEVELOPER_MODE], [ + m4_foreach([language], [$1], [m4_set_add([languages], language)]) + + AC_ARG_ENABLE( + [developer], + AS_HELP_STRING([--enable-developer], [enable developer features]),, + [if test -d ${srcdir}/.git; then + AC_MSG_NOTICE([building from HEAD; developer mode autoenabled]) + enable_developer=yes + else + enable_developer=no + fi]) - try_c_flags="-Wmissing-prototypes \ - -Wno-traditional \ - -Wstrict-prototypes" + # + # The following warning flags should also be enabled but cannot be. + # Reasons given below. + # + # -Wold-style-cast: Raises errors when using TIOCGWINSZ, at least under + # Mac OS X. This is due to the way _IOR is defined. + # - try_cxx_flags="-Wabi \ - -Wctor-dtor-privacy \ - -Wno-deprecated \ - -Wno-non-template-friend \ - -Wno-pmf-conversions \ - -Wnon-virtual-dtor \ - -Woverloaded-virtual \ - -Wreorder \ - -Wsign-promo \ - -Wsynth" + try_c_cxx_flags="-D_FORTIFY_SOURCE=2 \ + -Wall \ + -Wcast-qual \ + -Wextra \ + -Wpointer-arith \ + -Wredundant-decls \ + -Wreturn-type \ + -Wshadow \ + -Wsign-compare \ + -Wswitch \ + -Wwrite-strings" - # - # The following flags should also be enabled but cannot be. Reasons - # given below. - # - # -Wold-style-cast: Raises errors when using TIOCGWINSZ, at least under - # Mac OS X. This is due to the way _IOR is defined. - # + try_c_flags="-Wmissing-prototypes \ + -Wno-traditional \ + -Wstrict-prototypes" + + try_cxx_flags="-Wabi \ + -Wctor-dtor-privacy \ + -Wno-deprecated \ + -Wno-non-template-friend \ + -Wno-pmf-conversions \ + -Wnon-virtual-dtor \ + -Woverloaded-virtual \ + -Wreorder \ + -Wsign-promo \ + -Wsynth" + + if test ${enable_developer} = yes; then + try_werror=yes + try_c_cxx_flags="${try_c_cxx_flags} -g -Werror" else try_werror=no - try_c_cxx_flags="-DNDEBUG" - try_c_flags= - try_cxx_flags= - fi - try_c_cxx_flags="${try_c_cxx_flags} -D_FORTIFY_SOURCE=2" - - # Try and set -Werror first so that tests for other flags are accurate. - # Otherwise, compilers such as clang will report the flags as a warning and - # we will conclude they are supported... but when they are combined with - # -Werror they cause build failures. - if test ${try_werror} = yes; then - ATF_CC_FLAGS(-Werror, CFLAGS) - ATF_CXX_FLAGS(-Werror, CXXFLAGS) + try_c_cxx_flags="${try_c_cxx_flags} -DNDEBUG" fi - ATF_CC_FLAGS(${try_c_cxx_flags} ${try_c_flags}, CFLAGS) - ATF_CXX_FLAGS(${try_c_cxx_flags} ${try_cxx_flags}, CXXFLAGS) + m4_set_contains([languages], [C], + [KYUA_CC_FLAGS(${try_c_cxx_flags} ${try_c_flags})]) + m4_set_contains([languages], [C++], + [KYUA_CXX_FLAGS(${try_c_cxx_flags} ${try_cxx_flags})]) ]) diff --git a/unit/atf-src/m4/module-application.m4 b/unit/atf-src/m4/module-application.m4 index cdcbc77d..709c8493 100644 --- a/unit/atf-src/m4/module-application.m4 +++ b/unit/atf-src/m4/module-application.m4 @@ -1,7 +1,7 @@ dnl dnl Automated Testing Framework (atf) dnl -dnl Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. +dnl Copyright (c) 2007 The NetBSD Foundation, Inc. dnl All rights reserved. dnl dnl Redistribution and use in source and binary forms, with or without @@ -30,9 +30,11 @@ dnl AC_DEFUN([ATF_MODULE_APPLICATION], [ ATF_CHECK_STD_VSNPRINTF - AC_LANG_PUSH([C]) - AC_MSG_CHECKING(whether getopt allows a + sign for POSIX behavior) - AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdlib.h> + AC_CACHE_CHECK( + [whether getopt allows a + sign for POSIX behavior], + [kyua_cv_getopt_plus], [ + AC_LANG_PUSH([C]) + AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <stdlib.h> #include <string.h> #include <unistd.h>], [ int argc = 4; @@ -64,25 +66,29 @@ AC_DEFUN([ATF_MODULE_APPLICATION], [ return (seen_a && !seen_plus) ? EXIT_SUCCESS : EXIT_FAILURE; ])], - [getopt_allows_plus=yes - AC_DEFINE([HAVE_GNU_GETOPT], [1], - [Define to 1 if getopt allows a + sign for POSIX behavior])], - [getopt_allows_plus=no]) - AC_MSG_RESULT(${getopt_allows_plus}) - AC_LANG_POP([C]) + [kyua_cv_getopt_plus=yes], + [kyua_cv_getopt_plus=no]) + AC_LANG_POP([C]) + ]) + if test x"${kyua_cv_getopt_plus}" = xyes; then + AC_DEFINE([HAVE_GNU_GETOPT], [1], + [Define to 1 if getopt allows a + sign for POSIX behavior]) + fi - AC_LANG_PUSH([C]) - AC_MSG_CHECKING(whether getopt has optreset) - AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdlib.h> + AC_CACHE_CHECK( + [whether getopt has optreset], + [kyua_cv_getopt_optreset], [ + AC_LANG_PUSH([C]) + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <stdlib.h> #include <unistd.h>], [ optreset = 1; return EXIT_SUCCESS; ])], - [getopt_has_optreset=yes], - [getopt_has_optreset=no]) - if test x"${getopt_has_optreset}" = yes; then + [kyua_cv_getopt_optreset=yes], + [kyua_cv_getopt_optreset=no]) + AC_LANG_POP([C]) + ]) + if test x"${kyua_cv_getopt_optreset}" = xyes; then AC_DEFINE([HAVE_OPTRESET], [1], [Define to 1 if getopt has optreset]) fi - AC_MSG_RESULT(${getopt_has_optreset}) - AC_LANG_POP([C]) ]) diff --git a/unit/atf-src/m4/module-defs.m4 b/unit/atf-src/m4/module-defs.m4 index 6803cbcf..eb08eb62 100644 --- a/unit/atf-src/m4/module-defs.m4 +++ b/unit/atf-src/m4/module-defs.m4 @@ -1,7 +1,7 @@ dnl dnl Automated Testing Framework (atf) dnl -dnl Copyright (c) 2008, 2010 The NetBSD Foundation, Inc. +dnl Copyright (c) 2008 The NetBSD Foundation, Inc. dnl All rights reserved. dnl dnl Redistribution and use in source and binary forms, with or without @@ -27,25 +27,86 @@ dnl OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. dnl -AC_DEFUN([ATF_MODULE_DEFS], [ +AC_DEFUN([ATF_ATTRIBUTE_FORMAT_PRINTF], [ + AC_MSG_CHECKING( + [whether __attribute__((__format__(__printf__, a, b))) is supported]) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ +#include <stdarg.h> +#include <stdio.h> + +static void test_printf(const char *, ...) + __attribute__((__format__(__printf__, 1, 2))); + +static void +test_printf(const char *format, ...) +{ + va_list ap; + + va_start(ap, format); + vprintf(format, ap); + va_end(ap); +}], [ + test_printf("foo %s", "bar"); + return 0; +])], + [AC_MSG_RESULT(yes) + value="__attribute__((__format__(__printf__, a, b)))"], + [AC_MSG_RESULT(no) + value=""] + ) + AC_SUBST([ATTRIBUTE_FORMAT_PRINTF], [${value}]) +]) + +AC_DEFUN([ATF_ATTRIBUTE_NORETURN], [ dnl XXX This check is overly simple and should be fixed. For example, dnl Sun's cc does support the noreturn attribute but CC (the C++ dnl compiler) does not. And in that case, CC just raises a warning dnl during compilation, not an error, which later breaks the dnl atf-c++/t_pkg_config:cxx_build check. - AC_MSG_CHECKING(whether __attribute__((noreturn)) is supported) - AC_RUN_IFELSE( - [AC_LANG_PROGRAM([], [ + AC_CACHE_CHECK( + [whether __attribute__((__noreturn__)) is supported], + [kyua_cv_attribute_noreturn], [ + AC_RUN_IFELSE( + [AC_LANG_PROGRAM([], [ #if ((__GNUC__ == 2 && __GNUC_MINOR__ >= 5) || __GNUC__ > 2) return 0; #else return 1; #endif ])], + [kyua_cv_attribute_noreturn=yes], + [kyua_cv_attribute_noreturn=no]) + ]) + if test x"${kyua_cv_attribute_noreturn}" = xyes; then + value="__attribute__((__noreturn__))" + else + value="" + fi + AC_SUBST([ATTRIBUTE_NORETURN], [${value}]) +]) + +AC_DEFUN([ATF_ATTRIBUTE_UNUSED], [ + AC_MSG_CHECKING(whether __attribute__((__unused__)) is supported) + AC_COMPILE_IFELSE( + [AC_LANG_PROGRAM([ +static void +function(int a __attribute__((__unused__))) +{ +}], [ + function(3); + return 0; +])], [AC_MSG_RESULT(yes) - value="__attribute__((noreturn))"], + value="__attribute__((__unused__))"], [AC_MSG_RESULT(no) value=""] ) - AC_SUBST([ATTRIBUTE_NORETURN], [${value}]) + AC_SUBST([ATTRIBUTE_UNUSED], [${value}]) +]) + +AC_DEFUN([ATF_MODULE_DEFS], [ + ATF_ATTRIBUTE_FORMAT_PRINTF + ATF_ATTRIBUTE_NORETURN + ATF_ATTRIBUTE_UNUSED ]) diff --git a/unit/atf-src/m4/module-env.m4 b/unit/atf-src/m4/module-env.m4 index cd7b4702..8080e1c3 100644 --- a/unit/atf-src/m4/module-env.m4 +++ b/unit/atf-src/m4/module-env.m4 @@ -1,7 +1,7 @@ dnl dnl Automated Testing Framework (atf) dnl -dnl Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. +dnl Copyright (c) 2007 The NetBSD Foundation, Inc. dnl All rights reserved. dnl dnl Redistribution and use in source and binary forms, with or without diff --git a/unit/atf-src/m4/module-fs.m4 b/unit/atf-src/m4/module-fs.m4 index bb0442c6..7019a664 100644 --- a/unit/atf-src/m4/module-fs.m4 +++ b/unit/atf-src/m4/module-fs.m4 @@ -1,7 +1,7 @@ dnl dnl Automated Testing Framework (atf) dnl -dnl Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. +dnl Copyright (c) 2007 The NetBSD Foundation, Inc. dnl All rights reserved. dnl dnl Redistribution and use in source and binary forms, with or without @@ -50,17 +50,22 @@ AC_DEFUN([ATF_MODULE_FS], [ [Define to 1 if dirname takes a constant pointer]), AC_MSG_RESULT(no)) - AC_MSG_CHECKING(whether getcwd(NULL, 0) works) - AC_RUN_IFELSE( - [AC_LANG_PROGRAM([#include <stdlib.h> + AC_CACHE_CHECK( + [whether getcwd(NULL, 0) works], + [kyua_cv_getcwd_works], [ + AC_RUN_IFELSE( + [AC_LANG_PROGRAM([#include <stdlib.h> #include <unistd.h>], [ char *cwd = getcwd(NULL, 0); return (cwd != NULL) ? EXIT_SUCCESS : EXIT_FAILURE; ])], - AC_MSG_RESULT(yes) + [kyua_cv_getcwd_works=yes], + [kyua_cv_getcwd_works=no]) + ]) + if test x"${kyua_cv_getcwd_works}" = xyes; then AC_DEFINE([HAVE_GETCWD_DYN], [1], - [Define to 1 if getcwd(NULL, 0) works]), - AC_MSG_RESULT(no)) + [Define to 1 if getcwd(NULL, 0) works]) + fi AC_CHECK_FUNCS([unmount]) ]) diff --git a/unit/atf-src/m4/module-sanity.m4 b/unit/atf-src/m4/module-sanity.m4 index 369c921b..9d146c1c 100644 --- a/unit/atf-src/m4/module-sanity.m4 +++ b/unit/atf-src/m4/module-sanity.m4 @@ -1,7 +1,7 @@ dnl dnl Automated Testing Framework (atf) dnl -dnl Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. +dnl Copyright (c) 2007 The NetBSD Foundation, Inc. dnl All rights reserved. dnl dnl Redistribution and use in source and binary forms, with or without diff --git a/unit/atf-src/m4/module-signals.m4 b/unit/atf-src/m4/module-signals.m4 index 5f0049c0..6580eb6e 100644 --- a/unit/atf-src/m4/module-signals.m4 +++ b/unit/atf-src/m4/module-signals.m4 @@ -28,8 +28,10 @@ dnl IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. dnl AC_DEFUN([ATF_MODULE_SIGNALS], [ - AC_MSG_CHECKING(for the last valid signal) - AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <err.h> + AC_CACHE_CHECK( + [for the last valid signal], + [kyua_cv_signal_lastno], [ + AC_RUN_IFELSE([AC_LANG_PROGRAM([#include <err.h> #include <errno.h> #include <signal.h> #include <stdio.h> @@ -71,16 +73,14 @@ AC_DEFUN([ATF_MODULE_SIGNALS], [ return EXIT_SUCCESS; ])], - [if test ! -f conftest.cnt; then - last_signo=15 - AC_MSG_RESULT(failed; assuming ${last_signo}) - else - last_signo=$(cat conftest.cnt) - rm -f conftest.cnt - AC_MSG_RESULT(${last_signo}) - fi], - [last_signo=15 - AC_MSG_RESULT(failed; assuming ${last_signo})]) - AC_DEFINE_UNQUOTED([LAST_SIGNO], [${last_signo}], + [if test ! -f conftest.cnt; then + kyua_cv_signal_lastno=15 + else + kyua_cv_signal_lastno=$(cat conftest.cnt) + rm -f conftest.cnt + fi], + [kyua_cv_signal_lastno=15]) + ]) + AC_DEFINE_UNQUOTED([LAST_SIGNO], [${kyua_cv_signal_lastno}], [Define to the last valid signal number]) ]) |