1 # Most of this is probably too coreutils-centric to be useful to other packages.
5 write_loser
= printf
'\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
8 t
=$(TMPDIR
)/$(PACKAGE
)/test
11 # More than once, tainted build and source directory names would
12 # have caused at least one "make check" test to apply "chmod 700"
13 # to all directories under $HOME. Make sure it doesn't happen again.
14 tp
:= $(shell echo
"$(TMPDIR)/$(PACKAGE)-$$$$")
16 t_taint
= '$(t_prefix) b'
17 fake_home
= $(tp
)/home
19 # Ensure that tests run from tainted build and src dir names work,
20 # and don't affect anything in $HOME. Create witness files in $HOME,
21 # record their attributes, and build/test. Then ensure that the
22 # witnesses were not affected.
23 ALL_RECURSIVE_TARGETS
+= taint-distcheck
24 taint-distcheck
: $(DIST_ARCHIVES
)
25 test -d
$(t_taint
) && chmod
-R
700 $(t_taint
) ||
:
26 -rm -rf
$(t_taint
) $(fake_home
)
27 mkdir
-p
$(t_prefix
) $(t_taint
) $(fake_home
)
28 GZIP
=$(GZIP_ENV
) $(AMTAR
) -C
$(t_taint
) -zxf
$(distdir
).
tar.gz
29 mkfifo
$(fake_home
)/fifo
31 mkdir
-p
$(fake_home
)/d
/e
32 ls
-lR
$(fake_home
) $(t_prefix
) > $(tp
)/.ls-before
33 cd
$(t_taint
)/$(distdir
) \
36 && HOME
=$(fake_home
) $(MAKE
) check \
37 && ls
-lR
$(fake_home
) $(t_prefix
) > $(tp
)/.ls-after \
38 && diff
$(tp
)/.ls-before
$(tp
)/.ls-after \
39 && test -d
$(t_prefix
)
42 # Verify that a twisted use of --program-transform-name=PROGRAM works.
43 define install-transform-check
44 echo running install-transform-check \
46 && $(MAKE
) program_transform_name
='s/.*/zyx/' \
47 prefix=$(pfx
) install \
48 && test "$$(echo $(pfx)/bin/*)" = "$(pfx)/bin/zyx" \
49 && test "$$(find $(pfx)/share/man -type f|sed 's,.*/,,;s,\..*,,')" = "zyx"
52 # Install, then verify that all binaries and man pages are in place.
53 # Note that neither the binary, ginstall, nor the ].1 man page is installed.
55 $(MAKE
) prefix=$(pfx
) install \
56 && test ! -f
$(pfx
)/bin
/ginstall \
58 for i in
$(built_programs
); do \
59 test "$$i" = ginstall
&& i
=install; \
60 for j in
"$(pfx)/bin/$$i" \
61 "$(pfx)/share/man/man1/$$i.1"; do \
62 case
$$j in
*'[.1') continue
;; esac
; \
64 ||
{ echo
"$$j not installed"; fail
=1; }; \
67 test $$fail = 1 && exit
1 ||
:; \
71 define coreutils-path-check
73 if
test -f
$(srcdir)/src
/true.c
; then \
76 && ($(write_loser
)) > $(bin
)/loser \
77 && chmod a
+x
$(bin
)/loser \
78 && for i in
$(built_programs
); do \
80 rm|expr|
basename|echo|
sort|ls|tr
);; \
81 cat|dirname|mv|wc
);; \
82 *) ln
$(bin
)/loser
$(bin
)/$$i;; \
85 && ln
-sf ..
/src
/true
$(bin
)/false \
86 && PATH
=`pwd`/$(bin
)$(PATH_SEPARATOR
)$$PATH \
87 $(MAKE
) -C tests
check \
88 && { test -d gnulib-tests \
89 && $(MAKE
) -C gnulib-tests
check \
96 test $$fail = 1 && exit
1 ||
:; \
100 # Use -Wformat -Werror to detect format-string/arg-list mismatches.
101 # Also, check for shadowing problems with -Wshadow, and for pointer
102 # arithmetic problems with -Wpointer-arith.
103 # These CFLAGS are pretty strict. If you build this target, you probably
104 # have to have a recent version of gcc and glibc headers.
105 # The hard-linking for-loop below ensures that there is a bin/ directory
106 # full of all of the programs under test (except the ones that are required
107 # for basic Makefile rules), all symlinked to the just-built "false" program.
108 # This is to ensure that if ever a test neglects to make PATH include
109 # the build srcdir, these always-failing programs will run.
110 # Otherwise, it is too easy to test the wrong programs.
111 # Note that "false" itself is a symlink to true, so it too will malfunction.
112 ALL_RECURSIVE_TARGETS
+= my-distcheck
113 my-distcheck
: $(DIST_ARCHIVES
) $(local-check
)
118 GZIP
=$(GZIP_ENV
) $(AMTAR
) -C
$(t
) -zxf
$(distdir
).
tar.gz
120 && .
/configure
--enable-gcc-warnings
--disable-nls \
121 && $(MAKE
) AM_MAKEFLAGS
='$(null_AM_MAKEFLAGS)' \
123 && $(install-transform-check
) \
125 && $(coreutils-path-check
) \
127 (cd
$(t
) && mv
$(distdir
) $(distdir
).old \
128 && $(AMTAR
) -zxf
- ) < $(distdir
).
tar.gz
129 diff
-ur
$(t
)/$(distdir
).old
$(t
)/$(distdir
)
131 @echo
"========================"; \
132 echo
"$(distdir).tar.gz is ready for distribution"; \
133 echo
"========================"