Blame dist-check.mk

Packit Service 2723c6
# Most of this is probably too coreutils-centric to be useful to other packages.
Packit Service 2723c6
Packit Service 2723c6
bin=bin-$$$$
Packit Service 2723c6
Packit Service 2723c6
write_loser = printf '\#!%s\necho $$0: bad path 1>&2; exit 1\n' '$(SHELL)'
Packit Service 2723c6
Packit Service 2723c6
tmpdir = $(abs_top_builddir)/tests/torture
Packit Service 2723c6
Packit Service 2723c6
t=$(tmpdir)/$(PACKAGE)/test
Packit Service 2723c6
pfx=$(t)/i
Packit Service 2723c6
Packit Service 2723c6
built_programs := $(sort $(patsubst src/%$(EXEEXT),%,$(bin_PROGRAMS)))
Packit Service 2723c6
Packit Service 2723c6
# More than once, tainted build and source directory names would
Packit Service 2723c6
# have caused at least one "make check" test to apply "chmod 700"
Packit Service 2723c6
# to all directories under $HOME.  Make sure it doesn't happen again.
Packit Service 2723c6
tp = $(tmpdir)/taint
Packit Service 2723c6
t_prefix = $(tp)/a
Packit Service 2723c6
t_taint = '$(t_prefix) b'
Packit Service 2723c6
fake_home = $(tp)/home
Packit Service 2723c6
Packit Service 2723c6
# When extracting from a distribution tarball, extract using the fastest
Packit Service 2723c6
# method possible.  With dist-xz, that means using the *.xz file.
Packit Service 2723c6
ifneq ('', $(filter *.xz, $(DIST_ARCHIVES)))
Packit Service 2723c6
  tar_decompress_opt_ = J
Packit Service 2723c6
  suffix_ = xz
Packit Service 2723c6
else
Packit Service 2723c6
  ifneq ('', $(filter *.gz, $(DIST_ARCHIVES)))
Packit Service 2723c6
    tar_decompress_opt_ = z
Packit Service 2723c6
    suffix_ = gz
Packit Service 2723c6
  else
Packit Service 2723c6
    tar_decompress_opt_ = j
Packit Service 2723c6
    suffix_ = bz2
Packit Service 2723c6
  endif
Packit Service 2723c6
endif
Packit Service 2723c6
amtar_extract_ = $(AMTAR) -$(tar_decompress_opt_)xf
Packit Service 2723c6
preferred_tarball_ = $(distdir).tar.$(suffix_)
Packit Service 2723c6
Packit Service 2723c6
# Ensure that tests run from tainted build and src dir names work,
Packit Service 2723c6
# and don't affect anything in $HOME.  Create witness files in $HOME,
Packit Service 2723c6
# record their attributes, and build/test.  Then ensure that the
Packit Service 2723c6
# witnesses were not affected.
Packit Service 2723c6
# Skip this test when using libtool, since libtool-generated scripts
Packit Service 2723c6
# cannot deal with a space-tainted srcdir.
Packit Service 2723c6
ALL_RECURSIVE_TARGETS += taint-distcheck
Packit Service 2723c6
taint-distcheck: $(DIST_ARCHIVES)
Packit Service 2723c6
	grep '^[	 ]*LT_INIT' configure.ac >/dev/null && exit 0 || :
Packit Service 2723c6
	test -d $(t_taint) && chmod -R 700 $(t_taint) || :
Packit Service 2723c6
	-rm -rf $(t_taint) $(fake_home)
Packit Service 2723c6
	mkdir -p $(t_prefix) $(t_taint) $(fake_home)
Packit Service 2723c6
	$(amtar_extract_) $(preferred_tarball_) -C $(t_taint)
Packit Service 2723c6
	mkfifo $(fake_home)/fifo
Packit Service 2723c6
	touch $(fake_home)/f
Packit Service 2723c6
	mkdir -p $(fake_home)/d/e
Packit Service 2723c6
	ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-before
Packit Service 2723c6
	HOME=$(fake_home); export HOME;			\
Packit Service 2723c6
	cd $(t_taint)/$(distdir)			\
Packit Service 2723c6
	  && ./configure				\
Packit Service 2723c6
	  && $(MAKE)					\
Packit Service 2723c6
	  && $(MAKE) check				\
Packit Service 2723c6
	  && ls -lR $(fake_home) $(t_prefix) > $(tp)/.ls-after \
Packit Service 2723c6
	  && diff $(tp)/.ls-before $(tp)/.ls-after	\
Packit Service 2723c6
	  && test -d $(t_prefix)
Packit Service 2723c6
	rm -rf $(tp)
Packit Service 2723c6
Packit Service 2723c6
# Verify that a twisted use of --program-transform-name=PROGRAM works.
Packit Service 2723c6
define install-transform-check
Packit Service 2723c6
  echo running install-transform-check			\
Packit Service 2723c6
    && rm -rf $(pfx)					\
Packit Service 2723c6
    && $(MAKE) program_transform_name='s/.*/zyx/'	\
Packit Service 2723c6
      prefix=$(pfx) install				\
Packit Service 2723c6
    && test "$$(echo $(pfx)/bin/*)" = "$(pfx)/bin/zyx"	\
Packit Service 2723c6
    && test "$$(find $(pfx)/share/man -type f|sed 's,.*/,,;s,\..*,,')" = "zyx"
Packit Service 2723c6
endef
Packit Service 2723c6
Packit Service 2723c6
# Install, then verify that all binaries and man pages are in place.
Packit Service 2723c6
# Note that neither the binary, ginstall, nor the [.1 man page is installed.
Packit Service 2723c6
define my-instcheck
Packit Service 2723c6
  echo running my-instcheck;				\
Packit Service 2723c6
  $(MAKE) prefix=$(pfx) install				\
Packit Service 2723c6
    && test ! -f $(pfx)/bin/ginstall			\
Packit Service 2723c6
    && { fail=0;					\
Packit Service 2723c6
      for i in $(built_programs); do			\
Packit Service 2723c6
        test "$$i" = ginstall && i=install;		\
Packit Service 2723c6
        for j in "$(pfx)/bin/$$i"			\
Packit Service 2723c6
                 "$(pfx)/share/man/man1/$$i.1"; do	\
Packit Service 2723c6
          case $$j in *'[.1') continue;; esac;		\
Packit Service 2723c6
          test -f "$$j" && :				\
Packit Service 2723c6
            || { echo "$$j not installed"; fail=1; };	\
Packit Service 2723c6
        done;						\
Packit Service 2723c6
      done;						\
Packit Service 2723c6
      test $$fail = 1 && exit 1 || :;			\
Packit Service 2723c6
    }
Packit Service 2723c6
endef
Packit Service 2723c6
Packit Service 2723c6
# Use this to make sure we don't run these programs when building
Packit Service 2723c6
# from a virgin compressed tarball file, below.
Packit Service 2723c6
null_AM_MAKEFLAGS ?= \
Packit Service 2723c6
  ACLOCAL=false \
Packit Service 2723c6
  AUTOCONF=false \
Packit Service 2723c6
  AUTOMAKE=false \
Packit Service 2723c6
  AUTOHEADER=false \
Packit Service 2723c6
  GPERF=false \
Packit Service 2723c6
  MAKEINFO=false
Packit Service 2723c6
Packit Service 2723c6
ALL_RECURSIVE_TARGETS += my-distcheck
Packit Service 2723c6
my-distcheck: $(DIST_ARCHIVES) $(local-check)
Packit Service 2723c6
	$(MAKE) syntax-check
Packit Service 2723c6
	$(MAKE) check
Packit Service 2723c6
	-rm -rf $(t)
Packit Service 2723c6
	mkdir -p $(t)
Packit Service 2723c6
	$(amtar_extract_) $(preferred_tarball_) -C $(t)
Packit Service 2723c6
	(set -e; cd $(t)/$(distdir);			\
Packit Service 2723c6
	  ./configure --quiet --enable-gcc-warnings --disable-nls; \
Packit Service 2723c6
	  $(MAKE) AM_MAKEFLAGS='$(null_AM_MAKEFLAGS)';	\
Packit Service 2723c6
	  $(MAKE) dvi;					\
Packit Service 2723c6
	  $(install-transform-check);			\
Packit Service 2723c6
	  $(my-instcheck);				\
Packit Service 2723c6
	  $(MAKE) distclean				\
Packit Service 2723c6
	)
Packit Service 2723c6
	(cd $(t) && mv $(distdir) $(distdir).old	\
Packit Service 2723c6
	  && $(amtar_extract_) - ) < $(preferred_tarball_)
Packit Service 2723c6
# With post-v1.15 automake, "distclean" would fail to remove .deps
Packit Service 2723c6
# directories, leading to a spurious failure of the following recursive diff.
Packit Service 2723c6
# FIXME: remove this, once automake is fixed.
Packit Service 2723c6
	find $(t)/$(distdir).old $(t)/$(distdir) -name .deps | xargs -r rmdir
Packit Service 2723c6
	diff -ur $(t)/$(distdir).old $(t)/$(distdir)
Packit Service 2723c6
	-rm -rf $(t)
Packit Service 2723c6
	rmdir $(tmpdir)/$(PACKAGE) $(tmpdir)
Packit Service 2723c6
	@echo "========================"; \
Packit Service 2723c6
	echo "ready for distribution:"; \
Packit Service 2723c6
	for i in $(DIST_ARCHIVES); do echo "  $$i"; done; \
Packit Service 2723c6
	echo "========================"