autoupdate
[gnulib.git] / gnulib-tool
index 84ea7a0..d480f1e 100755 (executable)
@@ -2781,7 +2781,11 @@ func_emit_lib_Makefile_am ()
   done
   if test -z "$makefile_name"; then
     echo
-    echo "AM_CPPFLAGS ="
+    if $for_test; then
+      echo "AM_CPPFLAGS = -DGNULIB_STRICT_CHECKING=1"
+    else
+      echo "AM_CPPFLAGS ="
+    fi
     echo "AM_CFLAGS ="
   fi
   echo
@@ -2976,11 +2980,20 @@ func_emit_tests_Makefile_am ()
         } > "$tmp"/amsnippet
         # Skip the contents if it's entirely empty.
         if grep '[^     ]' "$tmp"/amsnippet > /dev/null ; then
-          echo "## begin gnulib module $module"
-          echo
-          cat "$tmp"/amsnippet
-          echo "## end   gnulib module $module"
-          echo
+          # Mention long-running tests at the end.
+          ofd=3
+          for word in `func_get_status "$module"`; do
+            if test "$word" = 'longrunning-test'; then
+              ofd=4
+              break
+            fi
+          done
+          { echo "## begin gnulib module $module"
+            echo
+            cat "$tmp"/amsnippet
+            echo "## end   gnulib module $module"
+            echo
+          } >&$ofd
         fi
         rm -f "$tmp"/amsnippet
         # Test whether there are some source files in subdirectories.
@@ -2994,7 +3007,7 @@ func_emit_tests_Makefile_am ()
         done
       fi
     done
-  } > "$tmp"/allsnippets
+  } 3> "$tmp"/main_snippets 4> "$tmp"/longrunning_snippets
   # Generate dependencies here, since it eases the debugging of test failures.
   # If there are source files in subdirectories, prevent collision of the
   # object files (example: hash.c and libxml/hash.c).
@@ -3011,7 +3024,7 @@ func_emit_tests_Makefile_am ()
   # Nothing is being added to SUBDIRS; nevertheless the existence of this
   # variable is needed to avoid an error from automake:
   #   "AM_GNU_GETTEXT used but SUBDIRS not defined"
-  echo "SUBDIRS ="
+  echo "SUBDIRS = ."
   echo "TESTS ="
   echo "XFAIL_TESTS ="
   echo "TESTS_ENVIRONMENT ="
@@ -3030,7 +3043,7 @@ func_emit_tests_Makefile_am ()
   fi
   # Automake versions < 1.9b create an empty pkgdatadir at installation time
   # if you specify pkgdata_DATA to empty. This is a workaround.
-  if grep '^pkgdata_DATA *+=' "$tmp"/allsnippets > /dev/null; then
+  if grep '^pkgdata_DATA *+=' "$tmp"/main_snippets "$tmp"/longrunning_snippets > /dev/null; then
     echo "pkgdata_DATA ="
   fi
   echo "EXTRA_DIST ="
@@ -3057,6 +3070,9 @@ func_emit_tests_Makefile_am ()
   done
   echo
   echo "AM_CPPFLAGS = \\"
+  if $for_test; then
+    echo "  -DGNULIB_STRICT_CHECKING=1 \\"
+  fi
   if test -n "${witness_macro}"; then
     echo "  -D@${witness_macro}@=1 \\"
   fi
@@ -3096,7 +3112,7 @@ func_emit_tests_Makefile_am ()
   # srcdir is defined by autoconf and automake.
   echo "TESTS_ENVIRONMENT += EXEEXT='@EXEEXT@' srcdir='\$(srcdir)'"
   echo
-  cat "$tmp"/allsnippets \
+  cat "$tmp"/main_snippets "$tmp"/longrunning_snippets \
     | sed -e 's|\$(top_srcdir)/build-aux/|$(top_srcdir)/'"$auxdir"'/|g'
   echo "# Clean up after Solaris cc."
   echo "clean-local:"
@@ -3109,7 +3125,7 @@ func_emit_tests_Makefile_am ()
   echo "         fi; \\"
   echo "       done; \\"
   echo "       :"
-  rm -f "$tmp"/allsnippets
+  rm -f "$tmp"/main_snippets "$tmp"/longrunning_snippets
 }
 
 # func_emit_initmacro_start macro_prefix
@@ -5122,13 +5138,13 @@ func_create_testdir ()
   fi
   # Need to run configure and make once, to create built files that are to be
   # distributed (such as getdate.c).
+  sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
   # Extract the value of "CLEANFILES += ..." and "MOSTLYCLEANFILES += ...".
   cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
                  | sed -n -e 's,^CLEANFILES[    ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[         ]*+=\([^#]*\).*$,\1,p'`
   cleaned_files=`for file in $cleaned_files; do echo " $file "; done`
   # Extract the value of "BUILT_SOURCES += ...". Remove variable references
   # such $(FOO_H) because they don't refer to distributed files.
-  sed_remove_make_variables='s,[$]([A-Za-z0-9_]*),,g'
   built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$sourcebase/Makefile.am" \
                  | sed -n -e 's,^BUILT_SOURCES[         ]*+=\([^#]*\).*$,\1,p' \
                  | sed -e "$sed_remove_make_variables"`
@@ -5138,14 +5154,44 @@ func_create_testdir ()
                                  *) echo $file ;;
                                esac;
                              done`
-  if test -n "$distributed_built_sources"; then
+  tests_distributed_built_sources=
+  if test -n "$inctests"; then
+    # Likewise for built files in the $testsbase directory.
+    tests_cleaned_files=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
+                         | sed -n -e 's,^CLEANFILES[    ]*+=\([^#]*\).*$,\1,p' -e 's,^MOSTLYCLEANFILES[         ]*+=\([^#]*\).*$,\1,p'`
+    tests_cleaned_files=`for file in $tests_cleaned_files; do echo " $file "; done`
+    tests_built_sources=`sed -e "$sed_remove_backslash_newline" < "$testdir/$testsbase/Makefile.am" \
+                         | sed -n -e 's,^BUILT_SOURCES[         ]*+=\([^#]*\).*$,\1,p' \
+                         | sed -e "$sed_remove_make_variables"`
+    tests_distributed_built_sources=`for file in $tests_built_sources; do
+                                       case "$tests_cleaned_files" in
+                                         *" "$file" "*) ;;
+                                         *) echo $file ;;
+                                       esac;
+                                     done`
+  fi
+  if test -n "$distributed_built_sources" || test -n "$tests_distributed_built_sources"; then
     (cd "$testdir"
      ./configure || func_exit 1
-       cd "$sourcebase"
-       echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
-       $MAKE built_sources || func_exit 1
-       cd ..
-     $MAKE distclean || func_exit 1
+       if test -n "$distributed_built_sources"; then
+         cd "$sourcebase"
+         echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
+         $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
+               built_sources \
+           || func_exit 1
+         cd ..
+       fi
+       if test -n "$tests_distributed_built_sources"; then
+         cd "$testsbase"
+         echo 'built_sources: $(BUILT_SOURCES)' >> Makefile
+         $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
+               built_sources \
+           || func_exit 1
+         cd ..
+       fi
+     $MAKE AUTOCONF="${AUTOCONF}" AUTOHEADER="${AUTOHEADER}" ACLOCAL="${ACLOCAL}" AUTOMAKE="${AUTOMAKE}" AUTORECONF="${AUTORECONF}" AUTOPOINT="${AUTOPOINT}" LIBTOOLIZE="${LIBTOOLIZE}" \
+           distclean \
+       || func_exit 1
     ) || func_exit 1
   fi
 }