summaryrefslogtreecommitdiff
path: root/build-aux
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2007-11-16 11:03:03 +0100
committerJim Meyering <meyering@redhat.com>2007-11-16 11:03:03 +0100
commit1379ed974f1fa39b12e2ffab18b3f7a607082202 (patch)
treebe28e87d7d142430b8bdc1f079946674a1e6f832 /build-aux
parentf77576a775f483c61adda2732ded9a76be9c0230 (diff)
downloadcoreutils-1379ed974f1fa39b12e2ffab18b3f7a607082202.tar.xz
Port to Solaris 'make' and use a Posixish shell on Solaris.
* bootstrap.conf (gnulib_modules): Add gnu-make, posix-shell. * build-aux/check.mk (SHELL): Set to $(PREFERABLY_POSIX_SHELL), so that commands can assume Posix syntax. (ENABLE_HARD_ERRORS, TEST_LOGS): Don't use GNU Make's "?=" syntax. (SH_E_WORKAROUND): New macro. (am__check_pre, $(TEST_SUITE_LOG)): Use it. (am__check_pre): Fail if "mkdir" fails. Use $(SHELL) rather than relying on the "#!/bin/sh" in the file, so that tests can use Posix syntax. (am__check_pre, am__tty_colors): Use $$src rather than $$<, to support the Posix-make $(TEST_LOGS) rule. (%.log: %.test, %.log: %$(EXEEXT)): Remove unused inference rules that rely on a GNU Make extension and cause Solaris 'make' to fail. (SUFFIXES): New macro, so that we can use Posix style inference rules. (%.log: %): Use this rule only if GNU_MAKE. Set $$src so that macros can use $$src rather than $$<. (CHECK-FORCE, DEPENDENCY, $(TEST_LOGS)): New macros and rules, which rely only on Posix 'make' semantics, and are used only with non-GNU 'make' implementations. $(TEST_LOGS) invokes 'make' recursively (and a bit inefficiently) to simulate the GNU 'make' rules. (.log.html): Renamed from "%.html: %.log", so that it relies only on Posix 'make' semantics. (check-clean, .PHONY): Do not depend on check-clean-local, since Solaris 'make' complains about nonexistent rules like that. * src/Makefile.am (SUFFIXES): Remove; no longer needed. (groups): Use a specific rule rather than an inference rule that is only instantiated once. The inference-rule approach does not work with Solaris 'make', which gets confused by the "groups: Makefile" line. It's not clear from the Posix spec that Solaris 'make' is buggy here, so instead of worrying about it, rewrite the makefile so that it clearly conforms to Posix. * tests/check.mk (TESTS_ENVIRONMENT): Export PACKAGE_BUGREPORT. GNU 'make' does this automatically for us, but Solaris 'make' doesn't. 2007-11-15 Paul Eggert <eggert@cs.ucla.edu>
Diffstat (limited to 'build-aux')
-rw-r--r--build-aux/check.mk81
1 files changed, 48 insertions, 33 deletions
diff --git a/build-aux/check.mk b/build-aux/check.mk
index fd6fb2b8d..9f63b6d17 100644
--- a/build-aux/check.mk
+++ b/build-aux/check.mk
@@ -23,18 +23,24 @@
## wait for all the tests to be compiled).
##
## Define TEST_SUITE_LOG to be the name of the global log to create.
-## Define TEST_LOGS to the set of logs to include in it. It defaults
-## to $(TESTS:.test=.log).
+## Define TEST_LOGS to the set of logs to include in it. One possibility
+## is $(TESTS:.test=.log).
##
## In addition to the magic "exit 77 means SKIP" feature (which was
## imported from automake), there is a magic "exit 177 means FAIL" feature
## which is useful if you need to issue a hard error no matter whether the
## test is XFAIL or not.
+# Use a POSIX-compatible shell if available, as this file uses
+# features of the POSIX shell that are not supported by some standard
+# shell implementations (e.g., Solaris 10 /bin/sh).
+SHELL = $(PREFERABLY_POSIX_SHELL)
+
# Set this to `false' to disable hard errors.
-ENABLE_HARD_ERRORS ?= :
+ENABLE_HARD_ERRORS = :
-## We use GNU Make extensions (%-rules), and override check-TESTS.
+## We use GNU Make extensions (%-rules) inside GNU_MAKE checks,
+## and we override check-TESTS.
AUTOMAKE_OPTIONS = -Wno-portability -Wno-override
# Restructured Text title and section.
@@ -78,15 +84,21 @@ tput sgr0 >/dev/null 2>&1 && \
std=$$(tput sgr0); \
}
+# Solaris 10 'make', and several other traditional 'make' implementations,
+# pass "-e" to $(SHELL). This contradicts POSIX. Work around the problem
+# by disabling -e (using the XSI extension "set +e") if it's set.
+SH_E_WORKAROUND = case $$- in *e*) set +e;; esac
+
# To be inserted before the command running the test. Creates the
# directory for the log if needed. Stores in $dir the directory
-# containing $<, and passes the TEST_ENVIRONMENT.
+# containing $src, and passes TESTS_ENVIRONMENT.
am__check_pre = \
-$(mkdir_p) "$$(dirname $@)"; \
-if test -f ./$<; then dir=./; \
-elif test -f $<; then dir=; \
+$(SH_E_WORKAROUND); \
+$(mkdir_p) "$$(dirname $@)" || exit; \
+if test -f "./$$src"; then dir=./; \
+elif test -f "$$src"; then dir=; \
else dir="$(srcdir)/"; fi; \
-$(TESTS_ENVIRONMENT)
+$(TESTS_ENVIRONMENT) $(SHELL)
# To be appended to the command running the test. Handles the stdout
# and stderr redirection, and catch the exit status.
@@ -99,7 +111,7 @@ fi; \
$(am__tty_colors); \
xfailed=PASS; \
for xfail in : $(XFAIL_TESTS); do \
- case $< in \
+ case $$src in \
$$xfail | */$$xfail) xfailed=XFAIL; break; \
esac; \
done; \
@@ -117,31 +129,34 @@ echo "$$res: $@ (exit: $$estatus)" | \
cat $@-t >>$@; \
rm $@-t
-# From a test file to a log file.
-# Do not use a regular `.test.log:' rule here, since in that case the
-# following rule (without incoming extension) will mask this one.
-%.log: %.test
- @$(am__check_pre) $${dir}$< $(am__check_post)
-
-# The exact same commands, but for programs.
-#
-# Should be active by default, because it sometimes triggers when in
-# should not. For instance I had foo.chk tests that relied on
-# directories with the name, without extensions (foo). Then Make
-# tried to run the directories to produce foo.log, not foo.chk.
-#
-%.log: %$(EXEEXT)
- @$(am__check_pre) $${dir}$< $(am__check_post)
-
-# The exact same commands, but for scripts without extension.
+SUFFIXES = .html .log
+
+# From a test (with no extension) to a log file.
+if GNU_MAKE
%.log: %
- @$(am__check_pre) $${dir}$< $(am__check_post)
+ @src='$<'; $(am__check_pre) "$$dir$$src" $(am__check_post)
+else
+# With POSIX 'make', inference rules cannot have FOO.log depend on FOO.
+# Work around the problem by calculating the dependency dynamically, and
+# then invoking a submake with the calculated dependency.
+CHECK-FORCE:
+DEPENDENCY = CHECK-FORCE
+$(TEST_LOGS): $(DEPENDENCY)
+ @if test '$(DEPENDENCY)' = CHECK-FORCE; then \
+ dst=$@; \
+ exec $(MAKE) $(AM_MAKEFLAGS) DEPENDENCY='$(srcdir)'/$${dst%.log} $@;\
+ else \
+ src='$(DEPENDENCY)'; \
+ $(am__check_pre) "$$dir$$src" $(am__check_post); \
+ fi
+endif
-TEST_LOGS ?= $(TESTS:.test=.log)
+#TEST_LOGS = $(TESTS:.test=.log)
TEST_SUITE_LOG = test-suite.log
$(TEST_SUITE_LOG): $(TEST_LOGS)
- @results=$$(for f in $(TEST_LOGS); do sed 1q $$f; done); \
+ @$(SH_E_WORKAROUND); \
+ results=$$(for f in $(TEST_LOGS); do sed 1q $$f; done); \
all=$$(echo "$$results" | wc -l | sed -e 's/^[ \t]*//'); \
fail=$$(echo "$$results" | grep -c '^FAIL'); \
pass=$$(echo "$$results" | grep -c '^PASS'); \
@@ -215,7 +230,7 @@ check-TESTS:
TEST_SUITE_HTML = $(TEST_SUITE_LOG:.log=.html)
-%.html: %.log
+.log.html:
@for r2h in $(RST2HTML) $$RST2HTML rst2html rst2html.py; \
do \
if ($$r2h --version) >/dev/null 2>&1; then \
@@ -245,7 +260,7 @@ check-html:
## Clean. ##
## ------- ##
-check-clean: check-clean-local
+check-clean:
rm -f $(CHECK_CLEANFILES) $(TEST_SUITE_LOG) $(TEST_SUITE_HTML) $(TEST_LOGS)
-.PHONY: check-clean check-clean-local
+.PHONY: check-clean
clean-local: check-clean