distcheck-no-prefix-or-srcdir-override.sh 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #! /bin/sh
  2. # Copyright (C) 2013-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Check that "make distcheck" overrides any --srcdir or --prefix flag
  17. # (mistakenly) defined in $(AM_DISTCHECK_CONFIGURE_FLAGS) or
  18. # $(DISTCHECK_CONFIGURE_FLAGS). See automake bug#14991.
  19. . test-init.sh
  20. echo AC_OUTPUT >> configure.ac
  21. orig_cwd=$(pwd); export orig_cwd
  22. cat > Makefile.am << 'END'
  23. # configure should choke on non-absolute prefix or non-existent
  24. # srcdir. We'll sanity-check that later.
  25. AM_DISTCHECK_CONFIGURE_FLAGS = --srcdir am-src --prefix am-pfx
  26. END
  27. # Same comments as above applies.
  28. DISTCHECK_CONFIGURE_FLAGS='--srcdir user-src --prefix user-pfx'
  29. export DISTCHECK_CONFIGURE_FLAGS
  30. $ACLOCAL
  31. $AUTOMAKE
  32. $AUTOCONF
  33. # Sanity check: configure should choke on non-absolute prefix
  34. # or non-existent srcdir.
  35. ./configure --prefix foobar 2>stderr && { cat stderr >&2; exit 99; }
  36. cat stderr >&2
  37. grep "expected an absolute directory name for --prefix" stderr || exit 99
  38. ./configure --srcdir foobar 2>stderr && { cat stderr >&2; exit 99; }
  39. cat stderr >&2
  40. grep "cannot find sources.* in foobar" stderr || exit 99
  41. ./configure
  42. run_make -E -O distcheck
  43. test ! -s stderr
  44. # Sanity check: the flags have been actually seen.
  45. $PERL -e 'undef $/; $_ = <>; s/ \\\n/ /g; print;' <stdout >t
  46. grep '/configure .* --srcdir am-src' t || exit 99
  47. grep '/configure .* --prefix am-pfx' t || exit 99
  48. grep '/configure .* --srcdir user-src' t || exit 99
  49. grep '/configure .* --prefix user-pfx' t || exit 99
  50. :