Merge branch 'aclocal-trace-macrodir'
[platform/upstream/automake.git] / Makefile.am
index c04db28..f05e82d 100644 (file)
 # You should have received a copy of the GNU General Public License
 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
-## '.' goes before 't', because this latter directory runs
-## aclocal and automake.
-SUBDIRS = . t
-
 ## Might be updated later.
 CLEANFILES =
 DISTCLEANFILES =
@@ -31,6 +27,37 @@ EXTRA_DIST =
 ##  Top level.  ##
 ## ------------ ##
 
+# We want a handful of substitutions to be fully-expanded by make;
+# then use config.status to substitute the remainder where a single
+# expansion is sufficient.  We use a funny notation here to avoid
+# configure substitutions in our text.
+do_subst = ( sed \
+  -e "s,[@]configure_input[@],Generated from $$in; do not edit by hand.,g" \
+  -e 's,[@]datadir[@],$(datadir),g' \
+  -e 's,[@]amdir[@],$(amdir),g' \
+  -e 's,[@]bindir[@],$(bindir),g' \
+  -e 's,[@]docdir[@],$(docdir),g' \
+  -e 's,[@]pkgvdatadir[@],$(pkgvdatadir),g' \
+  -e 's,[@]scriptdir[@],$(scriptdir),g' \
+  -e 's,[@]automake_acdir[@],$(automake_acdir),g' \
+  -e 's,[@]system_acdir[@],$(system_acdir),g' \
+## Hack to avoid a spurious substitution in the Automake script (part 1).
+  -e 's,[@]am__isrc[@],!!@!!am__isrc!!@!!,g' \
+  | $(SHELL) ./config.status --file=- \
+## Hack to avoid a spurious substitution in the Automake script (part 2).
+  | sed -e 's,!!@!!am__isrc!!@!!,@''am__isrc@,g' \
+  )
+
+# Generated  files shouldn't contain unexpanded '@substitutions@', and
+# should be made read-only, to prevent them from being edited by mistake
+# instead of the file the are generated from.
+generated_file_finalize = $(AM_V_at) \
+  if LC_ALL=C grep '@[a-zA-Z0-9_][a-zA-Z0-9_]*@' $@-t; then \
+    echo "$@ contains unexpanded substitution (see lines above)"; \
+    exit 1; \
+  fi; \
+  chmod a-w $@-t && mv -f $@-t $@
+
 bin_SCRIPTS = automake aclocal
 
 CLEANFILES += $(bin_SCRIPTS)
@@ -40,7 +67,7 @@ TAGS_FILES = $(AUTOMAKESOURCES)
 
 EXTRA_DIST += \
   $(AUTOMAKESOURCES) \
-  bootstrap \
+  bootstrap.sh \
   GNUmakefile \
   syntax-checks.mk \
   HACKING
@@ -65,32 +92,16 @@ uninstall-hook:
          rm -f "$(DESTDIR)$(bindir)/$$fv"; \
        done
 
-## We can't use configure to do the substitution here; we must do it
-## by hand.  We use a funny notation here to avoid configure
-## substitutions in our text.
-do_subst = sed \
-  -e 's,[@]APIVERSION[@],$(APIVERSION),g' \
-  -e 's,[@]PACKAGE[@],$(PACKAGE),g' \
-  -e 's,[@]PACKAGE_BUGREPORT[@],$(PACKAGE_BUGREPORT),g' \
-  -e 's,[@]PACKAGE_URL[@],$(PACKAGE_URL),g' \
-  -e 's,[@]PATH_SEPARATOR[@],$(PATH_SEPARATOR),g' \
-  -e 's,[@]PERL[@],$(PERL),g' \
-  -e 's,[@]PERL_THREADS[@],$(PERL_THREADS),g' \
-  -e 's,[@]SHELL[@],$(SHELL),g' \
-  -e 's,[@]am_AUTOCONF[@],$(am_AUTOCONF),g' \
-  -e 's,[@]am_AUTOM4TE[@],$(am_AUTOM4TE),g' \
-  -e 's,[@]VERSION[@],$(VERSION),g' \
-  -e 's,[@]configure_input[@],Generated from $@.in; do not edit by hand.,g' \
-  -e 's,[@]datadir[@],$(datadir),g'
-
 ## These files depend on Makefile so they are rebuilt if $(VERSION),
 ## $(datadir) or other do_subst'ituted variables change.
-## Use chmod a-w to prevent people from editing the wrong file by accident.
 automake: automake.in
 aclocal: aclocal.in
 automake aclocal: Makefile
        $(AM_V_at)rm -f $@ $@-t
-       $(AM_V_GEN)$(do_subst) $(srcdir)/$@.in >$@-t
+       $(AM_V_GEN)in=$@.in; $(do_subst) <$(srcdir)/$@.in >$@-t
+## We can't use '$(generated_file_finalize)' here, because currently
+## Automake contains occurrences of unexpanded @substitutions@ in
+## comments, and that is perfectly legit.
        $(AM_V_at)chmod a+x,a-w $@-t && mv -f $@-t $@
 
 ## The master location for INSTALL is lib/INSTALL.
@@ -99,11 +110,6 @@ automake aclocal: Makefile
 INSTALL: lib/INSTALL
        $(AM_V_GEN)cp $(srcdir)/lib/INSTALL $@
 
-# Convenience proxy target for the test suites.
-recheck:
-       $(am__cd) t && $(MAKE) $(AM_MAKEFLAGS) $@
-.PHONY: recheck
-
 # We don't use the default name for the autom4te cache directory,
 # so we need this.
 maintainer-clean-local:
@@ -150,7 +156,8 @@ install-data-hook:
              done; \
              exit $$st )
 
-installcheck-local:
+installcheck-local: installcheck-executable-scripts
+installcheck-executable-scripts:
        @for f in $(dist_script_DATA); do echo $$f; done \
          | sed 's,^lib/,,' \
          | while read f; do \
@@ -190,23 +197,12 @@ dist_perllib_DATA = \
 nodist_perllib_DATA = lib/Automake/Config.pm
 CLEANFILES += $(nodist_perllib_DATA)
 
-## This file depends on Makefile so it is rebuilt if $(VERSION),
-## $(datadir) or other do_subst'ituted variables change.
-## Use chmod a-w to prevent people from editing the wrong file by accident.
 lib/Automake/Config.pm: lib/Automake/Config.in Makefile
        $(AM_V_at)rm -f $@ $@-t
        $(AM_V_at)test -d lib/Automake || $(MKDIR_P) lib/Automake
-       $(AM_V_GEN)sed <$(srcdir)/lib/Automake/Config.in >$@-t \
-         -e 's,[@]APIVERSION[@],$(APIVERSION),g' \
-         -e 's,[@]PACKAGE[@],$(PACKAGE),g' \
-         -e 's,[@]PACKAGE_BUGREPORT[@],$(PACKAGE_BUGREPORT),g' \
-         -e 's,[@]PERL[@],$(PERL),g' \
-         -e 's,[@]PERL_THREADS[@],$(PERL_THREADS),g' \
-         -e 's,[@]SHELL[@],$(SHELL),g' \
-         -e 's,[@]VERSION[@],$(VERSION),g' \
-         -e "s,[@]configure_input[@],Generated from Config.in; do not edit by hand.,g" \
-         -e 's,[@]datadir[@],$(datadir),g'
-       $(AM_V_at)chmod a-w $@-t && mv -f $@-t $@
+       $(AM_V_GEN)in=Config.in \
+         && $(do_subst) <$(srcdir)/lib/Automake/Config.in >$@-t
+       $(generated_file_finalize)
 EXTRA_DIST += lib/Automake/Config.in
 
 
@@ -265,14 +261,13 @@ dist_automake_ac_DATA = \
   m4/ar-lib.m4 \
   m4/as.m4 \
   m4/auxdir.m4 \
-  m4/ccstdc.m4 \
   m4/cond.m4 \
   m4/cond-if.m4 \
   m4/depend.m4 \
   m4/depout.m4 \
   m4/dmalloc.m4 \
+  m4/extra-recurs.m4 \
   m4/gcj.m4 \
-  m4/header.m4 \
   m4/init.m4 \
   m4/install-sh.m4 \
   m4/lead-dot.m4 \
@@ -282,10 +277,6 @@ dist_automake_ac_DATA = \
   m4/make.m4 \
   m4/minuso.m4 \
   m4/missing.m4 \
-  m4/mkdirp.m4 \
-  m4/obsol-gt.m4 \
-  m4/obsol-lt.m4 \
-  m4/obsolete.m4 \
   m4/options.m4 \
   m4/protos.m4 \
   m4/python.m4 \
@@ -308,15 +299,148 @@ dist_system_ac_DATA = m4/acdir/README
 # Use '$(top_srcdir)/m4' for the benefit of non-GNU makes: this is
 # how amversion.m4 appears in our dependencies.
 $(top_srcdir)/m4/amversion.m4: $(srcdir)/configure.ac $(srcdir)/m4/amversion.in
-       $(AM_V_at)sed \
-           -e 's,[@]VERSION[@],$(VERSION),g' \
-           -e 's,[@]APIVERSION[@],$(APIVERSION),g' \
-           -e "s,[@]configure_input[@],Generated from amversion.in; do not edit by hand.,g" \
-           $(srcdir)/m4/amversion.in > $@-t
-       $(AM_V_at)chmod a-w $@-t && mv -f $@-t $@
+       $(AM_V_at)rm -f $@-t $@
+       $(AM_V_GEN)in=amversion.in \
+         && $(do_subst) <$(srcdir)/m4/amversion.in >$@-t
+       $(generated_file_finalize)
 EXTRA_DIST += m4/amversion.in
 
 
+## ------------ ##
+##  Testsuite.  ##
+## ------------ ##
+
+# Run the tests with a proper shell detected at configure time.
+LOG_COMPILER = $(AM_TEST_RUNNER_SHELL)
+
+TEST_EXTENSIONS = .pl .sh .tap
+SH_LOG_COMPILER = $(LOG_COMPILER)
+TAP_LOG_COMPILER = $(LOG_COMPILER)
+PL_LOG_COMPILER = $(PERL)
+AM_PL_LOG_FLAGS = -Mstrict -I $(builddir)/lib -I $(srcdir)/lib -w
+
+TAP_LOG_DRIVER = AM_TAP_AWK='$(AWK)' $(SHELL) $(srcdir)/lib/tap-driver.sh
+
+AM_TAP_LOG_DRIVER_FLAGS = --merge
+
+EXTRA_DIST += t/README t/ax/is t/ax/is_newest
+
+TESTS = ## Will be updated later.
+
+# Some testsuite-influential variables should be overridable from the
+# test scripts, but not from the environment.
+AM_TESTS_ENVIRONMENT = \
+  for v in \
+    required \
+    am_using_tap \
+    am_serial_tests \
+    am_test_prefer_config_shell \
+    am_original_AUTOMAKE \
+    am_original_ACLOCAL \
+  ; do \
+    eval test x"\$${$$v}" = x || unset $$v; \
+  done;
+# The 'AM_TESTS_REEXEC=no' setting tells the tests not to needlessly
+# re-execute themselves with the shell detected at configure time, since
+# we are already running them under it explicitly in our setup (see e.g.
+# the definition of TEST_LOG_COMPILER above).
+AM_TESTS_ENVIRONMENT += AM_TESTS_REEXEC=no; export AM_TESTS_REEXEC;
+# We want warning messages and explanations for skipped tests to go to
+# the console if possible, so set up 'stderr_fileno_' properly.
+AM_TESTS_FD_REDIRECT = 9>&2
+AM_TESTS_ENVIRONMENT += stderr_fileno_=9; export stderr_fileno_;
+
+# Hand-written tests.
+
+include $(srcdir)/t/list-of-tests.mk
+
+TESTS += $(handwritten_TESTS)
+EXTRA_DIST += $(handwritten_TESTS)
+
+# Automatically-generated tests wrapping hand-written ones.
+# Also, automatically-computed dependencies for tests.
+
+include $(srcdir)/t/testsuite-part.am
+
+TESTS += $(generated_TESTS)
+EXTRA_DIST += $(generated_TESTS)
+
+$(srcdir)/t/testsuite-part.am:
+       $(AM_V_at)rm -f t/testsuite-part.tmp $@
+       $(AM_V_GEN)$(PERL) $(srcdir)/gen-testsuite-part \
+         --srcdir $(srcdir) > t/testsuite-part.tmp
+       $(AM_V_at)chmod a-w t/testsuite-part.tmp
+       $(AM_V_at)mv -f t/testsuite-part.tmp $@
+EXTRA_DIST += gen-testsuite-part
+
+## The dependecies declared here are not truly complete, but such
+## completeness would cause more issues than it would solve.  See
+## automake bug#11347.
+$(generated_TESTS): $(srcdir)/gen-testsuite-part
+$(srcdir)/t/testsuite-part.am: $(srcdir)/gen-testsuite-part Makefile.am
+
+# Hand-written tests for stuff in 'contrib/'.
+include $(srcdir)/contrib/t/local.am
+TESTS += $(contrib_TESTS)
+EXTRA_DIST += $(contrib_TESTS)
+
+# Static dependencies valid for each test case.
+check_SCRIPTS = t/wrap/aclocal-$(APIVERSION) t/wrap/automake-$(APIVERSION)
+dist_check_DATA = \
+  t/ax/test-init.sh  \
+  t/ax/plain-functions.sh  \
+  t/ax/tap-functions.sh
+nodist_check_DATA = defs-static
+
+# Few more static dependencies.
+t/distcheck-missing-m4.log: t/ax/distcheck-hook-m4.am
+t/distcheck-outdated-m4.log: t/ax/distcheck-hook-m4.am
+EXTRA_DIST += t/ax/distcheck-hook-m4.am
+
+defs-static: defs-static.in Makefile
+       $(AM_V_at)rm -f $@ $@-t
+       $(AM_V_GEN)in=defs-static.in\
+         && $(do_subst) <$(srcdir)/defs-static.in >$@-t
+       $(generated_file_finalize)
+EXTRA_DIST += defs-static.in
+CLEANFILES += defs-static
+
+# If two test scripts have the same basename, they will end up sharing
+# the same log file, leading to all sort of undefined and undesired
+# behaviours.
+check-no-repeated-test-name:
+       @LC_ALL=C; export LC_ALL; \
+        lst='$(TEST_LOGS)'; for log in $$lst; do echo $$log; done \
+          | sort | uniq -c | awk '($$1 > 1) { print }' \
+          | sed 's/\.log$$//' | grep . >&2 \
+          && { \
+            echo $@: test names listed above are duplicated >&2; \
+            exit 1; \
+          }; :
+check-local: check-no-repeated-test-name
+.PHONY: check-no-repeated-test-name
+
+## Checking the list of tests.
+test_subdirs = t t/pm t/perf
+include $(srcdir)/t/CheckListOfTests.am
+
+# Run the testsuite with the installed aclocal and automake.
+installcheck-local: installcheck-testsuite
+installcheck-testsuite:
+       am_running_installcheck=yes $(MAKE) $(AM_MAKEFLAGS) check
+
+clean-local: clean-local-check
+.PHONY: clean-local-check
+clean-local-check:
+       -set x t/*.dir; shift; \
+        if test "$$#,$$1" = "1,*.dir"; then \
+          : there is no test directory to clean; \
+        else \
+          find "$$@" -type d ! -perm -700 -exec chmod u+rwx {} ';'; \
+          rm -rf "$$@"; \
+        fi;
+
+
 ## ---------------- ##
 ##  Documentation.  ##
 ## ---------------- ##
@@ -325,31 +449,33 @@ info_TEXINFOS = doc/automake.texi doc/automake-history.texi
 doc_automake_TEXINFOS = doc/fdl.texi
 doc_automake_history_TEXINFOS = doc/fdl.texi
 
-dist_man1_MANS = \
-  $(srcdir)/doc/aclocal.1 \
-  $(srcdir)/doc/automake.1 \
-  $(srcdir)/doc/aclocal-$(APIVERSION).1 \
-  $(srcdir)/doc/automake-$(APIVERSION).1
+man1_MANS = \
+  doc/aclocal.1 \
+  doc/automake.1 \
+  doc/aclocal-$(APIVERSION).1 \
+  doc/automake-$(APIVERSION).1
 
-$(dist_man1_MANS): $(srcdir)/configure.ac
+$(man1_MANS): $(srcdir)/configure.ac
 
-MAINTAINERCLEANFILES += $(dist_man1_MANS)
+CLEANFILES += $(man1_MANS)
+EXTRA_DIST += doc/help2man
 
 update_mans = \
   $(AM_V_GEN): \
-    && $(MAKE) $(AM_MAKEFLAGS) lib/Automake/Config.pm \
+    && $(MKDIR_P) doc \
     && PATH="$(abs_builddir)/t/wrap$(PATH_SEPARATOR)$$PATH" \
     && export PATH \
-    && $(HELP2MAN) --output=$@
+    && $(PERL) $(srcdir)/doc/help2man --output=$@
 
-$(srcdir)/doc/aclocal.1 $(srcdir)/doc/automake.1:
+doc/aclocal.1 doc/automake.1:
        $(AM_V_GEN): \
+         && $(MKDIR_P) doc \
          && f=`echo $@ | sed 's|.*/||; s|\.1$$||; $(transform)'` \
          && echo ".so man1/$$f-$(APIVERSION).1" > $@
 
-$(srcdir)/doc/aclocal-$(APIVERSION).1: $(srcdir)/aclocal.in
+doc/aclocal-$(APIVERSION).1: aclocal.in aclocal lib/Automake/Config.pm
        $(update_mans) aclocal-$(APIVERSION)
-$(srcdir)/doc/automake-$(APIVERSION).1: $(srcdir)/automake.in
+doc/automake-$(APIVERSION).1: automake.in automake lib/Automake/Config.pm
        $(update_mans) automake-$(APIVERSION)
 
 
@@ -487,11 +613,6 @@ ChangeLog: am--changelog-regen-hook
          exit 1; \
        fi
 
-# Ensure tests are world-executable.
-# FIXME: this should be turned into a maintainer check...
-dist-hook:
-       $(am__cd) $(distdir)/t && chmod a+rx *.sh *.tap
-
 
 ## --------------------------- ##
 ##  Perl coverage statistics.  ##
@@ -573,9 +694,6 @@ git-tag-release: maintainer-check
        esac; \
        $(determine_release_type); \
        $(git_must_have_clean_workdir); \
-## Make sure the NEWS file is up-to-date.
-       sed 1q $(srcdir)/NEWS | grep '$(VERSION)' >/dev/null \
-         || fatal "NEWS not updated"; \
 ## If all was successful, tag the release in the local repository.
        $$run $(GIT) tag -s "v$(VERSION)" -m "$$release_type $(VERSION)"
 
@@ -618,7 +736,7 @@ autodiffs:
               && $(am__cd) tmp \
               && $(GIT) checkout -q "$$rev" \
               && echo "$@: bootstrapping $$rev" \
-              && $(SHELL) ./bootstrap \
+              && $(SHELL) ./bootstrap.sh \
               && echo "$@: copying files from $$rev" \
               && makefile_ins=`find . -name Makefile.in` \
               && (tar cf - configure aclocal.m4 $$makefile_ins) | \
@@ -736,7 +854,12 @@ update_copyright_env = \
 
 .PHONY: update-copyright
 update-copyright:
-       $(AM_V_GEN)excluded_re=`echo $(FETCHFILES) \
+       $(AM_V_GEN)set -e; \
+       current_year=`date +%Y` && test -n "$$current_year" \
+         || { echo "$@: cannot get current year" >&2; exit 1; }; \
+       sed -i "/^RELEASE_YEAR=/s/=.*$$/=$$current_year/" \
+         bootstrap.sh configure.ac; \
+       excluded_re=`echo $(FETCHFILES) \
          | sed -e 's|^|lib/|' -e 's| | lib/|g' -e 's, ,|,g'`; \
        $(GIT) ls-files \
          | grep -Ev '^(lib/)?(COPYING|INSTALL)$$' \