+2010-03-27 Bruno Haible <bruno@clisp.org>
+
+ Avoid side effects from tests-related modules on the compilation of lib.
+ * m4/gnulib-common.m4 (gl_MODULE_INDICATOR_CONDITION): New macro.
+ (gl_MODULE_INDICATOR_SET_VARIABLE): Use its expansion as a value.
+ * gnulib-tool (func_emit_tests_Makefile_am): Accept a witness_macro
+ parameter. Emit into AM_CPPFLAGS a definition of the designated C
+ macro.
+ (func_import): Define a witness macro. Assign it a value that depends
+ on the current package. Override gl_MODULE_INDICATOR_CONDITION for the
+ tests-related modules.
+ (func_create_testdir): Update func_emit_tests_Makefile_am invocation.
+ Reported by Jim Meyering.
+
2010-03-27 Bruno Haible <bruno@clisp.org>
Factorize common .m4 code.
echo "$files" | sed -n -e "s,^lib/,$sourcebase/,p"
}
-# func_emit_tests_Makefile_am
+# func_emit_tests_Makefile_am witness_macro
# emits the contents of tests makefile to standard output.
# Input:
# - local_gnulib_dir from --local-dir
# - uses_subdirs nonempty if object files in subdirs exist
func_emit_tests_Makefile_am ()
{
+ witness_macro="$1"
if test "$libtool" = true; then
libext=la
sed_eliminate_LDFLAGS="$sed_noop"
done
echo
echo "AM_CPPFLAGS = \\"
+ if test -n "${witness_macro}"; then
+ echo " -D@${witness_macro}@=1 \\"
+ fi
echo " -I. -I\$(srcdir) \\"
echo " -I${testsbase_inverse} -I\$(srcdir)/${testsbase_inverse} \\"
echo " -I${testsbase_inverse}/${sourcebase-lib} -I\$(srcdir)/${testsbase_inverse}/${sourcebase-lib}"
echo " gltests_ltlibdeps="
func_emit_initmacro_start ${macro_prefix}tests
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.
+ # See <http://lists.gnu.org/archive/html/automake/2009-05/msg00145.html>.
+ echo " ${macro_prefix}tests_WITNESS=IN_\`echo \"\${PACKAGE-\$PACKAGE_TARNAME}\" | LC_ALL=C tr 'a-z' 'A-Z' | LC_ALL=C sed -e 's/[^A-Z0-9_]/_/g'\`_GNULIB_TESTS"
+ echo " AC_SUBST([${macro_prefix}tests_WITNESS])"
+ echo " gl_module_indicator_condition=\$${macro_prefix}tests_WITNESS"
+ echo " m4_pushdef([gl_MODULE_INDICATOR_CONDITION], [\$gl_module_indicator_condition])"
for module in $testsrelated_modules; do
func_verify_module
if test -n "$module"; then
-e 's/gl_ltlibdeps/gltests_ltlibdeps/g'
fi
done
+ echo " m4_popdef([gl_MODULE_INDICATOR_CONDITION])"
func_emit_initmacro_end ${macro_prefix}tests
# _LIBDEPS and _LTLIBDEPS variables are not needed if this library is
# created using libtool, because libtool already handles the dependencies.
func_dest_tmpfilename $testsbase/$makefile_am
destfile="$testsbase/$makefile_am"
modules="$testsrelated_modules"
- func_emit_tests_Makefile_am > "$tmpfile"
+ func_emit_tests_Makefile_am "${macro_prefix}tests_WITNESS" > "$tmpfile"
if test -f "$destdir"/$testsbase/$makefile_am; then
if cmp "$destdir"/$testsbase/$makefile_am "$tmpfile" > /dev/null; then
rm -f "$tmpfile"
# Create $testsbase/Makefile.am.
use_libtests=false
destfile="$testsbase/Makefile.am"
- func_emit_tests_Makefile_am > "$testdir/$testsbase/Makefile.am"
+ func_emit_tests_Makefile_am "" > "$testdir/$testsbase/Makefile.am"
any_uses_subdirs="$any_uses_subdirs$uses_subdirs"
# Create $testsbase/configure.ac.
(echo "# Process this file with autoconf to produce a configure script."
-# gnulib-common.m4 serial 14
+# gnulib-common.m4 serial 15
dnl Copyright (C) 2007-2010 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_MODULE_INDICATOR_CONDITION
+# expands to a C preprocessor expression that evaluates to 1 or 0, depending
+# whether a gnulib module that has been requested shall be considered present
+# or not.
+AC_DEFUN([gl_MODULE_INDICATOR_CONDITION], [1])
+
# gl_MODULE_INDICATOR_SET_VARIABLE([modulename])
# sets the shell variable that indicates the presence of the given module to
# a C preprocessor expression that will evaluate to 1.
AC_DEFUN([gl_MODULE_INDICATOR_SET_VARIABLE],
[
- GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=1
+ GNULIB_[]m4_translit([$1],[abcdefghijklmnopqrstuvwxyz./-],[ABCDEFGHIJKLMNOPQRSTUVWXYZ___])=gl_MODULE_INDICATOR_CONDITION
])
# gl_MODULE_INDICATOR([modulename])