1 # Most of this is probably too coreutils-centric to be useful to other packages.
3 warn_cflags = -Dlint -O -Werror -Wall -Wformat -Wshadow -Wpointer-arith
6 write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
9 t=$(TMPDIR)/$(PACKAGE)/test
12 # More than once, tainted build and source directory names would
13 # have caused at least one "make check" test to apply "chmod 700"
14 # to all directories under $HOME. Make sure it doesn't happen again.
15 tp := $(shell echo "$(TMPDIR)/$(PACKAGE)-$$$$")
17 t_taint = '$(t_prefix) b'
18 fake_home = $(tp)/home
20 # Disable this test, since libtool-generated scripts
21 # can't deal with a space-tainted srcdir.
22 ALL_RECURSIVE_TARGETS += taint-distcheck
23 .PHONY: taint-distcheck
26 # Verify that a twisted use of --program-transform-name=PROGRAM works.
27 define install-transform-check
28 echo running install-transform-check \
30 && $(MAKE) program_transform_name='s/.*/zyx/' \
31 prefix=$(pfx) install \
32 && test "$$(echo $(pfx)/sbin/*)" = "$(pfx)/sbin/zyx" \
33 && test "$$(find $(pfx)/share/man -type f|sed 's,.*/,,;s,\..*,,')" = "zyx"
36 # Install, then verify that all binaries and man pages are in place.
37 # Note that neither the binary, ginstall, nor the ].1 man page is installed.
39 $(MAKE) prefix=$(pfx) install \
40 && test ! -f $(pfx)/bin/ginstall \
42 for i in $(built_programs); do \
43 test "$$i" = ginstall && i=install; \
44 for j in "$(pfx)/bin/$$i" \
45 "$(pfx)/share/man/man1/$$i.1"; do \
46 case $$j in *'[.1') continue;; esac; \
48 || { echo "$$j not installed"; fail=1; }; \
51 test $$fail = 1 && exit 1 || :; \
55 define coreutils-path-check
57 if test -f $(srcdir)/src/true.c; then \
60 && ($(write_loser)) > $(bin)/loser \
61 && chmod a+x $(bin)/loser \
62 && for i in $(built_programs); do \
64 rm|expr|basename|echo|sort|ls|tr);; \
65 cat|dirname|mv|wc);; \
66 *) ln $(bin)/loser $(bin)/$$i;; \
69 && ln -sf ../src/true $(bin)/false \
70 && PATH=`pwd`/$(bin)$(PATH_SEPARATOR)$$PATH \
71 $(MAKE) -C tests check \
72 && { test -d gnulib-tests \
73 && $(MAKE) -C gnulib-tests check \
80 test $$fail = 1 && exit 1 || :; \
84 # Use -Wformat -Werror to detect format-string/arg-list mismatches.
85 # Also, check for shadowing problems with -Wshadow, and for pointer
86 # arithmetic problems with -Wpointer-arith.
87 # These CFLAGS are pretty strict. If you build this target, you probably
88 # have to have a recent version of gcc and glibc headers.
89 # The hard-linking for-loop below ensures that there is a bin/ directory
90 # full of all of the programs under test (except the ones that are required
91 # for basic Makefile rules), all symlinked to the just-built "false" program.
92 # This is to ensure that if ever a test neglects to make PATH include
93 # the build srcdir, these always-failing programs will run.
94 # Otherwise, it is too easy to test the wrong programs.
95 # Note that "false" itself is a symlink to true, so it too will malfunction.
96 ALL_RECURSIVE_TARGETS += my-distcheck
97 my-distcheck: $(DIST_ARCHIVES) $(local-check)
102 GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
104 && ./configure --disable-nls \
105 && $(MAKE) CFLAGS='$(warn_cflags)' \
106 AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
108 && $(install-transform-check) \
110 && $(coreutils-path-check) \
112 (cd $(t) && mv $(distdir) $(distdir).old \
113 && $(AMTAR) -zxf - ) < $(distdir).tar.gz
114 diff -ur $(t)/$(distdir).old $(t)/$(distdir)
116 @echo "========================"; \
117 echo "$(distdir).tar.gz is ready for distribution"; \
118 echo "========================"