fi
done
echo
+ # Insert a '-Wno-error' option in the compilation commands emitted by
+ # Automake, between $(AM_CPPFLAGS) and before the reference to @CFLAGS@.
+ # Why?
+ # 1) Because parts of the Gnulib tests exercise corner cases (invalid
+ # arguments, endless recursions, etc.) that a compiler may warn about,
+ # even with just the normal '-Wall' option.
+ # 2) Because every package maintainer has their preferred set of warnings
+ # that they may want to enforce in the main source code of their package.
+ # But Gnulib tests are maintained in Gnulib and don't end up in binaries
+ # that that package installs; therefore it does not make sense for
+ # package maintainers to enforce the absence of warnings on these tests.
+ # Why before @CFLAGS@?
+ # - Because "the user is always right": If a user adds '-Werror' to their
+ # CFLAGS, they have asked for errors, they will get errors. But they have
+ # no right to complain about these errors, because Gnulib does not support
+ # '-Werror'.
+ echo "CFLAGS = @GL_CFLAG_ALLOW_WARNINGS@ @CFLAGS@"
+ echo "CXXFLAGS = @GL_CXXFLAG_ALLOW_WARNINGS@ @CXXFLAGS@"
+ echo
echo "AM_CPPFLAGS = \\"
if $for_test; then
echo " -DGNULIB_STRICT_CHECKING=1 \\"
echo
cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
| sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
+ # Arrange to print a message before compiling the files in this directory.
+ echo "all: all-notice"
+ echo "all-notice:"
+ echo " @echo '## ---------------------------------------------------- ##'"
+ echo " @echo '## ------------------- Gnulib tests ------------------- ##'"
+ echo " @echo '## You can ignore compiler warnings in this directory. ##'"
+ echo " @echo '## ---------------------------------------------------- ##'"
+ echo
echo "# Clean up after Solaris cc."
echo "clean-local:"
echo " rm -rf SunWS_cache"
rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
}
-# func_emit_initmacro_start macro_prefix
+# func_emit_initmacro_start macro_prefix gentests
# emits the first few statements of the gl_INIT macro to standard output.
# - macro_prefix prefix of gl_EARLY, gl_INIT macros to use
+# - gentests true if a tests Makefile.am is being generated,
+# false otherwise
# - module_indicator_prefix prefix of GNULIB_<modulename> variables to use
func_emit_initmacro_start ()
{
# Scope the GNULIB_<modulename> variables.
echo " m4_pushdef([GL_MODULE_INDICATOR_PREFIX], [${module_indicator_prefix}])"
echo " gl_COMMON"
+ if "$2"; then
+ echo " AC_REQUIRE([gl_CC_ALLOW_WARNINGS])"
+ echo " AC_REQUIRE([gl_CXX_ALLOW_WARNINGS])"
+ fi
}
# func_emit_initmacro_end macro_prefix
sed_replace_build_aux="$sed_noop"
fi
echo " gl_m4_base='$m4base'"
- func_emit_initmacro_start $macro_prefix
+ func_emit_initmacro_start $macro_prefix false
echo " gl_source_base='$sourcebase'"
if test -n "$witness_c_macro"; then
echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [$witness_c_macro])"
func_emit_initmacro_end $macro_prefix
echo " gltests_libdeps="
echo " gltests_ltlibdeps="
- func_emit_initmacro_start ${macro_prefix}tests
+ func_emit_initmacro_start ${macro_prefix}tests $gentests
echo " gl_source_base='$testsbase'"
# Define a tests witness macro that depends on the package.
# PACKAGE is defined by AM_INIT_AUTOMAKE, PACKAGE_TARNAME is defined by AC_INIT.
ba
}'
echo "gl_m4_base='../$m4base'"
- func_emit_initmacro_start $macro_prefix
+ func_emit_initmacro_start $macro_prefix true
# We don't have explicit ordering constraints between the various
# autoconf snippets. It's cleanest to put those of the library before
# those of the tests.
sed_replace_build_aux="$sed_noop"
fi
echo "gl_m4_base='$m4base'"
- func_emit_initmacro_start $macro_prefix
+ func_emit_initmacro_start $macro_prefix false
echo "gl_source_base='$sourcebase'"
if $single_configure; then
func_emit_autoconf_snippets "$main_modules" "$main_modules" func_verify_module true false false
if $single_configure; then
echo " gltests_libdeps="
echo " gltests_ltlibdeps="
- func_emit_initmacro_start ${macro_prefix}tests
+ func_emit_initmacro_start ${macro_prefix}tests true
echo " gl_source_base='$testsbase'"
# Define a tests witness macro.
echo " ${macro_prefix}tests_WITNESS=IN_GNULIB_TESTS"
-# gnulib-common.m4 serial 65
+# gnulib-common.m4 serial 66
dnl Copyright (C) 2007-2021 Free Software Foundation, Inc.
dnl This file is free software; the Free Software Foundation
dnl gives unlimited permission to copy and/or distribute it,
])
])
+# gl_CC_ALLOW_WARNINGS
+# sets and substitutes a variable GL_CFLAG_ALLOW_WARNINGS, to a $(CC) option
+# that reverts a preceding '-Werror' option, if available.
+# This is expected to be '-Wno-error' on gcc, clang (except clang/MSVC), xlclang
+# and empty otherwise.
+AC_DEFUN([gl_CC_ALLOW_WARNINGS],
+[
+ AC_REQUIRE([AC_PROG_CC])
+ AC_CACHE_CHECK([for C compiler option to allow warnings],
+ [gl_cv_cc_wallow],
+ [rm -f conftest*
+ echo 'int dummy;' > conftest.c
+ AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c 2>conftest1.err]) >/dev/null
+ AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Wno-error -c conftest.c 2>conftest2.err]) >/dev/null
+ dnl Test the number of error output lines, because AIX xlc accepts the
+ dnl option '-Wno-error', just to produce a warning
+ dnl "Option -Wno-error was incorrectly specified. The option will be ignored."
+ dnl afterwards.
+ if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then
+ gl_cv_cc_wallow='-Wno-error'
+ else
+ gl_cv_cc_wallow=none
+ fi
+ rm -f conftest*
+ ])
+ case "$gl_cv_cc_wallow" in
+ none) GL_CFLAG_ALLOW_WARNINGS='' ;;
+ *) GL_CFLAG_ALLOW_WARNINGS="$gl_cv_cc_wallow" ;;
+ esac
+ AC_SUBST([GL_CFLAG_ALLOW_WARNINGS])
+])
+
+# gl_CXX_ALLOW_WARNINGS
+# sets and substitutes a variable GL_CXXFLAG_ALLOW_WARNINGS, to a $(CC) option
+# that reverts a preceding '-Werror' option, if available.
+AC_DEFUN([gl_CXX_ALLOW_WARNINGS],
+[
+ dnl Requires AC_PROG_CXX or gl_PROG_ANSI_CXX.
+ if test -n "$CXX" && test "$CXX" != no; then
+ AC_CACHE_CHECK([for C++ compiler option to allow warnings],
+ [gl_cv_cxx_wallow],
+ [rm -f conftest*
+ echo 'int dummy;' > conftest.cc
+ AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -c conftest.cc 2>conftest1.err]) >/dev/null
+ AC_TRY_COMMAND([${CXX-c++} $CXXFLAGS $CPPFLAGS -Wno-error -c conftest.cc 2>conftest2.err]) >/dev/null
+ dnl Test the number of error output lines, because AIX xlC accepts the
+ dnl option '-Wno-error', just to produce a warning
+ dnl "Option -Wno-error was incorrectly specified. The option will be ignored."
+ dnl afterwards.
+ if test $? = 0 && test `wc -l < conftest1.err` = `wc -l < conftest2.err`; then
+ gl_cv_cxx_wallow='-Wno-error'
+ else
+ gl_cv_cxx_wallow=none
+ fi
+ rm -f conftest*
+ ])
+ case "$gl_cv_cxx_wallow" in
+ none) GL_CXXFLAG_ALLOW_WARNINGS='' ;;
+ *) GL_CXXFLAG_ALLOW_WARNINGS="$gl_cv_cxx_wallow" ;;
+ esac
+ else
+ GL_CXXFLAG_ALLOW_WARNINGS=''
+ fi
+ AC_SUBST([GL_CXXFLAG_ALLOW_WARNINGS])
+])
+
dnl Expands to some code for use in .c programs that, on native Windows, defines
dnl the Microsoft deprecated alias function names to the underscore-prefixed
dnl actual function names. With this macro, these function names are available