OSDN Git Service

dos: factor out and define DOS_N_PRI_PARTITIONS
[android-x86/external-parted.git] / dist-check.mk
1 # Most of this is probably too coreutils-centric to be useful to other packages.
2
3 bin=bin-$$$$
4
5 write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
6
7 TMPDIR ?= /tmp
8 t=$(TMPDIR)/$(PACKAGE)/test
9 pfx=$(t)/i
10
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)-$$$$")
15 t_prefix = $(tp)/a
16 t_taint = '$(t_prefix) b'
17 fake_home = $(tp)/home
18
19 # Disable this test, since libtool-generated scripts
20 # can't deal with a space-tainted srcdir.
21 ALL_RECURSIVE_TARGETS += taint-distcheck
22 .PHONY: taint-distcheck
23 taint-distcheck:
24
25 # Verify that a twisted use of --program-transform-name=PROGRAM works.
26 define install-transform-check
27   echo running install-transform-check                  \
28     && rm -rf $(pfx)                                    \
29     && $(MAKE) program_transform_name='s/.*/zyx/'       \
30       prefix=$(pfx) install                             \
31     && test "$$(echo $(pfx)/sbin/*)" = "$(pfx)/sbin/zyx"        \
32     && test "$$(find $(pfx)/share/man -type f|sed 's,.*/,,;s,\..*,,')" = "zyx"
33 endef
34
35 # Install, then verify that all binaries and man pages are in place.
36 # Note that neither the binary, ginstall, nor the ].1 man page is installed.
37 define my-instcheck
38   $(MAKE) prefix=$(pfx) install                         \
39     && test ! -f $(pfx)/bin/ginstall                    \
40     && { fail=0;                                        \
41       for i in $(built_programs); do                    \
42         test "$$i" = ginstall && i=install;             \
43         for j in "$(pfx)/bin/$$i"                       \
44                  "$(pfx)/share/man/man1/$$i.1"; do      \
45           case $$j in *'[.1') continue;; esac;          \
46           test -f "$$j" && :                            \
47             || { echo "$$j not installed"; fail=1; };   \
48         done;                                           \
49       done;                                             \
50       test $$fail = 1 && exit 1 || :;                   \
51     }
52 endef
53
54 define coreutils-path-check
55   {                                                     \
56     if test -f $(srcdir)/src/true.c; then               \
57       fail=1;                                           \
58       mkdir $(bin)                                      \
59         && ($(write_loser)) > $(bin)/loser              \
60         && chmod a+x $(bin)/loser                       \
61         && for i in $(built_programs); do               \
62                case $$i in                              \
63                  rm|expr|basename|echo|sort|ls|tr);;    \
64                  cat|dirname|mv|wc);;                   \
65                  *) ln $(bin)/loser $(bin)/$$i;;        \
66                esac;                                    \
67              done                                       \
68           && ln -sf ../src/true $(bin)/false            \
69           && PATH=`pwd`/$(bin)$(PATH_SEPARATOR)$$PATH   \
70                 $(MAKE) -C tests check                  \
71           && { test -d gnulib-tests                     \
72                  && $(MAKE) -C gnulib-tests check       \
73                  || :; }                                \
74           && rm -rf $(bin)                              \
75           && fail=0;                                    \
76     else                                                \
77       fail=0;                                           \
78     fi;                                                 \
79     test $$fail = 1 && exit 1 || :;                     \
80   }
81 endef
82
83 # Use -Wformat -Werror to detect format-string/arg-list mismatches.
84 # Also, check for shadowing problems with -Wshadow, and for pointer
85 # arithmetic problems with -Wpointer-arith.
86 # These CFLAGS are pretty strict.  If you build this target, you probably
87 # have to have a recent version of gcc and glibc headers.
88 # The hard-linking for-loop below ensures that there is a bin/ directory
89 # full of all of the programs under test (except the ones that are required
90 # for basic Makefile rules), all symlinked to the just-built "false" program.
91 # This is to ensure that if ever a test neglects to make PATH include
92 # the build srcdir, these always-failing programs will run.
93 # Otherwise, it is too easy to test the wrong programs.
94 # Note that "false" itself is a symlink to true, so it too will malfunction.
95 ALL_RECURSIVE_TARGETS += my-distcheck
96 my-distcheck: $(DIST_ARCHIVES) $(local-check)
97         $(MAKE) syntax-check
98         $(MAKE) check
99         -rm -rf $(t)
100         mkdir -p $(t)
101         GZIP=$(GZIP_ENV) $(AMTAR) -C $(t) -zxf $(distdir).tar.gz
102         cd $(t)/$(distdir)                              \
103           && ./configure --enable-gcc-warnings --disable-nls \
104           && $(MAKE) AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)' \
105           && $(MAKE) dvi                                \
106           && $(install-transform-check)                 \
107           && $(my-instcheck)                            \
108           && $(coreutils-path-check)                    \
109           && $(MAKE) distclean
110         (cd $(t) && mv $(distdir) $(distdir).old        \
111           && $(AMTAR) -zxf - ) < $(distdir).tar.gz
112         diff -ur $(t)/$(distdir).old $(t)/$(distdir)
113         -rm -rf $(t)
114         @echo "========================"; \
115         echo "$(distdir).tar.gz is ready for distribution"; \
116         echo "========================"