autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v2 15/17] build: no more recursion for 'tests' subdir


From: Stefano Lattarini
Subject: [PATCH v2 15/17] build: no more recursion for 'tests' subdir
Date: Mon, 6 May 2013 15:21:22 +0200

* Makefile.am (SUBDIRS): Drop 'tests'.  Adjust comments.
(DISTCLEANFILES, MAINTAINERCLEANFILES): Define to empty, to be
updated later.
(MAINTAINERCLEANFILES): Adjust later definition to use '+='
rather than '='.
($(srcdir)/tests/local.mk): Include this.
* configure.ac (AC_CONFIG_FILES): Drop 'tests/Makefile'.
* lib/freeze.mk ($(AUTOM4TE_CFG)): Drop now-redundant remake rule.
($(build_libdir)/m4sugar/version.m4): Likewise.
* tests/Makefile.am: Rename ...
* tests/local.mk: ... like this, and adjust (quite heavily).
* tests/mktests.sh: Adjust to generate output files and temporary
files in the tests subdirectory rather than in the current
directory.

Signed-off-by: Stefano Lattarini <address@hidden>
---
 Makefile.am                     |   8 +-
 configure.ac                    |   2 +-
 lib/freeze.mk                   |   8 +-
 tests/{Makefile.am => local.mk} | 163 ++++++++++++++++++++++------------------
 tests/mktests.sh                |  32 ++++----
 5 files changed, 115 insertions(+), 98 deletions(-)
 rename tests/{Makefile.am => local.mk} (62%)

diff --git a/Makefile.am b/Makefile.am
index 047d686..fe49c64 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,9 +15,8 @@
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-# autom4te uses autotest.m4f to generate 'testsuite', so build tests last.
 # Rules in man/ use scripts from both bin/ and tests/, so *it* goes last.
-SUBDIRS = . tests man
+SUBDIRS = . man
 
 ACLOCAL_AMFLAGS = -I m4
 
@@ -26,6 +25,8 @@ ACLOCAL_AMFLAGS = -I m4
 ETAGS_ARGS =
 MOSTLYCLEANFILES =
 CLEANFILES =
+DISTCLEANFILES =
+MAINTAINERCLEANFILES =
 
 EXTRA_DIST = ChangeLog.0 ChangeLog.1 ChangeLog.2 ChangeLog.3 \
             BUGS COPYINGv3 COPYING.EXCEPTION \
@@ -65,7 +66,7 @@ custom_MAKEINFOFLAGS = --no-headers --no-validate --no-split
 
 if MAKE_CASE_SENSITIVE
 pkgdata_DATA = $(srcdir)/INSTALL
-MAINTAINERCLEANFILES = $(srcdir)/INSTALL
+MAINTAINERCLEANFILES += $(srcdir)/INSTALL
 
 # Don't leave blank line at end of file.
 OMIT_TRAILING_EMPTY_LINES = '/^$$/H; /^$$/d; x; s/\n//p; s/\n*//; x'
@@ -131,6 +132,7 @@ distclean-local:
 include $(srcdir)/bin/local.mk
 include $(srcdir)/doc/local.mk
 include $(srcdir)/lib/local.mk
+include $(srcdir)/tests/local.mk
 
 # Perl coverage statistics.
 PERL_COVERAGE_DB = `pwd`/cover_db
diff --git a/configure.ac b/configure.ac
index 0fa61f4..7eda742 100644
--- a/configure.ac
+++ b/configure.ac
@@ -106,7 +106,7 @@ AC_SUBST([ac_cv_dir_trailing_space])
 
 # Initialize the test suite.
 AC_CONFIG_TESTDIR([tests])
-AC_CONFIG_FILES([tests/Makefile tests/atlocal])
+AC_CONFIG_FILES([tests/atlocal])
 AC_PATH_PROG([EXPR], [expr])
 
 
diff --git a/lib/freeze.mk b/lib/freeze.mk
index fffc20c..f5e3859 100644
--- a/lib/freeze.mk
+++ b/lib/freeze.mk
@@ -22,9 +22,7 @@
 
 SUFFIXES = .m4 .m4f
 
-AUTOM4TE_CFG = $(top_builddir)/lib/autom4te.cfg
-$(AUTOM4TE_CFG): $(top_srcdir)/lib/autom4te.in
-       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) lib/autom4te.cfg
+AUTOM4TE_CFG = lib/autom4te.cfg
 
 # Do not use AUTOM4TE here, since maint.mk (my-distcheck)
 # checks if we are independent of Autoconf by defining AUTOM4TE (and
@@ -60,10 +58,6 @@ build_libdir = $(top_builddir)/lib
 
 m4f_dependencies = $(top_builddir)/bin/autom4te $(AUTOM4TE_CFG)
 
-# For parallel builds.
-$(build_libdir)/m4sugar/version.m4:
-       cd $(build_libdir) && $(MAKE) $(AM_MAKEFLAGS) m4sugar/version.m4
-
 m4sugar_m4f_dependencies =                     \
        $(m4f_dependencies)                     \
        $(src_libdir)/m4sugar/m4sugar.m4        \
diff --git a/tests/Makefile.am b/tests/local.mk
similarity index 62%
rename from tests/Makefile.am
rename to tests/local.mk
index 1203427..0f26f51 100644
--- a/tests/Makefile.am
+++ b/tests/local.mk
@@ -19,24 +19,20 @@
 # only needs m4 to build them, and m4 is required to install Autoconf.
 # But if you are borrowing from this file for setting up autotest in your
 # project, remember to distribute both testsuite and package.m4.
-EXTRA_DIST = $(TESTSUITE_AT) local.at mktests.sh \
-            atlocal.in wrapper.as statesave.m4
+EXTRA_DIST += \
+  $(TESTSUITE_AT) \
+  tests/local.at \
+  tests/mktests.sh \
+  tests/atlocal.in \
+  tests/wrapper.as \
+  tests/statesave.m4
 
 # Running the uninstalled scripts.  Build them upon 'all', for the manpages.
 noinst_SCRIPTS = $(wrappers)
-DISTCLEANFILES = atconfig atlocal $(TESTSUITE)
-MAINTAINERCLEANFILES = Makefile.in
-
-# Import the dependencies on Autotest and M4sh.
-include ../lib/freeze.mk
-
-
-## ------------ ##
-## package.m4.  ##
-## ------------ ##
+DISTCLEANFILES += tests/atconfig tests/atlocal $(TESTSUITE)
 
 # The ':;' works around a redirected compound command bash exit status bug.
-package.m4: Makefile
+tests/package.m4: Makefile
        :;{ \
          echo '# Signature of the current package.' && \
          echo 'm4_define([AT_PACKAGE_NAME],      [$(PACKAGE_NAME)])' && \
@@ -54,22 +50,33 @@ package.m4: Makefile
 ## Wrappers.  ##
 ## ---------- ##
 
-wrappers = autoconf autoheader autom4te autoreconf autoscan autoupdate ifnames
-CLEANFILES = wrapper.in $(wrappers) package.m4
-
-wrapper.in: $(srcdir)/wrapper.as $(m4sh_m4f_dependencies)
-       $(MY_AUTOM4TE) --language=M4sh $(srcdir)/wrapper.as -o $@
-
-edit = sed \
-       -e 's|@address@hidden|$@|g' \
-       -e 's|@address@hidden|@abs_top_srcdir@|g' \
-       -e 's|@address@hidden|@abs_top_builddir@|g' \
+wrappers = \
+  tests/autoconf \
+  tests/autoheader \
+  tests/autom4te \
+  tests/autoreconf \
+  tests/autoscan \
+  tests/autoupdate \
+  tests/ifnames
+
+CLEANFILES += \
+  tests/package.m4 \
+  tests/wrapper.in \
+  $(wrappers)
+
+tests/wrapper.in: $(srcdir)/tests/wrapper.as $(m4sh_m4f_dependencies)
+       $(MY_AUTOM4TE) --language=M4sh $(srcdir)/tests/wrapper.as -o $@
+
+edit_wrapper = sed \
+       -e 's|@address@hidden|$(@F)|g' \
+       -e 's|@address@hidden|$(abs_top_srcdir)|g' \
+       -e 's|@address@hidden|$(abs_top_builddir)|g' \
        -e "s|@address@hidden|Generated from $$input.|g"
 
-$(wrappers): wrapper.in
+$(wrappers): tests/wrapper.in
        rm -f $@ address@hidden
-       input=wrapper.in; \
-       $(edit) wrapper.in >address@hidden
+       input=tests/wrapper.in \
+         && $(edit_wrapper) tests/wrapper.in >address@hidden
        chmod +x address@hidden
        chmod a-w address@hidden
        mv -f address@hidden $@
@@ -81,47 +88,55 @@ $(wrappers): wrapper.in
 ## ------------ ##
 
 TESTSUITE_GENERATED_AT = \
-       $(srcdir)/aclang.at \
-       $(srcdir)/acc.at \
-       $(srcdir)/acfortran.at \
-       $(srcdir)/acgo.at \
-       $(srcdir)/acgeneral.at \
-       $(srcdir)/acstatus.at \
-       $(srcdir)/acautoheader.at \
-       $(srcdir)/acautoupdate.at \
-       $(srcdir)/acspecific.at \
-       $(srcdir)/acfunctions.at \
-       $(srcdir)/acheaders.at \
-       $(srcdir)/actypes.at \
-       $(srcdir)/aclibs.at \
-       $(srcdir)/acprograms.at
+  $(srcdir)/tests/aclang.at \
+  $(srcdir)/tests/acc.at \
+  $(srcdir)/tests/acfortran.at \
+  $(srcdir)/tests/acgo.at \
+  $(srcdir)/tests/acgeneral.at \
+  $(srcdir)/tests/acstatus.at \
+  $(srcdir)/tests/acautoheader.at \
+  $(srcdir)/tests/acautoupdate.at \
+  $(srcdir)/tests/acspecific.at \
+  $(srcdir)/tests/acfunctions.at \
+  $(srcdir)/tests/acheaders.at \
+  $(srcdir)/tests/actypes.at \
+  $(srcdir)/tests/aclibs.at \
+  $(srcdir)/tests/acprograms.at
 
 TESTSUITE_HAND_AT = \
-       suite.at \
-       m4sugar.at m4sh.at autotest.at \
-       base.at tools.at torture.at \
-       compile.at c.at erlang.at fortran.at go.at \
-       semantics.at \
-       autoscan.at \
-       foreign.at
+  tests/suite.at \
+  tests/m4sugar.at \
+  tests/m4sh.at \
+  tests/autotest.at \
+  tests/base.at \
+  tests/tools.at \
+  tests/torture.at \
+  tests/compile.at \
+  tests/c.at \
+  tests/erlang.at \
+  tests/fortran.at \
+  tests/go.at \
+  tests/semantics.at \
+  tests/autoscan.at \
+  tests/foreign.at
 
 TESTSUITE_AT = $(TESTSUITE_GENERATED_AT) $(TESTSUITE_HAND_AT)
-TESTSUITE = ./testsuite
+TESTSUITE = tests/testsuite
 
 # Run the non installed autom4te.
 # Don't use AUTOM4TE since 'make alpha' makes it unavailable although
 # we are allowed to use it (since we ship it).
+AUTOTESTFLAGS = -I tests -I $(srcdir)/tests
 AUTOTEST = $(MY_AUTOM4TE) --language=autotest
-$(TESTSUITE): package.m4 \
-             local.at \
+$(TESTSUITE): tests/package.m4 \
+             tests/local.at \
              $(TESTSUITE_AT) \
-             $(autotest_m4f_dependencies)
-       cd $(top_builddir)/lib/autotest && $(MAKE) $(AM_MAKEFLAGS) autotest.m4f
-       $(AUTOTEST) -I . -I $(srcdir) suite.at -o address@hidden
+             lib/autotest/autotest.m4f
+       $(AUTOTEST) $(AUTOTESTFLAGS) suite.at -o address@hidden
        mv address@hidden $@
 
-atconfig: $(top_builddir)/config.status
-       cd $(top_builddir) && ./config.status tests/$@
+# Factor out invocation of the testsuite script.
+run_testsuite = $(SHELL) $(TESTSUITE) -C tests
 
 # Avoid a race condition that would make parallel "distclean" fail.
 # The rule in clean-local tests for existence of $(TESTSUITE), and
@@ -135,16 +150,16 @@ distclean_generic = distclean-generic
 $(distclean_generic): clean-local
 
 clean-local:
-       test ! -f $(TESTSUITE) || $(SHELL) $(TESTSUITE) --clean
+       test ! -f $(TESTSUITE) || $(run_testsuite)  --clean
        rm -f *.tmp
        rm -f -r autom4te.cache
 
-check-local: atconfig atlocal $(TESTSUITE)
-       $(SHELL) $(TESTSUITE) $(TESTSUITEFLAGS)
+check-local: tests/atconfig tests/atlocal $(TESTSUITE)
+       $(run_testsuite) $(TESTSUITEFLAGS)
 
 # Run the test suite on the *installed* tree.
-installcheck-local: atconfig atlocal $(TESTSUITE)
-       $(SHELL) $(TESTSUITE) AUTOTEST_PATH="$(bindir)" $(TESTSUITEFLAGS)
+installcheck-local: tests/atconfig tests/atlocal $(TESTSUITE)
+       $(run_testsuite) AUTOTEST_PATH="$(bindir)" $(TESTSUITEFLAGS)
 
 
 
@@ -156,10 +171,10 @@ MAINTAINERCLEANFILES += $(TESTSUITE_GENERATED_AT)
 
 ## Producing the test files.
 
-# The files which contain macros we check for syntax.  Use $(top_srcdir)
+# The files which contain macros we check for syntax.  Use $(srcdir)
 # for the benefit of non-GNU make.  Fix the names in the rule below
 # where we 'cd' to $srcdir.
-autoconfdir = $(top_srcdir)/lib/autoconf
+autoconfdir = $(srcdir)/lib/autoconf
 AUTOCONF_FILES = $(autoconfdir)/general.m4 \
                 $(autoconfdir)/status.m4 \
                 $(autoconfdir)/autoheader.m4 \
@@ -176,24 +191,24 @@ AUTOCONF_FILES = $(autoconfdir)/general.m4 \
                 $(autoconfdir)/types.m4 \
                 $(autoconfdir)/programs.m4
 
-$(TESTSUITE_GENERATED_AT): mktests.stamp
+$(TESTSUITE_GENERATED_AT): tests/mktests.stamp
 ## Recover from the removal of $@
        @if test -f $@; then :; else \
-         rm -f mktests.stamp; \
-         $(MAKE) $(AM_MAKEFLAGS) mktests.stamp; \
+         rm -f tests/mktests.stamp; \
+         $(MAKE) $(AM_MAKEFLAGS) tests/mktests.stamp; \
        fi
 
-mktests.stamp : mktests.sh $(AUTOCONF_FILES)
-       @rm -f mktests.tmp
-       @touch mktests.tmp
-       cd $(srcdir) && ./mktests.sh \
-         `echo " "$(AUTOCONF_FILES) | sed 's, [^ ]*/, ../lib/autoconf/,g'`
-       @mv -f mktests.tmp $@
+tests/mktests.stamp : tests/mktests.sh $(AUTOCONF_FILES)
+       @rm -f tests/mktests.tmp
+       @touch tests/mktests.tmp
+       cd $(srcdir) && $(SHELL) tests/mktests.sh \
+         `echo " "$(AUTOCONF_FILES) | sed 's, [^ ]*/, lib/autoconf/,g'`
+       @mv -f tests/mktests.tmp $@
 
 ## Distribute the stamp file, since we distribute the generated files.
-EXTRA_DIST += mktests.stamp
-CLEANFILES += mktests.tmp
-MAINTAINERCLEANFILES += mktests.stamp
+EXTRA_DIST += tests/mktests.stamp
+CLEANFILES += tests/mktests.tmp
+MAINTAINERCLEANFILES += tests/mktests.stamp
 
 ## maintainer-check ##
 
diff --git a/tests/mktests.sh b/tests/mktests.sh
index b6f5d3f..f8a49c7 100755
--- a/tests/mktests.sh
+++ b/tests/mktests.sh
@@ -22,8 +22,13 @@
 
 as_me=`echo "$0" | sed 's|.*[\\/]||'`
 
+outdir=tests
+acdefuns=$outdir/acdefuns.tmp
+audefuns=$outdir/audefuns.tmp
+requires=$outdir/requires.tmp
+
 trap 'echo "'"$as_me"': failed." >&2
-      rm -f acdefuns audefuns requires *.tat
+      rm -f $acdefuns $audefuns $requires $outdir/*.tat
       trap "" 0
       exit 1' \
      0 1 2 15
@@ -48,7 +53,7 @@ LC_ALL=C export LC_ALL
 # Get the list of macros that are required: there is little interest
 # in testing them since they will be run by the guy who requires them.
 sed -n 's/dnl.*//;s/.*AC_REQUIRE(\[*\([a-zA-Z0-9_]*\).*$/\1/p' $src |
-  sort -u >requires
+  sort -u >$requires
 
 
 # exclude_list
@@ -180,17 +185,18 @@ au_exclude_script="$exclude_list $au_exclude_list {print}"
 for file in $src
 do
   base=`echo "$file" | sed 's|.*[\\/]||;s|\..*||'`
+  acbase=$outdir/ac$base
   # Get the list of macros which are defined in Autoconf level.
   # Get rid of the macros we are not interested in.
   sed -n -e 's/^AC_DEFUN(\[*\([a-zA-Z0-9_]*\).*$/\1/p' \
         -e 's/^AC_DEFUN_ONCE(\[*\([a-zA-Z0-9_]*\).*$/\1/p' $file |
     awk "$ac_exclude_script" |
-    sort -u >acdefuns
+    sort -u >$acdefuns
 
   # Get the list of macros which are defined in Autoupdate level.
   sed -n 's/^AU_DEFUN(\[*\([a-zA-Z][a-zA-Z0-9_]*\).*$/\1/p' $file |
     awk "$au_exclude_script" |
-    sort -u >audefuns
+    sort -u >$audefuns
 
   # Filter out required macros.
   {
@@ -209,26 +215,26 @@ do
 MK_EOF
 
     echo "# Modern macros."
-    comm -23 acdefuns requires | sed 's/.*/AT_CHECK_MACRO([&])/'
+    comm -23 $acdefuns $requires | sed 's/.*/AT_CHECK_MACRO([&])/'
     echo
     echo "# Obsolete macros."
-    comm -23 audefuns requires | sed 's/.*/AT_CHECK_AU_MACRO([&])/'
-  } >ac$base.tat
+    comm -23 $audefuns $requires | sed 's/.*/AT_CHECK_AU_MACRO([&])/'
+  } >$acbase.tat
 
   # In one atomic step so that if something above fails, the trap
   # preserves the old version of the file.  If there is nothing to
   # check, output /rien du tout/[1].
-  if grep AT_CHECK ac$base.tat >/dev/null 2>&1; then
-    mv -f ac$base.tat ac$base.at
+  if grep AT_CHECK $acbase.tat >/dev/null 2>&1; then
+    mv -f $acbase.tat $acbase.at
   else
-    rm -f ac$base.tat ac$base.at
-    touch ac$base.at
+    rm -f $acbase.tat $acbase.at
+    touch $acbase.at
   fi
   # Help people not to update these files by hand.
-  chmod a-w ac$base.at
+  chmod a-w $acbase.at
 done
 
-rm -f acdefuns audefuns requires
+rm -f $acdefuns $audefuns $requires
 
 trap '' 0
 exit 0
-- 
1.8.3.rc0.19.g7e6a0cc




reply via email to

[Prev in Thread] Current Thread [Next in Thread]